index.umd.js 325 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
  3. typeof define === 'function' && define.amd ? define(['exports'], factory) :
  4. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.qiankun = {}));
  5. }(this, (function (exports) { 'use strict';
  6. var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  7. function getDefaultExportFromCjs (x) {
  8. return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
  9. }
  10. function createCommonjsModule(fn, basedir, module) {
  11. return module = {
  12. path: basedir,
  13. exports: {},
  14. require: function (path, base) {
  15. return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
  16. }
  17. }, fn(module, module.exports), module.exports;
  18. }
  19. function commonjsRequire () {
  20. throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
  21. }
  22. var runtime_1 = createCommonjsModule(function (module) {
  23. /**
  24. * Copyright (c) 2014-present, Facebook, Inc.
  25. *
  26. * This source code is licensed under the MIT license found in the
  27. * LICENSE file in the root directory of this source tree.
  28. */
  29. var runtime = (function (exports) {
  30. var Op = Object.prototype;
  31. var hasOwn = Op.hasOwnProperty;
  32. var undefined$1; // More compressible than void 0.
  33. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  34. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  35. var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
  36. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  37. function define(obj, key, value) {
  38. Object.defineProperty(obj, key, {
  39. value: value,
  40. enumerable: true,
  41. configurable: true,
  42. writable: true
  43. });
  44. return obj[key];
  45. }
  46. try {
  47. // IE 8 has a broken Object.defineProperty that only works on DOM objects.
  48. define({}, "");
  49. } catch (err) {
  50. define = function(obj, key, value) {
  51. return obj[key] = value;
  52. };
  53. }
  54. function wrap(innerFn, outerFn, self, tryLocsList) {
  55. // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
  56. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  57. var generator = Object.create(protoGenerator.prototype);
  58. var context = new Context(tryLocsList || []);
  59. // The ._invoke method unifies the implementations of the .next,
  60. // .throw, and .return methods.
  61. generator._invoke = makeInvokeMethod(innerFn, self, context);
  62. return generator;
  63. }
  64. exports.wrap = wrap;
  65. // Try/catch helper to minimize deoptimizations. Returns a completion
  66. // record like context.tryEntries[i].completion. This interface could
  67. // have been (and was previously) designed to take a closure to be
  68. // invoked without arguments, but in all the cases we care about we
  69. // already have an existing method we want to call, so there's no need
  70. // to create a new function object. We can even get away with assuming
  71. // the method takes exactly one argument, since that happens to be true
  72. // in every case, so we don't have to touch the arguments object. The
  73. // only additional allocation required is the completion record, which
  74. // has a stable shape and so hopefully should be cheap to allocate.
  75. function tryCatch(fn, obj, arg) {
  76. try {
  77. return { type: "normal", arg: fn.call(obj, arg) };
  78. } catch (err) {
  79. return { type: "throw", arg: err };
  80. }
  81. }
  82. var GenStateSuspendedStart = "suspendedStart";
  83. var GenStateSuspendedYield = "suspendedYield";
  84. var GenStateExecuting = "executing";
  85. var GenStateCompleted = "completed";
  86. // Returning this object from the innerFn has the same effect as
  87. // breaking out of the dispatch switch statement.
  88. var ContinueSentinel = {};
  89. // Dummy constructor functions that we use as the .constructor and
  90. // .constructor.prototype properties for functions that return Generator
  91. // objects. For full spec compliance, you may wish to configure your
  92. // minifier not to mangle the names of these two functions.
  93. function Generator() {}
  94. function GeneratorFunction() {}
  95. function GeneratorFunctionPrototype() {}
  96. // This is a polyfill for %IteratorPrototype% for environments that
  97. // don't natively support it.
  98. var IteratorPrototype = {};
  99. define(IteratorPrototype, iteratorSymbol, function () {
  100. return this;
  101. });
  102. var getProto = Object.getPrototypeOf;
  103. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  104. if (NativeIteratorPrototype &&
  105. NativeIteratorPrototype !== Op &&
  106. hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  107. // This environment has a native %IteratorPrototype%; use it instead
  108. // of the polyfill.
  109. IteratorPrototype = NativeIteratorPrototype;
  110. }
  111. var Gp = GeneratorFunctionPrototype.prototype =
  112. Generator.prototype = Object.create(IteratorPrototype);
  113. GeneratorFunction.prototype = GeneratorFunctionPrototype;
  114. define(Gp, "constructor", GeneratorFunctionPrototype);
  115. define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
  116. GeneratorFunction.displayName = define(
  117. GeneratorFunctionPrototype,
  118. toStringTagSymbol,
  119. "GeneratorFunction"
  120. );
  121. // Helper for defining the .next, .throw, and .return methods of the
  122. // Iterator interface in terms of a single ._invoke method.
  123. function defineIteratorMethods(prototype) {
  124. ["next", "throw", "return"].forEach(function(method) {
  125. define(prototype, method, function(arg) {
  126. return this._invoke(method, arg);
  127. });
  128. });
  129. }
  130. exports.isGeneratorFunction = function(genFun) {
  131. var ctor = typeof genFun === "function" && genFun.constructor;
  132. return ctor
  133. ? ctor === GeneratorFunction ||
  134. // For the native GeneratorFunction constructor, the best we can
  135. // do is to check its .name property.
  136. (ctor.displayName || ctor.name) === "GeneratorFunction"
  137. : false;
  138. };
  139. exports.mark = function(genFun) {
  140. if (Object.setPrototypeOf) {
  141. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  142. } else {
  143. genFun.__proto__ = GeneratorFunctionPrototype;
  144. define(genFun, toStringTagSymbol, "GeneratorFunction");
  145. }
  146. genFun.prototype = Object.create(Gp);
  147. return genFun;
  148. };
  149. // Within the body of any async function, `await x` is transformed to
  150. // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
  151. // `hasOwn.call(value, "__await")` to determine if the yielded value is
  152. // meant to be awaited.
  153. exports.awrap = function(arg) {
  154. return { __await: arg };
  155. };
  156. function AsyncIterator(generator, PromiseImpl) {
  157. function invoke(method, arg, resolve, reject) {
  158. var record = tryCatch(generator[method], generator, arg);
  159. if (record.type === "throw") {
  160. reject(record.arg);
  161. } else {
  162. var result = record.arg;
  163. var value = result.value;
  164. if (value &&
  165. typeof value === "object" &&
  166. hasOwn.call(value, "__await")) {
  167. return PromiseImpl.resolve(value.__await).then(function(value) {
  168. invoke("next", value, resolve, reject);
  169. }, function(err) {
  170. invoke("throw", err, resolve, reject);
  171. });
  172. }
  173. return PromiseImpl.resolve(value).then(function(unwrapped) {
  174. // When a yielded Promise is resolved, its final value becomes
  175. // the .value of the Promise<{value,done}> result for the
  176. // current iteration.
  177. result.value = unwrapped;
  178. resolve(result);
  179. }, function(error) {
  180. // If a rejected Promise was yielded, throw the rejection back
  181. // into the async generator function so it can be handled there.
  182. return invoke("throw", error, resolve, reject);
  183. });
  184. }
  185. }
  186. var previousPromise;
  187. function enqueue(method, arg) {
  188. function callInvokeWithMethodAndArg() {
  189. return new PromiseImpl(function(resolve, reject) {
  190. invoke(method, arg, resolve, reject);
  191. });
  192. }
  193. return previousPromise =
  194. // If enqueue has been called before, then we want to wait until
  195. // all previous Promises have been resolved before calling invoke,
  196. // so that results are always delivered in the correct order. If
  197. // enqueue has not been called before, then it is important to
  198. // call invoke immediately, without waiting on a callback to fire,
  199. // so that the async generator function has the opportunity to do
  200. // any necessary setup in a predictable way. This predictability
  201. // is why the Promise constructor synchronously invokes its
  202. // executor callback, and why async functions synchronously
  203. // execute code before the first await. Since we implement simple
  204. // async functions in terms of async generators, it is especially
  205. // important to get this right, even though it requires care.
  206. previousPromise ? previousPromise.then(
  207. callInvokeWithMethodAndArg,
  208. // Avoid propagating failures to Promises returned by later
  209. // invocations of the iterator.
  210. callInvokeWithMethodAndArg
  211. ) : callInvokeWithMethodAndArg();
  212. }
  213. // Define the unified helper method that is used to implement .next,
  214. // .throw, and .return (see defineIteratorMethods).
  215. this._invoke = enqueue;
  216. }
  217. defineIteratorMethods(AsyncIterator.prototype);
  218. define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
  219. return this;
  220. });
  221. exports.AsyncIterator = AsyncIterator;
  222. // Note that simple async functions are implemented on top of
  223. // AsyncIterator objects; they just return a Promise for the value of
  224. // the final result produced by the iterator.
  225. exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
  226. if (PromiseImpl === void 0) PromiseImpl = Promise;
  227. var iter = new AsyncIterator(
  228. wrap(innerFn, outerFn, self, tryLocsList),
  229. PromiseImpl
  230. );
  231. return exports.isGeneratorFunction(outerFn)
  232. ? iter // If outerFn is a generator, return the full iterator.
  233. : iter.next().then(function(result) {
  234. return result.done ? result.value : iter.next();
  235. });
  236. };
  237. function makeInvokeMethod(innerFn, self, context) {
  238. var state = GenStateSuspendedStart;
  239. return function invoke(method, arg) {
  240. if (state === GenStateExecuting) {
  241. throw new Error("Generator is already running");
  242. }
  243. if (state === GenStateCompleted) {
  244. if (method === "throw") {
  245. throw arg;
  246. }
  247. // Be forgiving, per 25.3.3.3.3 of the spec:
  248. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
  249. return doneResult();
  250. }
  251. context.method = method;
  252. context.arg = arg;
  253. while (true) {
  254. var delegate = context.delegate;
  255. if (delegate) {
  256. var delegateResult = maybeInvokeDelegate(delegate, context);
  257. if (delegateResult) {
  258. if (delegateResult === ContinueSentinel) continue;
  259. return delegateResult;
  260. }
  261. }
  262. if (context.method === "next") {
  263. // Setting context._sent for legacy support of Babel's
  264. // function.sent implementation.
  265. context.sent = context._sent = context.arg;
  266. } else if (context.method === "throw") {
  267. if (state === GenStateSuspendedStart) {
  268. state = GenStateCompleted;
  269. throw context.arg;
  270. }
  271. context.dispatchException(context.arg);
  272. } else if (context.method === "return") {
  273. context.abrupt("return", context.arg);
  274. }
  275. state = GenStateExecuting;
  276. var record = tryCatch(innerFn, self, context);
  277. if (record.type === "normal") {
  278. // If an exception is thrown from innerFn, we leave state ===
  279. // GenStateExecuting and loop back for another invocation.
  280. state = context.done
  281. ? GenStateCompleted
  282. : GenStateSuspendedYield;
  283. if (record.arg === ContinueSentinel) {
  284. continue;
  285. }
  286. return {
  287. value: record.arg,
  288. done: context.done
  289. };
  290. } else if (record.type === "throw") {
  291. state = GenStateCompleted;
  292. // Dispatch the exception by looping back around to the
  293. // context.dispatchException(context.arg) call above.
  294. context.method = "throw";
  295. context.arg = record.arg;
  296. }
  297. }
  298. };
  299. }
  300. // Call delegate.iterator[context.method](context.arg) and handle the
  301. // result, either by returning a { value, done } result from the
  302. // delegate iterator, or by modifying context.method and context.arg,
  303. // setting context.delegate to null, and returning the ContinueSentinel.
  304. function maybeInvokeDelegate(delegate, context) {
  305. var method = delegate.iterator[context.method];
  306. if (method === undefined$1) {
  307. // A .throw or .return when the delegate iterator has no .throw
  308. // method always terminates the yield* loop.
  309. context.delegate = null;
  310. if (context.method === "throw") {
  311. // Note: ["return"] must be used for ES3 parsing compatibility.
  312. if (delegate.iterator["return"]) {
  313. // If the delegate iterator has a return method, give it a
  314. // chance to clean up.
  315. context.method = "return";
  316. context.arg = undefined$1;
  317. maybeInvokeDelegate(delegate, context);
  318. if (context.method === "throw") {
  319. // If maybeInvokeDelegate(context) changed context.method from
  320. // "return" to "throw", let that override the TypeError below.
  321. return ContinueSentinel;
  322. }
  323. }
  324. context.method = "throw";
  325. context.arg = new TypeError(
  326. "The iterator does not provide a 'throw' method");
  327. }
  328. return ContinueSentinel;
  329. }
  330. var record = tryCatch(method, delegate.iterator, context.arg);
  331. if (record.type === "throw") {
  332. context.method = "throw";
  333. context.arg = record.arg;
  334. context.delegate = null;
  335. return ContinueSentinel;
  336. }
  337. var info = record.arg;
  338. if (! info) {
  339. context.method = "throw";
  340. context.arg = new TypeError("iterator result is not an object");
  341. context.delegate = null;
  342. return ContinueSentinel;
  343. }
  344. if (info.done) {
  345. // Assign the result of the finished delegate to the temporary
  346. // variable specified by delegate.resultName (see delegateYield).
  347. context[delegate.resultName] = info.value;
  348. // Resume execution at the desired location (see delegateYield).
  349. context.next = delegate.nextLoc;
  350. // If context.method was "throw" but the delegate handled the
  351. // exception, let the outer generator proceed normally. If
  352. // context.method was "next", forget context.arg since it has been
  353. // "consumed" by the delegate iterator. If context.method was
  354. // "return", allow the original .return call to continue in the
  355. // outer generator.
  356. if (context.method !== "return") {
  357. context.method = "next";
  358. context.arg = undefined$1;
  359. }
  360. } else {
  361. // Re-yield the result returned by the delegate method.
  362. return info;
  363. }
  364. // The delegate iterator is finished, so forget it and continue with
  365. // the outer generator.
  366. context.delegate = null;
  367. return ContinueSentinel;
  368. }
  369. // Define Generator.prototype.{next,throw,return} in terms of the
  370. // unified ._invoke helper method.
  371. defineIteratorMethods(Gp);
  372. define(Gp, toStringTagSymbol, "Generator");
  373. // A Generator should always return itself as the iterator object when the
  374. // @@iterator function is called on it. Some browsers' implementations of the
  375. // iterator prototype chain incorrectly implement this, causing the Generator
  376. // object to not be returned from this call. This ensures that doesn't happen.
  377. // See https://github.com/facebook/regenerator/issues/274 for more details.
  378. define(Gp, iteratorSymbol, function() {
  379. return this;
  380. });
  381. define(Gp, "toString", function() {
  382. return "[object Generator]";
  383. });
  384. function pushTryEntry(locs) {
  385. var entry = { tryLoc: locs[0] };
  386. if (1 in locs) {
  387. entry.catchLoc = locs[1];
  388. }
  389. if (2 in locs) {
  390. entry.finallyLoc = locs[2];
  391. entry.afterLoc = locs[3];
  392. }
  393. this.tryEntries.push(entry);
  394. }
  395. function resetTryEntry(entry) {
  396. var record = entry.completion || {};
  397. record.type = "normal";
  398. delete record.arg;
  399. entry.completion = record;
  400. }
  401. function Context(tryLocsList) {
  402. // The root entry object (effectively a try statement without a catch
  403. // or a finally block) gives us a place to store values thrown from
  404. // locations where there is no enclosing try statement.
  405. this.tryEntries = [{ tryLoc: "root" }];
  406. tryLocsList.forEach(pushTryEntry, this);
  407. this.reset(true);
  408. }
  409. exports.keys = function(object) {
  410. var keys = [];
  411. for (var key in object) {
  412. keys.push(key);
  413. }
  414. keys.reverse();
  415. // Rather than returning an object with a next method, we keep
  416. // things simple and return the next function itself.
  417. return function next() {
  418. while (keys.length) {
  419. var key = keys.pop();
  420. if (key in object) {
  421. next.value = key;
  422. next.done = false;
  423. return next;
  424. }
  425. }
  426. // To avoid creating an additional object, we just hang the .value
  427. // and .done properties off the next function object itself. This
  428. // also ensures that the minifier will not anonymize the function.
  429. next.done = true;
  430. return next;
  431. };
  432. };
  433. function values(iterable) {
  434. if (iterable) {
  435. var iteratorMethod = iterable[iteratorSymbol];
  436. if (iteratorMethod) {
  437. return iteratorMethod.call(iterable);
  438. }
  439. if (typeof iterable.next === "function") {
  440. return iterable;
  441. }
  442. if (!isNaN(iterable.length)) {
  443. var i = -1, next = function next() {
  444. while (++i < iterable.length) {
  445. if (hasOwn.call(iterable, i)) {
  446. next.value = iterable[i];
  447. next.done = false;
  448. return next;
  449. }
  450. }
  451. next.value = undefined$1;
  452. next.done = true;
  453. return next;
  454. };
  455. return next.next = next;
  456. }
  457. }
  458. // Return an iterator with no values.
  459. return { next: doneResult };
  460. }
  461. exports.values = values;
  462. function doneResult() {
  463. return { value: undefined$1, done: true };
  464. }
  465. Context.prototype = {
  466. constructor: Context,
  467. reset: function(skipTempReset) {
  468. this.prev = 0;
  469. this.next = 0;
  470. // Resetting context._sent for legacy support of Babel's
  471. // function.sent implementation.
  472. this.sent = this._sent = undefined$1;
  473. this.done = false;
  474. this.delegate = null;
  475. this.method = "next";
  476. this.arg = undefined$1;
  477. this.tryEntries.forEach(resetTryEntry);
  478. if (!skipTempReset) {
  479. for (var name in this) {
  480. // Not sure about the optimal order of these conditions:
  481. if (name.charAt(0) === "t" &&
  482. hasOwn.call(this, name) &&
  483. !isNaN(+name.slice(1))) {
  484. this[name] = undefined$1;
  485. }
  486. }
  487. }
  488. },
  489. stop: function() {
  490. this.done = true;
  491. var rootEntry = this.tryEntries[0];
  492. var rootRecord = rootEntry.completion;
  493. if (rootRecord.type === "throw") {
  494. throw rootRecord.arg;
  495. }
  496. return this.rval;
  497. },
  498. dispatchException: function(exception) {
  499. if (this.done) {
  500. throw exception;
  501. }
  502. var context = this;
  503. function handle(loc, caught) {
  504. record.type = "throw";
  505. record.arg = exception;
  506. context.next = loc;
  507. if (caught) {
  508. // If the dispatched exception was caught by a catch block,
  509. // then let that catch block handle the exception normally.
  510. context.method = "next";
  511. context.arg = undefined$1;
  512. }
  513. return !! caught;
  514. }
  515. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  516. var entry = this.tryEntries[i];
  517. var record = entry.completion;
  518. if (entry.tryLoc === "root") {
  519. // Exception thrown outside of any try block that could handle
  520. // it, so set the completion value of the entire function to
  521. // throw the exception.
  522. return handle("end");
  523. }
  524. if (entry.tryLoc <= this.prev) {
  525. var hasCatch = hasOwn.call(entry, "catchLoc");
  526. var hasFinally = hasOwn.call(entry, "finallyLoc");
  527. if (hasCatch && hasFinally) {
  528. if (this.prev < entry.catchLoc) {
  529. return handle(entry.catchLoc, true);
  530. } else if (this.prev < entry.finallyLoc) {
  531. return handle(entry.finallyLoc);
  532. }
  533. } else if (hasCatch) {
  534. if (this.prev < entry.catchLoc) {
  535. return handle(entry.catchLoc, true);
  536. }
  537. } else if (hasFinally) {
  538. if (this.prev < entry.finallyLoc) {
  539. return handle(entry.finallyLoc);
  540. }
  541. } else {
  542. throw new Error("try statement without catch or finally");
  543. }
  544. }
  545. }
  546. },
  547. abrupt: function(type, arg) {
  548. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  549. var entry = this.tryEntries[i];
  550. if (entry.tryLoc <= this.prev &&
  551. hasOwn.call(entry, "finallyLoc") &&
  552. this.prev < entry.finallyLoc) {
  553. var finallyEntry = entry;
  554. break;
  555. }
  556. }
  557. if (finallyEntry &&
  558. (type === "break" ||
  559. type === "continue") &&
  560. finallyEntry.tryLoc <= arg &&
  561. arg <= finallyEntry.finallyLoc) {
  562. // Ignore the finally entry if control is not jumping to a
  563. // location outside the try/catch block.
  564. finallyEntry = null;
  565. }
  566. var record = finallyEntry ? finallyEntry.completion : {};
  567. record.type = type;
  568. record.arg = arg;
  569. if (finallyEntry) {
  570. this.method = "next";
  571. this.next = finallyEntry.finallyLoc;
  572. return ContinueSentinel;
  573. }
  574. return this.complete(record);
  575. },
  576. complete: function(record, afterLoc) {
  577. if (record.type === "throw") {
  578. throw record.arg;
  579. }
  580. if (record.type === "break" ||
  581. record.type === "continue") {
  582. this.next = record.arg;
  583. } else if (record.type === "return") {
  584. this.rval = this.arg = record.arg;
  585. this.method = "return";
  586. this.next = "end";
  587. } else if (record.type === "normal" && afterLoc) {
  588. this.next = afterLoc;
  589. }
  590. return ContinueSentinel;
  591. },
  592. finish: function(finallyLoc) {
  593. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  594. var entry = this.tryEntries[i];
  595. if (entry.finallyLoc === finallyLoc) {
  596. this.complete(entry.completion, entry.afterLoc);
  597. resetTryEntry(entry);
  598. return ContinueSentinel;
  599. }
  600. }
  601. },
  602. "catch": function(tryLoc) {
  603. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  604. var entry = this.tryEntries[i];
  605. if (entry.tryLoc === tryLoc) {
  606. var record = entry.completion;
  607. if (record.type === "throw") {
  608. var thrown = record.arg;
  609. resetTryEntry(entry);
  610. }
  611. return thrown;
  612. }
  613. }
  614. // The context.catch method must only be called with a location
  615. // argument that corresponds to a known catch block.
  616. throw new Error("illegal catch attempt");
  617. },
  618. delegateYield: function(iterable, resultName, nextLoc) {
  619. this.delegate = {
  620. iterator: values(iterable),
  621. resultName: resultName,
  622. nextLoc: nextLoc
  623. };
  624. if (this.method === "next") {
  625. // Deliberately forget the last sent value so that we don't
  626. // accidentally pass it on to the delegate.
  627. this.arg = undefined$1;
  628. }
  629. return ContinueSentinel;
  630. }
  631. };
  632. // Regardless of whether this script is executing as a CommonJS module
  633. // or not, return the runtime object so that we can declare the variable
  634. // regeneratorRuntime in the outer scope, which allows this module to be
  635. // injected easily by `bin/regenerator --include-runtime script.js`.
  636. return exports;
  637. }(
  638. // If this script is executing as a CommonJS module, use module.exports
  639. // as the regeneratorRuntime namespace. Otherwise create a new empty
  640. // object. Either way, the resulting object will be used to initialize
  641. // the regeneratorRuntime variable at the top of this file.
  642. module.exports
  643. ));
  644. try {
  645. regeneratorRuntime = runtime;
  646. } catch (accidentalStrictMode) {
  647. // This module should not be running in strict mode, so the above
  648. // assignment should always work unless something is misconfigured. Just
  649. // in case runtime.js accidentally runs in strict mode, in modern engines
  650. // we can explicitly access globalThis. In older engines we can escape
  651. // strict mode using a global Function call. This could conceivably fail
  652. // if a Content Security Policy forbids using Function, but in that case
  653. // the proper solution is to fix the accidental strict mode problem. If
  654. // you've misconfigured your bundler to force strict mode and applied a
  655. // CSP to forbid Function, and you're not willing to fix either of those
  656. // problems, please detail your unique predicament in a GitHub issue.
  657. if (typeof globalThis === "object") {
  658. globalThis.regeneratorRuntime = runtime;
  659. } else {
  660. Function("r", "regeneratorRuntime = r")(runtime);
  661. }
  662. }
  663. });
  664. var regenerator = runtime_1;
  665. var asyncToGenerator = createCommonjsModule(function (module) {
  666. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  667. try {
  668. var info = gen[key](arg);
  669. var value = info.value;
  670. } catch (error) {
  671. reject(error);
  672. return;
  673. }
  674. if (info.done) {
  675. resolve(value);
  676. } else {
  677. Promise.resolve(value).then(_next, _throw);
  678. }
  679. }
  680. function _asyncToGenerator(fn) {
  681. return function () {
  682. var self = this,
  683. args = arguments;
  684. return new Promise(function (resolve, reject) {
  685. var gen = fn.apply(self, args);
  686. function _next(value) {
  687. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
  688. }
  689. function _throw(err) {
  690. asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
  691. }
  692. _next(undefined);
  693. });
  694. };
  695. }
  696. module.exports = _asyncToGenerator;
  697. module.exports["default"] = module.exports, module.exports.__esModule = true;
  698. });
  699. var _asyncToGenerator = /*@__PURE__*/getDefaultExportFromCjs(asyncToGenerator);
  700. /**
  701. * This method returns `undefined`.
  702. *
  703. * @static
  704. * @memberOf _
  705. * @since 2.3.0
  706. * @category Util
  707. * @example
  708. *
  709. * _.times(2, _.noop);
  710. * // => [undefined, undefined]
  711. */
  712. function noop() {
  713. // No operation performed.
  714. }
  715. var noop_1 = noop;
  716. var objectWithoutPropertiesLoose = createCommonjsModule(function (module) {
  717. function _objectWithoutPropertiesLoose(source, excluded) {
  718. if (source == null) return {};
  719. var target = {};
  720. var sourceKeys = Object.keys(source);
  721. var key, i;
  722. for (i = 0; i < sourceKeys.length; i++) {
  723. key = sourceKeys[i];
  724. if (excluded.indexOf(key) >= 0) continue;
  725. target[key] = source[key];
  726. }
  727. return target;
  728. }
  729. module.exports = _objectWithoutPropertiesLoose;
  730. module.exports["default"] = module.exports, module.exports.__esModule = true;
  731. });
  732. var objectWithoutProperties = createCommonjsModule(function (module) {
  733. function _objectWithoutProperties(source, excluded) {
  734. if (source == null) return {};
  735. var target = objectWithoutPropertiesLoose(source, excluded);
  736. var key, i;
  737. if (Object.getOwnPropertySymbols) {
  738. var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
  739. for (i = 0; i < sourceSymbolKeys.length; i++) {
  740. key = sourceSymbolKeys[i];
  741. if (excluded.indexOf(key) >= 0) continue;
  742. if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
  743. target[key] = source[key];
  744. }
  745. }
  746. return target;
  747. }
  748. module.exports = _objectWithoutProperties;
  749. module.exports["default"] = module.exports, module.exports.__esModule = true;
  750. });
  751. var _objectWithoutProperties = /*@__PURE__*/getDefaultExportFromCjs(objectWithoutProperties);
  752. var arrayLikeToArray = createCommonjsModule(function (module) {
  753. function _arrayLikeToArray(arr, len) {
  754. if (len == null || len > arr.length) len = arr.length;
  755. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  756. arr2[i] = arr[i];
  757. }
  758. return arr2;
  759. }
  760. module.exports = _arrayLikeToArray;
  761. module.exports["default"] = module.exports, module.exports.__esModule = true;
  762. });
  763. var arrayWithoutHoles = createCommonjsModule(function (module) {
  764. function _arrayWithoutHoles(arr) {
  765. if (Array.isArray(arr)) return arrayLikeToArray(arr);
  766. }
  767. module.exports = _arrayWithoutHoles;
  768. module.exports["default"] = module.exports, module.exports.__esModule = true;
  769. });
  770. var iterableToArray = createCommonjsModule(function (module) {
  771. function _iterableToArray(iter) {
  772. if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
  773. }
  774. module.exports = _iterableToArray;
  775. module.exports["default"] = module.exports, module.exports.__esModule = true;
  776. });
  777. var unsupportedIterableToArray = createCommonjsModule(function (module) {
  778. function _unsupportedIterableToArray(o, minLen) {
  779. if (!o) return;
  780. if (typeof o === "string") return arrayLikeToArray(o, minLen);
  781. var n = Object.prototype.toString.call(o).slice(8, -1);
  782. if (n === "Object" && o.constructor) n = o.constructor.name;
  783. if (n === "Map" || n === "Set") return Array.from(o);
  784. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen);
  785. }
  786. module.exports = _unsupportedIterableToArray;
  787. module.exports["default"] = module.exports, module.exports.__esModule = true;
  788. });
  789. var nonIterableSpread = createCommonjsModule(function (module) {
  790. function _nonIterableSpread() {
  791. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  792. }
  793. module.exports = _nonIterableSpread;
  794. module.exports["default"] = module.exports, module.exports.__esModule = true;
  795. });
  796. var toConsumableArray = createCommonjsModule(function (module) {
  797. function _toConsumableArray(arr) {
  798. return arrayWithoutHoles(arr) || iterableToArray(arr) || unsupportedIterableToArray(arr) || nonIterableSpread();
  799. }
  800. module.exports = _toConsumableArray;
  801. module.exports["default"] = module.exports, module.exports.__esModule = true;
  802. });
  803. var _toConsumableArray = /*@__PURE__*/getDefaultExportFromCjs(toConsumableArray);
  804. var _typeof_1 = createCommonjsModule(function (module) {
  805. function _typeof(obj) {
  806. "@babel/helpers - typeof";
  807. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  808. module.exports = _typeof = function _typeof(obj) {
  809. return typeof obj;
  810. };
  811. module.exports["default"] = module.exports, module.exports.__esModule = true;
  812. } else {
  813. module.exports = _typeof = function _typeof(obj) {
  814. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  815. };
  816. module.exports["default"] = module.exports, module.exports.__esModule = true;
  817. }
  818. return _typeof(obj);
  819. }
  820. module.exports = _typeof;
  821. module.exports["default"] = module.exports, module.exports.__esModule = true;
  822. });
  823. var _typeof = /*@__PURE__*/getDefaultExportFromCjs(_typeof_1);
  824. var defineProperty = createCommonjsModule(function (module) {
  825. function _defineProperty(obj, key, value) {
  826. if (key in obj) {
  827. Object.defineProperty(obj, key, {
  828. value: value,
  829. enumerable: true,
  830. configurable: true,
  831. writable: true
  832. });
  833. } else {
  834. obj[key] = value;
  835. }
  836. return obj;
  837. }
  838. module.exports = _defineProperty;
  839. module.exports["default"] = module.exports, module.exports.__esModule = true;
  840. });
  841. var _defineProperty = /*@__PURE__*/getDefaultExportFromCjs(defineProperty);
  842. var objectSpread2 = createCommonjsModule(function (module) {
  843. function ownKeys(object, enumerableOnly) {
  844. var keys = Object.keys(object);
  845. if (Object.getOwnPropertySymbols) {
  846. var symbols = Object.getOwnPropertySymbols(object);
  847. if (enumerableOnly) {
  848. symbols = symbols.filter(function (sym) {
  849. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  850. });
  851. }
  852. keys.push.apply(keys, symbols);
  853. }
  854. return keys;
  855. }
  856. function _objectSpread2(target) {
  857. for (var i = 1; i < arguments.length; i++) {
  858. var source = arguments[i] != null ? arguments[i] : {};
  859. if (i % 2) {
  860. ownKeys(Object(source), true).forEach(function (key) {
  861. defineProperty(target, key, source[key]);
  862. });
  863. } else if (Object.getOwnPropertyDescriptors) {
  864. Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
  865. } else {
  866. ownKeys(Object(source)).forEach(function (key) {
  867. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
  868. });
  869. }
  870. }
  871. return target;
  872. }
  873. module.exports = _objectSpread2;
  874. module.exports["default"] = module.exports, module.exports.__esModule = true;
  875. });
  876. var _objectSpread = /*@__PURE__*/getDefaultExportFromCjs(objectSpread2);
  877. /* single-spa@5.9.3 - ESM - prod */
  878. var t=Object.freeze({__proto__:null,get start(){return xt},get ensureJQuerySupport(){return ft},get setBootstrapMaxTime(){return F},get setMountMaxTime(){return J},get setUnmountMaxTime(){return H},get setUnloadMaxTime(){return Q},get registerApplication(){return Ot},get unregisterApplication(){return Tt},get getMountedApps(){return Et},get getAppStatus(){return Pt},get unloadApplication(){return At},get checkActivityFunctions(){return bt},get getAppNames(){return yt},get pathToActiveWhen(){return _t},get navigateToUrl(){return nt},get triggerAppChange(){return Mt},get addErrorHandler(){return a},get removeErrorHandler(){return c},get mountRootParcel(){return C},get NOT_LOADED(){return l},get LOADING_SOURCE_CODE(){return p},get NOT_BOOTSTRAPPED(){return h},get BOOTSTRAPPING(){return m},get NOT_MOUNTED(){return v},get MOUNTING(){return d},get UPDATING(){return g},get LOAD_ERROR(){return y},get MOUNTED(){return w},get UNMOUNTING(){return E},get SKIP_BECAUSE_BROKEN(){return P}});function n(t){return (n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function e(t,n,e){return n in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}var r=("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{}).CustomEvent,o=function(){try{var t=new r("cat",{detail:{foo:"bar"}});return "cat"===t.type&&"bar"===t.detail.foo}catch(t){}return !1}()?r:"undefined"!=typeof document&&"function"==typeof document.createEvent?function(t,n){var e=document.createEvent("CustomEvent");return n?e.initCustomEvent(t,n.bubbles,n.cancelable,n.detail):e.initCustomEvent(t,!1,!1,void 0),e}:function(t,n){var e=document.createEventObject();return e.type=t,n?(e.bubbles=Boolean(n.bubbles),e.cancelable=Boolean(n.cancelable),e.detail=n.detail):(e.bubbles=!1,e.cancelable=!1,e.detail=void 0),e},i=[];function u(t,n,e){var r=f(t,n,e);i.length?i.forEach((function(t){return t(r)})):setTimeout((function(){throw r}));}function a(t){if("function"!=typeof t)throw Error(s(28,!1));i.push(t);}function c(t){if("function"!=typeof t)throw Error(s(29,!1));var n=!1;return i=i.filter((function(e){var r=e===t;return n=n||r,!r})),n}function s(t,n){for(var e=arguments.length,r=new Array(e>2?e-2:0),o=2;o<e;o++)r[o-2]=arguments[o];return "single-spa minified message #".concat(t,": ").concat(n?n+" ":"","See https://single-spa.js.org/error/?code=").concat(t).concat(r.length?"&arg=".concat(r.join("&arg=")):"")}function f(t,n,e){var r,o="".concat(N(n)," '").concat(T(n),"' died in status ").concat(n.status,": ");if(t instanceof Error){try{t.message=o+t.message;}catch(t){}r=t;}else {console.warn(s(30,!1,n.status,T(n)));try{r=Error(o+JSON.stringify(t));}catch(n){r=t;}}return r.appOrParcelName=T(n),n.status=e,r}var l="NOT_LOADED",p="LOADING_SOURCE_CODE",h="NOT_BOOTSTRAPPED",m="BOOTSTRAPPING",v="NOT_MOUNTED",d="MOUNTING",w="MOUNTED",g="UPDATING",E="UNMOUNTING",y="LOAD_ERROR",P="SKIP_BECAUSE_BROKEN";function O(t){return t.status===w}function b(t){try{return t.activeWhen(window.location)}catch(n){return u(n,t,P),!1}}function T(t){return t.name}function A(t){return Boolean(t.unmountThisParcel)}function N(t){return A(t)?"parcel":"application"}function S(){for(var t=arguments.length-1;t>0;t--)for(var n in arguments[t])"__proto__"!==n&&(arguments[t-1][n]=arguments[t][n]);return arguments[0]}function _(t,n){for(var e=0;e<t.length;e++)if(n(t[e]))return t[e];return null}function D(t){return t&&("function"==typeof t||(n=t,Array.isArray(n)&&!_(n,(function(t){return "function"!=typeof t}))));var n;}function U(t,n){var e=t[n]||[];0===(e=Array.isArray(e)?e:[e]).length&&(e=[function(){return Promise.resolve()}]);var r=N(t),o=T(t);return function(t){return e.reduce((function(e,i,u){return e.then((function(){var e=i(t);return j(e)?e:Promise.reject(s(15,!1,r,o,n,u))}))}),Promise.resolve())}}function j(t){return t&&"function"==typeof t.then&&"function"==typeof t.catch}function M(t,n){return Promise.resolve().then((function(){return t.status!==h?t:(t.status=m,t.bootstrap?V(t,"bootstrap").then(e).catch((function(e){if(n)throw f(e,t,P);return u(e,t,P),t})):Promise.resolve().then(e))}));function e(){return t.status=v,t}}function L(t,n){return Promise.resolve().then((function(){if(t.status!==w)return t;t.status=E;var e=Object.keys(t.parcels).map((function(n){return t.parcels[n].unmountThisParcel()}));return Promise.all(e).then(r,(function(e){return r().then((function(){var r=Error(e.message);if(n)throw f(r,t,P);u(r,t,P);}))})).then((function(){return t}));function r(){return V(t,"unmount").then((function(){t.status=v;})).catch((function(e){if(n)throw f(e,t,P);u(e,t,P);}))}}))}var R=!1,I=!1;function x(t,n){return Promise.resolve().then((function(){return t.status!==v?t:(R||(window.dispatchEvent(new o("single-spa:before-first-mount")),R=!0),V(t,"mount").then((function(){return t.status=w,I||(window.dispatchEvent(new o("single-spa:first-mount")),I=!0),t})).catch((function(e){return t.status=w,L(t,!0).then(r,r);function r(){if(n)throw f(e,t,P);return u(e,t,P),t}})))}))}var B=0,G={parcels:{}};function C(){return W.apply(G,arguments)}function W(t,e){var r=this;if(!t||"object"!==n(t)&&"function"!=typeof t)throw Error(s(2,!1));if(t.name&&"string"!=typeof t.name)throw Error(s(3,!1,n(t.name)));if("object"!==n(e))throw Error(s(4,!1,name,n(e)));if(!e.domElement)throw Error(s(5,!1,name));var o,i=B++,u="function"==typeof t,a=u?t:function(){return Promise.resolve(t)},c={id:i,parcels:{},status:u?p:h,customProps:e,parentName:T(r),unmountThisParcel:function(){return y.then((function(){if(c.status!==w)throw Error(s(6,!1,name,c.status));return L(c,!0)})).then((function(t){return c.parentName&&delete r.parcels[c.id],t})).then((function(t){return m(t),t})).catch((function(t){throw c.status=P,d(t),t}))}};r.parcels[i]=c;var l=a();if(!l||"function"!=typeof l.then)throw Error(s(7,!1));var m,d,E=(l=l.then((function(t){if(!t)throw Error(s(8,!1));var n=t.name||"parcel-".concat(i);if(Object.prototype.hasOwnProperty.call(t,"bootstrap")&&!D(t.bootstrap))throw Error(s(9,!1,n));if(!D(t.mount))throw Error(s(10,!1,n));if(!D(t.unmount))throw Error(s(11,!1,n));if(t.update&&!D(t.update))throw Error(s(12,!1,n));var e=U(t,"bootstrap"),r=U(t,"mount"),u=U(t,"unmount");c.status=h,c.name=n,c.bootstrap=e,c.mount=r,c.unmount=u,c.timeouts=q(t.timeouts),t.update&&(c.update=U(t,"update"),o.update=function(t){return c.customProps=t,$(function(t){return Promise.resolve().then((function(){if(t.status!==w)throw Error(s(32,!1,T(t)));return t.status=g,V(t,"update").then((function(){return t.status=w,t})).catch((function(n){throw f(n,t,P)}))}))}(c))});}))).then((function(){return M(c,!0)})),y=E.then((function(){return x(c,!0)})),O=new Promise((function(t,n){m=t,d=n;}));return o={mount:function(){return $(Promise.resolve().then((function(){if(c.status!==v)throw Error(s(13,!1,name,c.status));return r.parcels[i]=c,x(c)})))},unmount:function(){return $(c.unmountThisParcel())},getStatus:function(){return c.status},loadPromise:$(l),bootstrapPromise:$(E),mountPromise:$(y),unmountPromise:$(O)}}function $(t){return t.then((function(){return null}))}function k(e){var r=T(e),o="function"==typeof e.customProps?e.customProps(r,window.location):e.customProps;("object"!==n(o)||null===o||Array.isArray(o))&&(o={},console.warn(s(40,!1),r,o));var i=S({},o,{name:r,mountParcel:W.bind(e),singleSpa:t});return A(e)&&(i.unmountSelf=e.unmountThisParcel),i}var K={bootstrap:{millis:4e3,dieOnTimeout:!1,warningMillis:1e3},mount:{millis:3e3,dieOnTimeout:!1,warningMillis:1e3},unmount:{millis:3e3,dieOnTimeout:!1,warningMillis:1e3},unload:{millis:3e3,dieOnTimeout:!1,warningMillis:1e3},update:{millis:3e3,dieOnTimeout:!1,warningMillis:1e3}};function F(t,n,e){if("number"!=typeof t||t<=0)throw Error(s(16,!1));K.bootstrap={millis:t,dieOnTimeout:n,warningMillis:e||1e3};}function J(t,n,e){if("number"!=typeof t||t<=0)throw Error(s(17,!1));K.mount={millis:t,dieOnTimeout:n,warningMillis:e||1e3};}function H(t,n,e){if("number"!=typeof t||t<=0)throw Error(s(18,!1));K.unmount={millis:t,dieOnTimeout:n,warningMillis:e||1e3};}function Q(t,n,e){if("number"!=typeof t||t<=0)throw Error(s(19,!1));K.unload={millis:t,dieOnTimeout:n,warningMillis:e||1e3};}function V(t,n){var e=t.timeouts[n],r=e.warningMillis,o=N(t);return new Promise((function(i,u){var a=!1,c=!1;t[n](k(t)).then((function(t){a=!0,i(t);})).catch((function(t){a=!0,u(t);})),setTimeout((function(){return l(1)}),r),setTimeout((function(){return l(!0)}),e.millis);var f=s(31,!1,n,o,T(t),e.millis);function l(t){if(!a)if(!0===t)c=!0,e.dieOnTimeout?u(Error(f)):console.error(f);else if(!c){var n=t,o=n*r;console.warn(f),o+r<e.millis&&setTimeout((function(){return l(n+1)}),r);}}}))}function q(t){var n={};for(var e in K)n[e]=S({},K[e],t&&t[e]||{});return n}function z(t){return Promise.resolve().then((function(){return t.loadPromise?t.loadPromise:t.status!==l&&t.status!==y?t:(t.status=p,t.loadPromise=Promise.resolve().then((function(){var o=t.loadApp(k(t));if(!j(o))throw r=!0,Error(s(33,!1,T(t)));return o.then((function(r){var o;t.loadErrorTime=null,"object"!==n(e=r)&&(o=34),Object.prototype.hasOwnProperty.call(e,"bootstrap")&&!D(e.bootstrap)&&(o=35),D(e.mount)||(o=36),D(e.unmount)||(o=37);var i=N(e);if(o){var a;try{a=JSON.stringify(e);}catch(t){}return console.error(s(o,!1,i,T(t),a),e),u(void 0,t,P),t}return e.devtools&&e.devtools.overlays&&(t.devtools.overlays=S({},t.devtools.overlays,e.devtools.overlays)),t.status=h,t.bootstrap=U(e,"bootstrap"),t.mount=U(e,"mount"),t.unmount=U(e,"unmount"),t.unload=U(e,"unload"),t.timeouts=q(e.timeouts),delete t.loadPromise,t}))})).catch((function(n){var e;return delete t.loadPromise,r?e=P:(e=y,t.loadErrorTime=(new Date).getTime()),u(n,t,e),t})));var e,r;}))}var X,Y="undefined"!=typeof window,Z={hashchange:[],popstate:[]},tt=["hashchange","popstate"];function nt(t){var n;if("string"==typeof t)n=t;else if(this&&this.href)n=this.href;else {if(!(t&&t.currentTarget&&t.currentTarget.href&&t.preventDefault))throw Error(s(14,!1));n=t.currentTarget.href,t.preventDefault();}var e=ct(window.location.href),r=ct(n);0===n.indexOf("#")?window.location.hash=r.hash:e.host!==r.host&&r.host?window.location.href=n:r.pathname===e.pathname&&r.search===e.search?window.location.hash=r.hash:window.history.pushState(null,null,n);}function et(t){var n=this;if(t){var e=t[0].type;tt.indexOf(e)>=0&&Z[e].forEach((function(e){try{e.apply(n,t);}catch(t){setTimeout((function(){throw t}));}}));}}function rt(){Lt([],arguments);}function ot(t,n){return function(){var e=window.location.href,r=t.apply(this,arguments),o=window.location.href;return X&&e===o||(Bt()?window.dispatchEvent(it(window.history.state,n)):Lt([])),r}}function it(t,n){var e;try{e=new PopStateEvent("popstate",{state:t});}catch(n){(e=document.createEvent("PopStateEvent")).initPopStateEvent("popstate",!1,!1,t);}return e.singleSpa=!0,e.singleSpaTrigger=n,e}if(Y){window.addEventListener("hashchange",rt),window.addEventListener("popstate",rt);var ut=window.addEventListener,at=window.removeEventListener;window.addEventListener=function(t,n){if(!("function"==typeof n&&tt.indexOf(t)>=0)||_(Z[t],(function(t){return t===n})))return ut.apply(this,arguments);Z[t].push(n);},window.removeEventListener=function(t,n){if(!("function"==typeof n&&tt.indexOf(t)>=0))return at.apply(this,arguments);Z[t]=Z[t].filter((function(t){return t!==n}));},window.history.pushState=ot(window.history.pushState,"pushState"),window.history.replaceState=ot(window.history.replaceState,"replaceState"),window.singleSpaNavigate?console.warn(s(41,!1)):window.singleSpaNavigate=nt;}function ct(t){var n=document.createElement("a");return n.href=t,n}var st=!1;function ft(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.jQuery;if(t||window.$&&window.$.fn&&window.$.fn.jquery&&(t=window.$),t&&!st){var n=t.fn.on,e=t.fn.off;t.fn.on=function(t,e){return lt.call(this,n,window.addEventListener,t,e,arguments)},t.fn.off=function(t,n){return lt.call(this,e,window.removeEventListener,t,n,arguments)},st=!0;}}function lt(t,n,e,r,o){return "string"!=typeof e?t.apply(this,o):(e.split(/\s+/).forEach((function(t){tt.indexOf(t)>=0&&(n(t,r),e=e.replace(t,""));})),""===e.trim()?this:t.apply(this,o))}var pt={};function ht(t){return Promise.resolve().then((function(){var n=pt[T(t)];if(!n)return t;if(t.status===l)return mt(t,n),t;if("UNLOADING"===t.status)return n.promise.then((function(){return t}));if(t.status!==v&&t.status!==y)return t;var e=t.status===y?Promise.resolve():V(t,"unload");return t.status="UNLOADING",e.then((function(){return mt(t,n),t})).catch((function(e){return function(t,n,e){delete pt[T(t)],delete t.bootstrap,delete t.mount,delete t.unmount,delete t.unload,u(e,t,P),n.reject(e);}(t,n,e),t}))}))}function mt(t,n){delete pt[T(t)],delete t.bootstrap,delete t.mount,delete t.unmount,delete t.unload,t.status=l,n.resolve();}function vt(t,n,e,r){pt[T(t)]={app:t,resolve:e,reject:r},Object.defineProperty(pt[T(t)],"promise",{get:n});}function dt(t){return pt[t]}var wt=[];function gt(){var t=[],n=[],e=[],r=[],o=(new Date).getTime();return wt.forEach((function(i){var u=i.status!==P&&b(i);switch(i.status){case y:u&&o-i.loadErrorTime>=200&&e.push(i);break;case l:case p:u&&e.push(i);break;case h:case v:!u&&dt(T(i))?t.push(i):u&&r.push(i);break;case w:u||n.push(i);}})),{appsToUnload:t,appsToUnmount:n,appsToLoad:e,appsToMount:r}}function Et(){return wt.filter(O).map(T)}function yt(){return wt.map(T)}function Pt(t){var n=_(wt,(function(n){return T(n)===t}));return n?n.status:null}function Ot(t,e,r,o){var i=function(t,e,r,o){var i,u={name:null,loadApp:null,activeWhen:null,customProps:null};return "object"===n(t)?(function(t){if(Array.isArray(t)||null===t)throw Error(s(39,!1));var e=["name","app","activeWhen","customProps"],r=Object.keys(t).reduce((function(t,n){return e.indexOf(n)>=0?t:t.concat(n)}),[]);if(0!==r.length)throw Error(s(38,!1,e.join(", "),r.join(", ")));if("string"!=typeof t.name||0===t.name.length)throw Error(s(20,!1));if("object"!==n(t.app)&&"function"!=typeof t.app)throw Error(s(20,!1));var o=function(t){return "string"==typeof t||"function"==typeof t};if(!(o(t.activeWhen)||Array.isArray(t.activeWhen)&&t.activeWhen.every(o)))throw Error(s(24,!1));if(!St(t.customProps))throw Error(s(22,!1))}(t),u.name=t.name,u.loadApp=t.app,u.activeWhen=t.activeWhen,u.customProps=t.customProps):(function(t,n,e,r){if("string"!=typeof t||0===t.length)throw Error(s(20,!1));if(!n)throw Error(s(23,!1));if("function"!=typeof e)throw Error(s(24,!1));if(!St(r))throw Error(s(22,!1))}(t,e,r,o),u.name=t,u.loadApp=e,u.activeWhen=r,u.customProps=o),u.loadApp="function"!=typeof(i=u.loadApp)?function(){return Promise.resolve(i)}:i,u.customProps=function(t){return t||{}}(u.customProps),u.activeWhen=function(t){var n=Array.isArray(t)?t:[t];return n=n.map((function(t){return "function"==typeof t?t:_t(t)})),function(t){return n.some((function(n){return n(t)}))}}(u.activeWhen),u}(t,e,r,o);if(-1!==yt().indexOf(i.name))throw Error(s(21,!1,i.name));wt.push(S({loadErrorTime:null,status:l,parcels:{},devtools:{overlays:{options:{},selectors:[]}}},i)),Y&&(ft(),Lt());}function bt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.location;return wt.filter((function(n){return n.activeWhen(t)})).map(T)}function Tt(t){if(0===wt.filter((function(n){return T(n)===t})).length)throw Error(s(25,!1,t));return At(t).then((function(){var n=wt.map(T).indexOf(t);wt.splice(n,1);}))}function At(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{waitForUnmount:!1};if("string"!=typeof t)throw Error(s(26,!1));var e=_(wt,(function(n){return T(n)===t}));if(!e)throw Error(s(27,!1,t));var r,o=dt(T(e));if(n&&n.waitForUnmount){if(o)return o.promise;var i=new Promise((function(t,n){vt(e,(function(){return i}),t,n);}));return i}return o?(r=o.promise,Nt(e,o.resolve,o.reject)):r=new Promise((function(t,n){vt(e,(function(){return r}),t,n),Nt(e,t,n);})),r}function Nt(t,n,e){L(t).then(ht).then((function(){n(),setTimeout((function(){Lt();}));})).catch(e);}function St(t){return !t||"function"==typeof t||"object"===n(t)&&null!==t&&!Array.isArray(t)}function _t(t,n){var e=function(t,n){var e=0,r=!1,o="^";"/"!==t[0]&&(t="/"+t);for(var i=0;i<t.length;i++){var u=t[i];(!r&&":"===u||r&&"/"===u)&&a(i);}return a(t.length),new RegExp(o,"i");function a(i){var u=t.slice(e,i).replace(/[|\\{}()[\]^$+*?.]/g,"\\$&");if(o+=r?"[^/]+/?":u,i===t.length)if(r)n&&(o+="$");else {var a=n?"":".*";o="/"===o.charAt(o.length-1)?"".concat(o).concat(a,"$"):"".concat(o,"(/").concat(a,")?(#.*)?$");}r=!r,e=i;}}(t,n);return function(t){var n=t.origin;n||(n="".concat(t.protocol,"//").concat(t.host));var r=t.href.replace(n,"").replace(t.search,"").split("?")[0];return e.test(r)}}var Dt=!1,Ut=[],jt=Y&&window.location.href;function Mt(){return Lt()}function Lt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1?arguments[1]:void 0;if(Dt)return new Promise((function(t,e){Ut.push({resolve:t,reject:e,eventArguments:n});}));var r,i=gt(),u=i.appsToUnload,a=i.appsToUnmount,c=i.appsToLoad,s=i.appsToMount,f=!1,p=jt,h=jt=window.location.href;return Bt()?(Dt=!0,r=u.concat(c,a,s),g()):(r=c,d());function m(){f=!0;}function d(){return Promise.resolve().then((function(){var t=c.map(z);return Promise.all(t).then(y).then((function(){return []})).catch((function(t){throw y(),t}))}))}function g(){return Promise.resolve().then((function(){if(window.dispatchEvent(new o(0===r.length?"single-spa:before-no-app-change":"single-spa:before-app-change",O(!0))),window.dispatchEvent(new o("single-spa:before-routing-event",O(!0,{cancelNavigation:m}))),f)return window.dispatchEvent(new o("single-spa:before-mount-routing-event",O(!0))),E(),void nt(p);var n=u.map(ht),e=a.map(L).map((function(t){return t.then(ht)})).concat(n),i=Promise.all(e);i.then((function(){window.dispatchEvent(new o("single-spa:before-mount-routing-event",O(!0)));}));var l=c.map((function(t){return z(t).then((function(t){return Rt(t,i)}))})),h=s.filter((function(t){return c.indexOf(t)<0})).map((function(t){return Rt(t,i)}));return i.catch((function(t){throw y(),t})).then((function(){return y(),Promise.all(l.concat(h)).catch((function(n){throw t.forEach((function(t){return t.reject(n)})),n})).then(E)}))}))}function E(){var n=Et();t.forEach((function(t){return t.resolve(n)}));try{var e=0===r.length?"single-spa:no-app-change":"single-spa:app-change";window.dispatchEvent(new o(e,O())),window.dispatchEvent(new o("single-spa:routing-event",O()));}catch(t){setTimeout((function(){throw t}));}if(Dt=!1,Ut.length>0){var i=Ut;Ut=[],Lt(i);}return n}function y(){t.forEach((function(t){et(t.eventArguments);})),et(n);}function O(){var t,o=arguments.length>0&&void 0!==arguments[0]&&arguments[0],i=arguments.length>1?arguments[1]:void 0,m={},d=(e(t={},w,[]),e(t,v,[]),e(t,l,[]),e(t,P,[]),t);o?(c.concat(s).forEach((function(t,n){E(t,w);})),u.forEach((function(t){E(t,l);})),a.forEach((function(t){E(t,v);}))):r.forEach((function(t){E(t);}));var g={detail:{newAppStatuses:m,appsByNewStatus:d,totalAppChanges:r.length,originalEvent:null==n?void 0:n[0],oldUrl:p,newUrl:h,navigationIsCanceled:f}};return i&&S(g.detail,i),g;function E(t,n){var e=T(t);n=n||Pt(e),m[e]=n,(d[n]=d[n]||[]).push(e);}}}function Rt(t,n){return b(t)?M(t).then((function(t){return n.then((function(){return b(t)?x(t):t}))})):n.then((function(){return t}))}var It=!1;function xt(t){var n;It=!0,t&&t.urlRerouteOnly&&(n=t.urlRerouteOnly,X=n),Y&&Lt();}function Bt(){return It}Y&&setTimeout((function(){It||console.warn(s(1,!1));}),5e3);var Gt={getRawAppData:function(){return [].concat(wt)},reroute:Lt,NOT_LOADED:l,toLoadPromise:z,toBootstrapPromise:M,unregisterApplication:Tt};Y&&window.__SINGLE_SPA_DEVTOOLS__&&(window.__SINGLE_SPA_DEVTOOLS__.exposedMethods=Gt);
  879. /**
  880. * Appends the elements of `values` to `array`.
  881. *
  882. * @private
  883. * @param {Array} array The array to modify.
  884. * @param {Array} values The values to append.
  885. * @returns {Array} Returns `array`.
  886. */
  887. function arrayPush(array, values) {
  888. var index = -1,
  889. length = values.length,
  890. offset = array.length;
  891. while (++index < length) {
  892. array[offset + index] = values[index];
  893. }
  894. return array;
  895. }
  896. var _arrayPush = arrayPush;
  897. /** Detect free variable `global` from Node.js. */
  898. var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
  899. var _freeGlobal = freeGlobal;
  900. /** Detect free variable `self`. */
  901. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  902. /** Used as a reference to the global object. */
  903. var root = _freeGlobal || freeSelf || Function('return this')();
  904. var _root = root;
  905. /** Built-in value references. */
  906. var Symbol$1 = _root.Symbol;
  907. var _Symbol = Symbol$1;
  908. /** Used for built-in method references. */
  909. var objectProto = Object.prototype;
  910. /** Used to check objects for own properties. */
  911. var hasOwnProperty = objectProto.hasOwnProperty;
  912. /**
  913. * Used to resolve the
  914. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  915. * of values.
  916. */
  917. var nativeObjectToString = objectProto.toString;
  918. /** Built-in value references. */
  919. var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined;
  920. /**
  921. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  922. *
  923. * @private
  924. * @param {*} value The value to query.
  925. * @returns {string} Returns the raw `toStringTag`.
  926. */
  927. function getRawTag(value) {
  928. var isOwn = hasOwnProperty.call(value, symToStringTag),
  929. tag = value[symToStringTag];
  930. try {
  931. value[symToStringTag] = undefined;
  932. var unmasked = true;
  933. } catch (e) {}
  934. var result = nativeObjectToString.call(value);
  935. if (unmasked) {
  936. if (isOwn) {
  937. value[symToStringTag] = tag;
  938. } else {
  939. delete value[symToStringTag];
  940. }
  941. }
  942. return result;
  943. }
  944. var _getRawTag = getRawTag;
  945. /** Used for built-in method references. */
  946. var objectProto$1 = Object.prototype;
  947. /**
  948. * Used to resolve the
  949. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  950. * of values.
  951. */
  952. var nativeObjectToString$1 = objectProto$1.toString;
  953. /**
  954. * Converts `value` to a string using `Object.prototype.toString`.
  955. *
  956. * @private
  957. * @param {*} value The value to convert.
  958. * @returns {string} Returns the converted string.
  959. */
  960. function objectToString(value) {
  961. return nativeObjectToString$1.call(value);
  962. }
  963. var _objectToString = objectToString;
  964. /** `Object#toString` result references. */
  965. var nullTag = '[object Null]',
  966. undefinedTag = '[object Undefined]';
  967. /** Built-in value references. */
  968. var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined;
  969. /**
  970. * The base implementation of `getTag` without fallbacks for buggy environments.
  971. *
  972. * @private
  973. * @param {*} value The value to query.
  974. * @returns {string} Returns the `toStringTag`.
  975. */
  976. function baseGetTag(value) {
  977. if (value == null) {
  978. return value === undefined ? undefinedTag : nullTag;
  979. }
  980. return (symToStringTag$1 && symToStringTag$1 in Object(value))
  981. ? _getRawTag(value)
  982. : _objectToString(value);
  983. }
  984. var _baseGetTag = baseGetTag;
  985. /**
  986. * Checks if `value` is object-like. A value is object-like if it's not `null`
  987. * and has a `typeof` result of "object".
  988. *
  989. * @static
  990. * @memberOf _
  991. * @since 4.0.0
  992. * @category Lang
  993. * @param {*} value The value to check.
  994. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  995. * @example
  996. *
  997. * _.isObjectLike({});
  998. * // => true
  999. *
  1000. * _.isObjectLike([1, 2, 3]);
  1001. * // => true
  1002. *
  1003. * _.isObjectLike(_.noop);
  1004. * // => false
  1005. *
  1006. * _.isObjectLike(null);
  1007. * // => false
  1008. */
  1009. function isObjectLike(value) {
  1010. return value != null && typeof value == 'object';
  1011. }
  1012. var isObjectLike_1 = isObjectLike;
  1013. /** `Object#toString` result references. */
  1014. var argsTag = '[object Arguments]';
  1015. /**
  1016. * The base implementation of `_.isArguments`.
  1017. *
  1018. * @private
  1019. * @param {*} value The value to check.
  1020. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  1021. */
  1022. function baseIsArguments(value) {
  1023. return isObjectLike_1(value) && _baseGetTag(value) == argsTag;
  1024. }
  1025. var _baseIsArguments = baseIsArguments;
  1026. /** Used for built-in method references. */
  1027. var objectProto$2 = Object.prototype;
  1028. /** Used to check objects for own properties. */
  1029. var hasOwnProperty$1 = objectProto$2.hasOwnProperty;
  1030. /** Built-in value references. */
  1031. var propertyIsEnumerable = objectProto$2.propertyIsEnumerable;
  1032. /**
  1033. * Checks if `value` is likely an `arguments` object.
  1034. *
  1035. * @static
  1036. * @memberOf _
  1037. * @since 0.1.0
  1038. * @category Lang
  1039. * @param {*} value The value to check.
  1040. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  1041. * else `false`.
  1042. * @example
  1043. *
  1044. * _.isArguments(function() { return arguments; }());
  1045. * // => true
  1046. *
  1047. * _.isArguments([1, 2, 3]);
  1048. * // => false
  1049. */
  1050. var isArguments = _baseIsArguments(function() { return arguments; }()) ? _baseIsArguments : function(value) {
  1051. return isObjectLike_1(value) && hasOwnProperty$1.call(value, 'callee') &&
  1052. !propertyIsEnumerable.call(value, 'callee');
  1053. };
  1054. var isArguments_1 = isArguments;
  1055. /**
  1056. * Checks if `value` is classified as an `Array` object.
  1057. *
  1058. * @static
  1059. * @memberOf _
  1060. * @since 0.1.0
  1061. * @category Lang
  1062. * @param {*} value The value to check.
  1063. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  1064. * @example
  1065. *
  1066. * _.isArray([1, 2, 3]);
  1067. * // => true
  1068. *
  1069. * _.isArray(document.body.children);
  1070. * // => false
  1071. *
  1072. * _.isArray('abc');
  1073. * // => false
  1074. *
  1075. * _.isArray(_.noop);
  1076. * // => false
  1077. */
  1078. var isArray = Array.isArray;
  1079. var isArray_1 = isArray;
  1080. /** Built-in value references. */
  1081. var spreadableSymbol = _Symbol ? _Symbol.isConcatSpreadable : undefined;
  1082. /**
  1083. * Checks if `value` is a flattenable `arguments` object or array.
  1084. *
  1085. * @private
  1086. * @param {*} value The value to check.
  1087. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  1088. */
  1089. function isFlattenable(value) {
  1090. return isArray_1(value) || isArguments_1(value) ||
  1091. !!(spreadableSymbol && value && value[spreadableSymbol]);
  1092. }
  1093. var _isFlattenable = isFlattenable;
  1094. /**
  1095. * The base implementation of `_.flatten` with support for restricting flattening.
  1096. *
  1097. * @private
  1098. * @param {Array} array The array to flatten.
  1099. * @param {number} depth The maximum recursion depth.
  1100. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  1101. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  1102. * @param {Array} [result=[]] The initial result value.
  1103. * @returns {Array} Returns the new flattened array.
  1104. */
  1105. function baseFlatten(array, depth, predicate, isStrict, result) {
  1106. var index = -1,
  1107. length = array.length;
  1108. predicate || (predicate = _isFlattenable);
  1109. result || (result = []);
  1110. while (++index < length) {
  1111. var value = array[index];
  1112. if (depth > 0 && predicate(value)) {
  1113. if (depth > 1) {
  1114. // Recursively flatten arrays (susceptible to call stack limits).
  1115. baseFlatten(value, depth - 1, predicate, isStrict, result);
  1116. } else {
  1117. _arrayPush(result, value);
  1118. }
  1119. } else if (!isStrict) {
  1120. result[result.length] = value;
  1121. }
  1122. }
  1123. return result;
  1124. }
  1125. var _baseFlatten = baseFlatten;
  1126. /**
  1127. * Copies the values of `source` to `array`.
  1128. *
  1129. * @private
  1130. * @param {Array} source The array to copy values from.
  1131. * @param {Array} [array=[]] The array to copy values to.
  1132. * @returns {Array} Returns `array`.
  1133. */
  1134. function copyArray(source, array) {
  1135. var index = -1,
  1136. length = source.length;
  1137. array || (array = Array(length));
  1138. while (++index < length) {
  1139. array[index] = source[index];
  1140. }
  1141. return array;
  1142. }
  1143. var _copyArray = copyArray;
  1144. /**
  1145. * Creates a new array concatenating `array` with any additional arrays
  1146. * and/or values.
  1147. *
  1148. * @static
  1149. * @memberOf _
  1150. * @since 4.0.0
  1151. * @category Array
  1152. * @param {Array} array The array to concatenate.
  1153. * @param {...*} [values] The values to concatenate.
  1154. * @returns {Array} Returns the new concatenated array.
  1155. * @example
  1156. *
  1157. * var array = [1];
  1158. * var other = _.concat(array, 2, [3], [[4]]);
  1159. *
  1160. * console.log(other);
  1161. * // => [1, 2, 3, [4]]
  1162. *
  1163. * console.log(array);
  1164. * // => [1]
  1165. */
  1166. function concat() {
  1167. var length = arguments.length;
  1168. if (!length) {
  1169. return [];
  1170. }
  1171. var args = Array(length - 1),
  1172. array = arguments[0],
  1173. index = length;
  1174. while (index--) {
  1175. args[index - 1] = arguments[index];
  1176. }
  1177. return _arrayPush(isArray_1(array) ? _copyArray(array) : [array], _baseFlatten(args, 1));
  1178. }
  1179. var concat_1 = concat;
  1180. /**
  1181. * Removes all key-value entries from the list cache.
  1182. *
  1183. * @private
  1184. * @name clear
  1185. * @memberOf ListCache
  1186. */
  1187. function listCacheClear() {
  1188. this.__data__ = [];
  1189. this.size = 0;
  1190. }
  1191. var _listCacheClear = listCacheClear;
  1192. /**
  1193. * Performs a
  1194. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  1195. * comparison between two values to determine if they are equivalent.
  1196. *
  1197. * @static
  1198. * @memberOf _
  1199. * @since 4.0.0
  1200. * @category Lang
  1201. * @param {*} value The value to compare.
  1202. * @param {*} other The other value to compare.
  1203. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  1204. * @example
  1205. *
  1206. * var object = { 'a': 1 };
  1207. * var other = { 'a': 1 };
  1208. *
  1209. * _.eq(object, object);
  1210. * // => true
  1211. *
  1212. * _.eq(object, other);
  1213. * // => false
  1214. *
  1215. * _.eq('a', 'a');
  1216. * // => true
  1217. *
  1218. * _.eq('a', Object('a'));
  1219. * // => false
  1220. *
  1221. * _.eq(NaN, NaN);
  1222. * // => true
  1223. */
  1224. function eq(value, other) {
  1225. return value === other || (value !== value && other !== other);
  1226. }
  1227. var eq_1 = eq;
  1228. /**
  1229. * Gets the index at which the `key` is found in `array` of key-value pairs.
  1230. *
  1231. * @private
  1232. * @param {Array} array The array to inspect.
  1233. * @param {*} key The key to search for.
  1234. * @returns {number} Returns the index of the matched value, else `-1`.
  1235. */
  1236. function assocIndexOf(array, key) {
  1237. var length = array.length;
  1238. while (length--) {
  1239. if (eq_1(array[length][0], key)) {
  1240. return length;
  1241. }
  1242. }
  1243. return -1;
  1244. }
  1245. var _assocIndexOf = assocIndexOf;
  1246. /** Used for built-in method references. */
  1247. var arrayProto = Array.prototype;
  1248. /** Built-in value references. */
  1249. var splice = arrayProto.splice;
  1250. /**
  1251. * Removes `key` and its value from the list cache.
  1252. *
  1253. * @private
  1254. * @name delete
  1255. * @memberOf ListCache
  1256. * @param {string} key The key of the value to remove.
  1257. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  1258. */
  1259. function listCacheDelete(key) {
  1260. var data = this.__data__,
  1261. index = _assocIndexOf(data, key);
  1262. if (index < 0) {
  1263. return false;
  1264. }
  1265. var lastIndex = data.length - 1;
  1266. if (index == lastIndex) {
  1267. data.pop();
  1268. } else {
  1269. splice.call(data, index, 1);
  1270. }
  1271. --this.size;
  1272. return true;
  1273. }
  1274. var _listCacheDelete = listCacheDelete;
  1275. /**
  1276. * Gets the list cache value for `key`.
  1277. *
  1278. * @private
  1279. * @name get
  1280. * @memberOf ListCache
  1281. * @param {string} key The key of the value to get.
  1282. * @returns {*} Returns the entry value.
  1283. */
  1284. function listCacheGet(key) {
  1285. var data = this.__data__,
  1286. index = _assocIndexOf(data, key);
  1287. return index < 0 ? undefined : data[index][1];
  1288. }
  1289. var _listCacheGet = listCacheGet;
  1290. /**
  1291. * Checks if a list cache value for `key` exists.
  1292. *
  1293. * @private
  1294. * @name has
  1295. * @memberOf ListCache
  1296. * @param {string} key The key of the entry to check.
  1297. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  1298. */
  1299. function listCacheHas(key) {
  1300. return _assocIndexOf(this.__data__, key) > -1;
  1301. }
  1302. var _listCacheHas = listCacheHas;
  1303. /**
  1304. * Sets the list cache `key` to `value`.
  1305. *
  1306. * @private
  1307. * @name set
  1308. * @memberOf ListCache
  1309. * @param {string} key The key of the value to set.
  1310. * @param {*} value The value to set.
  1311. * @returns {Object} Returns the list cache instance.
  1312. */
  1313. function listCacheSet(key, value) {
  1314. var data = this.__data__,
  1315. index = _assocIndexOf(data, key);
  1316. if (index < 0) {
  1317. ++this.size;
  1318. data.push([key, value]);
  1319. } else {
  1320. data[index][1] = value;
  1321. }
  1322. return this;
  1323. }
  1324. var _listCacheSet = listCacheSet;
  1325. /**
  1326. * Creates an list cache object.
  1327. *
  1328. * @private
  1329. * @constructor
  1330. * @param {Array} [entries] The key-value pairs to cache.
  1331. */
  1332. function ListCache(entries) {
  1333. var index = -1,
  1334. length = entries == null ? 0 : entries.length;
  1335. this.clear();
  1336. while (++index < length) {
  1337. var entry = entries[index];
  1338. this.set(entry[0], entry[1]);
  1339. }
  1340. }
  1341. // Add methods to `ListCache`.
  1342. ListCache.prototype.clear = _listCacheClear;
  1343. ListCache.prototype['delete'] = _listCacheDelete;
  1344. ListCache.prototype.get = _listCacheGet;
  1345. ListCache.prototype.has = _listCacheHas;
  1346. ListCache.prototype.set = _listCacheSet;
  1347. var _ListCache = ListCache;
  1348. /**
  1349. * Removes all key-value entries from the stack.
  1350. *
  1351. * @private
  1352. * @name clear
  1353. * @memberOf Stack
  1354. */
  1355. function stackClear() {
  1356. this.__data__ = new _ListCache;
  1357. this.size = 0;
  1358. }
  1359. var _stackClear = stackClear;
  1360. /**
  1361. * Removes `key` and its value from the stack.
  1362. *
  1363. * @private
  1364. * @name delete
  1365. * @memberOf Stack
  1366. * @param {string} key The key of the value to remove.
  1367. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  1368. */
  1369. function stackDelete(key) {
  1370. var data = this.__data__,
  1371. result = data['delete'](key);
  1372. this.size = data.size;
  1373. return result;
  1374. }
  1375. var _stackDelete = stackDelete;
  1376. /**
  1377. * Gets the stack value for `key`.
  1378. *
  1379. * @private
  1380. * @name get
  1381. * @memberOf Stack
  1382. * @param {string} key The key of the value to get.
  1383. * @returns {*} Returns the entry value.
  1384. */
  1385. function stackGet(key) {
  1386. return this.__data__.get(key);
  1387. }
  1388. var _stackGet = stackGet;
  1389. /**
  1390. * Checks if a stack value for `key` exists.
  1391. *
  1392. * @private
  1393. * @name has
  1394. * @memberOf Stack
  1395. * @param {string} key The key of the entry to check.
  1396. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  1397. */
  1398. function stackHas(key) {
  1399. return this.__data__.has(key);
  1400. }
  1401. var _stackHas = stackHas;
  1402. /**
  1403. * Checks if `value` is the
  1404. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  1405. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  1406. *
  1407. * @static
  1408. * @memberOf _
  1409. * @since 0.1.0
  1410. * @category Lang
  1411. * @param {*} value The value to check.
  1412. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  1413. * @example
  1414. *
  1415. * _.isObject({});
  1416. * // => true
  1417. *
  1418. * _.isObject([1, 2, 3]);
  1419. * // => true
  1420. *
  1421. * _.isObject(_.noop);
  1422. * // => true
  1423. *
  1424. * _.isObject(null);
  1425. * // => false
  1426. */
  1427. function isObject(value) {
  1428. var type = typeof value;
  1429. return value != null && (type == 'object' || type == 'function');
  1430. }
  1431. var isObject_1 = isObject;
  1432. /** `Object#toString` result references. */
  1433. var asyncTag = '[object AsyncFunction]',
  1434. funcTag = '[object Function]',
  1435. genTag = '[object GeneratorFunction]',
  1436. proxyTag = '[object Proxy]';
  1437. /**
  1438. * Checks if `value` is classified as a `Function` object.
  1439. *
  1440. * @static
  1441. * @memberOf _
  1442. * @since 0.1.0
  1443. * @category Lang
  1444. * @param {*} value The value to check.
  1445. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  1446. * @example
  1447. *
  1448. * _.isFunction(_);
  1449. * // => true
  1450. *
  1451. * _.isFunction(/abc/);
  1452. * // => false
  1453. */
  1454. function isFunction(value) {
  1455. if (!isObject_1(value)) {
  1456. return false;
  1457. }
  1458. // The use of `Object#toString` avoids issues with the `typeof` operator
  1459. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  1460. var tag = _baseGetTag(value);
  1461. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  1462. }
  1463. var isFunction_1 = isFunction;
  1464. /** Used to detect overreaching core-js shims. */
  1465. var coreJsData = _root['__core-js_shared__'];
  1466. var _coreJsData = coreJsData;
  1467. /** Used to detect methods masquerading as native. */
  1468. var maskSrcKey = (function() {
  1469. var uid = /[^.]+$/.exec(_coreJsData && _coreJsData.keys && _coreJsData.keys.IE_PROTO || '');
  1470. return uid ? ('Symbol(src)_1.' + uid) : '';
  1471. }());
  1472. /**
  1473. * Checks if `func` has its source masked.
  1474. *
  1475. * @private
  1476. * @param {Function} func The function to check.
  1477. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  1478. */
  1479. function isMasked(func) {
  1480. return !!maskSrcKey && (maskSrcKey in func);
  1481. }
  1482. var _isMasked = isMasked;
  1483. /** Used for built-in method references. */
  1484. var funcProto = Function.prototype;
  1485. /** Used to resolve the decompiled source of functions. */
  1486. var funcToString = funcProto.toString;
  1487. /**
  1488. * Converts `func` to its source code.
  1489. *
  1490. * @private
  1491. * @param {Function} func The function to convert.
  1492. * @returns {string} Returns the source code.
  1493. */
  1494. function toSource(func) {
  1495. if (func != null) {
  1496. try {
  1497. return funcToString.call(func);
  1498. } catch (e) {}
  1499. try {
  1500. return (func + '');
  1501. } catch (e) {}
  1502. }
  1503. return '';
  1504. }
  1505. var _toSource = toSource;
  1506. /**
  1507. * Used to match `RegExp`
  1508. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  1509. */
  1510. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  1511. /** Used to detect host constructors (Safari). */
  1512. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  1513. /** Used for built-in method references. */
  1514. var funcProto$1 = Function.prototype,
  1515. objectProto$3 = Object.prototype;
  1516. /** Used to resolve the decompiled source of functions. */
  1517. var funcToString$1 = funcProto$1.toString;
  1518. /** Used to check objects for own properties. */
  1519. var hasOwnProperty$2 = objectProto$3.hasOwnProperty;
  1520. /** Used to detect if a method is native. */
  1521. var reIsNative = RegExp('^' +
  1522. funcToString$1.call(hasOwnProperty$2).replace(reRegExpChar, '\\$&')
  1523. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  1524. );
  1525. /**
  1526. * The base implementation of `_.isNative` without bad shim checks.
  1527. *
  1528. * @private
  1529. * @param {*} value The value to check.
  1530. * @returns {boolean} Returns `true` if `value` is a native function,
  1531. * else `false`.
  1532. */
  1533. function baseIsNative(value) {
  1534. if (!isObject_1(value) || _isMasked(value)) {
  1535. return false;
  1536. }
  1537. var pattern = isFunction_1(value) ? reIsNative : reIsHostCtor;
  1538. return pattern.test(_toSource(value));
  1539. }
  1540. var _baseIsNative = baseIsNative;
  1541. /**
  1542. * Gets the value at `key` of `object`.
  1543. *
  1544. * @private
  1545. * @param {Object} [object] The object to query.
  1546. * @param {string} key The key of the property to get.
  1547. * @returns {*} Returns the property value.
  1548. */
  1549. function getValue(object, key) {
  1550. return object == null ? undefined : object[key];
  1551. }
  1552. var _getValue = getValue;
  1553. /**
  1554. * Gets the native function at `key` of `object`.
  1555. *
  1556. * @private
  1557. * @param {Object} object The object to query.
  1558. * @param {string} key The key of the method to get.
  1559. * @returns {*} Returns the function if it's native, else `undefined`.
  1560. */
  1561. function getNative(object, key) {
  1562. var value = _getValue(object, key);
  1563. return _baseIsNative(value) ? value : undefined;
  1564. }
  1565. var _getNative = getNative;
  1566. /* Built-in method references that are verified to be native. */
  1567. var Map$1 = _getNative(_root, 'Map');
  1568. var _Map = Map$1;
  1569. /* Built-in method references that are verified to be native. */
  1570. var nativeCreate = _getNative(Object, 'create');
  1571. var _nativeCreate = nativeCreate;
  1572. /**
  1573. * Removes all key-value entries from the hash.
  1574. *
  1575. * @private
  1576. * @name clear
  1577. * @memberOf Hash
  1578. */
  1579. function hashClear() {
  1580. this.__data__ = _nativeCreate ? _nativeCreate(null) : {};
  1581. this.size = 0;
  1582. }
  1583. var _hashClear = hashClear;
  1584. /**
  1585. * Removes `key` and its value from the hash.
  1586. *
  1587. * @private
  1588. * @name delete
  1589. * @memberOf Hash
  1590. * @param {Object} hash The hash to modify.
  1591. * @param {string} key The key of the value to remove.
  1592. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  1593. */
  1594. function hashDelete(key) {
  1595. var result = this.has(key) && delete this.__data__[key];
  1596. this.size -= result ? 1 : 0;
  1597. return result;
  1598. }
  1599. var _hashDelete = hashDelete;
  1600. /** Used to stand-in for `undefined` hash values. */
  1601. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  1602. /** Used for built-in method references. */
  1603. var objectProto$4 = Object.prototype;
  1604. /** Used to check objects for own properties. */
  1605. var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
  1606. /**
  1607. * Gets the hash value for `key`.
  1608. *
  1609. * @private
  1610. * @name get
  1611. * @memberOf Hash
  1612. * @param {string} key The key of the value to get.
  1613. * @returns {*} Returns the entry value.
  1614. */
  1615. function hashGet(key) {
  1616. var data = this.__data__;
  1617. if (_nativeCreate) {
  1618. var result = data[key];
  1619. return result === HASH_UNDEFINED ? undefined : result;
  1620. }
  1621. return hasOwnProperty$3.call(data, key) ? data[key] : undefined;
  1622. }
  1623. var _hashGet = hashGet;
  1624. /** Used for built-in method references. */
  1625. var objectProto$5 = Object.prototype;
  1626. /** Used to check objects for own properties. */
  1627. var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
  1628. /**
  1629. * Checks if a hash value for `key` exists.
  1630. *
  1631. * @private
  1632. * @name has
  1633. * @memberOf Hash
  1634. * @param {string} key The key of the entry to check.
  1635. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  1636. */
  1637. function hashHas(key) {
  1638. var data = this.__data__;
  1639. return _nativeCreate ? (data[key] !== undefined) : hasOwnProperty$4.call(data, key);
  1640. }
  1641. var _hashHas = hashHas;
  1642. /** Used to stand-in for `undefined` hash values. */
  1643. var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
  1644. /**
  1645. * Sets the hash `key` to `value`.
  1646. *
  1647. * @private
  1648. * @name set
  1649. * @memberOf Hash
  1650. * @param {string} key The key of the value to set.
  1651. * @param {*} value The value to set.
  1652. * @returns {Object} Returns the hash instance.
  1653. */
  1654. function hashSet(key, value) {
  1655. var data = this.__data__;
  1656. this.size += this.has(key) ? 0 : 1;
  1657. data[key] = (_nativeCreate && value === undefined) ? HASH_UNDEFINED$1 : value;
  1658. return this;
  1659. }
  1660. var _hashSet = hashSet;
  1661. /**
  1662. * Creates a hash object.
  1663. *
  1664. * @private
  1665. * @constructor
  1666. * @param {Array} [entries] The key-value pairs to cache.
  1667. */
  1668. function Hash(entries) {
  1669. var index = -1,
  1670. length = entries == null ? 0 : entries.length;
  1671. this.clear();
  1672. while (++index < length) {
  1673. var entry = entries[index];
  1674. this.set(entry[0], entry[1]);
  1675. }
  1676. }
  1677. // Add methods to `Hash`.
  1678. Hash.prototype.clear = _hashClear;
  1679. Hash.prototype['delete'] = _hashDelete;
  1680. Hash.prototype.get = _hashGet;
  1681. Hash.prototype.has = _hashHas;
  1682. Hash.prototype.set = _hashSet;
  1683. var _Hash = Hash;
  1684. /**
  1685. * Removes all key-value entries from the map.
  1686. *
  1687. * @private
  1688. * @name clear
  1689. * @memberOf MapCache
  1690. */
  1691. function mapCacheClear() {
  1692. this.size = 0;
  1693. this.__data__ = {
  1694. 'hash': new _Hash,
  1695. 'map': new (_Map || _ListCache),
  1696. 'string': new _Hash
  1697. };
  1698. }
  1699. var _mapCacheClear = mapCacheClear;
  1700. /**
  1701. * Checks if `value` is suitable for use as unique object key.
  1702. *
  1703. * @private
  1704. * @param {*} value The value to check.
  1705. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  1706. */
  1707. function isKeyable(value) {
  1708. var type = typeof value;
  1709. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  1710. ? (value !== '__proto__')
  1711. : (value === null);
  1712. }
  1713. var _isKeyable = isKeyable;
  1714. /**
  1715. * Gets the data for `map`.
  1716. *
  1717. * @private
  1718. * @param {Object} map The map to query.
  1719. * @param {string} key The reference key.
  1720. * @returns {*} Returns the map data.
  1721. */
  1722. function getMapData(map, key) {
  1723. var data = map.__data__;
  1724. return _isKeyable(key)
  1725. ? data[typeof key == 'string' ? 'string' : 'hash']
  1726. : data.map;
  1727. }
  1728. var _getMapData = getMapData;
  1729. /**
  1730. * Removes `key` and its value from the map.
  1731. *
  1732. * @private
  1733. * @name delete
  1734. * @memberOf MapCache
  1735. * @param {string} key The key of the value to remove.
  1736. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  1737. */
  1738. function mapCacheDelete(key) {
  1739. var result = _getMapData(this, key)['delete'](key);
  1740. this.size -= result ? 1 : 0;
  1741. return result;
  1742. }
  1743. var _mapCacheDelete = mapCacheDelete;
  1744. /**
  1745. * Gets the map value for `key`.
  1746. *
  1747. * @private
  1748. * @name get
  1749. * @memberOf MapCache
  1750. * @param {string} key The key of the value to get.
  1751. * @returns {*} Returns the entry value.
  1752. */
  1753. function mapCacheGet(key) {
  1754. return _getMapData(this, key).get(key);
  1755. }
  1756. var _mapCacheGet = mapCacheGet;
  1757. /**
  1758. * Checks if a map value for `key` exists.
  1759. *
  1760. * @private
  1761. * @name has
  1762. * @memberOf MapCache
  1763. * @param {string} key The key of the entry to check.
  1764. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  1765. */
  1766. function mapCacheHas(key) {
  1767. return _getMapData(this, key).has(key);
  1768. }
  1769. var _mapCacheHas = mapCacheHas;
  1770. /**
  1771. * Sets the map `key` to `value`.
  1772. *
  1773. * @private
  1774. * @name set
  1775. * @memberOf MapCache
  1776. * @param {string} key The key of the value to set.
  1777. * @param {*} value The value to set.
  1778. * @returns {Object} Returns the map cache instance.
  1779. */
  1780. function mapCacheSet(key, value) {
  1781. var data = _getMapData(this, key),
  1782. size = data.size;
  1783. data.set(key, value);
  1784. this.size += data.size == size ? 0 : 1;
  1785. return this;
  1786. }
  1787. var _mapCacheSet = mapCacheSet;
  1788. /**
  1789. * Creates a map cache object to store key-value pairs.
  1790. *
  1791. * @private
  1792. * @constructor
  1793. * @param {Array} [entries] The key-value pairs to cache.
  1794. */
  1795. function MapCache(entries) {
  1796. var index = -1,
  1797. length = entries == null ? 0 : entries.length;
  1798. this.clear();
  1799. while (++index < length) {
  1800. var entry = entries[index];
  1801. this.set(entry[0], entry[1]);
  1802. }
  1803. }
  1804. // Add methods to `MapCache`.
  1805. MapCache.prototype.clear = _mapCacheClear;
  1806. MapCache.prototype['delete'] = _mapCacheDelete;
  1807. MapCache.prototype.get = _mapCacheGet;
  1808. MapCache.prototype.has = _mapCacheHas;
  1809. MapCache.prototype.set = _mapCacheSet;
  1810. var _MapCache = MapCache;
  1811. /** Used as the size to enable large array optimizations. */
  1812. var LARGE_ARRAY_SIZE = 200;
  1813. /**
  1814. * Sets the stack `key` to `value`.
  1815. *
  1816. * @private
  1817. * @name set
  1818. * @memberOf Stack
  1819. * @param {string} key The key of the value to set.
  1820. * @param {*} value The value to set.
  1821. * @returns {Object} Returns the stack cache instance.
  1822. */
  1823. function stackSet(key, value) {
  1824. var data = this.__data__;
  1825. if (data instanceof _ListCache) {
  1826. var pairs = data.__data__;
  1827. if (!_Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  1828. pairs.push([key, value]);
  1829. this.size = ++data.size;
  1830. return this;
  1831. }
  1832. data = this.__data__ = new _MapCache(pairs);
  1833. }
  1834. data.set(key, value);
  1835. this.size = data.size;
  1836. return this;
  1837. }
  1838. var _stackSet = stackSet;
  1839. /**
  1840. * Creates a stack cache object to store key-value pairs.
  1841. *
  1842. * @private
  1843. * @constructor
  1844. * @param {Array} [entries] The key-value pairs to cache.
  1845. */
  1846. function Stack(entries) {
  1847. var data = this.__data__ = new _ListCache(entries);
  1848. this.size = data.size;
  1849. }
  1850. // Add methods to `Stack`.
  1851. Stack.prototype.clear = _stackClear;
  1852. Stack.prototype['delete'] = _stackDelete;
  1853. Stack.prototype.get = _stackGet;
  1854. Stack.prototype.has = _stackHas;
  1855. Stack.prototype.set = _stackSet;
  1856. var _Stack = Stack;
  1857. var defineProperty$1 = (function() {
  1858. try {
  1859. var func = _getNative(Object, 'defineProperty');
  1860. func({}, '', {});
  1861. return func;
  1862. } catch (e) {}
  1863. }());
  1864. var _defineProperty$1 = defineProperty$1;
  1865. /**
  1866. * The base implementation of `assignValue` and `assignMergeValue` without
  1867. * value checks.
  1868. *
  1869. * @private
  1870. * @param {Object} object The object to modify.
  1871. * @param {string} key The key of the property to assign.
  1872. * @param {*} value The value to assign.
  1873. */
  1874. function baseAssignValue(object, key, value) {
  1875. if (key == '__proto__' && _defineProperty$1) {
  1876. _defineProperty$1(object, key, {
  1877. 'configurable': true,
  1878. 'enumerable': true,
  1879. 'value': value,
  1880. 'writable': true
  1881. });
  1882. } else {
  1883. object[key] = value;
  1884. }
  1885. }
  1886. var _baseAssignValue = baseAssignValue;
  1887. /**
  1888. * This function is like `assignValue` except that it doesn't assign
  1889. * `undefined` values.
  1890. *
  1891. * @private
  1892. * @param {Object} object The object to modify.
  1893. * @param {string} key The key of the property to assign.
  1894. * @param {*} value The value to assign.
  1895. */
  1896. function assignMergeValue(object, key, value) {
  1897. if ((value !== undefined && !eq_1(object[key], value)) ||
  1898. (value === undefined && !(key in object))) {
  1899. _baseAssignValue(object, key, value);
  1900. }
  1901. }
  1902. var _assignMergeValue = assignMergeValue;
  1903. /**
  1904. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  1905. *
  1906. * @private
  1907. * @param {boolean} [fromRight] Specify iterating from right to left.
  1908. * @returns {Function} Returns the new base function.
  1909. */
  1910. function createBaseFor(fromRight) {
  1911. return function(object, iteratee, keysFunc) {
  1912. var index = -1,
  1913. iterable = Object(object),
  1914. props = keysFunc(object),
  1915. length = props.length;
  1916. while (length--) {
  1917. var key = props[fromRight ? length : ++index];
  1918. if (iteratee(iterable[key], key, iterable) === false) {
  1919. break;
  1920. }
  1921. }
  1922. return object;
  1923. };
  1924. }
  1925. var _createBaseFor = createBaseFor;
  1926. /**
  1927. * The base implementation of `baseForOwn` which iterates over `object`
  1928. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  1929. * Iteratee functions may exit iteration early by explicitly returning `false`.
  1930. *
  1931. * @private
  1932. * @param {Object} object The object to iterate over.
  1933. * @param {Function} iteratee The function invoked per iteration.
  1934. * @param {Function} keysFunc The function to get the keys of `object`.
  1935. * @returns {Object} Returns `object`.
  1936. */
  1937. var baseFor = _createBaseFor();
  1938. var _baseFor = baseFor;
  1939. var _cloneBuffer = createCommonjsModule(function (module, exports) {
  1940. /** Detect free variable `exports`. */
  1941. var freeExports = exports && !exports.nodeType && exports;
  1942. /** Detect free variable `module`. */
  1943. var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
  1944. /** Detect the popular CommonJS extension `module.exports`. */
  1945. var moduleExports = freeModule && freeModule.exports === freeExports;
  1946. /** Built-in value references. */
  1947. var Buffer = moduleExports ? _root.Buffer : undefined,
  1948. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined;
  1949. /**
  1950. * Creates a clone of `buffer`.
  1951. *
  1952. * @private
  1953. * @param {Buffer} buffer The buffer to clone.
  1954. * @param {boolean} [isDeep] Specify a deep clone.
  1955. * @returns {Buffer} Returns the cloned buffer.
  1956. */
  1957. function cloneBuffer(buffer, isDeep) {
  1958. if (isDeep) {
  1959. return buffer.slice();
  1960. }
  1961. var length = buffer.length,
  1962. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  1963. buffer.copy(result);
  1964. return result;
  1965. }
  1966. module.exports = cloneBuffer;
  1967. });
  1968. /** Built-in value references. */
  1969. var Uint8Array = _root.Uint8Array;
  1970. var _Uint8Array = Uint8Array;
  1971. /**
  1972. * Creates a clone of `arrayBuffer`.
  1973. *
  1974. * @private
  1975. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  1976. * @returns {ArrayBuffer} Returns the cloned array buffer.
  1977. */
  1978. function cloneArrayBuffer(arrayBuffer) {
  1979. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  1980. new _Uint8Array(result).set(new _Uint8Array(arrayBuffer));
  1981. return result;
  1982. }
  1983. var _cloneArrayBuffer = cloneArrayBuffer;
  1984. /**
  1985. * Creates a clone of `typedArray`.
  1986. *
  1987. * @private
  1988. * @param {Object} typedArray The typed array to clone.
  1989. * @param {boolean} [isDeep] Specify a deep clone.
  1990. * @returns {Object} Returns the cloned typed array.
  1991. */
  1992. function cloneTypedArray(typedArray, isDeep) {
  1993. var buffer = isDeep ? _cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  1994. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  1995. }
  1996. var _cloneTypedArray = cloneTypedArray;
  1997. /** Built-in value references. */
  1998. var objectCreate = Object.create;
  1999. /**
  2000. * The base implementation of `_.create` without support for assigning
  2001. * properties to the created object.
  2002. *
  2003. * @private
  2004. * @param {Object} proto The object to inherit from.
  2005. * @returns {Object} Returns the new object.
  2006. */
  2007. var baseCreate = (function() {
  2008. function object() {}
  2009. return function(proto) {
  2010. if (!isObject_1(proto)) {
  2011. return {};
  2012. }
  2013. if (objectCreate) {
  2014. return objectCreate(proto);
  2015. }
  2016. object.prototype = proto;
  2017. var result = new object;
  2018. object.prototype = undefined;
  2019. return result;
  2020. };
  2021. }());
  2022. var _baseCreate = baseCreate;
  2023. /**
  2024. * Creates a unary function that invokes `func` with its argument transformed.
  2025. *
  2026. * @private
  2027. * @param {Function} func The function to wrap.
  2028. * @param {Function} transform The argument transform.
  2029. * @returns {Function} Returns the new function.
  2030. */
  2031. function overArg(func, transform) {
  2032. return function(arg) {
  2033. return func(transform(arg));
  2034. };
  2035. }
  2036. var _overArg = overArg;
  2037. /** Built-in value references. */
  2038. var getPrototype = _overArg(Object.getPrototypeOf, Object);
  2039. var _getPrototype = getPrototype;
  2040. /** Used for built-in method references. */
  2041. var objectProto$6 = Object.prototype;
  2042. /**
  2043. * Checks if `value` is likely a prototype object.
  2044. *
  2045. * @private
  2046. * @param {*} value The value to check.
  2047. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  2048. */
  2049. function isPrototype(value) {
  2050. var Ctor = value && value.constructor,
  2051. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$6;
  2052. return value === proto;
  2053. }
  2054. var _isPrototype = isPrototype;
  2055. /**
  2056. * Initializes an object clone.
  2057. *
  2058. * @private
  2059. * @param {Object} object The object to clone.
  2060. * @returns {Object} Returns the initialized clone.
  2061. */
  2062. function initCloneObject(object) {
  2063. return (typeof object.constructor == 'function' && !_isPrototype(object))
  2064. ? _baseCreate(_getPrototype(object))
  2065. : {};
  2066. }
  2067. var _initCloneObject = initCloneObject;
  2068. /** Used as references for various `Number` constants. */
  2069. var MAX_SAFE_INTEGER = 9007199254740991;
  2070. /**
  2071. * Checks if `value` is a valid array-like length.
  2072. *
  2073. * **Note:** This method is loosely based on
  2074. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  2075. *
  2076. * @static
  2077. * @memberOf _
  2078. * @since 4.0.0
  2079. * @category Lang
  2080. * @param {*} value The value to check.
  2081. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  2082. * @example
  2083. *
  2084. * _.isLength(3);
  2085. * // => true
  2086. *
  2087. * _.isLength(Number.MIN_VALUE);
  2088. * // => false
  2089. *
  2090. * _.isLength(Infinity);
  2091. * // => false
  2092. *
  2093. * _.isLength('3');
  2094. * // => false
  2095. */
  2096. function isLength(value) {
  2097. return typeof value == 'number' &&
  2098. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  2099. }
  2100. var isLength_1 = isLength;
  2101. /**
  2102. * Checks if `value` is array-like. A value is considered array-like if it's
  2103. * not a function and has a `value.length` that's an integer greater than or
  2104. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  2105. *
  2106. * @static
  2107. * @memberOf _
  2108. * @since 4.0.0
  2109. * @category Lang
  2110. * @param {*} value The value to check.
  2111. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  2112. * @example
  2113. *
  2114. * _.isArrayLike([1, 2, 3]);
  2115. * // => true
  2116. *
  2117. * _.isArrayLike(document.body.children);
  2118. * // => true
  2119. *
  2120. * _.isArrayLike('abc');
  2121. * // => true
  2122. *
  2123. * _.isArrayLike(_.noop);
  2124. * // => false
  2125. */
  2126. function isArrayLike(value) {
  2127. return value != null && isLength_1(value.length) && !isFunction_1(value);
  2128. }
  2129. var isArrayLike_1 = isArrayLike;
  2130. /**
  2131. * This method is like `_.isArrayLike` except that it also checks if `value`
  2132. * is an object.
  2133. *
  2134. * @static
  2135. * @memberOf _
  2136. * @since 4.0.0
  2137. * @category Lang
  2138. * @param {*} value The value to check.
  2139. * @returns {boolean} Returns `true` if `value` is an array-like object,
  2140. * else `false`.
  2141. * @example
  2142. *
  2143. * _.isArrayLikeObject([1, 2, 3]);
  2144. * // => true
  2145. *
  2146. * _.isArrayLikeObject(document.body.children);
  2147. * // => true
  2148. *
  2149. * _.isArrayLikeObject('abc');
  2150. * // => false
  2151. *
  2152. * _.isArrayLikeObject(_.noop);
  2153. * // => false
  2154. */
  2155. function isArrayLikeObject(value) {
  2156. return isObjectLike_1(value) && isArrayLike_1(value);
  2157. }
  2158. var isArrayLikeObject_1 = isArrayLikeObject;
  2159. /**
  2160. * This method returns `false`.
  2161. *
  2162. * @static
  2163. * @memberOf _
  2164. * @since 4.13.0
  2165. * @category Util
  2166. * @returns {boolean} Returns `false`.
  2167. * @example
  2168. *
  2169. * _.times(2, _.stubFalse);
  2170. * // => [false, false]
  2171. */
  2172. function stubFalse() {
  2173. return false;
  2174. }
  2175. var stubFalse_1 = stubFalse;
  2176. var isBuffer_1 = createCommonjsModule(function (module, exports) {
  2177. /** Detect free variable `exports`. */
  2178. var freeExports = exports && !exports.nodeType && exports;
  2179. /** Detect free variable `module`. */
  2180. var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
  2181. /** Detect the popular CommonJS extension `module.exports`. */
  2182. var moduleExports = freeModule && freeModule.exports === freeExports;
  2183. /** Built-in value references. */
  2184. var Buffer = moduleExports ? _root.Buffer : undefined;
  2185. /* Built-in method references for those with the same name as other `lodash` methods. */
  2186. var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
  2187. /**
  2188. * Checks if `value` is a buffer.
  2189. *
  2190. * @static
  2191. * @memberOf _
  2192. * @since 4.3.0
  2193. * @category Lang
  2194. * @param {*} value The value to check.
  2195. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  2196. * @example
  2197. *
  2198. * _.isBuffer(new Buffer(2));
  2199. * // => true
  2200. *
  2201. * _.isBuffer(new Uint8Array(2));
  2202. * // => false
  2203. */
  2204. var isBuffer = nativeIsBuffer || stubFalse_1;
  2205. module.exports = isBuffer;
  2206. });
  2207. /** `Object#toString` result references. */
  2208. var objectTag = '[object Object]';
  2209. /** Used for built-in method references. */
  2210. var funcProto$2 = Function.prototype,
  2211. objectProto$7 = Object.prototype;
  2212. /** Used to resolve the decompiled source of functions. */
  2213. var funcToString$2 = funcProto$2.toString;
  2214. /** Used to check objects for own properties. */
  2215. var hasOwnProperty$5 = objectProto$7.hasOwnProperty;
  2216. /** Used to infer the `Object` constructor. */
  2217. var objectCtorString = funcToString$2.call(Object);
  2218. /**
  2219. * Checks if `value` is a plain object, that is, an object created by the
  2220. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  2221. *
  2222. * @static
  2223. * @memberOf _
  2224. * @since 0.8.0
  2225. * @category Lang
  2226. * @param {*} value The value to check.
  2227. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  2228. * @example
  2229. *
  2230. * function Foo() {
  2231. * this.a = 1;
  2232. * }
  2233. *
  2234. * _.isPlainObject(new Foo);
  2235. * // => false
  2236. *
  2237. * _.isPlainObject([1, 2, 3]);
  2238. * // => false
  2239. *
  2240. * _.isPlainObject({ 'x': 0, 'y': 0 });
  2241. * // => true
  2242. *
  2243. * _.isPlainObject(Object.create(null));
  2244. * // => true
  2245. */
  2246. function isPlainObject(value) {
  2247. if (!isObjectLike_1(value) || _baseGetTag(value) != objectTag) {
  2248. return false;
  2249. }
  2250. var proto = _getPrototype(value);
  2251. if (proto === null) {
  2252. return true;
  2253. }
  2254. var Ctor = hasOwnProperty$5.call(proto, 'constructor') && proto.constructor;
  2255. return typeof Ctor == 'function' && Ctor instanceof Ctor &&
  2256. funcToString$2.call(Ctor) == objectCtorString;
  2257. }
  2258. var isPlainObject_1 = isPlainObject;
  2259. /** `Object#toString` result references. */
  2260. var argsTag$1 = '[object Arguments]',
  2261. arrayTag = '[object Array]',
  2262. boolTag = '[object Boolean]',
  2263. dateTag = '[object Date]',
  2264. errorTag = '[object Error]',
  2265. funcTag$1 = '[object Function]',
  2266. mapTag = '[object Map]',
  2267. numberTag = '[object Number]',
  2268. objectTag$1 = '[object Object]',
  2269. regexpTag = '[object RegExp]',
  2270. setTag = '[object Set]',
  2271. stringTag = '[object String]',
  2272. weakMapTag = '[object WeakMap]';
  2273. var arrayBufferTag = '[object ArrayBuffer]',
  2274. dataViewTag = '[object DataView]',
  2275. float32Tag = '[object Float32Array]',
  2276. float64Tag = '[object Float64Array]',
  2277. int8Tag = '[object Int8Array]',
  2278. int16Tag = '[object Int16Array]',
  2279. int32Tag = '[object Int32Array]',
  2280. uint8Tag = '[object Uint8Array]',
  2281. uint8ClampedTag = '[object Uint8ClampedArray]',
  2282. uint16Tag = '[object Uint16Array]',
  2283. uint32Tag = '[object Uint32Array]';
  2284. /** Used to identify `toStringTag` values of typed arrays. */
  2285. var typedArrayTags = {};
  2286. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  2287. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  2288. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  2289. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  2290. typedArrayTags[uint32Tag] = true;
  2291. typedArrayTags[argsTag$1] = typedArrayTags[arrayTag] =
  2292. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  2293. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  2294. typedArrayTags[errorTag] = typedArrayTags[funcTag$1] =
  2295. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  2296. typedArrayTags[objectTag$1] = typedArrayTags[regexpTag] =
  2297. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  2298. typedArrayTags[weakMapTag] = false;
  2299. /**
  2300. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  2301. *
  2302. * @private
  2303. * @param {*} value The value to check.
  2304. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  2305. */
  2306. function baseIsTypedArray(value) {
  2307. return isObjectLike_1(value) &&
  2308. isLength_1(value.length) && !!typedArrayTags[_baseGetTag(value)];
  2309. }
  2310. var _baseIsTypedArray = baseIsTypedArray;
  2311. /**
  2312. * The base implementation of `_.unary` without support for storing metadata.
  2313. *
  2314. * @private
  2315. * @param {Function} func The function to cap arguments for.
  2316. * @returns {Function} Returns the new capped function.
  2317. */
  2318. function baseUnary(func) {
  2319. return function(value) {
  2320. return func(value);
  2321. };
  2322. }
  2323. var _baseUnary = baseUnary;
  2324. var _nodeUtil = createCommonjsModule(function (module, exports) {
  2325. /** Detect free variable `exports`. */
  2326. var freeExports = exports && !exports.nodeType && exports;
  2327. /** Detect free variable `module`. */
  2328. var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
  2329. /** Detect the popular CommonJS extension `module.exports`. */
  2330. var moduleExports = freeModule && freeModule.exports === freeExports;
  2331. /** Detect free variable `process` from Node.js. */
  2332. var freeProcess = moduleExports && _freeGlobal.process;
  2333. /** Used to access faster Node.js helpers. */
  2334. var nodeUtil = (function() {
  2335. try {
  2336. // Use `util.types` for Node.js 10+.
  2337. var types = freeModule && freeModule.require && freeModule.require('util').types;
  2338. if (types) {
  2339. return types;
  2340. }
  2341. // Legacy `process.binding('util')` for Node.js < 10.
  2342. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  2343. } catch (e) {}
  2344. }());
  2345. module.exports = nodeUtil;
  2346. });
  2347. /* Node.js helper references. */
  2348. var nodeIsTypedArray = _nodeUtil && _nodeUtil.isTypedArray;
  2349. /**
  2350. * Checks if `value` is classified as a typed array.
  2351. *
  2352. * @static
  2353. * @memberOf _
  2354. * @since 3.0.0
  2355. * @category Lang
  2356. * @param {*} value The value to check.
  2357. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  2358. * @example
  2359. *
  2360. * _.isTypedArray(new Uint8Array);
  2361. * // => true
  2362. *
  2363. * _.isTypedArray([]);
  2364. * // => false
  2365. */
  2366. var isTypedArray = nodeIsTypedArray ? _baseUnary(nodeIsTypedArray) : _baseIsTypedArray;
  2367. var isTypedArray_1 = isTypedArray;
  2368. /**
  2369. * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
  2370. *
  2371. * @private
  2372. * @param {Object} object The object to query.
  2373. * @param {string} key The key of the property to get.
  2374. * @returns {*} Returns the property value.
  2375. */
  2376. function safeGet(object, key) {
  2377. if (key === 'constructor' && typeof object[key] === 'function') {
  2378. return;
  2379. }
  2380. if (key == '__proto__') {
  2381. return;
  2382. }
  2383. return object[key];
  2384. }
  2385. var _safeGet = safeGet;
  2386. /** Used for built-in method references. */
  2387. var objectProto$8 = Object.prototype;
  2388. /** Used to check objects for own properties. */
  2389. var hasOwnProperty$6 = objectProto$8.hasOwnProperty;
  2390. /**
  2391. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  2392. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  2393. * for equality comparisons.
  2394. *
  2395. * @private
  2396. * @param {Object} object The object to modify.
  2397. * @param {string} key The key of the property to assign.
  2398. * @param {*} value The value to assign.
  2399. */
  2400. function assignValue(object, key, value) {
  2401. var objValue = object[key];
  2402. if (!(hasOwnProperty$6.call(object, key) && eq_1(objValue, value)) ||
  2403. (value === undefined && !(key in object))) {
  2404. _baseAssignValue(object, key, value);
  2405. }
  2406. }
  2407. var _assignValue = assignValue;
  2408. /**
  2409. * Copies properties of `source` to `object`.
  2410. *
  2411. * @private
  2412. * @param {Object} source The object to copy properties from.
  2413. * @param {Array} props The property identifiers to copy.
  2414. * @param {Object} [object={}] The object to copy properties to.
  2415. * @param {Function} [customizer] The function to customize copied values.
  2416. * @returns {Object} Returns `object`.
  2417. */
  2418. function copyObject(source, props, object, customizer) {
  2419. var isNew = !object;
  2420. object || (object = {});
  2421. var index = -1,
  2422. length = props.length;
  2423. while (++index < length) {
  2424. var key = props[index];
  2425. var newValue = customizer
  2426. ? customizer(object[key], source[key], key, object, source)
  2427. : undefined;
  2428. if (newValue === undefined) {
  2429. newValue = source[key];
  2430. }
  2431. if (isNew) {
  2432. _baseAssignValue(object, key, newValue);
  2433. } else {
  2434. _assignValue(object, key, newValue);
  2435. }
  2436. }
  2437. return object;
  2438. }
  2439. var _copyObject = copyObject;
  2440. /**
  2441. * The base implementation of `_.times` without support for iteratee shorthands
  2442. * or max array length checks.
  2443. *
  2444. * @private
  2445. * @param {number} n The number of times to invoke `iteratee`.
  2446. * @param {Function} iteratee The function invoked per iteration.
  2447. * @returns {Array} Returns the array of results.
  2448. */
  2449. function baseTimes(n, iteratee) {
  2450. var index = -1,
  2451. result = Array(n);
  2452. while (++index < n) {
  2453. result[index] = iteratee(index);
  2454. }
  2455. return result;
  2456. }
  2457. var _baseTimes = baseTimes;
  2458. /** Used as references for various `Number` constants. */
  2459. var MAX_SAFE_INTEGER$1 = 9007199254740991;
  2460. /** Used to detect unsigned integer values. */
  2461. var reIsUint = /^(?:0|[1-9]\d*)$/;
  2462. /**
  2463. * Checks if `value` is a valid array-like index.
  2464. *
  2465. * @private
  2466. * @param {*} value The value to check.
  2467. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  2468. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  2469. */
  2470. function isIndex(value, length) {
  2471. var type = typeof value;
  2472. length = length == null ? MAX_SAFE_INTEGER$1 : length;
  2473. return !!length &&
  2474. (type == 'number' ||
  2475. (type != 'symbol' && reIsUint.test(value))) &&
  2476. (value > -1 && value % 1 == 0 && value < length);
  2477. }
  2478. var _isIndex = isIndex;
  2479. /** Used for built-in method references. */
  2480. var objectProto$9 = Object.prototype;
  2481. /** Used to check objects for own properties. */
  2482. var hasOwnProperty$7 = objectProto$9.hasOwnProperty;
  2483. /**
  2484. * Creates an array of the enumerable property names of the array-like `value`.
  2485. *
  2486. * @private
  2487. * @param {*} value The value to query.
  2488. * @param {boolean} inherited Specify returning inherited property names.
  2489. * @returns {Array} Returns the array of property names.
  2490. */
  2491. function arrayLikeKeys(value, inherited) {
  2492. var isArr = isArray_1(value),
  2493. isArg = !isArr && isArguments_1(value),
  2494. isBuff = !isArr && !isArg && isBuffer_1(value),
  2495. isType = !isArr && !isArg && !isBuff && isTypedArray_1(value),
  2496. skipIndexes = isArr || isArg || isBuff || isType,
  2497. result = skipIndexes ? _baseTimes(value.length, String) : [],
  2498. length = result.length;
  2499. for (var key in value) {
  2500. if ((inherited || hasOwnProperty$7.call(value, key)) &&
  2501. !(skipIndexes && (
  2502. // Safari 9 has enumerable `arguments.length` in strict mode.
  2503. key == 'length' ||
  2504. // Node.js 0.10 has enumerable non-index properties on buffers.
  2505. (isBuff && (key == 'offset' || key == 'parent')) ||
  2506. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  2507. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  2508. // Skip index properties.
  2509. _isIndex(key, length)
  2510. ))) {
  2511. result.push(key);
  2512. }
  2513. }
  2514. return result;
  2515. }
  2516. var _arrayLikeKeys = arrayLikeKeys;
  2517. /**
  2518. * This function is like
  2519. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  2520. * except that it includes inherited enumerable properties.
  2521. *
  2522. * @private
  2523. * @param {Object} object The object to query.
  2524. * @returns {Array} Returns the array of property names.
  2525. */
  2526. function nativeKeysIn(object) {
  2527. var result = [];
  2528. if (object != null) {
  2529. for (var key in Object(object)) {
  2530. result.push(key);
  2531. }
  2532. }
  2533. return result;
  2534. }
  2535. var _nativeKeysIn = nativeKeysIn;
  2536. /** Used for built-in method references. */
  2537. var objectProto$a = Object.prototype;
  2538. /** Used to check objects for own properties. */
  2539. var hasOwnProperty$8 = objectProto$a.hasOwnProperty;
  2540. /**
  2541. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  2542. *
  2543. * @private
  2544. * @param {Object} object The object to query.
  2545. * @returns {Array} Returns the array of property names.
  2546. */
  2547. function baseKeysIn(object) {
  2548. if (!isObject_1(object)) {
  2549. return _nativeKeysIn(object);
  2550. }
  2551. var isProto = _isPrototype(object),
  2552. result = [];
  2553. for (var key in object) {
  2554. if (!(key == 'constructor' && (isProto || !hasOwnProperty$8.call(object, key)))) {
  2555. result.push(key);
  2556. }
  2557. }
  2558. return result;
  2559. }
  2560. var _baseKeysIn = baseKeysIn;
  2561. /**
  2562. * Creates an array of the own and inherited enumerable property names of `object`.
  2563. *
  2564. * **Note:** Non-object values are coerced to objects.
  2565. *
  2566. * @static
  2567. * @memberOf _
  2568. * @since 3.0.0
  2569. * @category Object
  2570. * @param {Object} object The object to query.
  2571. * @returns {Array} Returns the array of property names.
  2572. * @example
  2573. *
  2574. * function Foo() {
  2575. * this.a = 1;
  2576. * this.b = 2;
  2577. * }
  2578. *
  2579. * Foo.prototype.c = 3;
  2580. *
  2581. * _.keysIn(new Foo);
  2582. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  2583. */
  2584. function keysIn(object) {
  2585. return isArrayLike_1(object) ? _arrayLikeKeys(object, true) : _baseKeysIn(object);
  2586. }
  2587. var keysIn_1 = keysIn;
  2588. /**
  2589. * Converts `value` to a plain object flattening inherited enumerable string
  2590. * keyed properties of `value` to own properties of the plain object.
  2591. *
  2592. * @static
  2593. * @memberOf _
  2594. * @since 3.0.0
  2595. * @category Lang
  2596. * @param {*} value The value to convert.
  2597. * @returns {Object} Returns the converted plain object.
  2598. * @example
  2599. *
  2600. * function Foo() {
  2601. * this.b = 2;
  2602. * }
  2603. *
  2604. * Foo.prototype.c = 3;
  2605. *
  2606. * _.assign({ 'a': 1 }, new Foo);
  2607. * // => { 'a': 1, 'b': 2 }
  2608. *
  2609. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  2610. * // => { 'a': 1, 'b': 2, 'c': 3 }
  2611. */
  2612. function toPlainObject(value) {
  2613. return _copyObject(value, keysIn_1(value));
  2614. }
  2615. var toPlainObject_1 = toPlainObject;
  2616. /**
  2617. * A specialized version of `baseMerge` for arrays and objects which performs
  2618. * deep merges and tracks traversed objects enabling objects with circular
  2619. * references to be merged.
  2620. *
  2621. * @private
  2622. * @param {Object} object The destination object.
  2623. * @param {Object} source The source object.
  2624. * @param {string} key The key of the value to merge.
  2625. * @param {number} srcIndex The index of `source`.
  2626. * @param {Function} mergeFunc The function to merge values.
  2627. * @param {Function} [customizer] The function to customize assigned values.
  2628. * @param {Object} [stack] Tracks traversed source values and their merged
  2629. * counterparts.
  2630. */
  2631. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  2632. var objValue = _safeGet(object, key),
  2633. srcValue = _safeGet(source, key),
  2634. stacked = stack.get(srcValue);
  2635. if (stacked) {
  2636. _assignMergeValue(object, key, stacked);
  2637. return;
  2638. }
  2639. var newValue = customizer
  2640. ? customizer(objValue, srcValue, (key + ''), object, source, stack)
  2641. : undefined;
  2642. var isCommon = newValue === undefined;
  2643. if (isCommon) {
  2644. var isArr = isArray_1(srcValue),
  2645. isBuff = !isArr && isBuffer_1(srcValue),
  2646. isTyped = !isArr && !isBuff && isTypedArray_1(srcValue);
  2647. newValue = srcValue;
  2648. if (isArr || isBuff || isTyped) {
  2649. if (isArray_1(objValue)) {
  2650. newValue = objValue;
  2651. }
  2652. else if (isArrayLikeObject_1(objValue)) {
  2653. newValue = _copyArray(objValue);
  2654. }
  2655. else if (isBuff) {
  2656. isCommon = false;
  2657. newValue = _cloneBuffer(srcValue, true);
  2658. }
  2659. else if (isTyped) {
  2660. isCommon = false;
  2661. newValue = _cloneTypedArray(srcValue, true);
  2662. }
  2663. else {
  2664. newValue = [];
  2665. }
  2666. }
  2667. else if (isPlainObject_1(srcValue) || isArguments_1(srcValue)) {
  2668. newValue = objValue;
  2669. if (isArguments_1(objValue)) {
  2670. newValue = toPlainObject_1(objValue);
  2671. }
  2672. else if (!isObject_1(objValue) || isFunction_1(objValue)) {
  2673. newValue = _initCloneObject(srcValue);
  2674. }
  2675. }
  2676. else {
  2677. isCommon = false;
  2678. }
  2679. }
  2680. if (isCommon) {
  2681. // Recursively merge objects and arrays (susceptible to call stack limits).
  2682. stack.set(srcValue, newValue);
  2683. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  2684. stack['delete'](srcValue);
  2685. }
  2686. _assignMergeValue(object, key, newValue);
  2687. }
  2688. var _baseMergeDeep = baseMergeDeep;
  2689. /**
  2690. * The base implementation of `_.merge` without support for multiple sources.
  2691. *
  2692. * @private
  2693. * @param {Object} object The destination object.
  2694. * @param {Object} source The source object.
  2695. * @param {number} srcIndex The index of `source`.
  2696. * @param {Function} [customizer] The function to customize merged values.
  2697. * @param {Object} [stack] Tracks traversed source values and their merged
  2698. * counterparts.
  2699. */
  2700. function baseMerge(object, source, srcIndex, customizer, stack) {
  2701. if (object === source) {
  2702. return;
  2703. }
  2704. _baseFor(source, function(srcValue, key) {
  2705. stack || (stack = new _Stack);
  2706. if (isObject_1(srcValue)) {
  2707. _baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  2708. }
  2709. else {
  2710. var newValue = customizer
  2711. ? customizer(_safeGet(object, key), srcValue, (key + ''), object, source, stack)
  2712. : undefined;
  2713. if (newValue === undefined) {
  2714. newValue = srcValue;
  2715. }
  2716. _assignMergeValue(object, key, newValue);
  2717. }
  2718. }, keysIn_1);
  2719. }
  2720. var _baseMerge = baseMerge;
  2721. /**
  2722. * This method returns the first argument it receives.
  2723. *
  2724. * @static
  2725. * @since 0.1.0
  2726. * @memberOf _
  2727. * @category Util
  2728. * @param {*} value Any value.
  2729. * @returns {*} Returns `value`.
  2730. * @example
  2731. *
  2732. * var object = { 'a': 1 };
  2733. *
  2734. * console.log(_.identity(object) === object);
  2735. * // => true
  2736. */
  2737. function identity(value) {
  2738. return value;
  2739. }
  2740. var identity_1 = identity;
  2741. /**
  2742. * A faster alternative to `Function#apply`, this function invokes `func`
  2743. * with the `this` binding of `thisArg` and the arguments of `args`.
  2744. *
  2745. * @private
  2746. * @param {Function} func The function to invoke.
  2747. * @param {*} thisArg The `this` binding of `func`.
  2748. * @param {Array} args The arguments to invoke `func` with.
  2749. * @returns {*} Returns the result of `func`.
  2750. */
  2751. function apply(func, thisArg, args) {
  2752. switch (args.length) {
  2753. case 0: return func.call(thisArg);
  2754. case 1: return func.call(thisArg, args[0]);
  2755. case 2: return func.call(thisArg, args[0], args[1]);
  2756. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  2757. }
  2758. return func.apply(thisArg, args);
  2759. }
  2760. var _apply = apply;
  2761. /* Built-in method references for those with the same name as other `lodash` methods. */
  2762. var nativeMax = Math.max;
  2763. /**
  2764. * A specialized version of `baseRest` which transforms the rest array.
  2765. *
  2766. * @private
  2767. * @param {Function} func The function to apply a rest parameter to.
  2768. * @param {number} [start=func.length-1] The start position of the rest parameter.
  2769. * @param {Function} transform The rest array transform.
  2770. * @returns {Function} Returns the new function.
  2771. */
  2772. function overRest(func, start, transform) {
  2773. start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
  2774. return function() {
  2775. var args = arguments,
  2776. index = -1,
  2777. length = nativeMax(args.length - start, 0),
  2778. array = Array(length);
  2779. while (++index < length) {
  2780. array[index] = args[start + index];
  2781. }
  2782. index = -1;
  2783. var otherArgs = Array(start + 1);
  2784. while (++index < start) {
  2785. otherArgs[index] = args[index];
  2786. }
  2787. otherArgs[start] = transform(array);
  2788. return _apply(func, this, otherArgs);
  2789. };
  2790. }
  2791. var _overRest = overRest;
  2792. /**
  2793. * Creates a function that returns `value`.
  2794. *
  2795. * @static
  2796. * @memberOf _
  2797. * @since 2.4.0
  2798. * @category Util
  2799. * @param {*} value The value to return from the new function.
  2800. * @returns {Function} Returns the new constant function.
  2801. * @example
  2802. *
  2803. * var objects = _.times(2, _.constant({ 'a': 1 }));
  2804. *
  2805. * console.log(objects);
  2806. * // => [{ 'a': 1 }, { 'a': 1 }]
  2807. *
  2808. * console.log(objects[0] === objects[1]);
  2809. * // => true
  2810. */
  2811. function constant(value) {
  2812. return function() {
  2813. return value;
  2814. };
  2815. }
  2816. var constant_1 = constant;
  2817. /**
  2818. * The base implementation of `setToString` without support for hot loop shorting.
  2819. *
  2820. * @private
  2821. * @param {Function} func The function to modify.
  2822. * @param {Function} string The `toString` result.
  2823. * @returns {Function} Returns `func`.
  2824. */
  2825. var baseSetToString = !_defineProperty$1 ? identity_1 : function(func, string) {
  2826. return _defineProperty$1(func, 'toString', {
  2827. 'configurable': true,
  2828. 'enumerable': false,
  2829. 'value': constant_1(string),
  2830. 'writable': true
  2831. });
  2832. };
  2833. var _baseSetToString = baseSetToString;
  2834. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  2835. var HOT_COUNT = 800,
  2836. HOT_SPAN = 16;
  2837. /* Built-in method references for those with the same name as other `lodash` methods. */
  2838. var nativeNow = Date.now;
  2839. /**
  2840. * Creates a function that'll short out and invoke `identity` instead
  2841. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  2842. * milliseconds.
  2843. *
  2844. * @private
  2845. * @param {Function} func The function to restrict.
  2846. * @returns {Function} Returns the new shortable function.
  2847. */
  2848. function shortOut(func) {
  2849. var count = 0,
  2850. lastCalled = 0;
  2851. return function() {
  2852. var stamp = nativeNow(),
  2853. remaining = HOT_SPAN - (stamp - lastCalled);
  2854. lastCalled = stamp;
  2855. if (remaining > 0) {
  2856. if (++count >= HOT_COUNT) {
  2857. return arguments[0];
  2858. }
  2859. } else {
  2860. count = 0;
  2861. }
  2862. return func.apply(undefined, arguments);
  2863. };
  2864. }
  2865. var _shortOut = shortOut;
  2866. /**
  2867. * Sets the `toString` method of `func` to return `string`.
  2868. *
  2869. * @private
  2870. * @param {Function} func The function to modify.
  2871. * @param {Function} string The `toString` result.
  2872. * @returns {Function} Returns `func`.
  2873. */
  2874. var setToString = _shortOut(_baseSetToString);
  2875. var _setToString = setToString;
  2876. /**
  2877. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  2878. *
  2879. * @private
  2880. * @param {Function} func The function to apply a rest parameter to.
  2881. * @param {number} [start=func.length-1] The start position of the rest parameter.
  2882. * @returns {Function} Returns the new function.
  2883. */
  2884. function baseRest(func, start) {
  2885. return _setToString(_overRest(func, start, identity_1), func + '');
  2886. }
  2887. var _baseRest = baseRest;
  2888. /**
  2889. * Checks if the given arguments are from an iteratee call.
  2890. *
  2891. * @private
  2892. * @param {*} value The potential iteratee value argument.
  2893. * @param {*} index The potential iteratee index or key argument.
  2894. * @param {*} object The potential iteratee object argument.
  2895. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  2896. * else `false`.
  2897. */
  2898. function isIterateeCall(value, index, object) {
  2899. if (!isObject_1(object)) {
  2900. return false;
  2901. }
  2902. var type = typeof index;
  2903. if (type == 'number'
  2904. ? (isArrayLike_1(object) && _isIndex(index, object.length))
  2905. : (type == 'string' && index in object)
  2906. ) {
  2907. return eq_1(object[index], value);
  2908. }
  2909. return false;
  2910. }
  2911. var _isIterateeCall = isIterateeCall;
  2912. /**
  2913. * Creates a function like `_.assign`.
  2914. *
  2915. * @private
  2916. * @param {Function} assigner The function to assign values.
  2917. * @returns {Function} Returns the new assigner function.
  2918. */
  2919. function createAssigner(assigner) {
  2920. return _baseRest(function(object, sources) {
  2921. var index = -1,
  2922. length = sources.length,
  2923. customizer = length > 1 ? sources[length - 1] : undefined,
  2924. guard = length > 2 ? sources[2] : undefined;
  2925. customizer = (assigner.length > 3 && typeof customizer == 'function')
  2926. ? (length--, customizer)
  2927. : undefined;
  2928. if (guard && _isIterateeCall(sources[0], sources[1], guard)) {
  2929. customizer = length < 3 ? undefined : customizer;
  2930. length = 1;
  2931. }
  2932. object = Object(object);
  2933. while (++index < length) {
  2934. var source = sources[index];
  2935. if (source) {
  2936. assigner(object, source, index, customizer);
  2937. }
  2938. }
  2939. return object;
  2940. });
  2941. }
  2942. var _createAssigner = createAssigner;
  2943. /**
  2944. * This method is like `_.merge` except that it accepts `customizer` which
  2945. * is invoked to produce the merged values of the destination and source
  2946. * properties. If `customizer` returns `undefined`, merging is handled by the
  2947. * method instead. The `customizer` is invoked with six arguments:
  2948. * (objValue, srcValue, key, object, source, stack).
  2949. *
  2950. * **Note:** This method mutates `object`.
  2951. *
  2952. * @static
  2953. * @memberOf _
  2954. * @since 4.0.0
  2955. * @category Object
  2956. * @param {Object} object The destination object.
  2957. * @param {...Object} sources The source objects.
  2958. * @param {Function} customizer The function to customize assigned values.
  2959. * @returns {Object} Returns `object`.
  2960. * @example
  2961. *
  2962. * function customizer(objValue, srcValue) {
  2963. * if (_.isArray(objValue)) {
  2964. * return objValue.concat(srcValue);
  2965. * }
  2966. * }
  2967. *
  2968. * var object = { 'a': [1], 'b': [2] };
  2969. * var other = { 'a': [3], 'b': [4] };
  2970. *
  2971. * _.mergeWith(object, other, customizer);
  2972. * // => { 'a': [1, 3], 'b': [2, 4] }
  2973. */
  2974. var mergeWith = _createAssigner(function(object, source, srcIndex, customizer) {
  2975. _baseMerge(object, source, srcIndex, customizer);
  2976. });
  2977. var mergeWith_1 = mergeWith;
  2978. /**
  2979. * A specialized version of `_.forEach` for arrays without support for
  2980. * iteratee shorthands.
  2981. *
  2982. * @private
  2983. * @param {Array} [array] The array to iterate over.
  2984. * @param {Function} iteratee The function invoked per iteration.
  2985. * @returns {Array} Returns `array`.
  2986. */
  2987. function arrayEach(array, iteratee) {
  2988. var index = -1,
  2989. length = array == null ? 0 : array.length;
  2990. while (++index < length) {
  2991. if (iteratee(array[index], index, array) === false) {
  2992. break;
  2993. }
  2994. }
  2995. return array;
  2996. }
  2997. var _arrayEach = arrayEach;
  2998. /* Built-in method references for those with the same name as other `lodash` methods. */
  2999. var nativeKeys = _overArg(Object.keys, Object);
  3000. var _nativeKeys = nativeKeys;
  3001. /** Used for built-in method references. */
  3002. var objectProto$b = Object.prototype;
  3003. /** Used to check objects for own properties. */
  3004. var hasOwnProperty$9 = objectProto$b.hasOwnProperty;
  3005. /**
  3006. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  3007. *
  3008. * @private
  3009. * @param {Object} object The object to query.
  3010. * @returns {Array} Returns the array of property names.
  3011. */
  3012. function baseKeys(object) {
  3013. if (!_isPrototype(object)) {
  3014. return _nativeKeys(object);
  3015. }
  3016. var result = [];
  3017. for (var key in Object(object)) {
  3018. if (hasOwnProperty$9.call(object, key) && key != 'constructor') {
  3019. result.push(key);
  3020. }
  3021. }
  3022. return result;
  3023. }
  3024. var _baseKeys = baseKeys;
  3025. /**
  3026. * Creates an array of the own enumerable property names of `object`.
  3027. *
  3028. * **Note:** Non-object values are coerced to objects. See the
  3029. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  3030. * for more details.
  3031. *
  3032. * @static
  3033. * @since 0.1.0
  3034. * @memberOf _
  3035. * @category Object
  3036. * @param {Object} object The object to query.
  3037. * @returns {Array} Returns the array of property names.
  3038. * @example
  3039. *
  3040. * function Foo() {
  3041. * this.a = 1;
  3042. * this.b = 2;
  3043. * }
  3044. *
  3045. * Foo.prototype.c = 3;
  3046. *
  3047. * _.keys(new Foo);
  3048. * // => ['a', 'b'] (iteration order is not guaranteed)
  3049. *
  3050. * _.keys('hi');
  3051. * // => ['0', '1']
  3052. */
  3053. function keys(object) {
  3054. return isArrayLike_1(object) ? _arrayLikeKeys(object) : _baseKeys(object);
  3055. }
  3056. var keys_1 = keys;
  3057. /**
  3058. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  3059. *
  3060. * @private
  3061. * @param {Object} object The object to iterate over.
  3062. * @param {Function} iteratee The function invoked per iteration.
  3063. * @returns {Object} Returns `object`.
  3064. */
  3065. function baseForOwn(object, iteratee) {
  3066. return object && _baseFor(object, iteratee, keys_1);
  3067. }
  3068. var _baseForOwn = baseForOwn;
  3069. /**
  3070. * Creates a `baseEach` or `baseEachRight` function.
  3071. *
  3072. * @private
  3073. * @param {Function} eachFunc The function to iterate over a collection.
  3074. * @param {boolean} [fromRight] Specify iterating from right to left.
  3075. * @returns {Function} Returns the new base function.
  3076. */
  3077. function createBaseEach(eachFunc, fromRight) {
  3078. return function(collection, iteratee) {
  3079. if (collection == null) {
  3080. return collection;
  3081. }
  3082. if (!isArrayLike_1(collection)) {
  3083. return eachFunc(collection, iteratee);
  3084. }
  3085. var length = collection.length,
  3086. index = fromRight ? length : -1,
  3087. iterable = Object(collection);
  3088. while ((fromRight ? index-- : ++index < length)) {
  3089. if (iteratee(iterable[index], index, iterable) === false) {
  3090. break;
  3091. }
  3092. }
  3093. return collection;
  3094. };
  3095. }
  3096. var _createBaseEach = createBaseEach;
  3097. /**
  3098. * The base implementation of `_.forEach` without support for iteratee shorthands.
  3099. *
  3100. * @private
  3101. * @param {Array|Object} collection The collection to iterate over.
  3102. * @param {Function} iteratee The function invoked per iteration.
  3103. * @returns {Array|Object} Returns `collection`.
  3104. */
  3105. var baseEach = _createBaseEach(_baseForOwn);
  3106. var _baseEach = baseEach;
  3107. /**
  3108. * Casts `value` to `identity` if it's not a function.
  3109. *
  3110. * @private
  3111. * @param {*} value The value to inspect.
  3112. * @returns {Function} Returns cast function.
  3113. */
  3114. function castFunction(value) {
  3115. return typeof value == 'function' ? value : identity_1;
  3116. }
  3117. var _castFunction = castFunction;
  3118. /**
  3119. * Iterates over elements of `collection` and invokes `iteratee` for each element.
  3120. * The iteratee is invoked with three arguments: (value, index|key, collection).
  3121. * Iteratee functions may exit iteration early by explicitly returning `false`.
  3122. *
  3123. * **Note:** As with other "Collections" methods, objects with a "length"
  3124. * property are iterated like arrays. To avoid this behavior use `_.forIn`
  3125. * or `_.forOwn` for object iteration.
  3126. *
  3127. * @static
  3128. * @memberOf _
  3129. * @since 0.1.0
  3130. * @alias each
  3131. * @category Collection
  3132. * @param {Array|Object} collection The collection to iterate over.
  3133. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  3134. * @returns {Array|Object} Returns `collection`.
  3135. * @see _.forEachRight
  3136. * @example
  3137. *
  3138. * _.forEach([1, 2], function(value) {
  3139. * console.log(value);
  3140. * });
  3141. * // => Logs `1` then `2`.
  3142. *
  3143. * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
  3144. * console.log(key);
  3145. * });
  3146. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  3147. */
  3148. function forEach(collection, iteratee) {
  3149. var func = isArray_1(collection) ? _arrayEach : _baseEach;
  3150. return func(collection, _castFunction(iteratee));
  3151. }
  3152. var forEach_1 = forEach;
  3153. var arrayWithHoles = createCommonjsModule(function (module) {
  3154. function _arrayWithHoles(arr) {
  3155. if (Array.isArray(arr)) return arr;
  3156. }
  3157. module.exports = _arrayWithHoles;
  3158. module.exports["default"] = module.exports, module.exports.__esModule = true;
  3159. });
  3160. var iterableToArrayLimit = createCommonjsModule(function (module) {
  3161. function _iterableToArrayLimit(arr, i) {
  3162. var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
  3163. if (_i == null) return;
  3164. var _arr = [];
  3165. var _n = true;
  3166. var _d = false;
  3167. var _s, _e;
  3168. try {
  3169. for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
  3170. _arr.push(_s.value);
  3171. if (i && _arr.length === i) break;
  3172. }
  3173. } catch (err) {
  3174. _d = true;
  3175. _e = err;
  3176. } finally {
  3177. try {
  3178. if (!_n && _i["return"] != null) _i["return"]();
  3179. } finally {
  3180. if (_d) throw _e;
  3181. }
  3182. }
  3183. return _arr;
  3184. }
  3185. module.exports = _iterableToArrayLimit;
  3186. module.exports["default"] = module.exports, module.exports.__esModule = true;
  3187. });
  3188. var nonIterableRest = createCommonjsModule(function (module) {
  3189. function _nonIterableRest() {
  3190. throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  3191. }
  3192. module.exports = _nonIterableRest;
  3193. module.exports["default"] = module.exports, module.exports.__esModule = true;
  3194. });
  3195. var slicedToArray = createCommonjsModule(function (module) {
  3196. function _slicedToArray(arr, i) {
  3197. return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest();
  3198. }
  3199. module.exports = _slicedToArray;
  3200. module.exports["default"] = module.exports, module.exports.__esModule = true;
  3201. });
  3202. var _slicedToArray = /*@__PURE__*/getDefaultExportFromCjs(slicedToArray);
  3203. /**
  3204. * @author Kuitos
  3205. * @homepage https://github.com/kuitos/
  3206. * @since 2019-02-25
  3207. * fork from https://github.com/systemjs/systemjs/blob/master/src/extras/global.js
  3208. */
  3209. var isIE11 = typeof navigator !== 'undefined' && navigator.userAgent.indexOf('Trident') !== -1;
  3210. function shouldSkipProperty(global, p) {
  3211. if (!global.hasOwnProperty(p) || !isNaN(p) && p < global.length) return true;
  3212. if (isIE11) {
  3213. // https://github.com/kuitos/import-html-entry/pull/32,最小化 try 范围
  3214. try {
  3215. return global[p] && typeof window !== 'undefined' && global[p].parent === window;
  3216. } catch (err) {
  3217. return true;
  3218. }
  3219. } else {
  3220. return false;
  3221. }
  3222. } // safari unpredictably lists some new globals first or second in object order
  3223. var firstGlobalProp, secondGlobalProp, lastGlobalProp;
  3224. function getGlobalProp(global) {
  3225. var cnt = 0;
  3226. var lastProp;
  3227. var hasIframe = false;
  3228. for (var p in global) {
  3229. if (shouldSkipProperty(global, p)) continue; // 遍历 iframe,检查 window 上的属性值是否是 iframe,是则跳过后面的 first 和 second 判断
  3230. for (var i = 0; i < window.frames.length && !hasIframe; i++) {
  3231. var frame = window.frames[i];
  3232. if (frame === global[p]) {
  3233. hasIframe = true;
  3234. break;
  3235. }
  3236. }
  3237. if (!hasIframe && (cnt === 0 && p !== firstGlobalProp || cnt === 1 && p !== secondGlobalProp)) return p;
  3238. cnt++;
  3239. lastProp = p;
  3240. }
  3241. if (lastProp !== lastGlobalProp) return lastProp;
  3242. }
  3243. function noteGlobalProps(global) {
  3244. // alternatively Object.keys(global).pop()
  3245. // but this may be faster (pending benchmarks)
  3246. firstGlobalProp = secondGlobalProp = undefined;
  3247. for (var p in global) {
  3248. if (shouldSkipProperty(global, p)) continue;
  3249. if (!firstGlobalProp) firstGlobalProp = p;else if (!secondGlobalProp) secondGlobalProp = p;
  3250. lastGlobalProp = p;
  3251. }
  3252. return lastGlobalProp;
  3253. }
  3254. function getInlineCode(match) {
  3255. var start = match.indexOf('>') + 1;
  3256. var end = match.lastIndexOf('<');
  3257. return match.substring(start, end);
  3258. }
  3259. function defaultGetPublicPath(entry) {
  3260. if (_typeof(entry) === 'object') {
  3261. return '/';
  3262. }
  3263. try {
  3264. // URL 构造函数不支持使用 // 前缀的 url
  3265. var _URL = new URL(entry.startsWith('//') ? "".concat(location.protocol).concat(entry) : entry, location.href),
  3266. origin = _URL.origin,
  3267. pathname = _URL.pathname;
  3268. var paths = pathname.split('/'); // 移除最后一个元素
  3269. paths.pop();
  3270. return "".concat(origin).concat(paths.join('/'), "/");
  3271. } catch (e) {
  3272. console.warn(e);
  3273. return '';
  3274. }
  3275. } // Detect whether browser supports `<script type=module>` or not
  3276. function isModuleScriptSupported() {
  3277. var s = document.createElement('script');
  3278. return 'noModule' in s;
  3279. } // RIC and shim for browsers setTimeout() without it
  3280. var requestIdleCallback = window.requestIdleCallback || function requestIdleCallback(cb) {
  3281. var start = Date.now();
  3282. return setTimeout(function () {
  3283. cb({
  3284. didTimeout: false,
  3285. timeRemaining: function timeRemaining() {
  3286. return Math.max(0, 50 - (Date.now() - start));
  3287. }
  3288. });
  3289. }, 1);
  3290. };
  3291. function readResAsString(response, autoDetectCharset) {
  3292. // 未启用自动检测
  3293. if (!autoDetectCharset) {
  3294. return response.text();
  3295. } // 如果没headers,发生在test环境下的mock数据,为兼容原有测试用例
  3296. if (!response.headers) {
  3297. return response.text();
  3298. } // 如果没返回content-type,走默认逻辑
  3299. var contentType = response.headers.get('Content-Type');
  3300. if (!contentType) {
  3301. return response.text();
  3302. } // 解析content-type内的charset
  3303. // Content-Type: text/html; charset=utf-8
  3304. // Content-Type: multipart/form-data; boundary=something
  3305. // GET请求下不会出现第二种content-type
  3306. var charset = 'utf-8';
  3307. var parts = contentType.split(';');
  3308. if (parts.length === 2) {
  3309. var _parts$1$split = parts[1].split('='),
  3310. _parts$1$split2 = _slicedToArray(_parts$1$split, 2),
  3311. value = _parts$1$split2[1];
  3312. var encoding = value && value.trim();
  3313. if (encoding) {
  3314. charset = encoding;
  3315. }
  3316. } // 如果还是utf-8,那么走默认,兼容原有逻辑,这段代码删除也应该工作
  3317. if (charset.toUpperCase() === 'UTF-8') {
  3318. return response.text();
  3319. } // 走流读取,编码可能是gbk,gb2312等,比如sofa 3默认是gbk编码
  3320. return response.blob().then(function (file) {
  3321. return new Promise(function (resolve, reject) {
  3322. var reader = new window.FileReader();
  3323. reader.onload = function () {
  3324. resolve(reader.result);
  3325. };
  3326. reader.onerror = reject;
  3327. reader.readAsText(file, charset);
  3328. });
  3329. });
  3330. }
  3331. var ALL_SCRIPT_REGEX = /(<script[\s\S]*?>)[\s\S]*?<\/script>/gi;
  3332. var SCRIPT_TAG_REGEX = /<(script)[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+((?!type=('|')text\/ng\x2Dtemplate\3)[\s\S])*?>[\s\S]*?<\/\1>/i;
  3333. var SCRIPT_SRC_REGEX = /.*\ssrc=('|")?([^>'"\s]+)/;
  3334. var SCRIPT_TYPE_REGEX = /.*\stype=('|")?([^>'"\s]+)/;
  3335. var SCRIPT_ENTRY_REGEX = /.*\sentry\s*.*/;
  3336. var SCRIPT_ASYNC_REGEX = /.*\sasync\s*.*/;
  3337. var SCRIPT_NO_MODULE_REGEX = /.*\snomodule\s*.*/;
  3338. var SCRIPT_MODULE_REGEX = /.*\stype=('|")?module('|")?\s*.*/;
  3339. var LINK_TAG_REGEX = /<(link)[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+[\s\S]*?>/ig;
  3340. var LINK_PRELOAD_OR_PREFETCH_REGEX = /\srel=('|")?(preload|prefetch)\1/;
  3341. var LINK_HREF_REGEX = /.*\shref=('|")?([^>'"\s]+)/;
  3342. var LINK_AS_FONT = /.*\sas=('|")?font\1.*/;
  3343. var STYLE_TAG_REGEX = /<style[^>]*>[\s\S]*?<\/style>/gi;
  3344. var STYLE_TYPE_REGEX = /\s+rel=('|")?stylesheet\1.*/;
  3345. var STYLE_HREF_REGEX = /.*\shref=('|")?([^>'"\s]+)/;
  3346. var HTML_COMMENT_REGEX = /<!--([\s\S]*?)-->/g;
  3347. var LINK_IGNORE_REGEX = /<link([\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+|[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+[\s\S]+[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+)ignore([\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*|[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+[\s\S]*|=[\s\S]*)>/i;
  3348. var STYLE_IGNORE_REGEX = /<style([\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+|[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+[\s\S]+[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+)ignore([\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*|[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+[\s\S]*|=[\s\S]*)>/i;
  3349. var SCRIPT_IGNORE_REGEX = /<script([\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+|[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+[\s\S]+[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+)ignore([\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*|[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+[\s\S]*|=[\s\S]*)>/i;
  3350. function hasProtocol(url) {
  3351. return url.startsWith('//') || url.startsWith('http://') || url.startsWith('https://');
  3352. }
  3353. function getEntirePath(path, baseURI) {
  3354. return new URL(path, baseURI).toString();
  3355. }
  3356. function isValidJavaScriptType(type) {
  3357. var handleTypes = ['text/javascript', 'module', 'application/javascript', 'text/ecmascript', 'application/ecmascript'];
  3358. return !type || handleTypes.indexOf(type) !== -1;
  3359. }
  3360. var genLinkReplaceSymbol = function genLinkReplaceSymbol(linkHref) {
  3361. var preloadOrPrefetch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  3362. return "<!-- ".concat(preloadOrPrefetch ? 'prefetch/preload' : '', " link ").concat(linkHref, " replaced by import-html-entry -->");
  3363. };
  3364. var genScriptReplaceSymbol = function genScriptReplaceSymbol(scriptSrc) {
  3365. var async = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  3366. return "<!-- ".concat(async ? 'async' : '', " script ").concat(scriptSrc, " replaced by import-html-entry -->");
  3367. };
  3368. var inlineScriptReplaceSymbol = "<!-- inline scripts replaced by import-html-entry -->";
  3369. var genIgnoreAssetReplaceSymbol = function genIgnoreAssetReplaceSymbol(url) {
  3370. return "<!-- ignore asset ".concat(url || 'file', " replaced by import-html-entry -->");
  3371. };
  3372. var genModuleScriptReplaceSymbol = function genModuleScriptReplaceSymbol(scriptSrc, moduleSupport) {
  3373. return "<!-- ".concat(moduleSupport ? 'nomodule' : 'module', " script ").concat(scriptSrc, " ignored by import-html-entry -->");
  3374. };
  3375. /**
  3376. * parse the script link from the template
  3377. * 1. collect stylesheets
  3378. * 2. use global eval to evaluate the inline scripts
  3379. * see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function#Difference_between_Function_constructor_and_function_declaration
  3380. * see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval#Do_not_ever_use_eval!
  3381. * @param tpl
  3382. * @param baseURI
  3383. * @stripStyles whether to strip the css links
  3384. * @returns {{template: void | string | *, scripts: *[], entry: *}}
  3385. */
  3386. function processTpl(tpl, baseURI) {
  3387. var scripts = [];
  3388. var styles = [];
  3389. var entry = null;
  3390. var moduleSupport = isModuleScriptSupported();
  3391. var template = tpl
  3392. /*
  3393. remove html comment first
  3394. */
  3395. .replace(HTML_COMMENT_REGEX, '').replace(LINK_TAG_REGEX, function (match) {
  3396. /*
  3397. change the css link
  3398. */
  3399. var styleType = !!match.match(STYLE_TYPE_REGEX);
  3400. if (styleType) {
  3401. var styleHref = match.match(STYLE_HREF_REGEX);
  3402. var styleIgnore = match.match(LINK_IGNORE_REGEX);
  3403. if (styleHref) {
  3404. var href = styleHref && styleHref[2];
  3405. var newHref = href;
  3406. if (href && !hasProtocol(href)) {
  3407. newHref = getEntirePath(href, baseURI);
  3408. }
  3409. if (styleIgnore) {
  3410. return genIgnoreAssetReplaceSymbol(newHref);
  3411. }
  3412. styles.push(newHref);
  3413. return genLinkReplaceSymbol(newHref);
  3414. }
  3415. }
  3416. var preloadOrPrefetchType = match.match(LINK_PRELOAD_OR_PREFETCH_REGEX) && match.match(LINK_HREF_REGEX) && !match.match(LINK_AS_FONT);
  3417. if (preloadOrPrefetchType) {
  3418. var _match$match = match.match(LINK_HREF_REGEX),
  3419. _match$match2 = _slicedToArray(_match$match, 3),
  3420. linkHref = _match$match2[2];
  3421. return genLinkReplaceSymbol(linkHref, true);
  3422. }
  3423. return match;
  3424. }).replace(STYLE_TAG_REGEX, function (match) {
  3425. if (STYLE_IGNORE_REGEX.test(match)) {
  3426. return genIgnoreAssetReplaceSymbol('style file');
  3427. }
  3428. return match;
  3429. }).replace(ALL_SCRIPT_REGEX, function (match, scriptTag) {
  3430. var scriptIgnore = scriptTag.match(SCRIPT_IGNORE_REGEX);
  3431. var moduleScriptIgnore = moduleSupport && !!scriptTag.match(SCRIPT_NO_MODULE_REGEX) || !moduleSupport && !!scriptTag.match(SCRIPT_MODULE_REGEX); // in order to keep the exec order of all javascripts
  3432. var matchedScriptTypeMatch = scriptTag.match(SCRIPT_TYPE_REGEX);
  3433. var matchedScriptType = matchedScriptTypeMatch && matchedScriptTypeMatch[2];
  3434. if (!isValidJavaScriptType(matchedScriptType)) {
  3435. return match;
  3436. } // if it is a external script
  3437. if (SCRIPT_TAG_REGEX.test(match) && scriptTag.match(SCRIPT_SRC_REGEX)) {
  3438. /*
  3439. collect scripts and replace the ref
  3440. */
  3441. var matchedScriptEntry = scriptTag.match(SCRIPT_ENTRY_REGEX);
  3442. var matchedScriptSrcMatch = scriptTag.match(SCRIPT_SRC_REGEX);
  3443. var matchedScriptSrc = matchedScriptSrcMatch && matchedScriptSrcMatch[2];
  3444. if (entry && matchedScriptEntry) {
  3445. throw new SyntaxError('You should not set multiply entry script!');
  3446. } else {
  3447. // append the domain while the script not have an protocol prefix
  3448. if (matchedScriptSrc && !hasProtocol(matchedScriptSrc)) {
  3449. matchedScriptSrc = getEntirePath(matchedScriptSrc, baseURI);
  3450. }
  3451. entry = entry || matchedScriptEntry && matchedScriptSrc;
  3452. }
  3453. if (scriptIgnore) {
  3454. return genIgnoreAssetReplaceSymbol(matchedScriptSrc || 'js file');
  3455. }
  3456. if (moduleScriptIgnore) {
  3457. return genModuleScriptReplaceSymbol(matchedScriptSrc || 'js file', moduleSupport);
  3458. }
  3459. if (matchedScriptSrc) {
  3460. var asyncScript = !!scriptTag.match(SCRIPT_ASYNC_REGEX);
  3461. scripts.push(asyncScript ? {
  3462. async: true,
  3463. src: matchedScriptSrc
  3464. } : matchedScriptSrc);
  3465. return genScriptReplaceSymbol(matchedScriptSrc, asyncScript);
  3466. }
  3467. return match;
  3468. } else {
  3469. if (scriptIgnore) {
  3470. return genIgnoreAssetReplaceSymbol('js file');
  3471. }
  3472. if (moduleScriptIgnore) {
  3473. return genModuleScriptReplaceSymbol('js file', moduleSupport);
  3474. } // if it is an inline script
  3475. var code = getInlineCode(match); // remove script blocks when all of these lines are comments.
  3476. var isPureCommentBlock = code.split(/[\r\n]+/).every(function (line) {
  3477. return !line.trim() || line.trim().startsWith('//');
  3478. });
  3479. if (!isPureCommentBlock) {
  3480. scripts.push(match);
  3481. }
  3482. return inlineScriptReplaceSymbol;
  3483. }
  3484. });
  3485. scripts = scripts.filter(function (script) {
  3486. // filter empty script
  3487. return !!script;
  3488. });
  3489. return {
  3490. template: template,
  3491. scripts: scripts,
  3492. styles: styles,
  3493. // set the last script as entry if have not set
  3494. entry: entry || scripts[scripts.length - 1]
  3495. };
  3496. }
  3497. /**
  3498. * @author Kuitos
  3499. * @homepage https://github.com/kuitos/
  3500. * @since 2018-08-15 11:37
  3501. */
  3502. var styleCache = {};
  3503. var scriptCache = {};
  3504. var embedHTMLCache = {};
  3505. if (!window.fetch) {
  3506. throw new Error('[import-html-entry] Here is no "fetch" on the window env, you need to polyfill it');
  3507. }
  3508. var defaultFetch = window.fetch.bind(window);
  3509. function defaultGetTemplate(tpl) {
  3510. return tpl;
  3511. }
  3512. /**
  3513. * convert external css link to inline style for performance optimization
  3514. * @param template
  3515. * @param styles
  3516. * @param opts
  3517. * @return embedHTML
  3518. */
  3519. function getEmbedHTML(template, styles) {
  3520. var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  3521. var _opts$fetch = opts.fetch,
  3522. fetch = _opts$fetch === void 0 ? defaultFetch : _opts$fetch;
  3523. var embedHTML = template;
  3524. return _getExternalStyleSheets(styles, fetch).then(function (styleSheets) {
  3525. embedHTML = styles.reduce(function (html, styleSrc, i) {
  3526. html = html.replace(genLinkReplaceSymbol(styleSrc), "<style>/* ".concat(styleSrc, " */").concat(styleSheets[i], "</style>"));
  3527. return html;
  3528. }, embedHTML);
  3529. return embedHTML;
  3530. });
  3531. }
  3532. var isInlineCode = function isInlineCode(code) {
  3533. return code.startsWith('<');
  3534. };
  3535. function getExecutableScript(scriptSrc, scriptText, proxy, strictGlobal) {
  3536. var sourceUrl = isInlineCode(scriptSrc) ? '' : "//# sourceURL=".concat(scriptSrc, "\n"); // 通过这种方式获取全局 window,因为 script 也是在全局作用域下运行的,所以我们通过 window.proxy 绑定时也必须确保绑定到全局 window 上
  3537. // 否则在嵌套场景下, window.proxy 设置的是内层应用的 window,而代码其实是在全局作用域运行的,会导致闭包里的 window.proxy 取的是最外层的微应用的 proxy
  3538. var globalWindow = (0, eval)('window');
  3539. globalWindow.proxy = proxy; // TODO 通过 strictGlobal 方式切换切换 with 闭包,待 with 方式坑趟平后再合并
  3540. return strictGlobal ? ";(function(window, self, globalThis){with(window){;".concat(scriptText, "\n").concat(sourceUrl, "}}).bind(window.proxy)(window.proxy, window.proxy, window.proxy);") : ";(function(window, self, globalThis){;".concat(scriptText, "\n").concat(sourceUrl, "}).bind(window.proxy)(window.proxy, window.proxy, window.proxy);");
  3541. } // for prefetch
  3542. function _getExternalStyleSheets(styles) {
  3543. var fetch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultFetch;
  3544. return Promise.all(styles.map(function (styleLink) {
  3545. if (isInlineCode(styleLink)) {
  3546. // if it is inline style
  3547. return getInlineCode(styleLink);
  3548. } else {
  3549. // external styles
  3550. return styleCache[styleLink] || (styleCache[styleLink] = fetch(styleLink).then(function (response) {
  3551. return response.text();
  3552. }));
  3553. }
  3554. }));
  3555. } // for prefetch
  3556. function _getExternalScripts(scripts) {
  3557. var fetch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultFetch;
  3558. var errorCallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {};
  3559. var fetchScript = function fetchScript(scriptUrl) {
  3560. return scriptCache[scriptUrl] || (scriptCache[scriptUrl] = fetch(scriptUrl).then(function (response) {
  3561. // usually browser treats 4xx and 5xx response of script loading as an error and will fire a script error event
  3562. // https://stackoverflow.com/questions/5625420/what-http-headers-responses-trigger-the-onerror-handler-on-a-script-tag/5625603
  3563. if (response.status >= 400) {
  3564. errorCallback();
  3565. throw new Error("".concat(scriptUrl, " load failed with status ").concat(response.status));
  3566. }
  3567. return response.text();
  3568. }));
  3569. };
  3570. return Promise.all(scripts.map(function (script) {
  3571. if (typeof script === 'string') {
  3572. if (isInlineCode(script)) {
  3573. // if it is inline script
  3574. return getInlineCode(script);
  3575. } else {
  3576. // external script
  3577. return fetchScript(script);
  3578. }
  3579. } else {
  3580. // use idle time to load async script
  3581. var src = script.src,
  3582. async = script.async;
  3583. if (async) {
  3584. return {
  3585. src: src,
  3586. async: true,
  3587. content: new Promise(function (resolve, reject) {
  3588. return requestIdleCallback(function () {
  3589. return fetchScript(src).then(resolve, reject);
  3590. });
  3591. })
  3592. };
  3593. }
  3594. return fetchScript(src);
  3595. }
  3596. }));
  3597. }
  3598. function throwNonBlockingError(error, msg) {
  3599. setTimeout(function () {
  3600. console.error(msg);
  3601. throw error;
  3602. });
  3603. }
  3604. var supportsUserTiming = typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function';
  3605. /**
  3606. * FIXME to consistent with browser behavior, we should only provide callback way to invoke success and error event
  3607. * @param entry
  3608. * @param scripts
  3609. * @param proxy
  3610. * @param opts
  3611. * @returns {Promise<unknown>}
  3612. */
  3613. function _execScripts(entry, scripts) {
  3614. var proxy = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : window;
  3615. var opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
  3616. var _opts$fetch2 = opts.fetch,
  3617. fetch = _opts$fetch2 === void 0 ? defaultFetch : _opts$fetch2,
  3618. _opts$strictGlobal = opts.strictGlobal,
  3619. strictGlobal = _opts$strictGlobal === void 0 ? false : _opts$strictGlobal,
  3620. success = opts.success,
  3621. _opts$error = opts.error,
  3622. error = _opts$error === void 0 ? function () {} : _opts$error,
  3623. _opts$beforeExec = opts.beforeExec,
  3624. beforeExec = _opts$beforeExec === void 0 ? function () {} : _opts$beforeExec,
  3625. _opts$afterExec = opts.afterExec,
  3626. afterExec = _opts$afterExec === void 0 ? function () {} : _opts$afterExec;
  3627. return _getExternalScripts(scripts, fetch, error).then(function (scriptsText) {
  3628. var geval = function geval(scriptSrc, inlineScript) {
  3629. var rawCode = beforeExec(inlineScript, scriptSrc) || inlineScript;
  3630. var code = getExecutableScript(scriptSrc, rawCode, proxy, strictGlobal);
  3631. (0, eval)(code);
  3632. afterExec(inlineScript, scriptSrc);
  3633. };
  3634. function exec(scriptSrc, inlineScript, resolve) {
  3635. var markName = "Evaluating script ".concat(scriptSrc);
  3636. var measureName = "Evaluating Time Consuming: ".concat(scriptSrc);
  3637. if ( supportsUserTiming) {
  3638. performance.mark(markName);
  3639. }
  3640. if (scriptSrc === entry) {
  3641. noteGlobalProps(strictGlobal ? proxy : window);
  3642. try {
  3643. // bind window.proxy to change `this` reference in script
  3644. geval(scriptSrc, inlineScript);
  3645. var exports = proxy[getGlobalProp(strictGlobal ? proxy : window)] || {};
  3646. resolve(exports);
  3647. } catch (e) {
  3648. // entry error must be thrown to make the promise settled
  3649. console.error("[import-html-entry]: error occurs while executing entry script ".concat(scriptSrc));
  3650. throw e;
  3651. }
  3652. } else {
  3653. if (typeof inlineScript === 'string') {
  3654. try {
  3655. // bind window.proxy to change `this` reference in script
  3656. geval(scriptSrc, inlineScript);
  3657. } catch (e) {
  3658. // consistent with browser behavior, any independent script evaluation error should not block the others
  3659. throwNonBlockingError(e, "[import-html-entry]: error occurs while executing normal script ".concat(scriptSrc));
  3660. }
  3661. } else {
  3662. // external script marked with async
  3663. inlineScript.async && (inlineScript === null || inlineScript === void 0 ? void 0 : inlineScript.content.then(function (downloadedScriptText) {
  3664. return geval(inlineScript.src, downloadedScriptText);
  3665. })["catch"](function (e) {
  3666. throwNonBlockingError(e, "[import-html-entry]: error occurs while executing async script ".concat(inlineScript.src));
  3667. }));
  3668. }
  3669. }
  3670. if ( supportsUserTiming) {
  3671. performance.measure(measureName, markName);
  3672. performance.clearMarks(markName);
  3673. performance.clearMeasures(measureName);
  3674. }
  3675. }
  3676. function schedule(i, resolvePromise) {
  3677. if (i < scripts.length) {
  3678. var scriptSrc = scripts[i];
  3679. var inlineScript = scriptsText[i];
  3680. exec(scriptSrc, inlineScript, resolvePromise); // resolve the promise while the last script executed and entry not provided
  3681. if (!entry && i === scripts.length - 1) {
  3682. resolvePromise();
  3683. } else {
  3684. schedule(i + 1, resolvePromise);
  3685. }
  3686. }
  3687. }
  3688. return new Promise(function (resolve) {
  3689. return schedule(0, success || resolve);
  3690. });
  3691. });
  3692. }
  3693. function importHTML(url) {
  3694. var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  3695. var fetch = defaultFetch;
  3696. var autoDecodeResponse = false;
  3697. var getPublicPath = defaultGetPublicPath;
  3698. var getTemplate = defaultGetTemplate; // compatible with the legacy importHTML api
  3699. if (typeof opts === 'function') {
  3700. fetch = opts;
  3701. } else {
  3702. // fetch option is availble
  3703. if (opts.fetch) {
  3704. // fetch is a funciton
  3705. if (typeof opts.fetch === 'function') {
  3706. fetch = opts.fetch;
  3707. } else {
  3708. // configuration
  3709. fetch = opts.fetch.fn || defaultFetch;
  3710. autoDecodeResponse = !!opts.fetch.autoDecodeResponse;
  3711. }
  3712. }
  3713. getPublicPath = opts.getPublicPath || opts.getDomain || defaultGetPublicPath;
  3714. getTemplate = opts.getTemplate || defaultGetTemplate;
  3715. }
  3716. return embedHTMLCache[url] || (embedHTMLCache[url] = fetch(url).then(function (response) {
  3717. return readResAsString(response, autoDecodeResponse);
  3718. }).then(function (html) {
  3719. var assetPublicPath = getPublicPath(url);
  3720. var _processTpl = processTpl(getTemplate(html), assetPublicPath),
  3721. template = _processTpl.template,
  3722. scripts = _processTpl.scripts,
  3723. entry = _processTpl.entry,
  3724. styles = _processTpl.styles;
  3725. return getEmbedHTML(template, styles, {
  3726. fetch: fetch
  3727. }).then(function (embedHTML) {
  3728. return {
  3729. template: embedHTML,
  3730. assetPublicPath: assetPublicPath,
  3731. getExternalScripts: function getExternalScripts() {
  3732. return _getExternalScripts(scripts, fetch);
  3733. },
  3734. getExternalStyleSheets: function getExternalStyleSheets() {
  3735. return _getExternalStyleSheets(styles, fetch);
  3736. },
  3737. execScripts: function execScripts(proxy, strictGlobal) {
  3738. var execScriptsHooks = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  3739. if (!scripts.length) {
  3740. return Promise.resolve();
  3741. }
  3742. return _execScripts(entry, scripts, proxy, {
  3743. fetch: fetch,
  3744. strictGlobal: strictGlobal,
  3745. beforeExec: execScriptsHooks.beforeExec,
  3746. afterExec: execScriptsHooks.afterExec
  3747. });
  3748. }
  3749. };
  3750. });
  3751. }));
  3752. }
  3753. function importEntry(entry) {
  3754. var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  3755. var _opts$fetch3 = opts.fetch,
  3756. fetch = _opts$fetch3 === void 0 ? defaultFetch : _opts$fetch3,
  3757. _opts$getTemplate = opts.getTemplate,
  3758. getTemplate = _opts$getTemplate === void 0 ? defaultGetTemplate : _opts$getTemplate;
  3759. var getPublicPath = opts.getPublicPath || opts.getDomain || defaultGetPublicPath;
  3760. if (!entry) {
  3761. throw new SyntaxError('entry should not be empty!');
  3762. } // html entry
  3763. if (typeof entry === 'string') {
  3764. return importHTML(entry, {
  3765. fetch: fetch,
  3766. getPublicPath: getPublicPath,
  3767. getTemplate: getTemplate
  3768. });
  3769. } // config entry
  3770. if (Array.isArray(entry.scripts) || Array.isArray(entry.styles)) {
  3771. var _entry$scripts = entry.scripts,
  3772. scripts = _entry$scripts === void 0 ? [] : _entry$scripts,
  3773. _entry$styles = entry.styles,
  3774. styles = _entry$styles === void 0 ? [] : _entry$styles,
  3775. _entry$html = entry.html,
  3776. html = _entry$html === void 0 ? '' : _entry$html;
  3777. var setStylePlaceholder2HTML = function setStylePlaceholder2HTML(tpl) {
  3778. return styles.reduceRight(function (html, styleSrc) {
  3779. return "".concat(genLinkReplaceSymbol(styleSrc)).concat(html);
  3780. }, tpl);
  3781. };
  3782. var setScriptPlaceholder2HTML = function setScriptPlaceholder2HTML(tpl) {
  3783. return scripts.reduce(function (html, scriptSrc) {
  3784. return "".concat(html).concat(genScriptReplaceSymbol(scriptSrc));
  3785. }, tpl);
  3786. };
  3787. return getEmbedHTML(getTemplate(setScriptPlaceholder2HTML(setStylePlaceholder2HTML(html))), styles, {
  3788. fetch: fetch
  3789. }).then(function (embedHTML) {
  3790. return {
  3791. template: embedHTML,
  3792. assetPublicPath: getPublicPath(entry),
  3793. getExternalScripts: function getExternalScripts() {
  3794. return _getExternalScripts(scripts, fetch);
  3795. },
  3796. getExternalStyleSheets: function getExternalStyleSheets() {
  3797. return _getExternalStyleSheets(styles, fetch);
  3798. },
  3799. execScripts: function execScripts(proxy, strictGlobal) {
  3800. var execScriptsHooks = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  3801. if (!scripts.length) {
  3802. return Promise.resolve();
  3803. }
  3804. return _execScripts(scripts[scripts.length - 1], scripts, proxy, {
  3805. fetch: fetch,
  3806. strictGlobal: strictGlobal,
  3807. beforeExec: execScriptsHooks.beforeExec,
  3808. afterExec: execScriptsHooks.afterExec
  3809. });
  3810. }
  3811. };
  3812. });
  3813. } else {
  3814. throw new SyntaxError('entry scripts or styles should be array!');
  3815. }
  3816. }
  3817. var rawPublicPath = window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__;
  3818. function getAddOn(global) {
  3819. var publicPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '/';
  3820. var hasMountedOnce = false;
  3821. return {
  3822. beforeLoad: function beforeLoad() {
  3823. return _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  3824. return regenerator.wrap(function _callee$(_context) {
  3825. while (1) {
  3826. switch (_context.prev = _context.next) {
  3827. case 0:
  3828. // eslint-disable-next-line no-param-reassign
  3829. global.__INJECTED_PUBLIC_PATH_BY_QIANKUN__ = publicPath;
  3830. case 1:
  3831. case "end":
  3832. return _context.stop();
  3833. }
  3834. }
  3835. }, _callee);
  3836. }))();
  3837. },
  3838. beforeMount: function beforeMount() {
  3839. return _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  3840. return regenerator.wrap(function _callee2$(_context2) {
  3841. while (1) {
  3842. switch (_context2.prev = _context2.next) {
  3843. case 0:
  3844. if (hasMountedOnce) {
  3845. // eslint-disable-next-line no-param-reassign
  3846. global.__INJECTED_PUBLIC_PATH_BY_QIANKUN__ = publicPath;
  3847. }
  3848. case 1:
  3849. case "end":
  3850. return _context2.stop();
  3851. }
  3852. }
  3853. }, _callee2);
  3854. }))();
  3855. },
  3856. beforeUnmount: function beforeUnmount() {
  3857. return _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
  3858. return regenerator.wrap(function _callee3$(_context3) {
  3859. while (1) {
  3860. switch (_context3.prev = _context3.next) {
  3861. case 0:
  3862. if (rawPublicPath === undefined) {
  3863. // eslint-disable-next-line no-param-reassign
  3864. delete global.__INJECTED_PUBLIC_PATH_BY_QIANKUN__;
  3865. } else {
  3866. // eslint-disable-next-line no-param-reassign
  3867. global.__INJECTED_PUBLIC_PATH_BY_QIANKUN__ = rawPublicPath;
  3868. }
  3869. hasMountedOnce = true;
  3870. case 2:
  3871. case "end":
  3872. return _context3.stop();
  3873. }
  3874. }
  3875. }, _callee3);
  3876. }))();
  3877. }
  3878. };
  3879. }
  3880. /**
  3881. * @author Kuitos
  3882. * @since 2020-05-15
  3883. */
  3884. function getAddOn$1(global) {
  3885. return {
  3886. beforeLoad: function beforeLoad() {
  3887. return _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  3888. return regenerator.wrap(function _callee$(_context) {
  3889. while (1) {
  3890. switch (_context.prev = _context.next) {
  3891. case 0:
  3892. // eslint-disable-next-line no-param-reassign
  3893. global.__POWERED_BY_QIANKUN__ = true;
  3894. case 1:
  3895. case "end":
  3896. return _context.stop();
  3897. }
  3898. }
  3899. }, _callee);
  3900. }))();
  3901. },
  3902. beforeMount: function beforeMount() {
  3903. return _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  3904. return regenerator.wrap(function _callee2$(_context2) {
  3905. while (1) {
  3906. switch (_context2.prev = _context2.next) {
  3907. case 0:
  3908. // eslint-disable-next-line no-param-reassign
  3909. global.__POWERED_BY_QIANKUN__ = true;
  3910. case 1:
  3911. case "end":
  3912. return _context2.stop();
  3913. }
  3914. }
  3915. }, _callee2);
  3916. }))();
  3917. },
  3918. beforeUnmount: function beforeUnmount() {
  3919. return _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
  3920. return regenerator.wrap(function _callee3$(_context3) {
  3921. while (1) {
  3922. switch (_context3.prev = _context3.next) {
  3923. case 0:
  3924. // eslint-disable-next-line no-param-reassign
  3925. delete global.__POWERED_BY_QIANKUN__;
  3926. case 1:
  3927. case "end":
  3928. return _context3.stop();
  3929. }
  3930. }
  3931. }, _callee3);
  3932. }))();
  3933. }
  3934. };
  3935. }
  3936. function getAddOns(global, publicPath) {
  3937. return mergeWith_1({}, getAddOn$1(global), getAddOn(global, publicPath), function (v1, v2) {
  3938. return concat_1(v1 !== null && v1 !== void 0 ? v1 : [], v2 !== null && v2 !== void 0 ? v2 : []);
  3939. });
  3940. }
  3941. var classCallCheck = createCommonjsModule(function (module) {
  3942. function _classCallCheck(instance, Constructor) {
  3943. if (!(instance instanceof Constructor)) {
  3944. throw new TypeError("Cannot call a class as a function");
  3945. }
  3946. }
  3947. module.exports = _classCallCheck;
  3948. module.exports["default"] = module.exports, module.exports.__esModule = true;
  3949. });
  3950. var _classCallCheck = /*@__PURE__*/getDefaultExportFromCjs(classCallCheck);
  3951. var setPrototypeOf = createCommonjsModule(function (module) {
  3952. function _setPrototypeOf(o, p) {
  3953. module.exports = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  3954. o.__proto__ = p;
  3955. return o;
  3956. };
  3957. module.exports["default"] = module.exports, module.exports.__esModule = true;
  3958. return _setPrototypeOf(o, p);
  3959. }
  3960. module.exports = _setPrototypeOf;
  3961. module.exports["default"] = module.exports, module.exports.__esModule = true;
  3962. });
  3963. var inherits = createCommonjsModule(function (module) {
  3964. function _inherits(subClass, superClass) {
  3965. if (typeof superClass !== "function" && superClass !== null) {
  3966. throw new TypeError("Super expression must either be null or a function");
  3967. }
  3968. subClass.prototype = Object.create(superClass && superClass.prototype, {
  3969. constructor: {
  3970. value: subClass,
  3971. writable: true,
  3972. configurable: true
  3973. }
  3974. });
  3975. if (superClass) setPrototypeOf(subClass, superClass);
  3976. }
  3977. module.exports = _inherits;
  3978. module.exports["default"] = module.exports, module.exports.__esModule = true;
  3979. });
  3980. var _inherits = /*@__PURE__*/getDefaultExportFromCjs(inherits);
  3981. var getPrototypeOf = createCommonjsModule(function (module) {
  3982. function _getPrototypeOf(o) {
  3983. module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
  3984. return o.__proto__ || Object.getPrototypeOf(o);
  3985. };
  3986. module.exports["default"] = module.exports, module.exports.__esModule = true;
  3987. return _getPrototypeOf(o);
  3988. }
  3989. module.exports = _getPrototypeOf;
  3990. module.exports["default"] = module.exports, module.exports.__esModule = true;
  3991. });
  3992. var isNativeReflectConstruct = createCommonjsModule(function (module) {
  3993. function _isNativeReflectConstruct() {
  3994. if (typeof Reflect === "undefined" || !Reflect.construct) return false;
  3995. if (Reflect.construct.sham) return false;
  3996. if (typeof Proxy === "function") return true;
  3997. try {
  3998. Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
  3999. return true;
  4000. } catch (e) {
  4001. return false;
  4002. }
  4003. }
  4004. module.exports = _isNativeReflectConstruct;
  4005. module.exports["default"] = module.exports, module.exports.__esModule = true;
  4006. });
  4007. var assertThisInitialized = createCommonjsModule(function (module) {
  4008. function _assertThisInitialized(self) {
  4009. if (self === void 0) {
  4010. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  4011. }
  4012. return self;
  4013. }
  4014. module.exports = _assertThisInitialized;
  4015. module.exports["default"] = module.exports, module.exports.__esModule = true;
  4016. });
  4017. var possibleConstructorReturn = createCommonjsModule(function (module) {
  4018. var _typeof = _typeof_1["default"];
  4019. function _possibleConstructorReturn(self, call) {
  4020. if (call && (_typeof(call) === "object" || typeof call === "function")) {
  4021. return call;
  4022. } else if (call !== void 0) {
  4023. throw new TypeError("Derived constructors may only return object or undefined");
  4024. }
  4025. return assertThisInitialized(self);
  4026. }
  4027. module.exports = _possibleConstructorReturn;
  4028. module.exports["default"] = module.exports, module.exports.__esModule = true;
  4029. });
  4030. var createSuper = createCommonjsModule(function (module) {
  4031. function _createSuper(Derived) {
  4032. var hasNativeReflectConstruct = isNativeReflectConstruct();
  4033. return function _createSuperInternal() {
  4034. var Super = getPrototypeOf(Derived),
  4035. result;
  4036. if (hasNativeReflectConstruct) {
  4037. var NewTarget = getPrototypeOf(this).constructor;
  4038. result = Reflect.construct(Super, arguments, NewTarget);
  4039. } else {
  4040. result = Super.apply(this, arguments);
  4041. }
  4042. return possibleConstructorReturn(this, result);
  4043. };
  4044. }
  4045. module.exports = _createSuper;
  4046. module.exports["default"] = module.exports, module.exports.__esModule = true;
  4047. });
  4048. var _createSuper = /*@__PURE__*/getDefaultExportFromCjs(createSuper);
  4049. var isNativeFunction = createCommonjsModule(function (module) {
  4050. function _isNativeFunction(fn) {
  4051. return Function.toString.call(fn).indexOf("[native code]") !== -1;
  4052. }
  4053. module.exports = _isNativeFunction;
  4054. module.exports["default"] = module.exports, module.exports.__esModule = true;
  4055. });
  4056. var construct = createCommonjsModule(function (module) {
  4057. function _construct(Parent, args, Class) {
  4058. if (isNativeReflectConstruct()) {
  4059. module.exports = _construct = Reflect.construct;
  4060. module.exports["default"] = module.exports, module.exports.__esModule = true;
  4061. } else {
  4062. module.exports = _construct = function _construct(Parent, args, Class) {
  4063. var a = [null];
  4064. a.push.apply(a, args);
  4065. var Constructor = Function.bind.apply(Parent, a);
  4066. var instance = new Constructor();
  4067. if (Class) setPrototypeOf(instance, Class.prototype);
  4068. return instance;
  4069. };
  4070. module.exports["default"] = module.exports, module.exports.__esModule = true;
  4071. }
  4072. return _construct.apply(null, arguments);
  4073. }
  4074. module.exports = _construct;
  4075. module.exports["default"] = module.exports, module.exports.__esModule = true;
  4076. });
  4077. var wrapNativeSuper = createCommonjsModule(function (module) {
  4078. function _wrapNativeSuper(Class) {
  4079. var _cache = typeof Map === "function" ? new Map() : undefined;
  4080. module.exports = _wrapNativeSuper = function _wrapNativeSuper(Class) {
  4081. if (Class === null || !isNativeFunction(Class)) return Class;
  4082. if (typeof Class !== "function") {
  4083. throw new TypeError("Super expression must either be null or a function");
  4084. }
  4085. if (typeof _cache !== "undefined") {
  4086. if (_cache.has(Class)) return _cache.get(Class);
  4087. _cache.set(Class, Wrapper);
  4088. }
  4089. function Wrapper() {
  4090. return construct(Class, arguments, getPrototypeOf(this).constructor);
  4091. }
  4092. Wrapper.prototype = Object.create(Class.prototype, {
  4093. constructor: {
  4094. value: Wrapper,
  4095. enumerable: false,
  4096. writable: true,
  4097. configurable: true
  4098. }
  4099. });
  4100. return setPrototypeOf(Wrapper, Class);
  4101. };
  4102. module.exports["default"] = module.exports, module.exports.__esModule = true;
  4103. return _wrapNativeSuper(Class);
  4104. }
  4105. module.exports = _wrapNativeSuper;
  4106. module.exports["default"] = module.exports, module.exports.__esModule = true;
  4107. });
  4108. var _wrapNativeSuper = /*@__PURE__*/getDefaultExportFromCjs(wrapNativeSuper);
  4109. var QiankunError = /*#__PURE__*/function (_Error) {
  4110. _inherits(QiankunError, _Error);
  4111. var _super = _createSuper(QiankunError);
  4112. function QiankunError(message) {
  4113. _classCallCheck(this, QiankunError);
  4114. return _super.call(this, "[qiankun]: ".concat(message));
  4115. }
  4116. return QiankunError;
  4117. }( /*#__PURE__*/_wrapNativeSuper(Error));
  4118. /**
  4119. * The base implementation of `_.assign` without support for multiple sources
  4120. * or `customizer` functions.
  4121. *
  4122. * @private
  4123. * @param {Object} object The destination object.
  4124. * @param {Object} source The source object.
  4125. * @returns {Object} Returns `object`.
  4126. */
  4127. function baseAssign(object, source) {
  4128. return object && _copyObject(source, keys_1(source), object);
  4129. }
  4130. var _baseAssign = baseAssign;
  4131. /**
  4132. * The base implementation of `_.assignIn` without support for multiple sources
  4133. * or `customizer` functions.
  4134. *
  4135. * @private
  4136. * @param {Object} object The destination object.
  4137. * @param {Object} source The source object.
  4138. * @returns {Object} Returns `object`.
  4139. */
  4140. function baseAssignIn(object, source) {
  4141. return object && _copyObject(source, keysIn_1(source), object);
  4142. }
  4143. var _baseAssignIn = baseAssignIn;
  4144. /**
  4145. * A specialized version of `_.filter` for arrays without support for
  4146. * iteratee shorthands.
  4147. *
  4148. * @private
  4149. * @param {Array} [array] The array to iterate over.
  4150. * @param {Function} predicate The function invoked per iteration.
  4151. * @returns {Array} Returns the new filtered array.
  4152. */
  4153. function arrayFilter(array, predicate) {
  4154. var index = -1,
  4155. length = array == null ? 0 : array.length,
  4156. resIndex = 0,
  4157. result = [];
  4158. while (++index < length) {
  4159. var value = array[index];
  4160. if (predicate(value, index, array)) {
  4161. result[resIndex++] = value;
  4162. }
  4163. }
  4164. return result;
  4165. }
  4166. var _arrayFilter = arrayFilter;
  4167. /**
  4168. * This method returns a new empty array.
  4169. *
  4170. * @static
  4171. * @memberOf _
  4172. * @since 4.13.0
  4173. * @category Util
  4174. * @returns {Array} Returns the new empty array.
  4175. * @example
  4176. *
  4177. * var arrays = _.times(2, _.stubArray);
  4178. *
  4179. * console.log(arrays);
  4180. * // => [[], []]
  4181. *
  4182. * console.log(arrays[0] === arrays[1]);
  4183. * // => false
  4184. */
  4185. function stubArray() {
  4186. return [];
  4187. }
  4188. var stubArray_1 = stubArray;
  4189. /** Used for built-in method references. */
  4190. var objectProto$c = Object.prototype;
  4191. /** Built-in value references. */
  4192. var propertyIsEnumerable$1 = objectProto$c.propertyIsEnumerable;
  4193. /* Built-in method references for those with the same name as other `lodash` methods. */
  4194. var nativeGetSymbols = Object.getOwnPropertySymbols;
  4195. /**
  4196. * Creates an array of the own enumerable symbols of `object`.
  4197. *
  4198. * @private
  4199. * @param {Object} object The object to query.
  4200. * @returns {Array} Returns the array of symbols.
  4201. */
  4202. var getSymbols = !nativeGetSymbols ? stubArray_1 : function(object) {
  4203. if (object == null) {
  4204. return [];
  4205. }
  4206. object = Object(object);
  4207. return _arrayFilter(nativeGetSymbols(object), function(symbol) {
  4208. return propertyIsEnumerable$1.call(object, symbol);
  4209. });
  4210. };
  4211. var _getSymbols = getSymbols;
  4212. /**
  4213. * Copies own symbols of `source` to `object`.
  4214. *
  4215. * @private
  4216. * @param {Object} source The object to copy symbols from.
  4217. * @param {Object} [object={}] The object to copy symbols to.
  4218. * @returns {Object} Returns `object`.
  4219. */
  4220. function copySymbols(source, object) {
  4221. return _copyObject(source, _getSymbols(source), object);
  4222. }
  4223. var _copySymbols = copySymbols;
  4224. /* Built-in method references for those with the same name as other `lodash` methods. */
  4225. var nativeGetSymbols$1 = Object.getOwnPropertySymbols;
  4226. /**
  4227. * Creates an array of the own and inherited enumerable symbols of `object`.
  4228. *
  4229. * @private
  4230. * @param {Object} object The object to query.
  4231. * @returns {Array} Returns the array of symbols.
  4232. */
  4233. var getSymbolsIn = !nativeGetSymbols$1 ? stubArray_1 : function(object) {
  4234. var result = [];
  4235. while (object) {
  4236. _arrayPush(result, _getSymbols(object));
  4237. object = _getPrototype(object);
  4238. }
  4239. return result;
  4240. };
  4241. var _getSymbolsIn = getSymbolsIn;
  4242. /**
  4243. * Copies own and inherited symbols of `source` to `object`.
  4244. *
  4245. * @private
  4246. * @param {Object} source The object to copy symbols from.
  4247. * @param {Object} [object={}] The object to copy symbols to.
  4248. * @returns {Object} Returns `object`.
  4249. */
  4250. function copySymbolsIn(source, object) {
  4251. return _copyObject(source, _getSymbolsIn(source), object);
  4252. }
  4253. var _copySymbolsIn = copySymbolsIn;
  4254. /**
  4255. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  4256. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  4257. * symbols of `object`.
  4258. *
  4259. * @private
  4260. * @param {Object} object The object to query.
  4261. * @param {Function} keysFunc The function to get the keys of `object`.
  4262. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  4263. * @returns {Array} Returns the array of property names and symbols.
  4264. */
  4265. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  4266. var result = keysFunc(object);
  4267. return isArray_1(object) ? result : _arrayPush(result, symbolsFunc(object));
  4268. }
  4269. var _baseGetAllKeys = baseGetAllKeys;
  4270. /**
  4271. * Creates an array of own enumerable property names and symbols of `object`.
  4272. *
  4273. * @private
  4274. * @param {Object} object The object to query.
  4275. * @returns {Array} Returns the array of property names and symbols.
  4276. */
  4277. function getAllKeys(object) {
  4278. return _baseGetAllKeys(object, keys_1, _getSymbols);
  4279. }
  4280. var _getAllKeys = getAllKeys;
  4281. /**
  4282. * Creates an array of own and inherited enumerable property names and
  4283. * symbols of `object`.
  4284. *
  4285. * @private
  4286. * @param {Object} object The object to query.
  4287. * @returns {Array} Returns the array of property names and symbols.
  4288. */
  4289. function getAllKeysIn(object) {
  4290. return _baseGetAllKeys(object, keysIn_1, _getSymbolsIn);
  4291. }
  4292. var _getAllKeysIn = getAllKeysIn;
  4293. /* Built-in method references that are verified to be native. */
  4294. var DataView = _getNative(_root, 'DataView');
  4295. var _DataView = DataView;
  4296. /* Built-in method references that are verified to be native. */
  4297. var Promise$1 = _getNative(_root, 'Promise');
  4298. var _Promise = Promise$1;
  4299. /* Built-in method references that are verified to be native. */
  4300. var Set$1 = _getNative(_root, 'Set');
  4301. var _Set = Set$1;
  4302. /* Built-in method references that are verified to be native. */
  4303. var WeakMap$1 = _getNative(_root, 'WeakMap');
  4304. var _WeakMap = WeakMap$1;
  4305. /** `Object#toString` result references. */
  4306. var mapTag$1 = '[object Map]',
  4307. objectTag$2 = '[object Object]',
  4308. promiseTag = '[object Promise]',
  4309. setTag$1 = '[object Set]',
  4310. weakMapTag$1 = '[object WeakMap]';
  4311. var dataViewTag$1 = '[object DataView]';
  4312. /** Used to detect maps, sets, and weakmaps. */
  4313. var dataViewCtorString = _toSource(_DataView),
  4314. mapCtorString = _toSource(_Map),
  4315. promiseCtorString = _toSource(_Promise),
  4316. setCtorString = _toSource(_Set),
  4317. weakMapCtorString = _toSource(_WeakMap);
  4318. /**
  4319. * Gets the `toStringTag` of `value`.
  4320. *
  4321. * @private
  4322. * @param {*} value The value to query.
  4323. * @returns {string} Returns the `toStringTag`.
  4324. */
  4325. var getTag = _baseGetTag;
  4326. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  4327. if ((_DataView && getTag(new _DataView(new ArrayBuffer(1))) != dataViewTag$1) ||
  4328. (_Map && getTag(new _Map) != mapTag$1) ||
  4329. (_Promise && getTag(_Promise.resolve()) != promiseTag) ||
  4330. (_Set && getTag(new _Set) != setTag$1) ||
  4331. (_WeakMap && getTag(new _WeakMap) != weakMapTag$1)) {
  4332. getTag = function(value) {
  4333. var result = _baseGetTag(value),
  4334. Ctor = result == objectTag$2 ? value.constructor : undefined,
  4335. ctorString = Ctor ? _toSource(Ctor) : '';
  4336. if (ctorString) {
  4337. switch (ctorString) {
  4338. case dataViewCtorString: return dataViewTag$1;
  4339. case mapCtorString: return mapTag$1;
  4340. case promiseCtorString: return promiseTag;
  4341. case setCtorString: return setTag$1;
  4342. case weakMapCtorString: return weakMapTag$1;
  4343. }
  4344. }
  4345. return result;
  4346. };
  4347. }
  4348. var _getTag = getTag;
  4349. /** Used for built-in method references. */
  4350. var objectProto$d = Object.prototype;
  4351. /** Used to check objects for own properties. */
  4352. var hasOwnProperty$a = objectProto$d.hasOwnProperty;
  4353. /**
  4354. * Initializes an array clone.
  4355. *
  4356. * @private
  4357. * @param {Array} array The array to clone.
  4358. * @returns {Array} Returns the initialized clone.
  4359. */
  4360. function initCloneArray(array) {
  4361. var length = array.length,
  4362. result = new array.constructor(length);
  4363. // Add properties assigned by `RegExp#exec`.
  4364. if (length && typeof array[0] == 'string' && hasOwnProperty$a.call(array, 'index')) {
  4365. result.index = array.index;
  4366. result.input = array.input;
  4367. }
  4368. return result;
  4369. }
  4370. var _initCloneArray = initCloneArray;
  4371. /**
  4372. * Creates a clone of `dataView`.
  4373. *
  4374. * @private
  4375. * @param {Object} dataView The data view to clone.
  4376. * @param {boolean} [isDeep] Specify a deep clone.
  4377. * @returns {Object} Returns the cloned data view.
  4378. */
  4379. function cloneDataView(dataView, isDeep) {
  4380. var buffer = isDeep ? _cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  4381. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  4382. }
  4383. var _cloneDataView = cloneDataView;
  4384. /** Used to match `RegExp` flags from their coerced string values. */
  4385. var reFlags = /\w*$/;
  4386. /**
  4387. * Creates a clone of `regexp`.
  4388. *
  4389. * @private
  4390. * @param {Object} regexp The regexp to clone.
  4391. * @returns {Object} Returns the cloned regexp.
  4392. */
  4393. function cloneRegExp(regexp) {
  4394. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  4395. result.lastIndex = regexp.lastIndex;
  4396. return result;
  4397. }
  4398. var _cloneRegExp = cloneRegExp;
  4399. /** Used to convert symbols to primitives and strings. */
  4400. var symbolProto = _Symbol ? _Symbol.prototype : undefined,
  4401. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
  4402. /**
  4403. * Creates a clone of the `symbol` object.
  4404. *
  4405. * @private
  4406. * @param {Object} symbol The symbol object to clone.
  4407. * @returns {Object} Returns the cloned symbol object.
  4408. */
  4409. function cloneSymbol(symbol) {
  4410. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  4411. }
  4412. var _cloneSymbol = cloneSymbol;
  4413. /** `Object#toString` result references. */
  4414. var boolTag$1 = '[object Boolean]',
  4415. dateTag$1 = '[object Date]',
  4416. mapTag$2 = '[object Map]',
  4417. numberTag$1 = '[object Number]',
  4418. regexpTag$1 = '[object RegExp]',
  4419. setTag$2 = '[object Set]',
  4420. stringTag$1 = '[object String]',
  4421. symbolTag = '[object Symbol]';
  4422. var arrayBufferTag$1 = '[object ArrayBuffer]',
  4423. dataViewTag$2 = '[object DataView]',
  4424. float32Tag$1 = '[object Float32Array]',
  4425. float64Tag$1 = '[object Float64Array]',
  4426. int8Tag$1 = '[object Int8Array]',
  4427. int16Tag$1 = '[object Int16Array]',
  4428. int32Tag$1 = '[object Int32Array]',
  4429. uint8Tag$1 = '[object Uint8Array]',
  4430. uint8ClampedTag$1 = '[object Uint8ClampedArray]',
  4431. uint16Tag$1 = '[object Uint16Array]',
  4432. uint32Tag$1 = '[object Uint32Array]';
  4433. /**
  4434. * Initializes an object clone based on its `toStringTag`.
  4435. *
  4436. * **Note:** This function only supports cloning values with tags of
  4437. * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
  4438. *
  4439. * @private
  4440. * @param {Object} object The object to clone.
  4441. * @param {string} tag The `toStringTag` of the object to clone.
  4442. * @param {boolean} [isDeep] Specify a deep clone.
  4443. * @returns {Object} Returns the initialized clone.
  4444. */
  4445. function initCloneByTag(object, tag, isDeep) {
  4446. var Ctor = object.constructor;
  4447. switch (tag) {
  4448. case arrayBufferTag$1:
  4449. return _cloneArrayBuffer(object);
  4450. case boolTag$1:
  4451. case dateTag$1:
  4452. return new Ctor(+object);
  4453. case dataViewTag$2:
  4454. return _cloneDataView(object, isDeep);
  4455. case float32Tag$1: case float64Tag$1:
  4456. case int8Tag$1: case int16Tag$1: case int32Tag$1:
  4457. case uint8Tag$1: case uint8ClampedTag$1: case uint16Tag$1: case uint32Tag$1:
  4458. return _cloneTypedArray(object, isDeep);
  4459. case mapTag$2:
  4460. return new Ctor;
  4461. case numberTag$1:
  4462. case stringTag$1:
  4463. return new Ctor(object);
  4464. case regexpTag$1:
  4465. return _cloneRegExp(object);
  4466. case setTag$2:
  4467. return new Ctor;
  4468. case symbolTag:
  4469. return _cloneSymbol(object);
  4470. }
  4471. }
  4472. var _initCloneByTag = initCloneByTag;
  4473. /** `Object#toString` result references. */
  4474. var mapTag$3 = '[object Map]';
  4475. /**
  4476. * The base implementation of `_.isMap` without Node.js optimizations.
  4477. *
  4478. * @private
  4479. * @param {*} value The value to check.
  4480. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  4481. */
  4482. function baseIsMap(value) {
  4483. return isObjectLike_1(value) && _getTag(value) == mapTag$3;
  4484. }
  4485. var _baseIsMap = baseIsMap;
  4486. /* Node.js helper references. */
  4487. var nodeIsMap = _nodeUtil && _nodeUtil.isMap;
  4488. /**
  4489. * Checks if `value` is classified as a `Map` object.
  4490. *
  4491. * @static
  4492. * @memberOf _
  4493. * @since 4.3.0
  4494. * @category Lang
  4495. * @param {*} value The value to check.
  4496. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  4497. * @example
  4498. *
  4499. * _.isMap(new Map);
  4500. * // => true
  4501. *
  4502. * _.isMap(new WeakMap);
  4503. * // => false
  4504. */
  4505. var isMap = nodeIsMap ? _baseUnary(nodeIsMap) : _baseIsMap;
  4506. var isMap_1 = isMap;
  4507. /** `Object#toString` result references. */
  4508. var setTag$3 = '[object Set]';
  4509. /**
  4510. * The base implementation of `_.isSet` without Node.js optimizations.
  4511. *
  4512. * @private
  4513. * @param {*} value The value to check.
  4514. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  4515. */
  4516. function baseIsSet(value) {
  4517. return isObjectLike_1(value) && _getTag(value) == setTag$3;
  4518. }
  4519. var _baseIsSet = baseIsSet;
  4520. /* Node.js helper references. */
  4521. var nodeIsSet = _nodeUtil && _nodeUtil.isSet;
  4522. /**
  4523. * Checks if `value` is classified as a `Set` object.
  4524. *
  4525. * @static
  4526. * @memberOf _
  4527. * @since 4.3.0
  4528. * @category Lang
  4529. * @param {*} value The value to check.
  4530. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  4531. * @example
  4532. *
  4533. * _.isSet(new Set);
  4534. * // => true
  4535. *
  4536. * _.isSet(new WeakSet);
  4537. * // => false
  4538. */
  4539. var isSet = nodeIsSet ? _baseUnary(nodeIsSet) : _baseIsSet;
  4540. var isSet_1 = isSet;
  4541. /** Used to compose bitmasks for cloning. */
  4542. var CLONE_DEEP_FLAG = 1,
  4543. CLONE_FLAT_FLAG = 2,
  4544. CLONE_SYMBOLS_FLAG = 4;
  4545. /** `Object#toString` result references. */
  4546. var argsTag$2 = '[object Arguments]',
  4547. arrayTag$1 = '[object Array]',
  4548. boolTag$2 = '[object Boolean]',
  4549. dateTag$2 = '[object Date]',
  4550. errorTag$1 = '[object Error]',
  4551. funcTag$2 = '[object Function]',
  4552. genTag$1 = '[object GeneratorFunction]',
  4553. mapTag$4 = '[object Map]',
  4554. numberTag$2 = '[object Number]',
  4555. objectTag$3 = '[object Object]',
  4556. regexpTag$2 = '[object RegExp]',
  4557. setTag$4 = '[object Set]',
  4558. stringTag$2 = '[object String]',
  4559. symbolTag$1 = '[object Symbol]',
  4560. weakMapTag$2 = '[object WeakMap]';
  4561. var arrayBufferTag$2 = '[object ArrayBuffer]',
  4562. dataViewTag$3 = '[object DataView]',
  4563. float32Tag$2 = '[object Float32Array]',
  4564. float64Tag$2 = '[object Float64Array]',
  4565. int8Tag$2 = '[object Int8Array]',
  4566. int16Tag$2 = '[object Int16Array]',
  4567. int32Tag$2 = '[object Int32Array]',
  4568. uint8Tag$2 = '[object Uint8Array]',
  4569. uint8ClampedTag$2 = '[object Uint8ClampedArray]',
  4570. uint16Tag$2 = '[object Uint16Array]',
  4571. uint32Tag$2 = '[object Uint32Array]';
  4572. /** Used to identify `toStringTag` values supported by `_.clone`. */
  4573. var cloneableTags = {};
  4574. cloneableTags[argsTag$2] = cloneableTags[arrayTag$1] =
  4575. cloneableTags[arrayBufferTag$2] = cloneableTags[dataViewTag$3] =
  4576. cloneableTags[boolTag$2] = cloneableTags[dateTag$2] =
  4577. cloneableTags[float32Tag$2] = cloneableTags[float64Tag$2] =
  4578. cloneableTags[int8Tag$2] = cloneableTags[int16Tag$2] =
  4579. cloneableTags[int32Tag$2] = cloneableTags[mapTag$4] =
  4580. cloneableTags[numberTag$2] = cloneableTags[objectTag$3] =
  4581. cloneableTags[regexpTag$2] = cloneableTags[setTag$4] =
  4582. cloneableTags[stringTag$2] = cloneableTags[symbolTag$1] =
  4583. cloneableTags[uint8Tag$2] = cloneableTags[uint8ClampedTag$2] =
  4584. cloneableTags[uint16Tag$2] = cloneableTags[uint32Tag$2] = true;
  4585. cloneableTags[errorTag$1] = cloneableTags[funcTag$2] =
  4586. cloneableTags[weakMapTag$2] = false;
  4587. /**
  4588. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  4589. * traversed objects.
  4590. *
  4591. * @private
  4592. * @param {*} value The value to clone.
  4593. * @param {boolean} bitmask The bitmask flags.
  4594. * 1 - Deep clone
  4595. * 2 - Flatten inherited properties
  4596. * 4 - Clone symbols
  4597. * @param {Function} [customizer] The function to customize cloning.
  4598. * @param {string} [key] The key of `value`.
  4599. * @param {Object} [object] The parent object of `value`.
  4600. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  4601. * @returns {*} Returns the cloned value.
  4602. */
  4603. function baseClone(value, bitmask, customizer, key, object, stack) {
  4604. var result,
  4605. isDeep = bitmask & CLONE_DEEP_FLAG,
  4606. isFlat = bitmask & CLONE_FLAT_FLAG,
  4607. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  4608. if (customizer) {
  4609. result = object ? customizer(value, key, object, stack) : customizer(value);
  4610. }
  4611. if (result !== undefined) {
  4612. return result;
  4613. }
  4614. if (!isObject_1(value)) {
  4615. return value;
  4616. }
  4617. var isArr = isArray_1(value);
  4618. if (isArr) {
  4619. result = _initCloneArray(value);
  4620. if (!isDeep) {
  4621. return _copyArray(value, result);
  4622. }
  4623. } else {
  4624. var tag = _getTag(value),
  4625. isFunc = tag == funcTag$2 || tag == genTag$1;
  4626. if (isBuffer_1(value)) {
  4627. return _cloneBuffer(value, isDeep);
  4628. }
  4629. if (tag == objectTag$3 || tag == argsTag$2 || (isFunc && !object)) {
  4630. result = (isFlat || isFunc) ? {} : _initCloneObject(value);
  4631. if (!isDeep) {
  4632. return isFlat
  4633. ? _copySymbolsIn(value, _baseAssignIn(result, value))
  4634. : _copySymbols(value, _baseAssign(result, value));
  4635. }
  4636. } else {
  4637. if (!cloneableTags[tag]) {
  4638. return object ? value : {};
  4639. }
  4640. result = _initCloneByTag(value, tag, isDeep);
  4641. }
  4642. }
  4643. // Check for circular references and return its corresponding clone.
  4644. stack || (stack = new _Stack);
  4645. var stacked = stack.get(value);
  4646. if (stacked) {
  4647. return stacked;
  4648. }
  4649. stack.set(value, result);
  4650. if (isSet_1(value)) {
  4651. value.forEach(function(subValue) {
  4652. result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
  4653. });
  4654. } else if (isMap_1(value)) {
  4655. value.forEach(function(subValue, key) {
  4656. result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
  4657. });
  4658. }
  4659. var keysFunc = isFull
  4660. ? (isFlat ? _getAllKeysIn : _getAllKeys)
  4661. : (isFlat ? keysIn_1 : keys_1);
  4662. var props = isArr ? undefined : keysFunc(value);
  4663. _arrayEach(props || value, function(subValue, key) {
  4664. if (props) {
  4665. key = subValue;
  4666. subValue = value[key];
  4667. }
  4668. // Recursively populate clone (susceptible to call stack limits).
  4669. _assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  4670. });
  4671. return result;
  4672. }
  4673. var _baseClone = baseClone;
  4674. /** Used to compose bitmasks for cloning. */
  4675. var CLONE_DEEP_FLAG$1 = 1,
  4676. CLONE_SYMBOLS_FLAG$1 = 4;
  4677. /**
  4678. * This method is like `_.clone` except that it recursively clones `value`.
  4679. *
  4680. * @static
  4681. * @memberOf _
  4682. * @since 1.0.0
  4683. * @category Lang
  4684. * @param {*} value The value to recursively clone.
  4685. * @returns {*} Returns the deep cloned value.
  4686. * @see _.clone
  4687. * @example
  4688. *
  4689. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  4690. *
  4691. * var deep = _.cloneDeep(objects);
  4692. * console.log(deep[0] === objects[0]);
  4693. * // => false
  4694. */
  4695. function cloneDeep(value) {
  4696. return _baseClone(value, CLONE_DEEP_FLAG$1 | CLONE_SYMBOLS_FLAG$1);
  4697. }
  4698. var cloneDeep_1 = cloneDeep;
  4699. var globalState = {};
  4700. var deps = {}; // 触发全局监听
  4701. function emitGlobal(state, prevState) {
  4702. Object.keys(deps).forEach(function (id) {
  4703. if (deps[id] instanceof Function) {
  4704. deps[id](cloneDeep_1(state), cloneDeep_1(prevState));
  4705. }
  4706. });
  4707. }
  4708. function initGlobalState() {
  4709. var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  4710. {
  4711. console.warn("[qiankun] globalState tools will be removed in 3.0, pls don't use it!");
  4712. }
  4713. if (state === globalState) {
  4714. console.warn('[qiankun] state has not changed!');
  4715. } else {
  4716. var prevGlobalState = cloneDeep_1(globalState);
  4717. globalState = cloneDeep_1(state);
  4718. emitGlobal(globalState, prevGlobalState);
  4719. }
  4720. return getMicroAppStateActions("global-".concat(+new Date()), true);
  4721. }
  4722. function getMicroAppStateActions(id, isMaster) {
  4723. return {
  4724. /**
  4725. * onGlobalStateChange 全局依赖监听
  4726. *
  4727. * 收集 setState 时所需要触发的依赖
  4728. *
  4729. * 限制条件:每个子应用只有一个激活状态的全局监听,新监听覆盖旧监听,若只是监听部分属性,请使用 onGlobalStateChange
  4730. *
  4731. * 这么设计是为了减少全局监听滥用导致的内存爆炸
  4732. *
  4733. * 依赖数据结构为:
  4734. * {
  4735. * {id}: callback
  4736. * }
  4737. *
  4738. * @param callback
  4739. * @param fireImmediately
  4740. */
  4741. onGlobalStateChange: function onGlobalStateChange(callback, fireImmediately) {
  4742. if (!(callback instanceof Function)) {
  4743. console.error('[qiankun] callback must be function!');
  4744. return;
  4745. }
  4746. if (deps[id]) {
  4747. console.warn("[qiankun] '".concat(id, "' global listener already exists before this, new listener will overwrite it."));
  4748. }
  4749. deps[id] = callback;
  4750. if (fireImmediately) {
  4751. var cloneState = cloneDeep_1(globalState);
  4752. callback(cloneState, cloneState);
  4753. }
  4754. },
  4755. /**
  4756. * setGlobalState 更新 store 数据
  4757. *
  4758. * 1. 对输入 state 的第一层属性做校验,只有初始化时声明过的第一层(bucket)属性才会被更改
  4759. * 2. 修改 store 并触发全局监听
  4760. *
  4761. * @param state
  4762. */
  4763. setGlobalState: function setGlobalState() {
  4764. var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  4765. if (state === globalState) {
  4766. console.warn('[qiankun] state has not changed!');
  4767. return false;
  4768. }
  4769. var changeKeys = [];
  4770. var prevGlobalState = cloneDeep_1(globalState);
  4771. globalState = cloneDeep_1(Object.keys(state).reduce(function (_globalState, changeKey) {
  4772. if (isMaster || _globalState.hasOwnProperty(changeKey)) {
  4773. changeKeys.push(changeKey);
  4774. return Object.assign(_globalState, _defineProperty({}, changeKey, state[changeKey]));
  4775. }
  4776. console.warn("[qiankun] '".concat(changeKey, "' not declared when init state\uFF01"));
  4777. return _globalState;
  4778. }, globalState));
  4779. if (changeKeys.length === 0) {
  4780. console.warn('[qiankun] state has not changed!');
  4781. return false;
  4782. }
  4783. emitGlobal(globalState, prevGlobalState);
  4784. return true;
  4785. },
  4786. // 注销该应用下的依赖
  4787. offGlobalStateChange: function offGlobalStateChange() {
  4788. delete deps[id];
  4789. return true;
  4790. }
  4791. };
  4792. }
  4793. var createClass = createCommonjsModule(function (module) {
  4794. function _defineProperties(target, props) {
  4795. for (var i = 0; i < props.length; i++) {
  4796. var descriptor = props[i];
  4797. descriptor.enumerable = descriptor.enumerable || false;
  4798. descriptor.configurable = true;
  4799. if ("value" in descriptor) descriptor.writable = true;
  4800. Object.defineProperty(target, descriptor.key, descriptor);
  4801. }
  4802. }
  4803. function _createClass(Constructor, protoProps, staticProps) {
  4804. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  4805. if (staticProps) _defineProperties(Constructor, staticProps);
  4806. return Constructor;
  4807. }
  4808. module.exports = _createClass;
  4809. module.exports["default"] = module.exports, module.exports.__esModule = true;
  4810. });
  4811. var _createClass = /*@__PURE__*/getDefaultExportFromCjs(createClass);
  4812. (function (SandBoxType) {
  4813. SandBoxType["Proxy"] = "Proxy";
  4814. SandBoxType["Snapshot"] = "Snapshot"; // for legacy sandbox
  4815. // https://github.com/umijs/qiankun/blob/0d1d3f0c5ed1642f01854f96c3fabf0a2148bd26/src/sandbox/legacy/sandbox.ts#L22...L25
  4816. SandBoxType["LegacyProxy"] = "LegacyProxy";
  4817. })(exports.SandBoxType || (exports.SandBoxType = {}));
  4818. /** Used to match a single whitespace character. */
  4819. var reWhitespace = /\s/;
  4820. /**
  4821. * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
  4822. * character of `string`.
  4823. *
  4824. * @private
  4825. * @param {string} string The string to inspect.
  4826. * @returns {number} Returns the index of the last non-whitespace character.
  4827. */
  4828. function trimmedEndIndex(string) {
  4829. var index = string.length;
  4830. while (index-- && reWhitespace.test(string.charAt(index))) {}
  4831. return index;
  4832. }
  4833. var _trimmedEndIndex = trimmedEndIndex;
  4834. /** Used to match leading whitespace. */
  4835. var reTrimStart = /^\s+/;
  4836. /**
  4837. * The base implementation of `_.trim`.
  4838. *
  4839. * @private
  4840. * @param {string} string The string to trim.
  4841. * @returns {string} Returns the trimmed string.
  4842. */
  4843. function baseTrim(string) {
  4844. return string
  4845. ? string.slice(0, _trimmedEndIndex(string) + 1).replace(reTrimStart, '')
  4846. : string;
  4847. }
  4848. var _baseTrim = baseTrim;
  4849. /** `Object#toString` result references. */
  4850. var symbolTag$2 = '[object Symbol]';
  4851. /**
  4852. * Checks if `value` is classified as a `Symbol` primitive or object.
  4853. *
  4854. * @static
  4855. * @memberOf _
  4856. * @since 4.0.0
  4857. * @category Lang
  4858. * @param {*} value The value to check.
  4859. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  4860. * @example
  4861. *
  4862. * _.isSymbol(Symbol.iterator);
  4863. * // => true
  4864. *
  4865. * _.isSymbol('abc');
  4866. * // => false
  4867. */
  4868. function isSymbol(value) {
  4869. return typeof value == 'symbol' ||
  4870. (isObjectLike_1(value) && _baseGetTag(value) == symbolTag$2);
  4871. }
  4872. var isSymbol_1 = isSymbol;
  4873. /** Used as references for various `Number` constants. */
  4874. var NAN = 0 / 0;
  4875. /** Used to detect bad signed hexadecimal string values. */
  4876. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  4877. /** Used to detect binary string values. */
  4878. var reIsBinary = /^0b[01]+$/i;
  4879. /** Used to detect octal string values. */
  4880. var reIsOctal = /^0o[0-7]+$/i;
  4881. /** Built-in method references without a dependency on `root`. */
  4882. var freeParseInt = parseInt;
  4883. /**
  4884. * Converts `value` to a number.
  4885. *
  4886. * @static
  4887. * @memberOf _
  4888. * @since 4.0.0
  4889. * @category Lang
  4890. * @param {*} value The value to process.
  4891. * @returns {number} Returns the number.
  4892. * @example
  4893. *
  4894. * _.toNumber(3.2);
  4895. * // => 3.2
  4896. *
  4897. * _.toNumber(Number.MIN_VALUE);
  4898. * // => 5e-324
  4899. *
  4900. * _.toNumber(Infinity);
  4901. * // => Infinity
  4902. *
  4903. * _.toNumber('3.2');
  4904. * // => 3.2
  4905. */
  4906. function toNumber(value) {
  4907. if (typeof value == 'number') {
  4908. return value;
  4909. }
  4910. if (isSymbol_1(value)) {
  4911. return NAN;
  4912. }
  4913. if (isObject_1(value)) {
  4914. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  4915. value = isObject_1(other) ? (other + '') : other;
  4916. }
  4917. if (typeof value != 'string') {
  4918. return value === 0 ? value : +value;
  4919. }
  4920. value = _baseTrim(value);
  4921. var isBinary = reIsBinary.test(value);
  4922. return (isBinary || reIsOctal.test(value))
  4923. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  4924. : (reIsBadHex.test(value) ? NAN : +value);
  4925. }
  4926. var toNumber_1 = toNumber;
  4927. /** Used as references for various `Number` constants. */
  4928. var INFINITY = 1 / 0,
  4929. MAX_INTEGER = 1.7976931348623157e+308;
  4930. /**
  4931. * Converts `value` to a finite number.
  4932. *
  4933. * @static
  4934. * @memberOf _
  4935. * @since 4.12.0
  4936. * @category Lang
  4937. * @param {*} value The value to convert.
  4938. * @returns {number} Returns the converted number.
  4939. * @example
  4940. *
  4941. * _.toFinite(3.2);
  4942. * // => 3.2
  4943. *
  4944. * _.toFinite(Number.MIN_VALUE);
  4945. * // => 5e-324
  4946. *
  4947. * _.toFinite(Infinity);
  4948. * // => 1.7976931348623157e+308
  4949. *
  4950. * _.toFinite('3.2');
  4951. * // => 3.2
  4952. */
  4953. function toFinite(value) {
  4954. if (!value) {
  4955. return value === 0 ? value : 0;
  4956. }
  4957. value = toNumber_1(value);
  4958. if (value === INFINITY || value === -INFINITY) {
  4959. var sign = (value < 0 ? -1 : 1);
  4960. return sign * MAX_INTEGER;
  4961. }
  4962. return value === value ? value : 0;
  4963. }
  4964. var toFinite_1 = toFinite;
  4965. /**
  4966. * Converts `value` to an integer.
  4967. *
  4968. * **Note:** This method is loosely based on
  4969. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  4970. *
  4971. * @static
  4972. * @memberOf _
  4973. * @since 4.0.0
  4974. * @category Lang
  4975. * @param {*} value The value to convert.
  4976. * @returns {number} Returns the converted integer.
  4977. * @example
  4978. *
  4979. * _.toInteger(3.2);
  4980. * // => 3
  4981. *
  4982. * _.toInteger(Number.MIN_VALUE);
  4983. * // => 0
  4984. *
  4985. * _.toInteger(Infinity);
  4986. * // => 1.7976931348623157e+308
  4987. *
  4988. * _.toInteger('3.2');
  4989. * // => 3
  4990. */
  4991. function toInteger(value) {
  4992. var result = toFinite_1(value),
  4993. remainder = result % 1;
  4994. return result === result ? (remainder ? result - remainder : result) : 0;
  4995. }
  4996. var toInteger_1 = toInteger;
  4997. /** Error message constants. */
  4998. var FUNC_ERROR_TEXT = 'Expected a function';
  4999. /**
  5000. * Creates a function that invokes `func`, with the `this` binding and arguments
  5001. * of the created function, while it's called less than `n` times. Subsequent
  5002. * calls to the created function return the result of the last `func` invocation.
  5003. *
  5004. * @static
  5005. * @memberOf _
  5006. * @since 3.0.0
  5007. * @category Function
  5008. * @param {number} n The number of calls at which `func` is no longer invoked.
  5009. * @param {Function} func The function to restrict.
  5010. * @returns {Function} Returns the new restricted function.
  5011. * @example
  5012. *
  5013. * jQuery(element).on('click', _.before(5, addContactToList));
  5014. * // => Allows adding up to 4 contacts to the list.
  5015. */
  5016. function before(n, func) {
  5017. var result;
  5018. if (typeof func != 'function') {
  5019. throw new TypeError(FUNC_ERROR_TEXT);
  5020. }
  5021. n = toInteger_1(n);
  5022. return function() {
  5023. if (--n > 0) {
  5024. result = func.apply(this, arguments);
  5025. }
  5026. if (n <= 1) {
  5027. func = undefined;
  5028. }
  5029. return result;
  5030. };
  5031. }
  5032. var before_1 = before;
  5033. /**
  5034. * Creates a function that is restricted to invoking `func` once. Repeat calls
  5035. * to the function return the value of the first invocation. The `func` is
  5036. * invoked with the `this` binding and arguments of the created function.
  5037. *
  5038. * @static
  5039. * @memberOf _
  5040. * @since 0.1.0
  5041. * @category Function
  5042. * @param {Function} func The function to restrict.
  5043. * @returns {Function} Returns the new restricted function.
  5044. * @example
  5045. *
  5046. * var initialize = _.once(createApplication);
  5047. * initialize();
  5048. * initialize();
  5049. * // => `createApplication` is invoked once
  5050. */
  5051. function once(func) {
  5052. return before_1(2, func);
  5053. }
  5054. var once_1 = once;
  5055. /**
  5056. * A specialized version of `_.reduce` for arrays without support for
  5057. * iteratee shorthands.
  5058. *
  5059. * @private
  5060. * @param {Array} [array] The array to iterate over.
  5061. * @param {Function} iteratee The function invoked per iteration.
  5062. * @param {*} [accumulator] The initial value.
  5063. * @param {boolean} [initAccum] Specify using the first element of `array` as
  5064. * the initial value.
  5065. * @returns {*} Returns the accumulated value.
  5066. */
  5067. function arrayReduce(array, iteratee, accumulator, initAccum) {
  5068. var index = -1,
  5069. length = array == null ? 0 : array.length;
  5070. if (initAccum && length) {
  5071. accumulator = array[++index];
  5072. }
  5073. while (++index < length) {
  5074. accumulator = iteratee(accumulator, array[index], index, array);
  5075. }
  5076. return accumulator;
  5077. }
  5078. var _arrayReduce = arrayReduce;
  5079. /**
  5080. * The base implementation of `_.propertyOf` without support for deep paths.
  5081. *
  5082. * @private
  5083. * @param {Object} object The object to query.
  5084. * @returns {Function} Returns the new accessor function.
  5085. */
  5086. function basePropertyOf(object) {
  5087. return function(key) {
  5088. return object == null ? undefined : object[key];
  5089. };
  5090. }
  5091. var _basePropertyOf = basePropertyOf;
  5092. /** Used to map Latin Unicode letters to basic Latin letters. */
  5093. var deburredLetters = {
  5094. // Latin-1 Supplement block.
  5095. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
  5096. '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
  5097. '\xc7': 'C', '\xe7': 'c',
  5098. '\xd0': 'D', '\xf0': 'd',
  5099. '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
  5100. '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
  5101. '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
  5102. '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
  5103. '\xd1': 'N', '\xf1': 'n',
  5104. '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
  5105. '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
  5106. '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
  5107. '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
  5108. '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
  5109. '\xc6': 'Ae', '\xe6': 'ae',
  5110. '\xde': 'Th', '\xfe': 'th',
  5111. '\xdf': 'ss',
  5112. // Latin Extended-A block.
  5113. '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
  5114. '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
  5115. '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
  5116. '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
  5117. '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
  5118. '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
  5119. '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
  5120. '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
  5121. '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
  5122. '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
  5123. '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
  5124. '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
  5125. '\u0134': 'J', '\u0135': 'j',
  5126. '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
  5127. '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
  5128. '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
  5129. '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
  5130. '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
  5131. '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
  5132. '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
  5133. '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
  5134. '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
  5135. '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
  5136. '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
  5137. '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
  5138. '\u0163': 't', '\u0165': 't', '\u0167': 't',
  5139. '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
  5140. '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
  5141. '\u0174': 'W', '\u0175': 'w',
  5142. '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
  5143. '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
  5144. '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
  5145. '\u0132': 'IJ', '\u0133': 'ij',
  5146. '\u0152': 'Oe', '\u0153': 'oe',
  5147. '\u0149': "'n", '\u017f': 's'
  5148. };
  5149. /**
  5150. * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
  5151. * letters to basic Latin letters.
  5152. *
  5153. * @private
  5154. * @param {string} letter The matched letter to deburr.
  5155. * @returns {string} Returns the deburred letter.
  5156. */
  5157. var deburrLetter = _basePropertyOf(deburredLetters);
  5158. var _deburrLetter = deburrLetter;
  5159. /**
  5160. * A specialized version of `_.map` for arrays without support for iteratee
  5161. * shorthands.
  5162. *
  5163. * @private
  5164. * @param {Array} [array] The array to iterate over.
  5165. * @param {Function} iteratee The function invoked per iteration.
  5166. * @returns {Array} Returns the new mapped array.
  5167. */
  5168. function arrayMap(array, iteratee) {
  5169. var index = -1,
  5170. length = array == null ? 0 : array.length,
  5171. result = Array(length);
  5172. while (++index < length) {
  5173. result[index] = iteratee(array[index], index, array);
  5174. }
  5175. return result;
  5176. }
  5177. var _arrayMap = arrayMap;
  5178. /** Used as references for various `Number` constants. */
  5179. var INFINITY$1 = 1 / 0;
  5180. /** Used to convert symbols to primitives and strings. */
  5181. var symbolProto$1 = _Symbol ? _Symbol.prototype : undefined,
  5182. symbolToString = symbolProto$1 ? symbolProto$1.toString : undefined;
  5183. /**
  5184. * The base implementation of `_.toString` which doesn't convert nullish
  5185. * values to empty strings.
  5186. *
  5187. * @private
  5188. * @param {*} value The value to process.
  5189. * @returns {string} Returns the string.
  5190. */
  5191. function baseToString(value) {
  5192. // Exit early for strings to avoid a performance hit in some environments.
  5193. if (typeof value == 'string') {
  5194. return value;
  5195. }
  5196. if (isArray_1(value)) {
  5197. // Recursively convert values (susceptible to call stack limits).
  5198. return _arrayMap(value, baseToString) + '';
  5199. }
  5200. if (isSymbol_1(value)) {
  5201. return symbolToString ? symbolToString.call(value) : '';
  5202. }
  5203. var result = (value + '');
  5204. return (result == '0' && (1 / value) == -INFINITY$1) ? '-0' : result;
  5205. }
  5206. var _baseToString = baseToString;
  5207. /**
  5208. * Converts `value` to a string. An empty string is returned for `null`
  5209. * and `undefined` values. The sign of `-0` is preserved.
  5210. *
  5211. * @static
  5212. * @memberOf _
  5213. * @since 4.0.0
  5214. * @category Lang
  5215. * @param {*} value The value to convert.
  5216. * @returns {string} Returns the converted string.
  5217. * @example
  5218. *
  5219. * _.toString(null);
  5220. * // => ''
  5221. *
  5222. * _.toString(-0);
  5223. * // => '-0'
  5224. *
  5225. * _.toString([1, 2, 3]);
  5226. * // => '1,2,3'
  5227. */
  5228. function toString(value) {
  5229. return value == null ? '' : _baseToString(value);
  5230. }
  5231. var toString_1 = toString;
  5232. /** Used to match Latin Unicode letters (excluding mathematical operators). */
  5233. var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
  5234. /** Used to compose unicode character classes. */
  5235. var rsComboMarksRange = '\\u0300-\\u036f',
  5236. reComboHalfMarksRange = '\\ufe20-\\ufe2f',
  5237. rsComboSymbolsRange = '\\u20d0-\\u20ff',
  5238. rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange;
  5239. /** Used to compose unicode capture groups. */
  5240. var rsCombo = '[' + rsComboRange + ']';
  5241. /**
  5242. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  5243. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  5244. */
  5245. var reComboMark = RegExp(rsCombo, 'g');
  5246. /**
  5247. * Deburrs `string` by converting
  5248. * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
  5249. * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
  5250. * letters to basic Latin letters and removing
  5251. * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
  5252. *
  5253. * @static
  5254. * @memberOf _
  5255. * @since 3.0.0
  5256. * @category String
  5257. * @param {string} [string=''] The string to deburr.
  5258. * @returns {string} Returns the deburred string.
  5259. * @example
  5260. *
  5261. * _.deburr('déjà vu');
  5262. * // => 'deja vu'
  5263. */
  5264. function deburr(string) {
  5265. string = toString_1(string);
  5266. return string && string.replace(reLatin, _deburrLetter).replace(reComboMark, '');
  5267. }
  5268. var deburr_1 = deburr;
  5269. /** Used to match words composed of alphanumeric characters. */
  5270. var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
  5271. /**
  5272. * Splits an ASCII `string` into an array of its words.
  5273. *
  5274. * @private
  5275. * @param {string} The string to inspect.
  5276. * @returns {Array} Returns the words of `string`.
  5277. */
  5278. function asciiWords(string) {
  5279. return string.match(reAsciiWord) || [];
  5280. }
  5281. var _asciiWords = asciiWords;
  5282. /** Used to detect strings that need a more robust regexp to match words. */
  5283. var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
  5284. /**
  5285. * Checks if `string` contains a word composed of Unicode symbols.
  5286. *
  5287. * @private
  5288. * @param {string} string The string to inspect.
  5289. * @returns {boolean} Returns `true` if a word is found, else `false`.
  5290. */
  5291. function hasUnicodeWord(string) {
  5292. return reHasUnicodeWord.test(string);
  5293. }
  5294. var _hasUnicodeWord = hasUnicodeWord;
  5295. /** Used to compose unicode character classes. */
  5296. var rsAstralRange = '\\ud800-\\udfff',
  5297. rsComboMarksRange$1 = '\\u0300-\\u036f',
  5298. reComboHalfMarksRange$1 = '\\ufe20-\\ufe2f',
  5299. rsComboSymbolsRange$1 = '\\u20d0-\\u20ff',
  5300. rsComboRange$1 = rsComboMarksRange$1 + reComboHalfMarksRange$1 + rsComboSymbolsRange$1,
  5301. rsDingbatRange = '\\u2700-\\u27bf',
  5302. rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
  5303. rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
  5304. rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
  5305. rsPunctuationRange = '\\u2000-\\u206f',
  5306. rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000',
  5307. rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
  5308. rsVarRange = '\\ufe0e\\ufe0f',
  5309. rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
  5310. /** Used to compose unicode capture groups. */
  5311. var rsApos = "['\u2019]",
  5312. rsBreak = '[' + rsBreakRange + ']',
  5313. rsCombo$1 = '[' + rsComboRange$1 + ']',
  5314. rsDigits = '\\d+',
  5315. rsDingbat = '[' + rsDingbatRange + ']',
  5316. rsLower = '[' + rsLowerRange + ']',
  5317. rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
  5318. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  5319. rsModifier = '(?:' + rsCombo$1 + '|' + rsFitz + ')',
  5320. rsNonAstral = '[^' + rsAstralRange + ']',
  5321. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  5322. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  5323. rsUpper = '[' + rsUpperRange + ']',
  5324. rsZWJ = '\\u200d';
  5325. /** Used to compose unicode regexes. */
  5326. var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
  5327. rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
  5328. rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
  5329. rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
  5330. reOptMod = rsModifier + '?',
  5331. rsOptVar = '[' + rsVarRange + ']?',
  5332. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  5333. rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
  5334. rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
  5335. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  5336. rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq;
  5337. /** Used to match complex or compound words. */
  5338. var reUnicodeWord = RegExp([
  5339. rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
  5340. rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
  5341. rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
  5342. rsUpper + '+' + rsOptContrUpper,
  5343. rsOrdUpper,
  5344. rsOrdLower,
  5345. rsDigits,
  5346. rsEmoji
  5347. ].join('|'), 'g');
  5348. /**
  5349. * Splits a Unicode `string` into an array of its words.
  5350. *
  5351. * @private
  5352. * @param {string} The string to inspect.
  5353. * @returns {Array} Returns the words of `string`.
  5354. */
  5355. function unicodeWords(string) {
  5356. return string.match(reUnicodeWord) || [];
  5357. }
  5358. var _unicodeWords = unicodeWords;
  5359. /**
  5360. * Splits `string` into an array of its words.
  5361. *
  5362. * @static
  5363. * @memberOf _
  5364. * @since 3.0.0
  5365. * @category String
  5366. * @param {string} [string=''] The string to inspect.
  5367. * @param {RegExp|string} [pattern] The pattern to match words.
  5368. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  5369. * @returns {Array} Returns the words of `string`.
  5370. * @example
  5371. *
  5372. * _.words('fred, barney, & pebbles');
  5373. * // => ['fred', 'barney', 'pebbles']
  5374. *
  5375. * _.words('fred, barney, & pebbles', /[^, ]+/g);
  5376. * // => ['fred', 'barney', '&', 'pebbles']
  5377. */
  5378. function words(string, pattern, guard) {
  5379. string = toString_1(string);
  5380. pattern = guard ? undefined : pattern;
  5381. if (pattern === undefined) {
  5382. return _hasUnicodeWord(string) ? _unicodeWords(string) : _asciiWords(string);
  5383. }
  5384. return string.match(pattern) || [];
  5385. }
  5386. var words_1 = words;
  5387. /** Used to compose unicode capture groups. */
  5388. var rsApos$1 = "['\u2019]";
  5389. /** Used to match apostrophes. */
  5390. var reApos = RegExp(rsApos$1, 'g');
  5391. /**
  5392. * Creates a function like `_.camelCase`.
  5393. *
  5394. * @private
  5395. * @param {Function} callback The function to combine each word.
  5396. * @returns {Function} Returns the new compounder function.
  5397. */
  5398. function createCompounder(callback) {
  5399. return function(string) {
  5400. return _arrayReduce(words_1(deburr_1(string).replace(reApos, '')), callback, '');
  5401. };
  5402. }
  5403. var _createCompounder = createCompounder;
  5404. /**
  5405. * Converts `string` to
  5406. * [snake case](https://en.wikipedia.org/wiki/Snake_case).
  5407. *
  5408. * @static
  5409. * @memberOf _
  5410. * @since 3.0.0
  5411. * @category String
  5412. * @param {string} [string=''] The string to convert.
  5413. * @returns {string} Returns the snake cased string.
  5414. * @example
  5415. *
  5416. * _.snakeCase('Foo Bar');
  5417. * // => 'foo_bar'
  5418. *
  5419. * _.snakeCase('fooBar');
  5420. * // => 'foo_bar'
  5421. *
  5422. * _.snakeCase('--FOO-BAR--');
  5423. * // => 'foo_bar'
  5424. */
  5425. var snakeCase = _createCompounder(function(result, word, index) {
  5426. return result + (index ? '_' : '') + word.toLowerCase();
  5427. });
  5428. var snakeCase_1 = snakeCase;
  5429. var version = '2.6.3';
  5430. function toArray(array) {
  5431. return Array.isArray(array) ? array : [array];
  5432. }
  5433. var nextTick = typeof window.Zone === 'function' ? setTimeout : function (cb) {
  5434. return Promise.resolve().then(cb);
  5435. };
  5436. var globalTaskPending = false;
  5437. /**
  5438. * Run a callback before next task executing, and the invocation is idempotent in every singular task
  5439. * That means even we called nextTask multi times in one task, only the first callback will be pushed to nextTick to be invoked.
  5440. * @param cb
  5441. */
  5442. function nextTask(cb) {
  5443. if (!globalTaskPending) {
  5444. globalTaskPending = true;
  5445. nextTick(function () {
  5446. cb();
  5447. globalTaskPending = false;
  5448. });
  5449. }
  5450. }
  5451. var fnRegexCheckCacheMap = new WeakMap();
  5452. function isConstructable(fn) {
  5453. // prototype methods might be changed while code running, so we need check it every time
  5454. var hasPrototypeMethods = fn.prototype && fn.prototype.constructor === fn && Object.getOwnPropertyNames(fn.prototype).length > 1;
  5455. if (hasPrototypeMethods) return true;
  5456. if (fnRegexCheckCacheMap.has(fn)) {
  5457. return fnRegexCheckCacheMap.get(fn);
  5458. }
  5459. /*
  5460. 1. 有 prototype 并且 prototype 上有定义一系列非 constructor 属性
  5461. 2. 函数名大写开头
  5462. 3. class 函数
  5463. 满足其一则可认定为构造函数
  5464. */
  5465. var constructable = hasPrototypeMethods;
  5466. if (!constructable) {
  5467. // fn.toString has a significant performance overhead, if hasPrototypeMethods check not passed, we will check the function string with regex
  5468. var fnString = fn.toString();
  5469. var constructableFunctionRegex = /^function\b\s[A-Z].*/;
  5470. var classRegex = /^class\b/;
  5471. constructable = constructableFunctionRegex.test(fnString) || classRegex.test(fnString);
  5472. }
  5473. fnRegexCheckCacheMap.set(fn, constructable);
  5474. return constructable;
  5475. }
  5476. /**
  5477. * in safari
  5478. * typeof document.all === 'undefined' // true
  5479. * typeof document.all === 'function' // true
  5480. * We need to discriminate safari for better performance
  5481. */
  5482. var naughtySafari = typeof document.all === 'function' && typeof document.all === 'undefined';
  5483. var callableFnCacheMap = new WeakMap();
  5484. var isCallable = function isCallable(fn) {
  5485. if (callableFnCacheMap.has(fn)) {
  5486. return true;
  5487. }
  5488. var callable = naughtySafari ? typeof fn === 'function' && typeof fn !== 'undefined' : typeof fn === 'function';
  5489. if (callable) {
  5490. callableFnCacheMap.set(fn, callable);
  5491. }
  5492. return callable;
  5493. };
  5494. var boundedMap = new WeakMap();
  5495. function isBoundedFunction(fn) {
  5496. if (boundedMap.has(fn)) {
  5497. return boundedMap.get(fn);
  5498. }
  5499. /*
  5500. indexOf is faster than startsWith
  5501. see https://jsperf.com/string-startswith/72
  5502. */
  5503. var bounded = fn.name.indexOf('bound ') === 0 && !fn.hasOwnProperty('prototype');
  5504. boundedMap.set(fn, bounded);
  5505. return bounded;
  5506. }
  5507. function getDefaultTplWrapper(name) {
  5508. return function (tpl) {
  5509. return "<div id=\"".concat(getWrapperId(name), "\" data-name=\"").concat(name, "\" data-version=\"").concat(version, "\">").concat(tpl, "</div>");
  5510. };
  5511. }
  5512. function getWrapperId(name) {
  5513. return "__qiankun_microapp_wrapper_for_".concat(snakeCase_1(name), "__");
  5514. }
  5515. var nativeGlobal = new Function('return this')();
  5516. var getGlobalAppInstanceMap = once_1(function () {
  5517. if (!nativeGlobal.hasOwnProperty('__app_instance_name_map__')) {
  5518. Object.defineProperty(nativeGlobal, '__app_instance_name_map__', {
  5519. enumerable: false,
  5520. configurable: true,
  5521. writable: true,
  5522. value: {}
  5523. });
  5524. }
  5525. return nativeGlobal.__app_instance_name_map__;
  5526. });
  5527. /**
  5528. * Get app instance name with the auto-increment approach
  5529. * @param appName
  5530. */
  5531. var genAppInstanceIdByName = function genAppInstanceIdByName(appName) {
  5532. var globalAppInstanceMap = getGlobalAppInstanceMap();
  5533. if (!(appName in globalAppInstanceMap)) {
  5534. nativeGlobal.__app_instance_name_map__[appName] = 0;
  5535. return appName;
  5536. }
  5537. globalAppInstanceMap[appName]++;
  5538. return "".concat(appName, "_").concat(globalAppInstanceMap[appName]);
  5539. };
  5540. /** 校验子应用导出的 生命周期 对象是否正确 */
  5541. function validateExportLifecycle(exports) {
  5542. var _ref = exports !== null && exports !== void 0 ? exports : {},
  5543. bootstrap = _ref.bootstrap,
  5544. mount = _ref.mount,
  5545. unmount = _ref.unmount;
  5546. return isFunction_1(bootstrap) && isFunction_1(mount) && isFunction_1(unmount);
  5547. }
  5548. var Deferred = function Deferred() {
  5549. var _this = this;
  5550. _classCallCheck(this, Deferred);
  5551. this.promise = void 0;
  5552. this.resolve = void 0;
  5553. this.reject = void 0;
  5554. this.promise = new Promise(function (resolve, reject) {
  5555. _this.resolve = resolve;
  5556. _this.reject = reject;
  5557. });
  5558. };
  5559. var supportsUserTiming$1 = typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function' && typeof performance.getEntriesByName === 'function';
  5560. function performanceGetEntriesByName(markName, type) {
  5561. var marks = null;
  5562. if (supportsUserTiming$1) {
  5563. marks = performance.getEntriesByName(markName, type);
  5564. }
  5565. return marks;
  5566. }
  5567. function performanceMark(markName) {
  5568. if (supportsUserTiming$1) {
  5569. performance.mark(markName);
  5570. }
  5571. }
  5572. function performanceMeasure(measureName, markName) {
  5573. if (supportsUserTiming$1 && performance.getEntriesByName(markName, 'mark').length) {
  5574. performance.measure(measureName, markName);
  5575. performance.clearMarks(markName);
  5576. performance.clearMeasures(measureName);
  5577. }
  5578. }
  5579. function isEnableScopedCSS(sandbox) {
  5580. if (_typeof(sandbox) !== 'object') {
  5581. return false;
  5582. }
  5583. if (sandbox.strictStyleIsolation) {
  5584. return false;
  5585. }
  5586. return !!sandbox.experimentalStyleIsolation;
  5587. }
  5588. /**
  5589. * copy from https://developer.mozilla.org/zh-CN/docs/Using_XPath
  5590. * @param el
  5591. * @param document
  5592. */
  5593. function getXPathForElement(el, document) {
  5594. // not support that if el not existed in document yet(such as it not append to document before it mounted)
  5595. if (!document.body.contains(el)) {
  5596. return undefined;
  5597. }
  5598. var xpath = '';
  5599. var pos;
  5600. var tmpEle;
  5601. var element = el;
  5602. while (element !== document.documentElement) {
  5603. pos = 0;
  5604. tmpEle = element;
  5605. while (tmpEle) {
  5606. if (tmpEle.nodeType === 1 && tmpEle.nodeName === element.nodeName) {
  5607. // If it is ELEMENT_NODE of the same name
  5608. pos += 1;
  5609. }
  5610. tmpEle = tmpEle.previousSibling;
  5611. }
  5612. xpath = "*[name()='".concat(element.nodeName, "'][").concat(pos, "]/").concat(xpath);
  5613. element = element.parentNode;
  5614. }
  5615. xpath = "/*[name()='".concat(document.documentElement.nodeName, "']/").concat(xpath);
  5616. xpath = xpath.replace(/\/$/, '');
  5617. return xpath;
  5618. }
  5619. function getContainer(container) {
  5620. return typeof container === 'string' ? document.querySelector(container) : container;
  5621. }
  5622. function getContainerXPath(container) {
  5623. if (container) {
  5624. var containerElement = getContainer(container);
  5625. if (containerElement) {
  5626. return getXPathForElement(containerElement, document);
  5627. }
  5628. }
  5629. return undefined;
  5630. }
  5631. var currentRunningApp = null;
  5632. /**
  5633. * get the app that running tasks at current tick
  5634. */
  5635. function getCurrentRunningApp() {
  5636. return currentRunningApp;
  5637. }
  5638. function setCurrentRunningApp(appInstance) {
  5639. // set currentRunningApp and it's proxySandbox to global window, as its only use case is for document.createElement from now on, which hijacked by a global way
  5640. currentRunningApp = appInstance;
  5641. }
  5642. var functionBoundedValueMap = new WeakMap();
  5643. function getTargetValue(target, _value) {
  5644. /*
  5645. 仅绑定 isCallable && !isBoundedFunction && !isConstructable 的函数对象,如 window.console、window.atob 这类,不然微应用中调用时会抛出 Illegal invocation 异常
  5646. 目前没有完美的检测方式,这里通过 prototype 中是否还有可枚举的拓展方法的方式来判断
  5647. @warning 这里不要随意替换成别的判断方式,因为可能触发一些 edge case(比如在 lodash.isFunction 在 iframe 上下文中可能由于调用了 top window 对象触发的安全异常)
  5648. */
  5649. if (isCallable(_value) && !isBoundedFunction(_value) && !isConstructable(_value)) {
  5650. var cachedBoundFunction = functionBoundedValueMap.get(_value);
  5651. if (cachedBoundFunction) {
  5652. return cachedBoundFunction;
  5653. }
  5654. var boundValue = Function.prototype.bind.call(_value, target); // some callable function has custom fields, we need to copy the enumerable props to boundValue. such as moment function.
  5655. // use for..in rather than Object.keys.forEach for performance reason
  5656. // eslint-disable-next-line guard-for-in,no-restricted-syntax
  5657. for (var key in _value) {
  5658. boundValue[key] = _value[key];
  5659. } // copy prototype if bound function not have but target one have
  5660. // as prototype is non-enumerable mostly, we need to copy it from target function manually
  5661. if (_value.hasOwnProperty('prototype') && !boundValue.hasOwnProperty('prototype')) {
  5662. // we should not use assignment operator to set boundValue prototype like `boundValue.prototype = value.prototype`
  5663. // as the assignment will also look up prototype chain while it hasn't own prototype property,
  5664. // when the lookup succeed, the assignment will throw an TypeError like `Cannot assign to read only property 'prototype' of function` if its descriptor configured with writable false or just have a getter accessor
  5665. // see https://github.com/umijs/qiankun/issues/1121
  5666. Object.defineProperty(boundValue, 'prototype', {
  5667. value: _value.prototype,
  5668. enumerable: false,
  5669. writable: true
  5670. });
  5671. } // Some util, like `function isNative() { return typeof Ctor === 'function' && /native code/.test(Ctor.toString()) }` relies on the original `toString()` result
  5672. // but bound functions will always return "function() {[native code]}" for `toString`, which is misleading
  5673. if (typeof _value.toString === 'function') {
  5674. var valueHasInstanceToString = _value.hasOwnProperty('toString') && !boundValue.hasOwnProperty('toString');
  5675. var boundValueHasPrototypeToString = boundValue.toString === Function.prototype.toString;
  5676. if (valueHasInstanceToString || boundValueHasPrototypeToString) {
  5677. var originToStringDescriptor = Object.getOwnPropertyDescriptor(valueHasInstanceToString ? _value : Function.prototype, 'toString');
  5678. Object.defineProperty(boundValue, 'toString', _objectSpread(_objectSpread({}, originToStringDescriptor), (originToStringDescriptor === null || originToStringDescriptor === void 0 ? void 0 : originToStringDescriptor.get) ? null : {
  5679. value: function value() {
  5680. return _value.toString();
  5681. }
  5682. }));
  5683. }
  5684. }
  5685. functionBoundedValueMap.set(_value, boundValue);
  5686. return boundValue;
  5687. }
  5688. return _value;
  5689. }
  5690. function isPropConfigurable(target, prop) {
  5691. var descriptor = Object.getOwnPropertyDescriptor(target, prop);
  5692. return descriptor ? descriptor.configurable : true;
  5693. }
  5694. /**
  5695. * 基于 Proxy 实现的沙箱
  5696. * TODO: 为了兼容性 singular 模式下依旧使用该沙箱,等新沙箱稳定之后再切换
  5697. */
  5698. var LegacySandbox = /*#__PURE__*/function () {
  5699. function LegacySandbox(name) {
  5700. var _this = this;
  5701. var globalContext = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window;
  5702. _classCallCheck(this, LegacySandbox);
  5703. this.addedPropsMapInSandbox = new Map();
  5704. this.modifiedPropsOriginalValueMapInSandbox = new Map();
  5705. this.currentUpdatedPropsValueMap = new Map();
  5706. this.name = void 0;
  5707. this.proxy = void 0;
  5708. this.globalContext = void 0;
  5709. this.type = void 0;
  5710. this.sandboxRunning = true;
  5711. this.latestSetProp = null;
  5712. this.name = name;
  5713. this.globalContext = globalContext;
  5714. this.type = exports.SandBoxType.LegacyProxy;
  5715. var addedPropsMapInSandbox = this.addedPropsMapInSandbox,
  5716. modifiedPropsOriginalValueMapInSandbox = this.modifiedPropsOriginalValueMapInSandbox,
  5717. currentUpdatedPropsValueMap = this.currentUpdatedPropsValueMap;
  5718. var rawWindow = globalContext;
  5719. var fakeWindow = Object.create(null);
  5720. var setTrap = function setTrap(p, value, originalValue) {
  5721. var sync2Window = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
  5722. if (_this.sandboxRunning) {
  5723. if (!rawWindow.hasOwnProperty(p)) {
  5724. addedPropsMapInSandbox.set(p, value);
  5725. } else if (!modifiedPropsOriginalValueMapInSandbox.has(p)) {
  5726. // 如果当前 window 对象存在该属性,且 record map 中未记录过,则记录该属性初始值
  5727. modifiedPropsOriginalValueMapInSandbox.set(p, originalValue);
  5728. }
  5729. currentUpdatedPropsValueMap.set(p, value);
  5730. if (sync2Window) {
  5731. // 必须重新设置 window 对象保证下次 get 时能拿到已更新的数据
  5732. rawWindow[p] = value;
  5733. }
  5734. _this.latestSetProp = p;
  5735. return true;
  5736. }
  5737. {
  5738. console.warn("[qiankun] Set window.".concat(p.toString(), " while sandbox destroyed or inactive in ").concat(name, "!"));
  5739. } // 在 strict-mode 下,Proxy 的 handler.set 返回 false 会抛出 TypeError,在沙箱卸载的情况下应该忽略错误
  5740. return true;
  5741. };
  5742. var proxy = new Proxy(fakeWindow, {
  5743. set: function set(_, p, value) {
  5744. var originalValue = rawWindow[p];
  5745. return setTrap(p, value, originalValue, true);
  5746. },
  5747. get: function get(_, p) {
  5748. // avoid who using window.window or window.self to escape the sandbox environment to touch the really window
  5749. // or use window.top to check if an iframe context
  5750. // see https://github.com/eligrey/FileSaver.js/blob/master/src/FileSaver.js#L13
  5751. if (p === 'top' || p === 'parent' || p === 'window' || p === 'self') {
  5752. return proxy;
  5753. }
  5754. var value = rawWindow[p];
  5755. return getTargetValue(rawWindow, value);
  5756. },
  5757. // trap in operator
  5758. // see https://github.com/styled-components/styled-components/blob/master/packages/styled-components/src/constants.js#L12
  5759. has: function has(_, p) {
  5760. return p in rawWindow;
  5761. },
  5762. getOwnPropertyDescriptor: function getOwnPropertyDescriptor(_, p) {
  5763. var descriptor = Object.getOwnPropertyDescriptor(rawWindow, p); // A property cannot be reported as non-configurable, if it does not exists as an own property of the target object
  5764. if (descriptor && !descriptor.configurable) {
  5765. descriptor.configurable = true;
  5766. }
  5767. return descriptor;
  5768. },
  5769. defineProperty: function defineProperty(_, p, attributes) {
  5770. var originalValue = rawWindow[p];
  5771. var done = Reflect.defineProperty(rawWindow, p, attributes);
  5772. var value = rawWindow[p];
  5773. setTrap(p, value, originalValue, false);
  5774. return done;
  5775. }
  5776. });
  5777. this.proxy = proxy;
  5778. }
  5779. _createClass(LegacySandbox, [{
  5780. key: "setWindowProp",
  5781. value:
  5782. /** 沙箱期间新增的全局变量 */
  5783. /** 沙箱期间更新的全局变量 */
  5784. /** 持续记录更新的(新增和修改的)全局变量的 map,用于在任意时刻做 snapshot */
  5785. function setWindowProp(prop, value, toDelete) {
  5786. if (value === undefined && toDelete) {
  5787. // eslint-disable-next-line no-param-reassign
  5788. delete this.globalContext[prop];
  5789. } else if (isPropConfigurable(this.globalContext, prop) && _typeof(prop) !== 'symbol') {
  5790. Object.defineProperty(this.globalContext, prop, {
  5791. writable: true,
  5792. configurable: true
  5793. }); // eslint-disable-next-line no-param-reassign
  5794. this.globalContext[prop] = value;
  5795. }
  5796. }
  5797. }, {
  5798. key: "active",
  5799. value: function active() {
  5800. var _this2 = this;
  5801. if (!this.sandboxRunning) {
  5802. this.currentUpdatedPropsValueMap.forEach(function (v, p) {
  5803. return _this2.setWindowProp(p, v);
  5804. });
  5805. }
  5806. this.sandboxRunning = true;
  5807. }
  5808. }, {
  5809. key: "inactive",
  5810. value: function inactive() {
  5811. var _this3 = this;
  5812. {
  5813. console.info("[qiankun:sandbox] ".concat(this.name, " modified global properties restore..."), [].concat(_toConsumableArray(this.addedPropsMapInSandbox.keys()), _toConsumableArray(this.modifiedPropsOriginalValueMapInSandbox.keys())));
  5814. } // renderSandboxSnapshot = snapshot(currentUpdatedPropsValueMapForSnapshot);
  5815. // restore global props to initial snapshot
  5816. this.modifiedPropsOriginalValueMapInSandbox.forEach(function (v, p) {
  5817. return _this3.setWindowProp(p, v);
  5818. });
  5819. this.addedPropsMapInSandbox.forEach(function (_, p) {
  5820. return _this3.setWindowProp(p, undefined, true);
  5821. });
  5822. this.sandboxRunning = false;
  5823. }
  5824. }]);
  5825. return LegacySandbox;
  5826. }();
  5827. /**
  5828. * @author Saviio
  5829. * @since 2020-4-19
  5830. */
  5831. // https://developer.mozilla.org/en-US/docs/Web/API/CSSRule
  5832. var RuleType;
  5833. (function (RuleType) {
  5834. // type: rule will be rewrote
  5835. RuleType[RuleType["STYLE"] = 1] = "STYLE";
  5836. RuleType[RuleType["MEDIA"] = 4] = "MEDIA";
  5837. RuleType[RuleType["SUPPORTS"] = 12] = "SUPPORTS"; // type: value will be kept
  5838. RuleType[RuleType["IMPORT"] = 3] = "IMPORT";
  5839. RuleType[RuleType["FONT_FACE"] = 5] = "FONT_FACE";
  5840. RuleType[RuleType["PAGE"] = 6] = "PAGE";
  5841. RuleType[RuleType["KEYFRAMES"] = 7] = "KEYFRAMES";
  5842. RuleType[RuleType["KEYFRAME"] = 8] = "KEYFRAME";
  5843. })(RuleType || (RuleType = {}));
  5844. var arrayify = function arrayify(list) {
  5845. return [].slice.call(list, 0);
  5846. };
  5847. var rawDocumentBodyAppend = HTMLBodyElement.prototype.appendChild;
  5848. var ScopedCSS = /*#__PURE__*/function () {
  5849. function ScopedCSS() {
  5850. _classCallCheck(this, ScopedCSS);
  5851. this.sheet = void 0;
  5852. this.swapNode = void 0;
  5853. var styleNode = document.createElement('style');
  5854. rawDocumentBodyAppend.call(document.body, styleNode);
  5855. this.swapNode = styleNode;
  5856. this.sheet = styleNode.sheet;
  5857. this.sheet.disabled = true;
  5858. }
  5859. _createClass(ScopedCSS, [{
  5860. key: "process",
  5861. value: function process(styleNode) {
  5862. var _this = this;
  5863. var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  5864. if (styleNode.textContent !== '') {
  5865. var _sheet$cssRules;
  5866. var textNode = document.createTextNode(styleNode.textContent || '');
  5867. this.swapNode.appendChild(textNode);
  5868. var sheet = this.swapNode.sheet; // type is missing
  5869. var rules = arrayify((_sheet$cssRules = sheet === null || sheet === void 0 ? void 0 : sheet.cssRules) !== null && _sheet$cssRules !== void 0 ? _sheet$cssRules : []);
  5870. var css = this.rewrite(rules, prefix); // eslint-disable-next-line no-param-reassign
  5871. styleNode.textContent = css; // cleanup
  5872. this.swapNode.removeChild(textNode);
  5873. return;
  5874. }
  5875. var mutator = new MutationObserver(function (mutations) {
  5876. for (var i = 0; i < mutations.length; i += 1) {
  5877. var mutation = mutations[i];
  5878. if (ScopedCSS.ModifiedTag in styleNode) {
  5879. return;
  5880. }
  5881. if (mutation.type === 'childList') {
  5882. var _sheet$cssRules2;
  5883. var _sheet = styleNode.sheet;
  5884. var _rules = arrayify((_sheet$cssRules2 = _sheet === null || _sheet === void 0 ? void 0 : _sheet.cssRules) !== null && _sheet$cssRules2 !== void 0 ? _sheet$cssRules2 : []);
  5885. var _css = _this.rewrite(_rules, prefix); // eslint-disable-next-line no-param-reassign
  5886. styleNode.textContent = _css; // eslint-disable-next-line no-param-reassign
  5887. styleNode[ScopedCSS.ModifiedTag] = true;
  5888. }
  5889. }
  5890. }); // since observer will be deleted when node be removed
  5891. // we dont need create a cleanup function manually
  5892. // see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver/disconnect
  5893. mutator.observe(styleNode, {
  5894. childList: true
  5895. });
  5896. }
  5897. }, {
  5898. key: "rewrite",
  5899. value: function rewrite(rules) {
  5900. var _this2 = this;
  5901. var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  5902. var css = '';
  5903. rules.forEach(function (rule) {
  5904. switch (rule.type) {
  5905. case RuleType.STYLE:
  5906. css += _this2.ruleStyle(rule, prefix);
  5907. break;
  5908. case RuleType.MEDIA:
  5909. css += _this2.ruleMedia(rule, prefix);
  5910. break;
  5911. case RuleType.SUPPORTS:
  5912. css += _this2.ruleSupport(rule, prefix);
  5913. break;
  5914. default:
  5915. css += "".concat(rule.cssText);
  5916. break;
  5917. }
  5918. });
  5919. return css;
  5920. } // handle case:
  5921. // .app-main {}
  5922. // html, body {}
  5923. // eslint-disable-next-line class-methods-use-this
  5924. }, {
  5925. key: "ruleStyle",
  5926. value: function ruleStyle(rule, prefix) {
  5927. var rootSelectorRE = /((?:[^\w\-.#]|^)(body|html|:root))/gm;
  5928. var rootCombinationRE = /(html[^\w{[]+)/gm;
  5929. var selector = rule.selectorText.trim();
  5930. var cssText = rule.cssText; // handle html { ... }
  5931. // handle body { ... }
  5932. // handle :root { ... }
  5933. if (selector === 'html' || selector === 'body' || selector === ':root') {
  5934. return cssText.replace(rootSelectorRE, prefix);
  5935. } // handle html body { ... }
  5936. // handle html > body { ... }
  5937. if (rootCombinationRE.test(rule.selectorText)) {
  5938. var siblingSelectorRE = /(html[^\w{]+)(\+|~)/gm; // since html + body is a non-standard rule for html
  5939. // transformer will ignore it
  5940. if (!siblingSelectorRE.test(rule.selectorText)) {
  5941. cssText = cssText.replace(rootCombinationRE, '');
  5942. }
  5943. } // handle grouping selector, a,span,p,div { ... }
  5944. cssText = cssText.replace(/^[\s\S]+{/, function (selectors) {
  5945. return selectors.replace(/(^|,\n?)([^,]+)/g, function (item, p, s) {
  5946. // handle div,body,span { ... }
  5947. if (rootSelectorRE.test(item)) {
  5948. return item.replace(rootSelectorRE, function (m) {
  5949. // do not discard valid previous character, such as body,html or *:not(:root)
  5950. var whitePrevChars = [',', '('];
  5951. if (m && whitePrevChars.includes(m[0])) {
  5952. return "".concat(m[0]).concat(prefix);
  5953. } // replace root selector with prefix
  5954. return prefix;
  5955. });
  5956. }
  5957. return "".concat(p).concat(prefix, " ").concat(s.replace(/^ */, ''));
  5958. });
  5959. });
  5960. return cssText;
  5961. } // handle case:
  5962. // @media screen and (max-width: 300px) {}
  5963. }, {
  5964. key: "ruleMedia",
  5965. value: function ruleMedia(rule, prefix) {
  5966. var css = this.rewrite(arrayify(rule.cssRules), prefix);
  5967. return "@media ".concat(rule.conditionText, " {").concat(css, "}");
  5968. } // handle case:
  5969. // @supports (display: grid) {}
  5970. }, {
  5971. key: "ruleSupport",
  5972. value: function ruleSupport(rule, prefix) {
  5973. var css = this.rewrite(arrayify(rule.cssRules), prefix);
  5974. return "@supports ".concat(rule.conditionText, " {").concat(css, "}");
  5975. }
  5976. }]);
  5977. return ScopedCSS;
  5978. }();
  5979. ScopedCSS.ModifiedTag = 'Symbol(style-modified-qiankun)';
  5980. var processor;
  5981. var QiankunCSSRewriteAttr = 'data-qiankun';
  5982. var process = function process(appWrapper, stylesheetElement, appName) {
  5983. // lazy singleton pattern
  5984. if (!processor) {
  5985. processor = new ScopedCSS();
  5986. }
  5987. if (stylesheetElement.tagName === 'LINK') {
  5988. console.warn('Feature: sandbox.experimentalStyleIsolation is not support for link element yet.');
  5989. }
  5990. var mountDOM = appWrapper;
  5991. if (!mountDOM) {
  5992. return;
  5993. }
  5994. var tag = (mountDOM.tagName || '').toLowerCase();
  5995. if (tag && stylesheetElement.tagName === 'STYLE') {
  5996. var prefix = "".concat(tag, "[").concat(QiankunCSSRewriteAttr, "=\"").concat(appName, "\"]");
  5997. processor.process(stylesheetElement, prefix);
  5998. }
  5999. };
  6000. var rawHeadAppendChild = HTMLHeadElement.prototype.appendChild;
  6001. var rawHeadRemoveChild = HTMLHeadElement.prototype.removeChild;
  6002. var rawBodyAppendChild = HTMLBodyElement.prototype.appendChild;
  6003. var rawBodyRemoveChild = HTMLBodyElement.prototype.removeChild;
  6004. var rawHeadInsertBefore = HTMLHeadElement.prototype.insertBefore;
  6005. var rawRemoveChild = HTMLElement.prototype.removeChild;
  6006. var SCRIPT_TAG_NAME = 'SCRIPT';
  6007. var LINK_TAG_NAME = 'LINK';
  6008. var STYLE_TAG_NAME = 'STYLE';
  6009. function isHijackingTag(tagName) {
  6010. return (tagName === null || tagName === void 0 ? void 0 : tagName.toUpperCase()) === LINK_TAG_NAME || (tagName === null || tagName === void 0 ? void 0 : tagName.toUpperCase()) === STYLE_TAG_NAME || (tagName === null || tagName === void 0 ? void 0 : tagName.toUpperCase()) === SCRIPT_TAG_NAME;
  6011. }
  6012. /**
  6013. * Check if a style element is a styled-component liked.
  6014. * A styled-components liked element is which not have textContext but keep the rules in its styleSheet.cssRules.
  6015. * Such as the style element generated by styled-components and emotion.
  6016. * @param element
  6017. */
  6018. function isStyledComponentsLike(element) {
  6019. var _element$sheet, _getStyledElementCSSR;
  6020. return !element.textContent && (((_element$sheet = element.sheet) === null || _element$sheet === void 0 ? void 0 : _element$sheet.cssRules.length) || ((_getStyledElementCSSR = getStyledElementCSSRules(element)) === null || _getStyledElementCSSR === void 0 ? void 0 : _getStyledElementCSSR.length));
  6021. }
  6022. function patchCustomEvent(e, elementGetter) {
  6023. Object.defineProperties(e, {
  6024. srcElement: {
  6025. get: elementGetter
  6026. },
  6027. target: {
  6028. get: elementGetter
  6029. }
  6030. });
  6031. return e;
  6032. }
  6033. function manualInvokeElementOnLoad(element) {
  6034. // we need to invoke the onload event manually to notify the event listener that the script was completed
  6035. // here are the two typical ways of dynamic script loading
  6036. // 1. element.onload callback way, which webpack and loadjs used, see https://github.com/muicss/loadjs/blob/master/src/loadjs.js#L138
  6037. // 2. addEventListener way, which toast-loader used, see https://github.com/pyrsmk/toast/blob/master/src/Toast.ts#L64
  6038. var loadEvent = new CustomEvent('load');
  6039. var patchedEvent = patchCustomEvent(loadEvent, function () {
  6040. return element;
  6041. });
  6042. if (isFunction_1(element.onload)) {
  6043. element.onload(patchedEvent);
  6044. } else {
  6045. element.dispatchEvent(patchedEvent);
  6046. }
  6047. }
  6048. function manualInvokeElementOnError(element) {
  6049. var errorEvent = new CustomEvent('error');
  6050. var patchedEvent = patchCustomEvent(errorEvent, function () {
  6051. return element;
  6052. });
  6053. if (isFunction_1(element.onerror)) {
  6054. element.onerror(patchedEvent);
  6055. } else {
  6056. element.dispatchEvent(patchedEvent);
  6057. }
  6058. }
  6059. function convertLinkAsStyle(element, postProcess) {
  6060. var fetchFn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : fetch;
  6061. var styleElement = document.createElement('style');
  6062. var href = element.href; // add source link element href
  6063. styleElement.dataset.qiankunHref = href;
  6064. fetchFn(href).then(function (res) {
  6065. return res.text();
  6066. }).then(function (styleContext) {
  6067. styleElement.appendChild(document.createTextNode(styleContext));
  6068. postProcess(styleElement);
  6069. manualInvokeElementOnLoad(element);
  6070. }).catch(function () {
  6071. return manualInvokeElementOnError(element);
  6072. });
  6073. return styleElement;
  6074. }
  6075. var styledComponentCSSRulesMap = new WeakMap();
  6076. var dynamicScriptAttachedCommentMap = new WeakMap();
  6077. var dynamicLinkAttachedInlineStyleMap = new WeakMap();
  6078. function recordStyledComponentsCSSRules(styleElements) {
  6079. styleElements.forEach(function (styleElement) {
  6080. /*
  6081. With a styled-components generated style element, we need to record its cssRules for restore next re-mounting time.
  6082. We're doing this because the sheet of style element is going to be cleaned automatically by browser after the style element dom removed from document.
  6083. see https://www.w3.org/TR/cssom-1/#associated-css-style-sheet
  6084. */
  6085. if (styleElement instanceof HTMLStyleElement && isStyledComponentsLike(styleElement)) {
  6086. if (styleElement.sheet) {
  6087. // record the original css rules of the style element for restore
  6088. styledComponentCSSRulesMap.set(styleElement, styleElement.sheet.cssRules);
  6089. }
  6090. }
  6091. });
  6092. }
  6093. function getStyledElementCSSRules(styledElement) {
  6094. return styledComponentCSSRulesMap.get(styledElement);
  6095. }
  6096. function getOverwrittenAppendChildOrInsertBefore(opts) {
  6097. return function appendChildOrInsertBefore(newChild) {
  6098. var refChild = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  6099. var element = newChild;
  6100. var rawDOMAppendOrInsertBefore = opts.rawDOMAppendOrInsertBefore,
  6101. isInvokedByMicroApp = opts.isInvokedByMicroApp,
  6102. containerConfigGetter = opts.containerConfigGetter;
  6103. if (!isHijackingTag(element.tagName) || !isInvokedByMicroApp(element)) {
  6104. return rawDOMAppendOrInsertBefore.call(this, element, refChild);
  6105. }
  6106. if (element.tagName) {
  6107. var containerConfig = containerConfigGetter(element);
  6108. var appName = containerConfig.appName,
  6109. appWrapperGetter = containerConfig.appWrapperGetter,
  6110. proxy = containerConfig.proxy,
  6111. strictGlobal = containerConfig.strictGlobal,
  6112. dynamicStyleSheetElements = containerConfig.dynamicStyleSheetElements,
  6113. scopedCSS = containerConfig.scopedCSS,
  6114. excludeAssetFilter = containerConfig.excludeAssetFilter;
  6115. switch (element.tagName) {
  6116. case LINK_TAG_NAME:
  6117. case STYLE_TAG_NAME:
  6118. {
  6119. var stylesheetElement = newChild;
  6120. var _stylesheetElement = stylesheetElement,
  6121. href = _stylesheetElement.href;
  6122. if (excludeAssetFilter && href && excludeAssetFilter(href)) {
  6123. return rawDOMAppendOrInsertBefore.call(this, element, refChild);
  6124. }
  6125. var mountDOM = appWrapperGetter();
  6126. if (scopedCSS) {
  6127. var _element$tagName;
  6128. // exclude link elements like <link rel="icon" href="favicon.ico">
  6129. var linkElementUsingStylesheet = ((_element$tagName = element.tagName) === null || _element$tagName === void 0 ? void 0 : _element$tagName.toUpperCase()) === LINK_TAG_NAME && element.rel === 'stylesheet' && element.href;
  6130. if (linkElementUsingStylesheet) {
  6131. var _frameworkConfigurati;
  6132. var _fetch = typeof frameworkConfiguration.fetch === 'function' ? frameworkConfiguration.fetch : (_frameworkConfigurati = frameworkConfiguration.fetch) === null || _frameworkConfigurati === void 0 ? void 0 : _frameworkConfigurati.fn;
  6133. stylesheetElement = convertLinkAsStyle(element, function (styleElement) {
  6134. return process(mountDOM, styleElement, appName);
  6135. }, _fetch);
  6136. dynamicLinkAttachedInlineStyleMap.set(element, stylesheetElement);
  6137. } else {
  6138. process(mountDOM, stylesheetElement, appName);
  6139. }
  6140. } // eslint-disable-next-line no-shadow
  6141. dynamicStyleSheetElements.push(stylesheetElement);
  6142. var referenceNode = mountDOM.contains(refChild) ? refChild : null;
  6143. return rawDOMAppendOrInsertBefore.call(mountDOM, stylesheetElement, referenceNode);
  6144. }
  6145. case SCRIPT_TAG_NAME:
  6146. {
  6147. var _element = element,
  6148. src = _element.src,
  6149. text = _element.text; // some script like jsonp maybe not support cors which should't use execScripts
  6150. if (excludeAssetFilter && src && excludeAssetFilter(src)) {
  6151. return rawDOMAppendOrInsertBefore.call(this, element, refChild);
  6152. }
  6153. var _mountDOM = appWrapperGetter();
  6154. var _fetch2 = frameworkConfiguration.fetch;
  6155. var _referenceNode = _mountDOM.contains(refChild) ? refChild : null;
  6156. if (src) {
  6157. _execScripts(null, [src], proxy, {
  6158. fetch: _fetch2,
  6159. strictGlobal: strictGlobal,
  6160. beforeExec: function beforeExec() {
  6161. var isCurrentScriptConfigurable = function isCurrentScriptConfigurable() {
  6162. var descriptor = Object.getOwnPropertyDescriptor(document, 'currentScript');
  6163. return !descriptor || descriptor.configurable;
  6164. };
  6165. if (isCurrentScriptConfigurable()) {
  6166. Object.defineProperty(document, 'currentScript', {
  6167. get: function get() {
  6168. return element;
  6169. },
  6170. configurable: true
  6171. });
  6172. }
  6173. },
  6174. success: function success() {
  6175. manualInvokeElementOnLoad(element);
  6176. element = null;
  6177. },
  6178. error: function error() {
  6179. manualInvokeElementOnError(element);
  6180. element = null;
  6181. }
  6182. });
  6183. var dynamicScriptCommentElement = document.createComment("dynamic script ".concat(src, " replaced by qiankun"));
  6184. dynamicScriptAttachedCommentMap.set(element, dynamicScriptCommentElement);
  6185. return rawDOMAppendOrInsertBefore.call(_mountDOM, dynamicScriptCommentElement, _referenceNode);
  6186. } // inline script never trigger the onload and onerror event
  6187. _execScripts(null, ["<script>".concat(text, "</script>")], proxy, {
  6188. strictGlobal: strictGlobal
  6189. });
  6190. var dynamicInlineScriptCommentElement = document.createComment('dynamic inline script replaced by qiankun');
  6191. dynamicScriptAttachedCommentMap.set(element, dynamicInlineScriptCommentElement);
  6192. return rawDOMAppendOrInsertBefore.call(_mountDOM, dynamicInlineScriptCommentElement, _referenceNode);
  6193. }
  6194. }
  6195. }
  6196. return rawDOMAppendOrInsertBefore.call(this, element, refChild);
  6197. };
  6198. }
  6199. function getNewRemoveChild(headOrBodyRemoveChild, appWrapperGetterGetter) {
  6200. return function removeChild(child) {
  6201. var tagName = child.tagName;
  6202. if (!isHijackingTag(tagName)) return headOrBodyRemoveChild.call(this, child);
  6203. try {
  6204. var attachedElement;
  6205. switch (tagName) {
  6206. case LINK_TAG_NAME:
  6207. {
  6208. attachedElement = dynamicLinkAttachedInlineStyleMap.get(child) || child;
  6209. break;
  6210. }
  6211. case SCRIPT_TAG_NAME:
  6212. {
  6213. attachedElement = dynamicScriptAttachedCommentMap.get(child) || child;
  6214. break;
  6215. }
  6216. default:
  6217. {
  6218. attachedElement = child;
  6219. }
  6220. } // container may had been removed while app unmounting if the removeChild action was async
  6221. var appWrapperGetter = appWrapperGetterGetter(child);
  6222. var container = appWrapperGetter();
  6223. if (container.contains(attachedElement)) {
  6224. return rawRemoveChild.call(container, attachedElement);
  6225. }
  6226. } catch (e) {
  6227. console.warn(e);
  6228. }
  6229. return headOrBodyRemoveChild.call(this, child);
  6230. };
  6231. }
  6232. function patchHTMLDynamicAppendPrototypeFunctions(isInvokedByMicroApp, containerConfigGetter) {
  6233. // Just overwrite it while it have not been overwrite
  6234. if (HTMLHeadElement.prototype.appendChild === rawHeadAppendChild && HTMLBodyElement.prototype.appendChild === rawBodyAppendChild && HTMLHeadElement.prototype.insertBefore === rawHeadInsertBefore) {
  6235. HTMLHeadElement.prototype.appendChild = getOverwrittenAppendChildOrInsertBefore({
  6236. rawDOMAppendOrInsertBefore: rawHeadAppendChild,
  6237. containerConfigGetter: containerConfigGetter,
  6238. isInvokedByMicroApp: isInvokedByMicroApp
  6239. });
  6240. HTMLBodyElement.prototype.appendChild = getOverwrittenAppendChildOrInsertBefore({
  6241. rawDOMAppendOrInsertBefore: rawBodyAppendChild,
  6242. containerConfigGetter: containerConfigGetter,
  6243. isInvokedByMicroApp: isInvokedByMicroApp
  6244. });
  6245. HTMLHeadElement.prototype.insertBefore = getOverwrittenAppendChildOrInsertBefore({
  6246. rawDOMAppendOrInsertBefore: rawHeadInsertBefore,
  6247. containerConfigGetter: containerConfigGetter,
  6248. isInvokedByMicroApp: isInvokedByMicroApp
  6249. });
  6250. } // Just overwrite it while it have not been overwrite
  6251. if (HTMLHeadElement.prototype.removeChild === rawHeadRemoveChild && HTMLBodyElement.prototype.removeChild === rawBodyRemoveChild) {
  6252. HTMLHeadElement.prototype.removeChild = getNewRemoveChild(rawHeadRemoveChild, function (element) {
  6253. return containerConfigGetter(element).appWrapperGetter;
  6254. });
  6255. HTMLBodyElement.prototype.removeChild = getNewRemoveChild(rawBodyRemoveChild, function (element) {
  6256. return containerConfigGetter(element).appWrapperGetter;
  6257. });
  6258. }
  6259. return function unpatch() {
  6260. HTMLHeadElement.prototype.appendChild = rawHeadAppendChild;
  6261. HTMLHeadElement.prototype.removeChild = rawHeadRemoveChild;
  6262. HTMLBodyElement.prototype.appendChild = rawBodyAppendChild;
  6263. HTMLBodyElement.prototype.removeChild = rawBodyRemoveChild;
  6264. HTMLHeadElement.prototype.insertBefore = rawHeadInsertBefore;
  6265. };
  6266. }
  6267. function rebuildCSSRules(styleSheetElements, reAppendElement) {
  6268. styleSheetElements.forEach(function (stylesheetElement) {
  6269. // re-append the dynamic stylesheet to sub-app container
  6270. var appendSuccess = reAppendElement(stylesheetElement);
  6271. if (appendSuccess) {
  6272. /*
  6273. get the stored css rules from styled-components generated element, and the re-insert rules for them.
  6274. note that we must do this after style element had been added to document, which stylesheet would be associated to the document automatically.
  6275. check the spec https://www.w3.org/TR/cssom-1/#associated-css-style-sheet
  6276. */
  6277. if (stylesheetElement instanceof HTMLStyleElement && isStyledComponentsLike(stylesheetElement)) {
  6278. var cssRules = getStyledElementCSSRules(stylesheetElement);
  6279. if (cssRules) {
  6280. // eslint-disable-next-line no-plusplus
  6281. for (var i = 0; i < cssRules.length; i++) {
  6282. var cssRule = cssRules[i];
  6283. var cssStyleSheetElement = stylesheetElement.sheet;
  6284. cssStyleSheetElement.insertRule(cssRule.cssText, cssStyleSheetElement.cssRules.length);
  6285. }
  6286. }
  6287. }
  6288. }
  6289. });
  6290. }
  6291. /**
  6292. * @author Kuitos
  6293. * @since 2020-10-13
  6294. */
  6295. var bootstrappingPatchCount = 0;
  6296. var mountingPatchCount = 0;
  6297. /**
  6298. * Just hijack dynamic head append, that could avoid accidentally hijacking the insertion of elements except in head.
  6299. * Such a case: ReactDOM.createPortal(<style>.test{color:blue}</style>, container),
  6300. * this could made we append the style element into app wrapper but it will cause an error while the react portal unmounting, as ReactDOM could not find the style in body children list.
  6301. * @param appName
  6302. * @param appWrapperGetter
  6303. * @param proxy
  6304. * @param mounting
  6305. * @param scopedCSS
  6306. * @param excludeAssetFilter
  6307. */
  6308. function patchLooseSandbox(appName, appWrapperGetter, proxy) {
  6309. var mounting = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
  6310. var scopedCSS = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  6311. var excludeAssetFilter = arguments.length > 5 ? arguments[5] : undefined;
  6312. var dynamicStyleSheetElements = [];
  6313. var unpatchDynamicAppendPrototypeFunctions = patchHTMLDynamicAppendPrototypeFunctions(
  6314. /*
  6315. check if the currently specified application is active
  6316. While we switch page from qiankun app to a normal react routing page, the normal one may load stylesheet dynamically while page rendering,
  6317. but the url change listener must to wait until the current call stack is flushed.
  6318. This scenario may cause we record the stylesheet from react routing page dynamic injection,
  6319. and remove them after the url change triggered and qiankun app is unmouting
  6320. see https://github.com/ReactTraining/history/blob/master/modules/createHashHistory.js#L222-L230
  6321. */
  6322. function () {
  6323. return bt(window.location).some(function (name) {
  6324. return name === appName;
  6325. });
  6326. }, function () {
  6327. return {
  6328. appName: appName,
  6329. appWrapperGetter: appWrapperGetter,
  6330. proxy: proxy,
  6331. strictGlobal: false,
  6332. scopedCSS: scopedCSS,
  6333. dynamicStyleSheetElements: dynamicStyleSheetElements,
  6334. excludeAssetFilter: excludeAssetFilter
  6335. };
  6336. });
  6337. if (!mounting) bootstrappingPatchCount++;
  6338. if (mounting) mountingPatchCount++;
  6339. return function free() {
  6340. // bootstrap patch just called once but its freer will be called multiple times
  6341. if (!mounting && bootstrappingPatchCount !== 0) bootstrappingPatchCount--;
  6342. if (mounting) mountingPatchCount--;
  6343. var allMicroAppUnmounted = mountingPatchCount === 0 && bootstrappingPatchCount === 0; // release the overwrite prototype after all the micro apps unmounted
  6344. if (allMicroAppUnmounted) unpatchDynamicAppendPrototypeFunctions();
  6345. recordStyledComponentsCSSRules(dynamicStyleSheetElements); // As now the sub app content all wrapped with a special id container,
  6346. // the dynamic style sheet would be removed automatically while unmoutting
  6347. return function rebuild() {
  6348. rebuildCSSRules(dynamicStyleSheetElements, function (stylesheetElement) {
  6349. var appWrapper = appWrapperGetter();
  6350. if (!appWrapper.contains(stylesheetElement)) {
  6351. // Using document.head.appendChild ensures that appendChild invocation can also directly use the HTMLHeadElement.prototype.appendChild method which is overwritten at mounting phase
  6352. document.head.appendChild.call(appWrapper, stylesheetElement);
  6353. return true;
  6354. }
  6355. return false;
  6356. }); // As the patcher will be invoked every mounting phase, we could release the cache for gc after rebuilding
  6357. if (mounting) {
  6358. dynamicStyleSheetElements = [];
  6359. }
  6360. };
  6361. };
  6362. }
  6363. /**
  6364. * @author Kuitos
  6365. * @since 2020-10-13
  6366. */
  6367. Object.defineProperty(nativeGlobal, '__proxyAttachContainerConfigMap__', {
  6368. enumerable: false,
  6369. writable: true
  6370. }); // Share proxyAttachContainerConfigMap between multiple qiankun instance, thus they could access the same record
  6371. nativeGlobal.__proxyAttachContainerConfigMap__ = nativeGlobal.__proxyAttachContainerConfigMap__ || new WeakMap();
  6372. var proxyAttachContainerConfigMap = nativeGlobal.__proxyAttachContainerConfigMap__;
  6373. var elementAttachContainerConfigMap = new WeakMap();
  6374. var docCreatePatchedMap = new WeakMap();
  6375. function patchDocumentCreateElement() {
  6376. var docCreateElementFnBeforeOverwrite = docCreatePatchedMap.get(document.createElement);
  6377. if (!docCreateElementFnBeforeOverwrite) {
  6378. var rawDocumentCreateElement = document.createElement;
  6379. Document.prototype.createElement = function createElement(tagName, options) {
  6380. var element = rawDocumentCreateElement.call(this, tagName, options);
  6381. if (isHijackingTag(tagName)) {
  6382. var _ref = getCurrentRunningApp() || {},
  6383. currentRunningSandboxProxy = _ref.window;
  6384. if (currentRunningSandboxProxy) {
  6385. var proxyContainerConfig = proxyAttachContainerConfigMap.get(currentRunningSandboxProxy);
  6386. if (proxyContainerConfig) {
  6387. elementAttachContainerConfigMap.set(element, proxyContainerConfig);
  6388. }
  6389. }
  6390. }
  6391. return element;
  6392. }; // It means it have been overwritten while createElement is an own property of document
  6393. if (document.hasOwnProperty('createElement')) {
  6394. document.createElement = Document.prototype.createElement;
  6395. }
  6396. docCreatePatchedMap.set(Document.prototype.createElement, rawDocumentCreateElement);
  6397. }
  6398. return function unpatch() {
  6399. if (docCreateElementFnBeforeOverwrite) {
  6400. Document.prototype.createElement = docCreateElementFnBeforeOverwrite;
  6401. document.createElement = docCreateElementFnBeforeOverwrite;
  6402. }
  6403. };
  6404. }
  6405. var bootstrappingPatchCount$1 = 0;
  6406. var mountingPatchCount$1 = 0;
  6407. function patchStrictSandbox(appName, appWrapperGetter, proxy) {
  6408. var mounting = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
  6409. var scopedCSS = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  6410. var excludeAssetFilter = arguments.length > 5 ? arguments[5] : undefined;
  6411. var containerConfig = proxyAttachContainerConfigMap.get(proxy);
  6412. if (!containerConfig) {
  6413. containerConfig = {
  6414. appName: appName,
  6415. proxy: proxy,
  6416. appWrapperGetter: appWrapperGetter,
  6417. dynamicStyleSheetElements: [],
  6418. strictGlobal: true,
  6419. excludeAssetFilter: excludeAssetFilter,
  6420. scopedCSS: scopedCSS
  6421. };
  6422. proxyAttachContainerConfigMap.set(proxy, containerConfig);
  6423. } // all dynamic style sheets are stored in proxy container
  6424. var _containerConfig = containerConfig,
  6425. dynamicStyleSheetElements = _containerConfig.dynamicStyleSheetElements;
  6426. var unpatchDocumentCreate = patchDocumentCreateElement();
  6427. var unpatchDynamicAppendPrototypeFunctions = patchHTMLDynamicAppendPrototypeFunctions(function (element) {
  6428. return elementAttachContainerConfigMap.has(element);
  6429. }, function (element) {
  6430. return elementAttachContainerConfigMap.get(element);
  6431. });
  6432. if (!mounting) bootstrappingPatchCount$1++;
  6433. if (mounting) mountingPatchCount$1++;
  6434. return function free() {
  6435. // bootstrap patch just called once but its freer will be called multiple times
  6436. if (!mounting && bootstrappingPatchCount$1 !== 0) bootstrappingPatchCount$1--;
  6437. if (mounting) mountingPatchCount$1--;
  6438. var allMicroAppUnmounted = mountingPatchCount$1 === 0 && bootstrappingPatchCount$1 === 0; // release the overwrite prototype after all the micro apps unmounted
  6439. if (allMicroAppUnmounted) {
  6440. unpatchDynamicAppendPrototypeFunctions();
  6441. unpatchDocumentCreate();
  6442. }
  6443. recordStyledComponentsCSSRules(dynamicStyleSheetElements); // As now the sub app content all wrapped with a special id container,
  6444. // the dynamic style sheet would be removed automatically while unmoutting
  6445. return function rebuild() {
  6446. rebuildCSSRules(dynamicStyleSheetElements, function (stylesheetElement) {
  6447. var appWrapper = appWrapperGetter();
  6448. if (!appWrapper.contains(stylesheetElement)) {
  6449. rawHeadAppendChild.call(appWrapper, stylesheetElement);
  6450. return true;
  6451. }
  6452. return false;
  6453. });
  6454. };
  6455. };
  6456. }
  6457. function patch() {
  6458. // FIXME umi unmount feature request
  6459. // eslint-disable-next-line @typescript-eslint/no-unused-vars
  6460. var rawHistoryListen = function rawHistoryListen(_) {
  6461. return noop_1;
  6462. };
  6463. var historyListeners = [];
  6464. var historyUnListens = [];
  6465. if (window.g_history && isFunction_1(window.g_history.listen)) {
  6466. rawHistoryListen = window.g_history.listen.bind(window.g_history);
  6467. window.g_history.listen = function (listener) {
  6468. historyListeners.push(listener);
  6469. var unListen = rawHistoryListen(listener);
  6470. historyUnListens.push(unListen);
  6471. return function () {
  6472. unListen();
  6473. historyUnListens.splice(historyUnListens.indexOf(unListen), 1);
  6474. historyListeners.splice(historyListeners.indexOf(listener), 1);
  6475. };
  6476. };
  6477. }
  6478. return function free() {
  6479. var rebuild = noop_1;
  6480. /*
  6481. 还存在余量 listener 表明未被卸载,存在两种情况
  6482. 1. 应用在 unmout 时未正确卸载 listener
  6483. 2. listener 是应用 mount 之前绑定的,
  6484. 第二种情况下应用在下次 mount 之前需重新绑定该 listener
  6485. */
  6486. if (historyListeners.length) {
  6487. rebuild = function rebuild() {
  6488. // 必须使用 window.g_history.listen 的方式重新绑定 listener,从而能保证 rebuild 这部分也能被捕获到,否则在应用卸载后无法正确的移除这部分副作用
  6489. historyListeners.forEach(function (listener) {
  6490. return window.g_history.listen(listener);
  6491. });
  6492. };
  6493. } // 卸载余下的 listener
  6494. historyUnListens.forEach(function (unListen) {
  6495. return unListen();
  6496. }); // restore
  6497. if (window.g_history && isFunction_1(window.g_history.listen)) {
  6498. window.g_history.listen = rawHistoryListen;
  6499. }
  6500. return rebuild;
  6501. };
  6502. }
  6503. var rawWindowInterval = window.setInterval;
  6504. var rawWindowClearInterval = window.clearInterval;
  6505. function patch$1(global) {
  6506. var intervals = [];
  6507. global.clearInterval = function (intervalId) {
  6508. intervals = intervals.filter(function (id) {
  6509. return id !== intervalId;
  6510. });
  6511. return rawWindowClearInterval.call(window, intervalId);
  6512. };
  6513. global.setInterval = function (handler, timeout) {
  6514. for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
  6515. args[_key - 2] = arguments[_key];
  6516. }
  6517. var intervalId = rawWindowInterval.apply(void 0, [handler, timeout].concat(args));
  6518. intervals = [].concat(_toConsumableArray(intervals), [intervalId]);
  6519. return intervalId;
  6520. };
  6521. return function free() {
  6522. intervals.forEach(function (id) {
  6523. return global.clearInterval(id);
  6524. });
  6525. global.setInterval = rawWindowInterval;
  6526. global.clearInterval = rawWindowClearInterval;
  6527. return noop_1;
  6528. };
  6529. }
  6530. var rawAddEventListener = window.addEventListener;
  6531. var rawRemoveEventListener = window.removeEventListener;
  6532. function patch$2(global) {
  6533. var listenerMap = new Map();
  6534. global.addEventListener = function (type, listener, options) {
  6535. var listeners = listenerMap.get(type) || [];
  6536. listenerMap.set(type, [].concat(_toConsumableArray(listeners), [listener]));
  6537. return rawAddEventListener.call(window, type, listener, options);
  6538. };
  6539. global.removeEventListener = function (type, listener, options) {
  6540. var storedTypeListeners = listenerMap.get(type);
  6541. if (storedTypeListeners && storedTypeListeners.length && storedTypeListeners.indexOf(listener) !== -1) {
  6542. storedTypeListeners.splice(storedTypeListeners.indexOf(listener), 1);
  6543. }
  6544. return rawRemoveEventListener.call(window, type, listener, options);
  6545. };
  6546. return function free() {
  6547. listenerMap.forEach(function (listeners, type) {
  6548. return _toConsumableArray(listeners).forEach(function (listener) {
  6549. return global.removeEventListener(type, listener);
  6550. });
  6551. });
  6552. global.addEventListener = rawAddEventListener;
  6553. global.removeEventListener = rawRemoveEventListener;
  6554. return noop_1;
  6555. };
  6556. }
  6557. function patchAtMounting(appName, elementGetter, sandbox, scopedCSS, excludeAssetFilter) {
  6558. var _patchersInSandbox, _patchersInSandbox$sa;
  6559. var basePatchers = [function () {
  6560. return patch$1(sandbox.proxy);
  6561. }, function () {
  6562. return patch$2(sandbox.proxy);
  6563. }, function () {
  6564. return patch();
  6565. }];
  6566. var patchersInSandbox = (_patchersInSandbox = {}, _defineProperty(_patchersInSandbox, exports.SandBoxType.LegacyProxy, [].concat(basePatchers, [function () {
  6567. return patchLooseSandbox(appName, elementGetter, sandbox.proxy, true, scopedCSS, excludeAssetFilter);
  6568. }])), _defineProperty(_patchersInSandbox, exports.SandBoxType.Proxy, [].concat(basePatchers, [function () {
  6569. return patchStrictSandbox(appName, elementGetter, sandbox.proxy, true, scopedCSS, excludeAssetFilter);
  6570. }])), _defineProperty(_patchersInSandbox, exports.SandBoxType.Snapshot, [].concat(basePatchers, [function () {
  6571. return patchLooseSandbox(appName, elementGetter, sandbox.proxy, true, scopedCSS, excludeAssetFilter);
  6572. }])), _patchersInSandbox);
  6573. return (_patchersInSandbox$sa = patchersInSandbox[sandbox.type]) === null || _patchersInSandbox$sa === void 0 ? void 0 : _patchersInSandbox$sa.map(function (patch) {
  6574. return patch();
  6575. });
  6576. }
  6577. function patchAtBootstrapping(appName, elementGetter, sandbox, scopedCSS, excludeAssetFilter) {
  6578. var _patchersInSandbox2, _patchersInSandbox$sa2;
  6579. var patchersInSandbox = (_patchersInSandbox2 = {}, _defineProperty(_patchersInSandbox2, exports.SandBoxType.LegacyProxy, [function () {
  6580. return patchLooseSandbox(appName, elementGetter, sandbox.proxy, false, scopedCSS, excludeAssetFilter);
  6581. }]), _defineProperty(_patchersInSandbox2, exports.SandBoxType.Proxy, [function () {
  6582. return patchStrictSandbox(appName, elementGetter, sandbox.proxy, false, scopedCSS, excludeAssetFilter);
  6583. }]), _defineProperty(_patchersInSandbox2, exports.SandBoxType.Snapshot, [function () {
  6584. return patchLooseSandbox(appName, elementGetter, sandbox.proxy, false, scopedCSS, excludeAssetFilter);
  6585. }]), _patchersInSandbox2);
  6586. return (_patchersInSandbox$sa2 = patchersInSandbox[sandbox.type]) === null || _patchersInSandbox$sa2 === void 0 ? void 0 : _patchersInSandbox$sa2.map(function (patch) {
  6587. return patch();
  6588. });
  6589. }
  6590. /**
  6591. * fastest(at most time) unique array method
  6592. * @see https://jsperf.com/array-filter-unique/30
  6593. */
  6594. function uniq(array) {
  6595. return array.filter(function filter(element) {
  6596. return element in this ? false : this[element] = true;
  6597. }, Object.create(null));
  6598. } // zone.js will overwrite Object.defineProperty
  6599. var rawObjectDefineProperty = Object.defineProperty;
  6600. var variableWhiteListInDev = [// for react hot reload
  6601. // see https://github.com/facebook/create-react-app/blob/66bf7dfc43350249e2f09d138a20840dae8a0a4a/packages/react-error-overlay/src/index.js#L180
  6602. '__REACT_ERROR_OVERLAY_GLOBAL_HOOK__'] ; // who could escape the sandbox
  6603. var variableWhiteList = [// FIXME System.js used a indirect call with eval, which would make it scope escape to global
  6604. // To make System.js works well, we write it back to global window temporary
  6605. // see https://github.com/systemjs/systemjs/blob/457f5b7e8af6bd120a279540477552a07d5de086/src/evaluate.js#L106
  6606. 'System', // see https://github.com/systemjs/systemjs/blob/457f5b7e8af6bd120a279540477552a07d5de086/src/instantiate.js#L357
  6607. '__cjsWrapper'].concat(variableWhiteListInDev);
  6608. /*
  6609. variables who are impossible to be overwrite need to be escaped from proxy sandbox for performance reasons
  6610. */
  6611. var unscopables = {
  6612. undefined: true,
  6613. Array: true,
  6614. Object: true,
  6615. String: true,
  6616. Boolean: true,
  6617. Math: true,
  6618. Number: true,
  6619. Symbol: true,
  6620. parseFloat: true,
  6621. Float32Array: true,
  6622. isNaN: true,
  6623. Infinity: true,
  6624. Reflect: true,
  6625. Float64Array: true,
  6626. Function: true,
  6627. Map: true,
  6628. NaN: true,
  6629. Promise: true,
  6630. Proxy: true,
  6631. Set: true,
  6632. parseInt: true,
  6633. requestAnimationFrame: true
  6634. };
  6635. var useNativeWindowForBindingsProps = new Map([['fetch', true], ['mockDomAPIInBlackList', "development" === 'test']]);
  6636. function createFakeWindow(globalContext) {
  6637. // map always has the fastest performance in has check scenario
  6638. // see https://jsperf.com/array-indexof-vs-set-has/23
  6639. var propertiesWithGetter = new Map();
  6640. var fakeWindow = {};
  6641. /*
  6642. copy the non-configurable property of global to fakeWindow
  6643. see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/getOwnPropertyDescriptor
  6644. > A property cannot be reported as non-configurable, if it does not exists as an own property of the target object or if it exists as a configurable own property of the target object.
  6645. */
  6646. Object.getOwnPropertyNames(globalContext).filter(function (p) {
  6647. var descriptor = Object.getOwnPropertyDescriptor(globalContext, p);
  6648. return !(descriptor === null || descriptor === void 0 ? void 0 : descriptor.configurable);
  6649. }).forEach(function (p) {
  6650. var descriptor = Object.getOwnPropertyDescriptor(globalContext, p);
  6651. if (descriptor) {
  6652. var hasGetter = Object.prototype.hasOwnProperty.call(descriptor, 'get');
  6653. /*
  6654. make top/self/window property configurable and writable, otherwise it will cause TypeError while get trap return.
  6655. see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/get
  6656. > The value reported for a property must be the same as the value of the corresponding target object property if the target object property is a non-writable, non-configurable data property.
  6657. */
  6658. if (p === 'top' || p === 'parent' || p === 'self' || p === 'window' || "development" === 'test' ) {
  6659. descriptor.configurable = true;
  6660. /*
  6661. The descriptor of window.window/window.top/window.self in Safari/FF are accessor descriptors, we need to avoid adding a data descriptor while it was
  6662. Example:
  6663. Safari/FF: Object.getOwnPropertyDescriptor(window, 'top') -> {get: function, set: undefined, enumerable: true, configurable: false}
  6664. Chrome: Object.getOwnPropertyDescriptor(window, 'top') -> {value: Window, writable: false, enumerable: true, configurable: false}
  6665. */
  6666. if (!hasGetter) {
  6667. descriptor.writable = true;
  6668. }
  6669. }
  6670. if (hasGetter) propertiesWithGetter.set(p, true); // freeze the descriptor to avoid being modified by zone.js
  6671. // see https://github.com/angular/zone.js/blob/a5fe09b0fac27ac5df1fa746042f96f05ccb6a00/lib/browser/define-property.ts#L71
  6672. rawObjectDefineProperty(fakeWindow, p, Object.freeze(descriptor));
  6673. }
  6674. });
  6675. return {
  6676. fakeWindow: fakeWindow,
  6677. propertiesWithGetter: propertiesWithGetter
  6678. };
  6679. }
  6680. var activeSandboxCount = 0;
  6681. /**
  6682. * 基于 Proxy 实现的沙箱
  6683. */
  6684. var ProxySandbox = /*#__PURE__*/function () {
  6685. function ProxySandbox(name) {
  6686. var _this = this;
  6687. var globalContext = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window;
  6688. _classCallCheck(this, ProxySandbox);
  6689. this.updatedValueSet = new Set();
  6690. this.name = void 0;
  6691. this.type = void 0;
  6692. this.proxy = void 0;
  6693. this.globalContext = void 0;
  6694. this.sandboxRunning = true;
  6695. this.latestSetProp = null;
  6696. this.name = name;
  6697. this.globalContext = globalContext;
  6698. this.type = exports.SandBoxType.Proxy;
  6699. var updatedValueSet = this.updatedValueSet;
  6700. var _createFakeWindow = createFakeWindow(globalContext),
  6701. fakeWindow = _createFakeWindow.fakeWindow,
  6702. propertiesWithGetter = _createFakeWindow.propertiesWithGetter;
  6703. var descriptorTargetMap = new Map();
  6704. var hasOwnProperty = function hasOwnProperty(key) {
  6705. return fakeWindow.hasOwnProperty(key) || globalContext.hasOwnProperty(key);
  6706. };
  6707. var proxy = new Proxy(fakeWindow, {
  6708. set: function set(target, p, value) {
  6709. if (_this.sandboxRunning) {
  6710. _this.registerRunningApp(name, proxy); // We must kept its description while the property existed in globalContext before
  6711. if (!target.hasOwnProperty(p) && globalContext.hasOwnProperty(p)) {
  6712. var descriptor = Object.getOwnPropertyDescriptor(globalContext, p);
  6713. var writable = descriptor.writable,
  6714. configurable = descriptor.configurable,
  6715. enumerable = descriptor.enumerable;
  6716. if (writable) {
  6717. Object.defineProperty(target, p, {
  6718. configurable: configurable,
  6719. enumerable: enumerable,
  6720. writable: writable,
  6721. value: value
  6722. });
  6723. }
  6724. } else {
  6725. // @ts-ignore
  6726. target[p] = value;
  6727. }
  6728. if (variableWhiteList.indexOf(p) !== -1) {
  6729. // @ts-ignore
  6730. globalContext[p] = value;
  6731. }
  6732. updatedValueSet.add(p);
  6733. _this.latestSetProp = p;
  6734. return true;
  6735. }
  6736. {
  6737. console.warn("[qiankun] Set window.".concat(p.toString(), " while sandbox destroyed or inactive in ").concat(name, "!"));
  6738. } // 在 strict-mode 下,Proxy 的 handler.set 返回 false 会抛出 TypeError,在沙箱卸载的情况下应该忽略错误
  6739. return true;
  6740. },
  6741. get: function get(target, p) {
  6742. _this.registerRunningApp(name, proxy);
  6743. if (p === Symbol.unscopables) return unscopables; // avoid who using window.window or window.self to escape the sandbox environment to touch the really window
  6744. // see https://github.com/eligrey/FileSaver.js/blob/master/src/FileSaver.js#L13
  6745. if (p === 'window' || p === 'self') {
  6746. return proxy;
  6747. } // hijack globalWindow accessing with globalThis keyword
  6748. if (p === 'globalThis') {
  6749. return proxy;
  6750. }
  6751. if (p === 'top' || p === 'parent' || "development" === 'test' ) {
  6752. // if your master app in an iframe context, allow these props escape the sandbox
  6753. if (globalContext === globalContext.parent) {
  6754. return proxy;
  6755. }
  6756. return globalContext[p];
  6757. } // proxy.hasOwnProperty would invoke getter firstly, then its value represented as globalContext.hasOwnProperty
  6758. if (p === 'hasOwnProperty') {
  6759. return hasOwnProperty;
  6760. }
  6761. if (p === 'document') {
  6762. return document;
  6763. }
  6764. if (p === 'eval') {
  6765. return eval;
  6766. }
  6767. var value = propertiesWithGetter.has(p) ? globalContext[p] : p in target ? target[p] : globalContext[p];
  6768. /* Some dom api must be bound to native window, otherwise it would cause exception like 'TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation'
  6769. See this code:
  6770. const proxy = new Proxy(window, {});
  6771. const proxyFetch = fetch.bind(proxy);
  6772. proxyFetch('https://qiankun.com');
  6773. */
  6774. var boundTarget = useNativeWindowForBindingsProps.get(p) ? nativeGlobal : globalContext;
  6775. return getTargetValue(boundTarget, value);
  6776. },
  6777. // trap in operator
  6778. // see https://github.com/styled-components/styled-components/blob/master/packages/styled-components/src/constants.js#L12
  6779. has: function has(target, p) {
  6780. return p in unscopables || p in target || p in globalContext;
  6781. },
  6782. getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, p) {
  6783. /*
  6784. as the descriptor of top/self/window/mockTop in raw window are configurable but not in proxy target, we need to get it from target to avoid TypeError
  6785. see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/getOwnPropertyDescriptor
  6786. > A property cannot be reported as non-configurable, if it does not exists as an own property of the target object or if it exists as a configurable own property of the target object.
  6787. */
  6788. if (target.hasOwnProperty(p)) {
  6789. var descriptor = Object.getOwnPropertyDescriptor(target, p);
  6790. descriptorTargetMap.set(p, 'target');
  6791. return descriptor;
  6792. }
  6793. if (globalContext.hasOwnProperty(p)) {
  6794. var _descriptor = Object.getOwnPropertyDescriptor(globalContext, p);
  6795. descriptorTargetMap.set(p, 'globalContext'); // A property cannot be reported as non-configurable, if it does not exists as an own property of the target object
  6796. if (_descriptor && !_descriptor.configurable) {
  6797. _descriptor.configurable = true;
  6798. }
  6799. return _descriptor;
  6800. }
  6801. return undefined;
  6802. },
  6803. // trap to support iterator with sandbox
  6804. ownKeys: function ownKeys(target) {
  6805. return uniq(Reflect.ownKeys(globalContext).concat(Reflect.ownKeys(target)));
  6806. },
  6807. defineProperty: function defineProperty(target, p, attributes) {
  6808. var from = descriptorTargetMap.get(p);
  6809. /*
  6810. Descriptor must be defined to native window while it comes from native window via Object.getOwnPropertyDescriptor(window, p),
  6811. otherwise it would cause a TypeError with illegal invocation.
  6812. */
  6813. switch (from) {
  6814. case 'globalContext':
  6815. return Reflect.defineProperty(globalContext, p, attributes);
  6816. default:
  6817. return Reflect.defineProperty(target, p, attributes);
  6818. }
  6819. },
  6820. deleteProperty: function deleteProperty(target, p) {
  6821. _this.registerRunningApp(name, proxy);
  6822. if (target.hasOwnProperty(p)) {
  6823. // @ts-ignore
  6824. delete target[p];
  6825. updatedValueSet.delete(p);
  6826. return true;
  6827. }
  6828. return true;
  6829. },
  6830. // makes sure `window instanceof Window` returns truthy in micro app
  6831. getPrototypeOf: function getPrototypeOf() {
  6832. return Reflect.getPrototypeOf(globalContext);
  6833. }
  6834. });
  6835. this.proxy = proxy;
  6836. activeSandboxCount++;
  6837. }
  6838. _createClass(ProxySandbox, [{
  6839. key: "registerRunningApp",
  6840. value:
  6841. /** window 值变更记录 */
  6842. function registerRunningApp(name, proxy) {
  6843. if (this.sandboxRunning) {
  6844. var currentRunningApp = getCurrentRunningApp();
  6845. if (!currentRunningApp || currentRunningApp.name !== name) {
  6846. setCurrentRunningApp({
  6847. name: name,
  6848. window: proxy
  6849. });
  6850. } // FIXME if you have any other good ideas
  6851. // remove the mark in next tick, thus we can identify whether it in micro app or not
  6852. // this approach is just a workaround, it could not cover all complex cases, such as the micro app runs in the same task context with master in some case
  6853. nextTask(function () {
  6854. setCurrentRunningApp(null);
  6855. });
  6856. }
  6857. }
  6858. }, {
  6859. key: "active",
  6860. value: function active() {
  6861. if (!this.sandboxRunning) activeSandboxCount++;
  6862. this.sandboxRunning = true;
  6863. }
  6864. }, {
  6865. key: "inactive",
  6866. value: function inactive() {
  6867. var _this2 = this;
  6868. {
  6869. console.info("[qiankun:sandbox] ".concat(this.name, " modified global properties restore..."), _toConsumableArray(this.updatedValueSet.keys()));
  6870. }
  6871. if (--activeSandboxCount === 0) {
  6872. variableWhiteList.forEach(function (p) {
  6873. if (_this2.proxy.hasOwnProperty(p)) {
  6874. // @ts-ignore
  6875. delete _this2.globalContext[p];
  6876. }
  6877. });
  6878. }
  6879. this.sandboxRunning = false;
  6880. }
  6881. }]);
  6882. return ProxySandbox;
  6883. }();
  6884. function iter(obj, callbackFn) {
  6885. // eslint-disable-next-line guard-for-in, no-restricted-syntax
  6886. for (var prop in obj) {
  6887. // patch for clearInterval for compatible reason, see #1490
  6888. if (obj.hasOwnProperty(prop) || prop === 'clearInterval') {
  6889. callbackFn(prop);
  6890. }
  6891. }
  6892. }
  6893. /**
  6894. * 基于 diff 方式实现的沙箱,用于不支持 Proxy 的低版本浏览器
  6895. */
  6896. var SnapshotSandbox = /*#__PURE__*/function () {
  6897. function SnapshotSandbox(name) {
  6898. _classCallCheck(this, SnapshotSandbox);
  6899. this.proxy = void 0;
  6900. this.name = void 0;
  6901. this.type = void 0;
  6902. this.sandboxRunning = true;
  6903. this.windowSnapshot = void 0;
  6904. this.modifyPropsMap = {};
  6905. this.name = name;
  6906. this.proxy = window;
  6907. this.type = exports.SandBoxType.Snapshot;
  6908. }
  6909. _createClass(SnapshotSandbox, [{
  6910. key: "active",
  6911. value: function active() {
  6912. var _this = this;
  6913. // 记录当前快照
  6914. this.windowSnapshot = {};
  6915. iter(window, function (prop) {
  6916. _this.windowSnapshot[prop] = window[prop];
  6917. }); // 恢复之前的变更
  6918. Object.keys(this.modifyPropsMap).forEach(function (p) {
  6919. window[p] = _this.modifyPropsMap[p];
  6920. });
  6921. this.sandboxRunning = true;
  6922. }
  6923. }, {
  6924. key: "inactive",
  6925. value: function inactive() {
  6926. var _this2 = this;
  6927. this.modifyPropsMap = {};
  6928. iter(window, function (prop) {
  6929. if (window[prop] !== _this2.windowSnapshot[prop]) {
  6930. // 记录变更,恢复环境
  6931. _this2.modifyPropsMap[prop] = window[prop];
  6932. window[prop] = _this2.windowSnapshot[prop];
  6933. }
  6934. });
  6935. {
  6936. console.info("[qiankun:sandbox] ".concat(this.name, " origin window restore..."), Object.keys(this.modifyPropsMap));
  6937. }
  6938. this.sandboxRunning = false;
  6939. }
  6940. }]);
  6941. return SnapshotSandbox;
  6942. }();
  6943. /**
  6944. * 生成应用运行时沙箱
  6945. *
  6946. * 沙箱分两个类型:
  6947. * 1. app 环境沙箱
  6948. * app 环境沙箱是指应用初始化过之后,应用会在什么样的上下文环境运行。每个应用的环境沙箱只会初始化一次,因为子应用只会触发一次 bootstrap 。
  6949. * 子应用在切换时,实际上切换的是 app 环境沙箱。
  6950. * 2. render 沙箱
  6951. * 子应用在 app mount 开始前生成好的的沙箱。每次子应用切换过后,render 沙箱都会重现初始化。
  6952. *
  6953. * 这么设计的目的是为了保证每个子应用切换回来之后,还能运行在应用 bootstrap 之后的环境下。
  6954. *
  6955. * @param appName
  6956. * @param elementGetter
  6957. * @param scopedCSS
  6958. * @param useLooseSandbox
  6959. * @param excludeAssetFilter
  6960. * @param globalContext
  6961. */
  6962. function createSandboxContainer(appName, elementGetter, scopedCSS, useLooseSandbox, excludeAssetFilter, globalContext) {
  6963. var sandbox;
  6964. if (window.Proxy) {
  6965. sandbox = useLooseSandbox ? new LegacySandbox(appName, globalContext) : new ProxySandbox(appName, globalContext);
  6966. } else {
  6967. sandbox = new SnapshotSandbox(appName);
  6968. } // some side effect could be be invoked while bootstrapping, such as dynamic stylesheet injection with style-loader, especially during the development phase
  6969. var bootstrappingFreers = patchAtBootstrapping(appName, elementGetter, sandbox, scopedCSS, excludeAssetFilter); // mounting freers are one-off and should be re-init at every mounting time
  6970. var mountingFreers = [];
  6971. var sideEffectsRebuilders = [];
  6972. return {
  6973. instance: sandbox,
  6974. /**
  6975. * 沙箱被 mount
  6976. * 可能是从 bootstrap 状态进入的 mount
  6977. * 也可能是从 unmount 之后再次唤醒进入 mount
  6978. */
  6979. mount: function mount() {
  6980. return _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  6981. var sideEffectsRebuildersAtBootstrapping, sideEffectsRebuildersAtMounting;
  6982. return regenerator.wrap(function _callee$(_context) {
  6983. while (1) {
  6984. switch (_context.prev = _context.next) {
  6985. case 0:
  6986. /* ------------------------------------------ 因为有上下文依赖(window),以下代码执行顺序不能变 ------------------------------------------ */
  6987. /* ------------------------------------------ 1. 启动/恢复 沙箱------------------------------------------ */
  6988. sandbox.active();
  6989. sideEffectsRebuildersAtBootstrapping = sideEffectsRebuilders.slice(0, bootstrappingFreers.length);
  6990. sideEffectsRebuildersAtMounting = sideEffectsRebuilders.slice(bootstrappingFreers.length); // must rebuild the side effects which added at bootstrapping firstly to recovery to nature state
  6991. if (sideEffectsRebuildersAtBootstrapping.length) {
  6992. sideEffectsRebuildersAtBootstrapping.forEach(function (rebuild) {
  6993. return rebuild();
  6994. });
  6995. }
  6996. /* ------------------------------------------ 2. 开启全局变量补丁 ------------------------------------------*/
  6997. // render 沙箱启动时开始劫持各类全局监听,尽量不要在应用初始化阶段有 事件监听/定时器 等副作用
  6998. mountingFreers = patchAtMounting(appName, elementGetter, sandbox, scopedCSS, excludeAssetFilter);
  6999. /* ------------------------------------------ 3. 重置一些初始化时的副作用 ------------------------------------------*/
  7000. // 存在 rebuilder 则表明有些副作用需要重建
  7001. if (sideEffectsRebuildersAtMounting.length) {
  7002. sideEffectsRebuildersAtMounting.forEach(function (rebuild) {
  7003. return rebuild();
  7004. });
  7005. } // clean up rebuilders
  7006. sideEffectsRebuilders = [];
  7007. case 7:
  7008. case "end":
  7009. return _context.stop();
  7010. }
  7011. }
  7012. }, _callee);
  7013. }))();
  7014. },
  7015. /**
  7016. * 恢复 global 状态,使其能回到应用加载之前的状态
  7017. */
  7018. unmount: function unmount() {
  7019. return _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  7020. return regenerator.wrap(function _callee2$(_context2) {
  7021. while (1) {
  7022. switch (_context2.prev = _context2.next) {
  7023. case 0:
  7024. // record the rebuilders of window side effects (event listeners or timers)
  7025. // note that the frees of mounting phase are one-off as it will be re-init at next mounting
  7026. sideEffectsRebuilders = [].concat(_toConsumableArray(bootstrappingFreers), _toConsumableArray(mountingFreers)).map(function (free) {
  7027. return free();
  7028. });
  7029. sandbox.inactive();
  7030. case 2:
  7031. case "end":
  7032. return _context2.stop();
  7033. }
  7034. }
  7035. }, _callee2);
  7036. }))();
  7037. }
  7038. };
  7039. }
  7040. var _excluded = ["singular", "sandbox", "excludeAssetFilter", "globalContext"];
  7041. function assertElementExist(element, msg) {
  7042. if (!element) {
  7043. if (msg) {
  7044. throw new QiankunError(msg);
  7045. }
  7046. throw new QiankunError('element not existed!');
  7047. }
  7048. }
  7049. function execHooksChain(hooks, app) {
  7050. var global = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : window;
  7051. if (hooks.length) {
  7052. return hooks.reduce(function (chain, hook) {
  7053. return chain.then(function () {
  7054. return hook(app, global);
  7055. });
  7056. }, Promise.resolve());
  7057. }
  7058. return Promise.resolve();
  7059. }
  7060. function validateSingularMode(_x, _x2) {
  7061. return _validateSingularMode.apply(this, arguments);
  7062. } // @ts-ignore
  7063. function _validateSingularMode() {
  7064. _validateSingularMode = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(validate, app) {
  7065. return regenerator.wrap(function _callee$(_context) {
  7066. while (1) {
  7067. switch (_context.prev = _context.next) {
  7068. case 0:
  7069. return _context.abrupt("return", typeof validate === 'function' ? validate(app) : !!validate);
  7070. case 1:
  7071. case "end":
  7072. return _context.stop();
  7073. }
  7074. }
  7075. }, _callee);
  7076. }));
  7077. return _validateSingularMode.apply(this, arguments);
  7078. }
  7079. var supportShadowDOM = document.head.attachShadow || document.head.createShadowRoot;
  7080. function createElement(appContent, strictStyleIsolation, scopedCSS, appInstanceId) {
  7081. var containerElement = document.createElement('div');
  7082. containerElement.innerHTML = appContent; // appContent always wrapped with a singular div
  7083. var appElement = containerElement.firstChild;
  7084. if (strictStyleIsolation) {
  7085. if (!supportShadowDOM) {
  7086. console.warn('[qiankun]: As current browser not support shadow dom, your strictStyleIsolation configuration will be ignored!');
  7087. } else {
  7088. var innerHTML = appElement.innerHTML;
  7089. appElement.innerHTML = '';
  7090. var shadow;
  7091. if (appElement.attachShadow) {
  7092. shadow = appElement.attachShadow({
  7093. mode: 'open'
  7094. });
  7095. } else {
  7096. // createShadowRoot was proposed in initial spec, which has then been deprecated
  7097. shadow = appElement.createShadowRoot();
  7098. }
  7099. shadow.innerHTML = innerHTML;
  7100. }
  7101. }
  7102. if (scopedCSS) {
  7103. var attr = appElement.getAttribute(QiankunCSSRewriteAttr);
  7104. if (!attr) {
  7105. appElement.setAttribute(QiankunCSSRewriteAttr, appInstanceId);
  7106. }
  7107. var styleNodes = appElement.querySelectorAll('style') || [];
  7108. forEach_1(styleNodes, function (stylesheetElement) {
  7109. process(appElement, stylesheetElement, appInstanceId);
  7110. });
  7111. }
  7112. return appElement;
  7113. }
  7114. /** generate app wrapper dom getter */
  7115. function getAppWrapperGetter(appInstanceId, useLegacyRender, strictStyleIsolation, scopedCSS, elementGetter) {
  7116. return function () {
  7117. if (useLegacyRender) {
  7118. if (strictStyleIsolation) throw new QiankunError('strictStyleIsolation can not be used with legacy render!');
  7119. if (scopedCSS) throw new QiankunError('experimentalStyleIsolation can not be used with legacy render!');
  7120. var appWrapper = document.getElementById(getWrapperId(appInstanceId));
  7121. assertElementExist(appWrapper, "Wrapper element for ".concat(appInstanceId, " is not existed!"));
  7122. return appWrapper;
  7123. }
  7124. var element = elementGetter();
  7125. assertElementExist(element, "Wrapper element for ".concat(appInstanceId, " is not existed!"));
  7126. if (strictStyleIsolation && supportShadowDOM) {
  7127. return element.shadowRoot;
  7128. }
  7129. return element;
  7130. };
  7131. }
  7132. var rawAppendChild = HTMLElement.prototype.appendChild;
  7133. var rawRemoveChild$1 = HTMLElement.prototype.removeChild;
  7134. /**
  7135. * Get the render function
  7136. * If the legacy render function is provide, used as it, otherwise we will insert the app element to target container by qiankun
  7137. * @param appInstanceId
  7138. * @param appContent
  7139. * @param legacyRender
  7140. */
  7141. function getRender(appInstanceId, appContent, legacyRender) {
  7142. var render = function render(_ref, phase) {
  7143. var element = _ref.element,
  7144. loading = _ref.loading,
  7145. container = _ref.container;
  7146. if (legacyRender) {
  7147. {
  7148. console.error('[qiankun] Custom rendering function is deprecated and will be removed in 3.0, you can use the container element setting instead!');
  7149. }
  7150. return legacyRender({
  7151. loading: loading,
  7152. appContent: element ? appContent : ''
  7153. });
  7154. }
  7155. var containerElement = getContainer(container); // The container might have be removed after micro app unmounted.
  7156. // Such as the micro app unmount lifecycle called by a react componentWillUnmount lifecycle, after micro app unmounted, the react component might also be removed
  7157. if (phase !== 'unmounted') {
  7158. var errorMsg = function () {
  7159. switch (phase) {
  7160. case 'loading':
  7161. case 'mounting':
  7162. return "Target container with ".concat(container, " not existed while ").concat(appInstanceId, " ").concat(phase, "!");
  7163. case 'mounted':
  7164. return "Target container with ".concat(container, " not existed after ").concat(appInstanceId, " ").concat(phase, "!");
  7165. default:
  7166. return "Target container with ".concat(container, " not existed while ").concat(appInstanceId, " rendering!");
  7167. }
  7168. }();
  7169. assertElementExist(containerElement, errorMsg);
  7170. }
  7171. if (containerElement && !containerElement.contains(element)) {
  7172. // clear the container
  7173. while (containerElement.firstChild) {
  7174. rawRemoveChild$1.call(containerElement, containerElement.firstChild);
  7175. } // append the element to container if it exist
  7176. if (element) {
  7177. rawAppendChild.call(containerElement, element);
  7178. }
  7179. }
  7180. return undefined;
  7181. };
  7182. return render;
  7183. }
  7184. function getLifecyclesFromExports(scriptExports, appName, global, globalLatestSetProp) {
  7185. if (validateExportLifecycle(scriptExports)) {
  7186. return scriptExports;
  7187. } // fallback to sandbox latest set property if it had
  7188. if (globalLatestSetProp) {
  7189. var lifecycles = global[globalLatestSetProp];
  7190. if (validateExportLifecycle(lifecycles)) {
  7191. return lifecycles;
  7192. }
  7193. }
  7194. {
  7195. console.warn("[qiankun] lifecycle not found from ".concat(appName, " entry exports, fallback to get from window['").concat(appName, "']"));
  7196. } // fallback to global variable who named with ${appName} while module exports not found
  7197. var globalVariableExports = global[appName];
  7198. if (validateExportLifecycle(globalVariableExports)) {
  7199. return globalVariableExports;
  7200. }
  7201. throw new QiankunError("You need to export lifecycle functions in ".concat(appName, " entry"));
  7202. }
  7203. var prevAppUnmountedDeferred;
  7204. function loadApp(_x3) {
  7205. return _loadApp.apply(this, arguments);
  7206. }
  7207. function _loadApp() {
  7208. _loadApp = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee17(app) {
  7209. var _sandboxContainer, _sandboxContainer$ins;
  7210. var configuration,
  7211. lifeCycles,
  7212. entry,
  7213. appName,
  7214. appInstanceId,
  7215. markName,
  7216. _configuration$singul,
  7217. singular,
  7218. _configuration$sandbo,
  7219. sandbox,
  7220. excludeAssetFilter,
  7221. _configuration$global,
  7222. globalContext,
  7223. importEntryOpts,
  7224. _yield$importEntry,
  7225. template,
  7226. execScripts,
  7227. assetPublicPath,
  7228. appContent,
  7229. strictStyleIsolation,
  7230. scopedCSS,
  7231. initialAppWrapperElement,
  7232. initialContainer,
  7233. legacyRender,
  7234. render,
  7235. initialAppWrapperGetter,
  7236. global,
  7237. mountSandbox,
  7238. unmountSandbox,
  7239. useLooseSandbox,
  7240. sandboxContainer,
  7241. _mergeWith,
  7242. _mergeWith$beforeUnmo,
  7243. beforeUnmount,
  7244. _mergeWith$afterUnmou,
  7245. afterUnmount,
  7246. _mergeWith$afterMount,
  7247. afterMount,
  7248. _mergeWith$beforeMoun,
  7249. beforeMount,
  7250. _mergeWith$beforeLoad,
  7251. beforeLoad,
  7252. scriptExports,
  7253. _getLifecyclesFromExp,
  7254. bootstrap,
  7255. mount,
  7256. unmount,
  7257. update,
  7258. _getMicroAppStateActi,
  7259. onGlobalStateChange,
  7260. setGlobalState,
  7261. offGlobalStateChange,
  7262. syncAppWrapperElement2Sandbox,
  7263. parcelConfigGetter,
  7264. _args17 = arguments;
  7265. return regenerator.wrap(function _callee17$(_context17) {
  7266. while (1) {
  7267. switch (_context17.prev = _context17.next) {
  7268. case 0:
  7269. configuration = _args17.length > 1 && _args17[1] !== undefined ? _args17[1] : {};
  7270. lifeCycles = _args17.length > 2 ? _args17[2] : undefined;
  7271. entry = app.entry, appName = app.name;
  7272. appInstanceId = genAppInstanceIdByName(appName);
  7273. markName = "[qiankun] App ".concat(appInstanceId, " Loading");
  7274. {
  7275. performanceMark(markName);
  7276. }
  7277. _configuration$singul = configuration.singular, singular = _configuration$singul === void 0 ? false : _configuration$singul, _configuration$sandbo = configuration.sandbox, sandbox = _configuration$sandbo === void 0 ? true : _configuration$sandbo, excludeAssetFilter = configuration.excludeAssetFilter, _configuration$global = configuration.globalContext, globalContext = _configuration$global === void 0 ? window : _configuration$global, importEntryOpts = _objectWithoutProperties(configuration, _excluded); // get the entry html content and script executor
  7278. _context17.next = 9;
  7279. return importEntry(entry, importEntryOpts);
  7280. case 9:
  7281. _yield$importEntry = _context17.sent;
  7282. template = _yield$importEntry.template;
  7283. execScripts = _yield$importEntry.execScripts;
  7284. assetPublicPath = _yield$importEntry.assetPublicPath;
  7285. _context17.next = 15;
  7286. return validateSingularMode(singular, app);
  7287. case 15:
  7288. if (!_context17.sent) {
  7289. _context17.next = 18;
  7290. break;
  7291. }
  7292. _context17.next = 18;
  7293. return prevAppUnmountedDeferred && prevAppUnmountedDeferred.promise;
  7294. case 18:
  7295. appContent = getDefaultTplWrapper(appInstanceId)(template);
  7296. strictStyleIsolation = _typeof(sandbox) === 'object' && !!sandbox.strictStyleIsolation;
  7297. if ( strictStyleIsolation) {
  7298. console.warn("[qiankun] strictStyleIsolation configuration will be removed in 3.0, pls don't depend on it or use experimentalStyleIsolation instead!");
  7299. }
  7300. scopedCSS = isEnableScopedCSS(sandbox);
  7301. initialAppWrapperElement = createElement(appContent, strictStyleIsolation, scopedCSS, appInstanceId);
  7302. initialContainer = 'container' in app ? app.container : undefined;
  7303. legacyRender = 'render' in app ? app.render : undefined;
  7304. render = getRender(appInstanceId, appContent, legacyRender); // 第一次加载设置应用可见区域 dom 结构
  7305. // 确保每次应用加载前容器 dom 结构已经设置完毕
  7306. render({
  7307. element: initialAppWrapperElement,
  7308. loading: true,
  7309. container: initialContainer
  7310. }, 'loading');
  7311. initialAppWrapperGetter = getAppWrapperGetter(appInstanceId, !!legacyRender, strictStyleIsolation, scopedCSS, function () {
  7312. return initialAppWrapperElement;
  7313. });
  7314. global = globalContext;
  7315. mountSandbox = function mountSandbox() {
  7316. return Promise.resolve();
  7317. };
  7318. unmountSandbox = function unmountSandbox() {
  7319. return Promise.resolve();
  7320. };
  7321. useLooseSandbox = _typeof(sandbox) === 'object' && !!sandbox.loose;
  7322. if (sandbox) {
  7323. sandboxContainer = createSandboxContainer(appInstanceId, // FIXME should use a strict sandbox logic while remount, see https://github.com/umijs/qiankun/issues/518
  7324. initialAppWrapperGetter, scopedCSS, useLooseSandbox, excludeAssetFilter, global); // 用沙箱的代理对象作为接下来使用的全局对象
  7325. global = sandboxContainer.instance.proxy;
  7326. mountSandbox = sandboxContainer.mount;
  7327. unmountSandbox = sandboxContainer.unmount;
  7328. }
  7329. _mergeWith = mergeWith_1({}, getAddOns(global, assetPublicPath), lifeCycles, function (v1, v2) {
  7330. return concat_1(v1 !== null && v1 !== void 0 ? v1 : [], v2 !== null && v2 !== void 0 ? v2 : []);
  7331. }), _mergeWith$beforeUnmo = _mergeWith.beforeUnmount, beforeUnmount = _mergeWith$beforeUnmo === void 0 ? [] : _mergeWith$beforeUnmo, _mergeWith$afterUnmou = _mergeWith.afterUnmount, afterUnmount = _mergeWith$afterUnmou === void 0 ? [] : _mergeWith$afterUnmou, _mergeWith$afterMount = _mergeWith.afterMount, afterMount = _mergeWith$afterMount === void 0 ? [] : _mergeWith$afterMount, _mergeWith$beforeMoun = _mergeWith.beforeMount, beforeMount = _mergeWith$beforeMoun === void 0 ? [] : _mergeWith$beforeMoun, _mergeWith$beforeLoad = _mergeWith.beforeLoad, beforeLoad = _mergeWith$beforeLoad === void 0 ? [] : _mergeWith$beforeLoad;
  7332. _context17.next = 36;
  7333. return execHooksChain(toArray(beforeLoad), app, global);
  7334. case 36:
  7335. _context17.next = 38;
  7336. return execScripts(global, sandbox && !useLooseSandbox);
  7337. case 38:
  7338. scriptExports = _context17.sent;
  7339. _getLifecyclesFromExp = getLifecyclesFromExports(scriptExports, appName, global, (_sandboxContainer = sandboxContainer) === null || _sandboxContainer === void 0 ? void 0 : (_sandboxContainer$ins = _sandboxContainer.instance) === null || _sandboxContainer$ins === void 0 ? void 0 : _sandboxContainer$ins.latestSetProp), bootstrap = _getLifecyclesFromExp.bootstrap, mount = _getLifecyclesFromExp.mount, unmount = _getLifecyclesFromExp.unmount, update = _getLifecyclesFromExp.update;
  7340. _getMicroAppStateActi = getMicroAppStateActions(appInstanceId), onGlobalStateChange = _getMicroAppStateActi.onGlobalStateChange, setGlobalState = _getMicroAppStateActi.setGlobalState, offGlobalStateChange = _getMicroAppStateActi.offGlobalStateChange; // FIXME temporary way
  7341. syncAppWrapperElement2Sandbox = function syncAppWrapperElement2Sandbox(element) {
  7342. return initialAppWrapperElement = element;
  7343. };
  7344. parcelConfigGetter = function parcelConfigGetter() {
  7345. var remountContainer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialContainer;
  7346. var appWrapperElement;
  7347. var appWrapperGetter;
  7348. var parcelConfig = {
  7349. name: appInstanceId,
  7350. bootstrap: bootstrap,
  7351. mount: [/*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  7352. var marks;
  7353. return regenerator.wrap(function _callee2$(_context2) {
  7354. while (1) {
  7355. switch (_context2.prev = _context2.next) {
  7356. case 0:
  7357. {
  7358. marks = performanceGetEntriesByName(markName, 'mark'); // mark length is zero means the app is remounting
  7359. if (marks && !marks.length) {
  7360. performanceMark(markName);
  7361. }
  7362. }
  7363. case 1:
  7364. case "end":
  7365. return _context2.stop();
  7366. }
  7367. }
  7368. }, _callee2);
  7369. })), /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
  7370. return regenerator.wrap(function _callee3$(_context3) {
  7371. while (1) {
  7372. switch (_context3.prev = _context3.next) {
  7373. case 0:
  7374. _context3.next = 2;
  7375. return validateSingularMode(singular, app);
  7376. case 2:
  7377. _context3.t0 = _context3.sent;
  7378. if (!_context3.t0) {
  7379. _context3.next = 5;
  7380. break;
  7381. }
  7382. _context3.t0 = prevAppUnmountedDeferred;
  7383. case 5:
  7384. if (!_context3.t0) {
  7385. _context3.next = 7;
  7386. break;
  7387. }
  7388. return _context3.abrupt("return", prevAppUnmountedDeferred.promise);
  7389. case 7:
  7390. return _context3.abrupt("return", undefined);
  7391. case 8:
  7392. case "end":
  7393. return _context3.stop();
  7394. }
  7395. }
  7396. }, _callee3);
  7397. })),
  7398. /*#__PURE__*/
  7399. // initial wrapper element before app mount/remount
  7400. _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4() {
  7401. return regenerator.wrap(function _callee4$(_context4) {
  7402. while (1) {
  7403. switch (_context4.prev = _context4.next) {
  7404. case 0:
  7405. appWrapperElement = initialAppWrapperElement;
  7406. appWrapperGetter = getAppWrapperGetter(appInstanceId, !!legacyRender, strictStyleIsolation, scopedCSS, function () {
  7407. return appWrapperElement;
  7408. });
  7409. case 2:
  7410. case "end":
  7411. return _context4.stop();
  7412. }
  7413. }
  7414. }, _callee4);
  7415. })),
  7416. /*#__PURE__*/
  7417. // 添加 mount hook, 确保每次应用加载前容器 dom 结构已经设置完毕
  7418. _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5() {
  7419. var useNewContainer;
  7420. return regenerator.wrap(function _callee5$(_context5) {
  7421. while (1) {
  7422. switch (_context5.prev = _context5.next) {
  7423. case 0:
  7424. useNewContainer = remountContainer !== initialContainer;
  7425. if (useNewContainer || !appWrapperElement) {
  7426. // element will be destroyed after unmounted, we need to recreate it if it not exist
  7427. // or we try to remount into a new container
  7428. appWrapperElement = createElement(appContent, strictStyleIsolation, scopedCSS, appInstanceId);
  7429. syncAppWrapperElement2Sandbox(appWrapperElement);
  7430. }
  7431. render({
  7432. element: appWrapperElement,
  7433. loading: true,
  7434. container: remountContainer
  7435. }, 'mounting');
  7436. case 3:
  7437. case "end":
  7438. return _context5.stop();
  7439. }
  7440. }
  7441. }, _callee5);
  7442. })), mountSandbox,
  7443. /*#__PURE__*/
  7444. // exec the chain after rendering to keep the behavior with beforeLoad
  7445. _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6() {
  7446. return regenerator.wrap(function _callee6$(_context6) {
  7447. while (1) {
  7448. switch (_context6.prev = _context6.next) {
  7449. case 0:
  7450. return _context6.abrupt("return", execHooksChain(toArray(beforeMount), app, global));
  7451. case 1:
  7452. case "end":
  7453. return _context6.stop();
  7454. }
  7455. }
  7456. }, _callee6);
  7457. })), /*#__PURE__*/function () {
  7458. var _ref7 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7(props) {
  7459. return regenerator.wrap(function _callee7$(_context7) {
  7460. while (1) {
  7461. switch (_context7.prev = _context7.next) {
  7462. case 0:
  7463. return _context7.abrupt("return", mount(_objectSpread(_objectSpread({}, props), {}, {
  7464. container: appWrapperGetter(),
  7465. setGlobalState: setGlobalState,
  7466. onGlobalStateChange: onGlobalStateChange
  7467. })));
  7468. case 1:
  7469. case "end":
  7470. return _context7.stop();
  7471. }
  7472. }
  7473. }, _callee7);
  7474. }));
  7475. return function (_x4) {
  7476. return _ref7.apply(this, arguments);
  7477. };
  7478. }(),
  7479. /*#__PURE__*/
  7480. // finish loading after app mounted
  7481. _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee8() {
  7482. return regenerator.wrap(function _callee8$(_context8) {
  7483. while (1) {
  7484. switch (_context8.prev = _context8.next) {
  7485. case 0:
  7486. return _context8.abrupt("return", render({
  7487. element: appWrapperElement,
  7488. loading: false,
  7489. container: remountContainer
  7490. }, 'mounted'));
  7491. case 1:
  7492. case "end":
  7493. return _context8.stop();
  7494. }
  7495. }
  7496. }, _callee8);
  7497. })), /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9() {
  7498. return regenerator.wrap(function _callee9$(_context9) {
  7499. while (1) {
  7500. switch (_context9.prev = _context9.next) {
  7501. case 0:
  7502. return _context9.abrupt("return", execHooksChain(toArray(afterMount), app, global));
  7503. case 1:
  7504. case "end":
  7505. return _context9.stop();
  7506. }
  7507. }
  7508. }, _callee9);
  7509. })),
  7510. /*#__PURE__*/
  7511. // initialize the unmount defer after app mounted and resolve the defer after it unmounted
  7512. _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee10() {
  7513. return regenerator.wrap(function _callee10$(_context10) {
  7514. while (1) {
  7515. switch (_context10.prev = _context10.next) {
  7516. case 0:
  7517. _context10.next = 2;
  7518. return validateSingularMode(singular, app);
  7519. case 2:
  7520. if (!_context10.sent) {
  7521. _context10.next = 4;
  7522. break;
  7523. }
  7524. prevAppUnmountedDeferred = new Deferred();
  7525. case 4:
  7526. case "end":
  7527. return _context10.stop();
  7528. }
  7529. }
  7530. }, _callee10);
  7531. })), /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee11() {
  7532. var measureName;
  7533. return regenerator.wrap(function _callee11$(_context11) {
  7534. while (1) {
  7535. switch (_context11.prev = _context11.next) {
  7536. case 0:
  7537. {
  7538. measureName = "[qiankun] App ".concat(appInstanceId, " Loading Consuming");
  7539. performanceMeasure(measureName, markName);
  7540. }
  7541. case 1:
  7542. case "end":
  7543. return _context11.stop();
  7544. }
  7545. }
  7546. }, _callee11);
  7547. }))],
  7548. unmount: [/*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee12() {
  7549. return regenerator.wrap(function _callee12$(_context12) {
  7550. while (1) {
  7551. switch (_context12.prev = _context12.next) {
  7552. case 0:
  7553. return _context12.abrupt("return", execHooksChain(toArray(beforeUnmount), app, global));
  7554. case 1:
  7555. case "end":
  7556. return _context12.stop();
  7557. }
  7558. }
  7559. }, _callee12);
  7560. })), /*#__PURE__*/function () {
  7561. var _ref13 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee13(props) {
  7562. return regenerator.wrap(function _callee13$(_context13) {
  7563. while (1) {
  7564. switch (_context13.prev = _context13.next) {
  7565. case 0:
  7566. return _context13.abrupt("return", unmount(_objectSpread(_objectSpread({}, props), {}, {
  7567. container: appWrapperGetter()
  7568. })));
  7569. case 1:
  7570. case "end":
  7571. return _context13.stop();
  7572. }
  7573. }
  7574. }, _callee13);
  7575. }));
  7576. return function (_x5) {
  7577. return _ref13.apply(this, arguments);
  7578. };
  7579. }(), unmountSandbox, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee14() {
  7580. return regenerator.wrap(function _callee14$(_context14) {
  7581. while (1) {
  7582. switch (_context14.prev = _context14.next) {
  7583. case 0:
  7584. return _context14.abrupt("return", execHooksChain(toArray(afterUnmount), app, global));
  7585. case 1:
  7586. case "end":
  7587. return _context14.stop();
  7588. }
  7589. }
  7590. }, _callee14);
  7591. })), /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee15() {
  7592. return regenerator.wrap(function _callee15$(_context15) {
  7593. while (1) {
  7594. switch (_context15.prev = _context15.next) {
  7595. case 0:
  7596. render({
  7597. element: null,
  7598. loading: false,
  7599. container: remountContainer
  7600. }, 'unmounted');
  7601. offGlobalStateChange(appInstanceId); // for gc
  7602. appWrapperElement = null;
  7603. syncAppWrapperElement2Sandbox(appWrapperElement);
  7604. case 4:
  7605. case "end":
  7606. return _context15.stop();
  7607. }
  7608. }
  7609. }, _callee15);
  7610. })), /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee16() {
  7611. return regenerator.wrap(function _callee16$(_context16) {
  7612. while (1) {
  7613. switch (_context16.prev = _context16.next) {
  7614. case 0:
  7615. _context16.next = 2;
  7616. return validateSingularMode(singular, app);
  7617. case 2:
  7618. _context16.t0 = _context16.sent;
  7619. if (!_context16.t0) {
  7620. _context16.next = 5;
  7621. break;
  7622. }
  7623. _context16.t0 = prevAppUnmountedDeferred;
  7624. case 5:
  7625. if (!_context16.t0) {
  7626. _context16.next = 7;
  7627. break;
  7628. }
  7629. prevAppUnmountedDeferred.resolve();
  7630. case 7:
  7631. case "end":
  7632. return _context16.stop();
  7633. }
  7634. }
  7635. }, _callee16);
  7636. }))]
  7637. };
  7638. if (typeof update === 'function') {
  7639. parcelConfig.update = update;
  7640. }
  7641. return parcelConfig;
  7642. };
  7643. return _context17.abrupt("return", parcelConfigGetter);
  7644. case 44:
  7645. case "end":
  7646. return _context17.stop();
  7647. }
  7648. }
  7649. }, _callee17);
  7650. }));
  7651. return _loadApp.apply(this, arguments);
  7652. }
  7653. var requestIdleCallback$1 = window.requestIdleCallback || function requestIdleCallback(cb) {
  7654. var start = Date.now();
  7655. return setTimeout(function () {
  7656. cb({
  7657. didTimeout: false,
  7658. timeRemaining: function timeRemaining() {
  7659. return Math.max(0, 50 - (Date.now() - start));
  7660. }
  7661. });
  7662. }, 1);
  7663. };
  7664. var isSlowNetwork = navigator.connection ? navigator.connection.saveData || navigator.connection.type !== 'wifi' && navigator.connection.type !== 'ethernet' && /([23])g/.test(navigator.connection.effectiveType) : false;
  7665. /**
  7666. * prefetch assets, do nothing while in mobile network
  7667. * @param entry
  7668. * @param opts
  7669. */
  7670. function prefetch(entry, opts) {
  7671. if (!navigator.onLine || isSlowNetwork) {
  7672. // Don't prefetch if in a slow network or offline
  7673. return;
  7674. }
  7675. requestIdleCallback$1( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  7676. var _yield$importEntry, getExternalScripts, getExternalStyleSheets;
  7677. return regenerator.wrap(function _callee$(_context) {
  7678. while (1) {
  7679. switch (_context.prev = _context.next) {
  7680. case 0:
  7681. _context.next = 2;
  7682. return importEntry(entry, opts);
  7683. case 2:
  7684. _yield$importEntry = _context.sent;
  7685. getExternalScripts = _yield$importEntry.getExternalScripts;
  7686. getExternalStyleSheets = _yield$importEntry.getExternalStyleSheets;
  7687. requestIdleCallback$1(getExternalStyleSheets);
  7688. requestIdleCallback$1(getExternalScripts);
  7689. case 7:
  7690. case "end":
  7691. return _context.stop();
  7692. }
  7693. }
  7694. }, _callee);
  7695. })));
  7696. }
  7697. function prefetchAfterFirstMounted(apps, opts) {
  7698. window.addEventListener('single-spa:first-mount', function listener() {
  7699. var notLoadedApps = apps.filter(function (app) {
  7700. return Pt(app.name) === l;
  7701. });
  7702. {
  7703. var mountedApps = Et();
  7704. console.log("[qiankun] prefetch starting after ".concat(mountedApps, " mounted..."), notLoadedApps);
  7705. }
  7706. notLoadedApps.forEach(function (_ref2) {
  7707. var entry = _ref2.entry;
  7708. return prefetch(entry, opts);
  7709. });
  7710. window.removeEventListener('single-spa:first-mount', listener);
  7711. });
  7712. }
  7713. function prefetchImmediately(apps, opts) {
  7714. {
  7715. console.log('[qiankun] prefetch starting for apps...', apps);
  7716. }
  7717. apps.forEach(function (_ref3) {
  7718. var entry = _ref3.entry;
  7719. return prefetch(entry, opts);
  7720. });
  7721. }
  7722. function doPrefetchStrategy(apps, prefetchStrategy, importEntryOpts) {
  7723. var appsName2Apps = function appsName2Apps(names) {
  7724. return apps.filter(function (app) {
  7725. return names.includes(app.name);
  7726. });
  7727. };
  7728. if (Array.isArray(prefetchStrategy)) {
  7729. prefetchAfterFirstMounted(appsName2Apps(prefetchStrategy), importEntryOpts);
  7730. } else if (isFunction_1(prefetchStrategy)) {
  7731. _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  7732. var _yield$prefetchStrate, _yield$prefetchStrate2, criticalAppNames, _yield$prefetchStrate3, minorAppsName;
  7733. return regenerator.wrap(function _callee2$(_context2) {
  7734. while (1) {
  7735. switch (_context2.prev = _context2.next) {
  7736. case 0:
  7737. _context2.next = 2;
  7738. return prefetchStrategy(apps);
  7739. case 2:
  7740. _yield$prefetchStrate = _context2.sent;
  7741. _yield$prefetchStrate2 = _yield$prefetchStrate.criticalAppNames;
  7742. criticalAppNames = _yield$prefetchStrate2 === void 0 ? [] : _yield$prefetchStrate2;
  7743. _yield$prefetchStrate3 = _yield$prefetchStrate.minorAppsName;
  7744. minorAppsName = _yield$prefetchStrate3 === void 0 ? [] : _yield$prefetchStrate3;
  7745. prefetchImmediately(appsName2Apps(criticalAppNames), importEntryOpts);
  7746. prefetchAfterFirstMounted(appsName2Apps(minorAppsName), importEntryOpts);
  7747. case 9:
  7748. case "end":
  7749. return _context2.stop();
  7750. }
  7751. }
  7752. }, _callee2);
  7753. }))();
  7754. } else {
  7755. switch (prefetchStrategy) {
  7756. case true:
  7757. prefetchAfterFirstMounted(apps, importEntryOpts);
  7758. break;
  7759. case 'all':
  7760. prefetchImmediately(apps, importEntryOpts);
  7761. break;
  7762. }
  7763. }
  7764. }
  7765. var _excluded$1 = ["name", "activeRule", "loader", "props"],
  7766. _excluded2 = ["mount"],
  7767. _excluded3 = ["prefetch", "sandbox", "singular", "urlRerouteOnly"];
  7768. var microApps = [];
  7769. var frameworkConfiguration = {};
  7770. var started = false;
  7771. var defaultUrlRerouteOnly = true;
  7772. var frameworkStartedDefer = new Deferred();
  7773. var autoDowngradeForLowVersionBrowser = function autoDowngradeForLowVersionBrowser(configuration) {
  7774. var sandbox = configuration.sandbox,
  7775. singular = configuration.singular;
  7776. if (sandbox) {
  7777. if (!window.Proxy) {
  7778. console.warn('[qiankun] Miss window.Proxy, proxySandbox will degenerate into snapshotSandbox');
  7779. if (singular === false) {
  7780. console.warn('[qiankun] Setting singular as false may cause unexpected behavior while your browser not support window.Proxy');
  7781. }
  7782. return _objectSpread(_objectSpread({}, configuration), {}, {
  7783. sandbox: _typeof(sandbox) === 'object' ? _objectSpread(_objectSpread({}, sandbox), {}, {
  7784. loose: true
  7785. }) : {
  7786. loose: true
  7787. }
  7788. });
  7789. }
  7790. }
  7791. return configuration;
  7792. };
  7793. function registerMicroApps(apps, lifeCycles) {
  7794. // Each app only needs to be registered once
  7795. var unregisteredApps = apps.filter(function (app) {
  7796. return !microApps.some(function (registeredApp) {
  7797. return registeredApp.name === app.name;
  7798. });
  7799. });
  7800. microApps = [].concat(_toConsumableArray(microApps), _toConsumableArray(unregisteredApps));
  7801. unregisteredApps.forEach(function (app) {
  7802. var name = app.name,
  7803. activeRule = app.activeRule,
  7804. _app$loader = app.loader,
  7805. loader = _app$loader === void 0 ? noop_1 : _app$loader,
  7806. props = app.props,
  7807. appConfig = _objectWithoutProperties(app, _excluded$1);
  7808. Ot({
  7809. name: name,
  7810. app: function () {
  7811. var _app = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
  7812. var _yield$loadApp, mount, otherMicroAppConfigs;
  7813. return regenerator.wrap(function _callee3$(_context3) {
  7814. while (1) {
  7815. switch (_context3.prev = _context3.next) {
  7816. case 0:
  7817. loader(true);
  7818. _context3.next = 3;
  7819. return frameworkStartedDefer.promise;
  7820. case 3:
  7821. _context3.next = 5;
  7822. return loadApp(_objectSpread({
  7823. name: name,
  7824. props: props
  7825. }, appConfig), frameworkConfiguration, lifeCycles);
  7826. case 5:
  7827. _context3.t0 = _context3.sent;
  7828. _yield$loadApp = (0, _context3.t0)();
  7829. mount = _yield$loadApp.mount;
  7830. otherMicroAppConfigs = _objectWithoutProperties(_yield$loadApp, _excluded2);
  7831. return _context3.abrupt("return", _objectSpread({
  7832. mount: [/*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
  7833. return regenerator.wrap(function _callee$(_context) {
  7834. while (1) {
  7835. switch (_context.prev = _context.next) {
  7836. case 0:
  7837. return _context.abrupt("return", loader(true));
  7838. case 1:
  7839. case "end":
  7840. return _context.stop();
  7841. }
  7842. }
  7843. }, _callee);
  7844. }))].concat(_toConsumableArray(toArray(mount)), [/*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
  7845. return regenerator.wrap(function _callee2$(_context2) {
  7846. while (1) {
  7847. switch (_context2.prev = _context2.next) {
  7848. case 0:
  7849. return _context2.abrupt("return", loader(false));
  7850. case 1:
  7851. case "end":
  7852. return _context2.stop();
  7853. }
  7854. }
  7855. }, _callee2);
  7856. }))])
  7857. }, otherMicroAppConfigs));
  7858. case 10:
  7859. case "end":
  7860. return _context3.stop();
  7861. }
  7862. }
  7863. }, _callee3);
  7864. }));
  7865. function app() {
  7866. return _app.apply(this, arguments);
  7867. }
  7868. return app;
  7869. }(),
  7870. activeWhen: activeRule,
  7871. customProps: props
  7872. });
  7873. });
  7874. }
  7875. var appConfigPromiseGetterMap = new Map();
  7876. var containerMicroAppsMap = new Map();
  7877. function loadMicroApp(app, configuration, lifeCycles) {
  7878. var props = app.props,
  7879. name = app.name;
  7880. var container = 'container' in app ? app.container : undefined; // Must compute the container xpath at beginning to keep it consist around app running
  7881. // If we compute it every time, the container dom structure most probably been changed and result in a different xpath value
  7882. var containerXPath = getContainerXPath(container);
  7883. var appContainerXPathKey = "".concat(name, "-").concat(containerXPath);
  7884. var microApp;
  7885. var wrapParcelConfigForRemount = function wrapParcelConfigForRemount(config) {
  7886. var microAppConfig = config;
  7887. if (container) {
  7888. if (containerXPath) {
  7889. var containerMicroApps = containerMicroAppsMap.get(appContainerXPathKey);
  7890. if (containerMicroApps === null || containerMicroApps === void 0 ? void 0 : containerMicroApps.length) {
  7891. var mount = [/*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4() {
  7892. var prevLoadMicroApps, prevLoadMicroAppsWhichNotBroken;
  7893. return regenerator.wrap(function _callee4$(_context4) {
  7894. while (1) {
  7895. switch (_context4.prev = _context4.next) {
  7896. case 0:
  7897. // While there are multiple micro apps mounted on the same container, we must wait until the prev instances all had unmounted
  7898. // Otherwise it will lead some concurrent issues
  7899. prevLoadMicroApps = containerMicroApps.slice(0, containerMicroApps.indexOf(microApp));
  7900. prevLoadMicroAppsWhichNotBroken = prevLoadMicroApps.filter(function (v) {
  7901. return v.getStatus() !== 'LOAD_ERROR' && v.getStatus() !== 'SKIP_BECAUSE_BROKEN';
  7902. });
  7903. _context4.next = 4;
  7904. return Promise.all(prevLoadMicroAppsWhichNotBroken.map(function (v) {
  7905. return v.unmountPromise;
  7906. }));
  7907. case 4:
  7908. case "end":
  7909. return _context4.stop();
  7910. }
  7911. }
  7912. }, _callee4);
  7913. }))].concat(_toConsumableArray(toArray(microAppConfig.mount)));
  7914. microAppConfig = _objectSpread(_objectSpread({}, config), {}, {
  7915. mount: mount
  7916. });
  7917. }
  7918. }
  7919. }
  7920. return _objectSpread(_objectSpread({}, microAppConfig), {}, {
  7921. // empty bootstrap hook which should not run twice while it calling from cached micro app
  7922. bootstrap: function bootstrap() {
  7923. return Promise.resolve();
  7924. }
  7925. });
  7926. };
  7927. /**
  7928. * using name + container xpath as the micro app instance id,
  7929. * it means if you rendering a micro app to a dom which have been rendered before,
  7930. * the micro app would not load and evaluate its lifecycles again
  7931. */
  7932. var memorizedLoadingFn = /*#__PURE__*/function () {
  7933. var _ref4 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5() {
  7934. var userConfiguration, $$cacheLifecycleByAppName, parcelConfigGetterPromise, _parcelConfigGetterPromise, parcelConfigObjectGetterPromise;
  7935. return regenerator.wrap(function _callee5$(_context5) {
  7936. while (1) {
  7937. switch (_context5.prev = _context5.next) {
  7938. case 0:
  7939. userConfiguration = autoDowngradeForLowVersionBrowser(configuration !== null && configuration !== void 0 ? configuration : _objectSpread(_objectSpread({}, frameworkConfiguration), {}, {
  7940. singular: false
  7941. }));
  7942. $$cacheLifecycleByAppName = userConfiguration.$$cacheLifecycleByAppName;
  7943. if (!container) {
  7944. _context5.next = 21;
  7945. break;
  7946. }
  7947. if (!$$cacheLifecycleByAppName) {
  7948. _context5.next = 12;
  7949. break;
  7950. }
  7951. parcelConfigGetterPromise = appConfigPromiseGetterMap.get(name);
  7952. if (!parcelConfigGetterPromise) {
  7953. _context5.next = 12;
  7954. break;
  7955. }
  7956. _context5.t0 = wrapParcelConfigForRemount;
  7957. _context5.next = 9;
  7958. return parcelConfigGetterPromise;
  7959. case 9:
  7960. _context5.t1 = _context5.sent;
  7961. _context5.t2 = (0, _context5.t1)(container);
  7962. return _context5.abrupt("return", (0, _context5.t0)(_context5.t2));
  7963. case 12:
  7964. if (!containerXPath) {
  7965. _context5.next = 21;
  7966. break;
  7967. }
  7968. _parcelConfigGetterPromise = appConfigPromiseGetterMap.get(appContainerXPathKey);
  7969. if (!_parcelConfigGetterPromise) {
  7970. _context5.next = 21;
  7971. break;
  7972. }
  7973. _context5.t3 = wrapParcelConfigForRemount;
  7974. _context5.next = 18;
  7975. return _parcelConfigGetterPromise;
  7976. case 18:
  7977. _context5.t4 = _context5.sent;
  7978. _context5.t5 = (0, _context5.t4)(container);
  7979. return _context5.abrupt("return", (0, _context5.t3)(_context5.t5));
  7980. case 21:
  7981. parcelConfigObjectGetterPromise = loadApp(app, userConfiguration, lifeCycles);
  7982. if (container) {
  7983. if ($$cacheLifecycleByAppName) {
  7984. appConfigPromiseGetterMap.set(name, parcelConfigObjectGetterPromise);
  7985. } else if (containerXPath) appConfigPromiseGetterMap.set(appContainerXPathKey, parcelConfigObjectGetterPromise);
  7986. }
  7987. _context5.next = 25;
  7988. return parcelConfigObjectGetterPromise;
  7989. case 25:
  7990. _context5.t6 = _context5.sent;
  7991. return _context5.abrupt("return", (0, _context5.t6)(container));
  7992. case 27:
  7993. case "end":
  7994. return _context5.stop();
  7995. }
  7996. }
  7997. }, _callee5);
  7998. }));
  7999. return function memorizedLoadingFn() {
  8000. return _ref4.apply(this, arguments);
  8001. };
  8002. }();
  8003. if (!started && (configuration === null || configuration === void 0 ? void 0 : configuration.autoStart) !== false) {
  8004. var _frameworkConfigurati;
  8005. // We need to invoke start method of single-spa as the popstate event should be dispatched while the main app calling pushState/replaceState automatically,
  8006. // but in single-spa it will check the start status before it dispatch popstate
  8007. // see https://github.com/single-spa/single-spa/blob/f28b5963be1484583a072c8145ac0b5a28d91235/src/navigation/navigation-events.js#L101
  8008. // ref https://github.com/umijs/qiankun/pull/1071
  8009. xt({
  8010. urlRerouteOnly: (_frameworkConfigurati = frameworkConfiguration.urlRerouteOnly) !== null && _frameworkConfigurati !== void 0 ? _frameworkConfigurati : defaultUrlRerouteOnly
  8011. });
  8012. }
  8013. microApp = C(memorizedLoadingFn, _objectSpread({
  8014. domElement: document.createElement('div')
  8015. }, props));
  8016. if (container) {
  8017. if (containerXPath) {
  8018. // Store the microApps which they mounted on the same container
  8019. var microAppsRef = containerMicroAppsMap.get(appContainerXPathKey) || [];
  8020. microAppsRef.push(microApp);
  8021. containerMicroAppsMap.set(appContainerXPathKey, microAppsRef);
  8022. var cleanup = function cleanup() {
  8023. var index = microAppsRef.indexOf(microApp);
  8024. microAppsRef.splice(index, 1); // @ts-ignore
  8025. microApp = null;
  8026. }; // gc after unmount
  8027. microApp.unmountPromise.then(cleanup).catch(cleanup);
  8028. }
  8029. }
  8030. return microApp;
  8031. }
  8032. function start() {
  8033. var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  8034. frameworkConfiguration = _objectSpread({
  8035. prefetch: true,
  8036. singular: true,
  8037. sandbox: true
  8038. }, opts);
  8039. var _frameworkConfigurati2 = frameworkConfiguration,
  8040. prefetch = _frameworkConfigurati2.prefetch,
  8041. sandbox = _frameworkConfigurati2.sandbox,
  8042. singular = _frameworkConfigurati2.singular,
  8043. _frameworkConfigurati3 = _frameworkConfigurati2.urlRerouteOnly,
  8044. urlRerouteOnly = _frameworkConfigurati3 === void 0 ? defaultUrlRerouteOnly : _frameworkConfigurati3,
  8045. importEntryOpts = _objectWithoutProperties(_frameworkConfigurati2, _excluded3);
  8046. if (prefetch) {
  8047. doPrefetchStrategy(microApps, prefetch, importEntryOpts);
  8048. }
  8049. frameworkConfiguration = autoDowngradeForLowVersionBrowser(frameworkConfiguration);
  8050. xt({
  8051. urlRerouteOnly: urlRerouteOnly
  8052. });
  8053. started = true;
  8054. frameworkStartedDefer.resolve();
  8055. }
  8056. /**
  8057. * @author Kuitos
  8058. * @since 2020-02-21
  8059. */
  8060. function addGlobalUncaughtErrorHandler(errorHandler) {
  8061. window.addEventListener('error', errorHandler);
  8062. window.addEventListener('unhandledrejection', errorHandler);
  8063. }
  8064. function removeGlobalUncaughtErrorHandler(errorHandler) {
  8065. window.removeEventListener('error', errorHandler);
  8066. window.removeEventListener('unhandledrejection', errorHandler);
  8067. }
  8068. /**
  8069. * @author Kuitos
  8070. * @since 2019-02-19
  8071. */
  8072. var firstMountLogLabel = '[qiankun] first app mounted';
  8073. {
  8074. console.time(firstMountLogLabel);
  8075. }
  8076. function setDefaultMountApp(defaultAppLink) {
  8077. // can not use addEventListener once option for ie support
  8078. window.addEventListener('single-spa:no-app-change', function listener() {
  8079. var mountedApps = Et();
  8080. if (!mountedApps.length) {
  8081. nt(defaultAppLink);
  8082. }
  8083. window.removeEventListener('single-spa:no-app-change', listener);
  8084. });
  8085. }
  8086. function runDefaultMountEffects(defaultAppLink) {
  8087. console.warn('[qiankun] runDefaultMountEffects will be removed in next version, please use setDefaultMountApp instead');
  8088. setDefaultMountApp(defaultAppLink);
  8089. }
  8090. function runAfterFirstMounted(effect) {
  8091. // can not use addEventListener once option for ie support
  8092. window.addEventListener('single-spa:first-mount', function listener() {
  8093. {
  8094. console.timeEnd(firstMountLogLabel);
  8095. }
  8096. effect();
  8097. window.removeEventListener('single-spa:first-mount', listener);
  8098. });
  8099. }
  8100. exports.__internalGetCurrentRunningApp = getCurrentRunningApp;
  8101. exports.addErrorHandler = a;
  8102. exports.addGlobalUncaughtErrorHandler = addGlobalUncaughtErrorHandler;
  8103. exports.initGlobalState = initGlobalState;
  8104. exports.loadMicroApp = loadMicroApp;
  8105. exports.prefetchApps = prefetchImmediately;
  8106. exports.registerMicroApps = registerMicroApps;
  8107. exports.removeErrorHandler = c;
  8108. exports.removeGlobalUncaughtErrorHandler = removeGlobalUncaughtErrorHandler;
  8109. exports.runAfterFirstMounted = runAfterFirstMounted;
  8110. exports.runDefaultMountEffects = runDefaultMountEffects;
  8111. exports.setDefaultMountApp = setDefaultMountApp;
  8112. exports.start = start;
  8113. Object.defineProperty(exports, '__esModule', { value: true });
  8114. })));
  8115. //# sourceMappingURL=index.umd.js.map