123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507 |
- (function (global, factory) {
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
- typeof define === 'function' && define.amd ? define(['exports'], factory) :
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.qiankun = {}));
- }(this, (function (exports) { 'use strict';
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
- function getDefaultExportFromCjs (x) {
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
- }
- function createCommonjsModule(fn, basedir, module) {
- return module = {
- path: basedir,
- exports: {},
- require: function (path, base) {
- return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
- }
- }, fn(module, module.exports), module.exports;
- }
- function commonjsRequire () {
- throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
- }
- var runtime_1 = createCommonjsModule(function (module) {
- /**
- * Copyright (c) 2014-present, Facebook, Inc.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
- var runtime = (function (exports) {
- var Op = Object.prototype;
- var hasOwn = Op.hasOwnProperty;
- var undefined$1; // More compressible than void 0.
- var $Symbol = typeof Symbol === "function" ? Symbol : {};
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
- var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
- var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
- function define(obj, key, value) {
- Object.defineProperty(obj, key, {
- value: value,
- enumerable: true,
- configurable: true,
- writable: true
- });
- return obj[key];
- }
- try {
- // IE 8 has a broken Object.defineProperty that only works on DOM objects.
- define({}, "");
- } catch (err) {
- define = function(obj, key, value) {
- return obj[key] = value;
- };
- }
- function wrap(innerFn, outerFn, self, tryLocsList) {
- // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
- var generator = Object.create(protoGenerator.prototype);
- var context = new Context(tryLocsList || []);
- // The ._invoke method unifies the implementations of the .next,
- // .throw, and .return methods.
- generator._invoke = makeInvokeMethod(innerFn, self, context);
- return generator;
- }
- exports.wrap = wrap;
- // Try/catch helper to minimize deoptimizations. Returns a completion
- // record like context.tryEntries[i].completion. This interface could
- // have been (and was previously) designed to take a closure to be
- // invoked without arguments, but in all the cases we care about we
- // already have an existing method we want to call, so there's no need
- // to create a new function object. We can even get away with assuming
- // the method takes exactly one argument, since that happens to be true
- // in every case, so we don't have to touch the arguments object. The
- // only additional allocation required is the completion record, which
- // has a stable shape and so hopefully should be cheap to allocate.
- function tryCatch(fn, obj, arg) {
- try {
- return { type: "normal", arg: fn.call(obj, arg) };
- } catch (err) {
- return { type: "throw", arg: err };
- }
- }
- var GenStateSuspendedStart = "suspendedStart";
- var GenStateSuspendedYield = "suspendedYield";
- var GenStateExecuting = "executing";
- var GenStateCompleted = "completed";
- // Returning this object from the innerFn has the same effect as
- // breaking out of the dispatch switch statement.
- var ContinueSentinel = {};
- // Dummy constructor functions that we use as the .constructor and
- // .constructor.prototype properties for functions that return Generator
- // objects. For full spec compliance, you may wish to configure your
- // minifier not to mangle the names of these two functions.
- function Generator() {}
- function GeneratorFunction() {}
- function GeneratorFunctionPrototype() {}
- // This is a polyfill for %IteratorPrototype% for environments that
- // don't natively support it.
- var IteratorPrototype = {};
- define(IteratorPrototype, iteratorSymbol, function () {
- return this;
- });
- var getProto = Object.getPrototypeOf;
- var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
- if (NativeIteratorPrototype &&
- NativeIteratorPrototype !== Op &&
- hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
- // This environment has a native %IteratorPrototype%; use it instead
- // of the polyfill.
- IteratorPrototype = NativeIteratorPrototype;
- }
- var Gp = GeneratorFunctionPrototype.prototype =
- Generator.prototype = Object.create(IteratorPrototype);
- GeneratorFunction.prototype = GeneratorFunctionPrototype;
- define(Gp, "constructor", GeneratorFunctionPrototype);
- define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
- GeneratorFunction.displayName = define(
- GeneratorFunctionPrototype,
- toStringTagSymbol,
- "GeneratorFunction"
- );
- // Helper for defining the .next, .throw, and .return methods of the
- // Iterator interface in terms of a single ._invoke method.
- function defineIteratorMethods(prototype) {
- ["next", "throw", "return"].forEach(function(method) {
- define(prototype, method, function(arg) {
- return this._invoke(method, arg);
- });
- });
- }
- exports.isGeneratorFunction = function(genFun) {
- var ctor = typeof genFun === "function" && genFun.constructor;
- return ctor
- ? ctor === GeneratorFunction ||
- // For the native GeneratorFunction constructor, the best we can
- // do is to check its .name property.
- (ctor.displayName || ctor.name) === "GeneratorFunction"
- : false;
- };
- exports.mark = function(genFun) {
- if (Object.setPrototypeOf) {
- Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
- } else {
- genFun.__proto__ = GeneratorFunctionPrototype;
- define(genFun, toStringTagSymbol, "GeneratorFunction");
- }
- genFun.prototype = Object.create(Gp);
- return genFun;
- };
- // Within the body of any async function, `await x` is transformed to
- // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
- // `hasOwn.call(value, "__await")` to determine if the yielded value is
- // meant to be awaited.
- exports.awrap = function(arg) {
- return { __await: arg };
- };
- function AsyncIterator(generator, PromiseImpl) {
- function invoke(method, arg, resolve, reject) {
- var record = tryCatch(generator[method], generator, arg);
- if (record.type === "throw") {
- reject(record.arg);
- } else {
- var result = record.arg;
- var value = result.value;
- if (value &&
- typeof value === "object" &&
- hasOwn.call(value, "__await")) {
- return PromiseImpl.resolve(value.__await).then(function(value) {
- invoke("next", value, resolve, reject);
- }, function(err) {
- invoke("throw", err, resolve, reject);
- });
- }
- return PromiseImpl.resolve(value).then(function(unwrapped) {
- // When a yielded Promise is resolved, its final value becomes
- // the .value of the Promise<{value,done}> result for the
- // current iteration.
- result.value = unwrapped;
- resolve(result);
- }, function(error) {
- // If a rejected Promise was yielded, throw the rejection back
- // into the async generator function so it can be handled there.
- return invoke("throw", error, resolve, reject);
- });
- }
- }
- var previousPromise;
- function enqueue(method, arg) {
- function callInvokeWithMethodAndArg() {
- return new PromiseImpl(function(resolve, reject) {
- invoke(method, arg, resolve, reject);
- });
- }
- return previousPromise =
- // If enqueue has been called before, then we want to wait until
- // all previous Promises have been resolved before calling invoke,
- // so that results are always delivered in the correct order. If
- // enqueue has not been called before, then it is important to
- // call invoke immediately, without waiting on a callback to fire,
- // so that the async generator function has the opportunity to do
- // any necessary setup in a predictable way. This predictability
- // is why the Promise constructor synchronously invokes its
- // executor callback, and why async functions synchronously
- // execute code before the first await. Since we implement simple
- // async functions in terms of async generators, it is especially
- // important to get this right, even though it requires care.
- previousPromise ? previousPromise.then(
- callInvokeWithMethodAndArg,
- // Avoid propagating failures to Promises returned by later
- // invocations of the iterator.
- callInvokeWithMethodAndArg
- ) : callInvokeWithMethodAndArg();
- }
- // Define the unified helper method that is used to implement .next,
- // .throw, and .return (see defineIteratorMethods).
- this._invoke = enqueue;
- }
- defineIteratorMethods(AsyncIterator.prototype);
- define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
- return this;
- });
- exports.AsyncIterator = AsyncIterator;
- // Note that simple async functions are implemented on top of
- // AsyncIterator objects; they just return a Promise for the value of
- // the final result produced by the iterator.
- exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
- if (PromiseImpl === void 0) PromiseImpl = Promise;
- var iter = new AsyncIterator(
- wrap(innerFn, outerFn, self, tryLocsList),
- PromiseImpl
- );
- return exports.isGeneratorFunction(outerFn)
- ? iter // If outerFn is a generator, return the full iterator.
- : iter.next().then(function(result) {
- return result.done ? result.value : iter.next();
- });
- };
- function makeInvokeMethod(innerFn, self, context) {
- var state = GenStateSuspendedStart;
- return function invoke(method, arg) {
- if (state === GenStateExecuting) {
- throw new Error("Generator is already running");
- }
- if (state === GenStateCompleted) {
- if (method === "throw") {
- throw arg;
- }
- // Be forgiving, per 25.3.3.3.3 of the spec:
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
- return doneResult();
- }
- context.method = method;
- context.arg = arg;
- while (true) {
- var delegate = context.delegate;
- if (delegate) {
- var delegateResult = maybeInvokeDelegate(delegate, context);
- if (delegateResult) {
- if (delegateResult === ContinueSentinel) continue;
- return delegateResult;
- }
- }
- if (context.method === "next") {
- // Setting context._sent for legacy support of Babel's
- // function.sent implementation.
- context.sent = context._sent = context.arg;
- } else if (context.method === "throw") {
- if (state === GenStateSuspendedStart) {
- state = GenStateCompleted;
- throw context.arg;
- }
- context.dispatchException(context.arg);
- } else if (context.method === "return") {
- context.abrupt("return", context.arg);
- }
- state = GenStateExecuting;
- var record = tryCatch(innerFn, self, context);
- if (record.type === "normal") {
- // If an exception is thrown from innerFn, we leave state ===
- // GenStateExecuting and loop back for another invocation.
- state = context.done
- ? GenStateCompleted
- : GenStateSuspendedYield;
- if (record.arg === ContinueSentinel) {
- continue;
- }
- return {
- value: record.arg,
- done: context.done
- };
- } else if (record.type === "throw") {
- state = GenStateCompleted;
- // Dispatch the exception by looping back around to the
- // context.dispatchException(context.arg) call above.
- context.method = "throw";
- context.arg = record.arg;
- }
- }
- };
- }
- // Call delegate.iterator[context.method](context.arg) and handle the
- // result, either by returning a { value, done } result from the
- // delegate iterator, or by modifying context.method and context.arg,
- // setting context.delegate to null, and returning the ContinueSentinel.
- function maybeInvokeDelegate(delegate, context) {
- var method = delegate.iterator[context.method];
- if (method === undefined$1) {
- // A .throw or .return when the delegate iterator has no .throw
- // method always terminates the yield* loop.
- context.delegate = null;
- if (context.method === "throw") {
- // Note: ["return"] must be used for ES3 parsing compatibility.
- if (delegate.iterator["return"]) {
- // If the delegate iterator has a return method, give it a
- // chance to clean up.
- context.method = "return";
- context.arg = undefined$1;
- maybeInvokeDelegate(delegate, context);
- if (context.method === "throw") {
- // If maybeInvokeDelegate(context) changed context.method from
- // "return" to "throw", let that override the TypeError below.
- return ContinueSentinel;
- }
- }
- context.method = "throw";
- context.arg = new TypeError(
- "The iterator does not provide a 'throw' method");
- }
- return ContinueSentinel;
- }
- var record = tryCatch(method, delegate.iterator, context.arg);
- if (record.type === "throw") {
- context.method = "throw";
- context.arg = record.arg;
- context.delegate = null;
- return ContinueSentinel;
- }
- var info = record.arg;
- if (! info) {
- context.method = "throw";
- context.arg = new TypeError("iterator result is not an object");
- context.delegate = null;
- return ContinueSentinel;
- }
- if (info.done) {
- // Assign the result of the finished delegate to the temporary
- // variable specified by delegate.resultName (see delegateYield).
- context[delegate.resultName] = info.value;
- // Resume execution at the desired location (see delegateYield).
- context.next = delegate.nextLoc;
- // If context.method was "throw" but the delegate handled the
- // exception, let the outer generator proceed normally. If
- // context.method was "next", forget context.arg since it has been
- // "consumed" by the delegate iterator. If context.method was
- // "return", allow the original .return call to continue in the
- // outer generator.
- if (context.method !== "return") {
- context.method = "next";
- context.arg = undefined$1;
- }
- } else {
- // Re-yield the result returned by the delegate method.
- return info;
- }
- // The delegate iterator is finished, so forget it and continue with
- // the outer generator.
- context.delegate = null;
- return ContinueSentinel;
- }
- // Define Generator.prototype.{next,throw,return} in terms of the
- // unified ._invoke helper method.
- defineIteratorMethods(Gp);
- define(Gp, toStringTagSymbol, "Generator");
- // A Generator should always return itself as the iterator object when the
- // @@iterator function is called on it. Some browsers' implementations of the
- // iterator prototype chain incorrectly implement this, causing the Generator
- // object to not be returned from this call. This ensures that doesn't happen.
- // See https://github.com/facebook/regenerator/issues/274 for more details.
- define(Gp, iteratorSymbol, function() {
- return this;
- });
- define(Gp, "toString", function() {
- return "[object Generator]";
- });
- function pushTryEntry(locs) {
- var entry = { tryLoc: locs[0] };
- if (1 in locs) {
- entry.catchLoc = locs[1];
- }
- if (2 in locs) {
- entry.finallyLoc = locs[2];
- entry.afterLoc = locs[3];
- }
- this.tryEntries.push(entry);
- }
- function resetTryEntry(entry) {
- var record = entry.completion || {};
- record.type = "normal";
- delete record.arg;
- entry.completion = record;
- }
- function Context(tryLocsList) {
- // The root entry object (effectively a try statement without a catch
- // or a finally block) gives us a place to store values thrown from
- // locations where there is no enclosing try statement.
- this.tryEntries = [{ tryLoc: "root" }];
- tryLocsList.forEach(pushTryEntry, this);
- this.reset(true);
- }
- exports.keys = function(object) {
- var keys = [];
- for (var key in object) {
- keys.push(key);
- }
- keys.reverse();
- // Rather than returning an object with a next method, we keep
- // things simple and return the next function itself.
- return function next() {
- while (keys.length) {
- var key = keys.pop();
- if (key in object) {
- next.value = key;
- next.done = false;
- return next;
- }
- }
- // To avoid creating an additional object, we just hang the .value
- // and .done properties off the next function object itself. This
- // also ensures that the minifier will not anonymize the function.
- next.done = true;
- return next;
- };
- };
- function values(iterable) {
- if (iterable) {
- var iteratorMethod = iterable[iteratorSymbol];
- if (iteratorMethod) {
- return iteratorMethod.call(iterable);
- }
- if (typeof iterable.next === "function") {
- return iterable;
- }
- if (!isNaN(iterable.length)) {
- var i = -1, next = function next() {
- while (++i < iterable.length) {
- if (hasOwn.call(iterable, i)) {
- next.value = iterable[i];
- next.done = false;
- return next;
- }
- }
- next.value = undefined$1;
- next.done = true;
- return next;
- };
- return next.next = next;
- }
- }
- // Return an iterator with no values.
- return { next: doneResult };
- }
- exports.values = values;
- function doneResult() {
- return { value: undefined$1, done: true };
- }
- Context.prototype = {
- constructor: Context,
- reset: function(skipTempReset) {
- this.prev = 0;
- this.next = 0;
- // Resetting context._sent for legacy support of Babel's
- // function.sent implementation.
- this.sent = this._sent = undefined$1;
- this.done = false;
- this.delegate = null;
- this.method = "next";
- this.arg = undefined$1;
- this.tryEntries.forEach(resetTryEntry);
- if (!skipTempReset) {
- for (var name in this) {
- // Not sure about the optimal order of these conditions:
- if (name.charAt(0) === "t" &&
- hasOwn.call(this, name) &&
- !isNaN(+name.slice(1))) {
- this[name] = undefined$1;
- }
- }
- }
- },
- stop: function() {
- this.done = true;
- var rootEntry = this.tryEntries[0];
- var rootRecord = rootEntry.completion;
- if (rootRecord.type === "throw") {
- throw rootRecord.arg;
- }
- return this.rval;
- },
- dispatchException: function(exception) {
- if (this.done) {
- throw exception;
- }
- var context = this;
- function handle(loc, caught) {
- record.type = "throw";
- record.arg = exception;
- context.next = loc;
- if (caught) {
- // If the dispatched exception was caught by a catch block,
- // then let that catch block handle the exception normally.
- context.method = "next";
- context.arg = undefined$1;
- }
- return !! caught;
- }
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
- var entry = this.tryEntries[i];
- var record = entry.completion;
- if (entry.tryLoc === "root") {
- // Exception thrown outside of any try block that could handle
- // it, so set the completion value of the entire function to
- // throw the exception.
- return handle("end");
- }
- if (entry.tryLoc <= this.prev) {
- var hasCatch = hasOwn.call(entry, "catchLoc");
- var hasFinally = hasOwn.call(entry, "finallyLoc");
- if (hasCatch && hasFinally) {
- if (this.prev < entry.catchLoc) {
- return handle(entry.catchLoc, true);
- } else if (this.prev < entry.finallyLoc) {
- return handle(entry.finallyLoc);
- }
- } else if (hasCatch) {
- if (this.prev < entry.catchLoc) {
- return handle(entry.catchLoc, true);
- }
- } else if (hasFinally) {
- if (this.prev < entry.finallyLoc) {
- return handle(entry.finallyLoc);
- }
- } else {
- throw new Error("try statement without catch or finally");
- }
- }
- }
- },
- abrupt: function(type, arg) {
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
- var entry = this.tryEntries[i];
- if (entry.tryLoc <= this.prev &&
- hasOwn.call(entry, "finallyLoc") &&
- this.prev < entry.finallyLoc) {
- var finallyEntry = entry;
- break;
- }
- }
- if (finallyEntry &&
- (type === "break" ||
- type === "continue") &&
- finallyEntry.tryLoc <= arg &&
- arg <= finallyEntry.finallyLoc) {
- // Ignore the finally entry if control is not jumping to a
- // location outside the try/catch block.
- finallyEntry = null;
- }
- var record = finallyEntry ? finallyEntry.completion : {};
- record.type = type;
- record.arg = arg;
- if (finallyEntry) {
- this.method = "next";
- this.next = finallyEntry.finallyLoc;
- return ContinueSentinel;
- }
- return this.complete(record);
- },
- complete: function(record, afterLoc) {
- if (record.type === "throw") {
- throw record.arg;
- }
- if (record.type === "break" ||
- record.type === "continue") {
- this.next = record.arg;
- } else if (record.type === "return") {
- this.rval = this.arg = record.arg;
- this.method = "return";
- this.next = "end";
- } else if (record.type === "normal" && afterLoc) {
- this.next = afterLoc;
- }
- return ContinueSentinel;
- },
- finish: function(finallyLoc) {
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
- var entry = this.tryEntries[i];
- if (entry.finallyLoc === finallyLoc) {
- this.complete(entry.completion, entry.afterLoc);
- resetTryEntry(entry);
- return ContinueSentinel;
- }
- }
- },
- "catch": function(tryLoc) {
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
- var entry = this.tryEntries[i];
- if (entry.tryLoc === tryLoc) {
- var record = entry.completion;
- if (record.type === "throw") {
- var thrown = record.arg;
- resetTryEntry(entry);
- }
- return thrown;
- }
- }
- // The context.catch method must only be called with a location
- // argument that corresponds to a known catch block.
- throw new Error("illegal catch attempt");
- },
- delegateYield: function(iterable, resultName, nextLoc) {
- this.delegate = {
- iterator: values(iterable),
- resultName: resultName,
- nextLoc: nextLoc
- };
- if (this.method === "next") {
- // Deliberately forget the last sent value so that we don't
- // accidentally pass it on to the delegate.
- this.arg = undefined$1;
- }
- return ContinueSentinel;
- }
- };
- // Regardless of whether this script is executing as a CommonJS module
- // or not, return the runtime object so that we can declare the variable
- // regeneratorRuntime in the outer scope, which allows this module to be
- // injected easily by `bin/regenerator --include-runtime script.js`.
- return exports;
- }(
- // If this script is executing as a CommonJS module, use module.exports
- // as the regeneratorRuntime namespace. Otherwise create a new empty
- // object. Either way, the resulting object will be used to initialize
- // the regeneratorRuntime variable at the top of this file.
- module.exports
- ));
- try {
- regeneratorRuntime = runtime;
- } catch (accidentalStrictMode) {
- // This module should not be running in strict mode, so the above
- // assignment should always work unless something is misconfigured. Just
- // in case runtime.js accidentally runs in strict mode, in modern engines
- // we can explicitly access globalThis. In older engines we can escape
- // strict mode using a global Function call. This could conceivably fail
- // if a Content Security Policy forbids using Function, but in that case
- // the proper solution is to fix the accidental strict mode problem. If
- // you've misconfigured your bundler to force strict mode and applied a
- // CSP to forbid Function, and you're not willing to fix either of those
- // problems, please detail your unique predicament in a GitHub issue.
- if (typeof globalThis === "object") {
- globalThis.regeneratorRuntime = runtime;
- } else {
- Function("r", "regeneratorRuntime = r")(runtime);
- }
- }
- });
- var regenerator = runtime_1;
- var asyncToGenerator = createCommonjsModule(function (module) {
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
- try {
- var info = gen[key](arg);
- var value = info.value;
- } catch (error) {
- reject(error);
- return;
- }
- if (info.done) {
- resolve(value);
- } else {
- Promise.resolve(value).then(_next, _throw);
- }
- }
- function _asyncToGenerator(fn) {
- return function () {
- var self = this,
- args = arguments;
- return new Promise(function (resolve, reject) {
- var gen = fn.apply(self, args);
- function _next(value) {
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
- }
- function _throw(err) {
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
- }
- _next(undefined);
- });
- };
- }
- module.exports = _asyncToGenerator;
- module.exports["default"] = module.exports, module.exports.__esModule = true;
- });
- var _asyncToGenerator = /*@__PURE__*/getDefaultExportFromCjs(asyncToGenerator);
- /**
- * This method returns `undefined`.
- *
- * @static
- * @memberOf _
- * @since 2.3.0
- * @category Util
- * @example
- *
- * _.times(2, _.noop);
- * // => [undefined, undefined]
- */
- function noop() {
- // No operation performed.
- }
- var noop_1 = noop;
- var objectWithoutPropertiesLoose = createCommonjsModule(function (module) {
- function _objectWithoutPropertiesLoose(source, excluded) {
- if (source == null) return {};
- var target = {};
- var sourceKeys = Object.keys(source);
- var key, i;
- for (i = 0; i < sourceKeys.length; i++) {
- key = sourceKeys[i];
- if (excluded.indexOf(key) >= 0) continue;
- target[key] = source[key];
- }
- return target;
- }
- module.exports = _objectWithoutPropertiesLoose;
- module.exports["default"] = module.exports, module.exports.__esModule = true;
- });
- var objectWithoutProperties = createCommonjsModule(function (module) {
- function _objectWithoutProperties(source, excluded) {
- if (source == null) return {};
- var target = objectWithoutPropertiesLoose(source, excluded);
- var key, i;
- if (Object.getOwnPropertySymbols) {
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
- for (i = 0; i < sourceSymbolKeys.length; i++) {
- key = sourceSymbolKeys[i];
- if (excluded.indexOf(key) >= 0) continue;
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
- target[key] = source[key];
- }
- }
- return target;
- }
- module.exports = _objectWithoutProperties;
- module.exports["default"] = module.exports, module.exports.__esModule = true;
- });
- var _objectWithoutProperties = /*@__PURE__*/getDefaultExportFromCjs(objectWithoutProperties);
- var arrayLikeToArray = createCommonjsModule(function (module) {
- function _arrayLikeToArray(arr, len) {
- if (len == null || len > arr.length) len = arr.length;
- for (var i = 0, arr2 = new Array(len); i < len; i++) {
- arr2[i] = arr[i];
- }
- return arr2;
- }
- module.exports = _arrayLikeToArray;
- module.exports["default"] = module.exports, module.exports.__esModule = true;
- });
- var arrayWithoutHoles = createCommonjsModule(function (module) {
- function _arrayWithoutHoles(arr) {
- if (Array.isArray(arr)) return arrayLikeToArray(arr);
- }
- module.exports = _arrayWithoutHoles;
- module.exports["default"] = module.exports, module.exports.__esModule = true;
- });
- var iterableToArray = createCommonjsModule(function (module) {
- function _iterableToArray(iter) {
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
- }
- module.exports = _iterableToArray;
- module.exports["default"] = module.exports, module.exports.__esModule = true;
- });
- var unsupportedIterableToArray = createCommonjsModule(function (module) {
- function _unsupportedIterableToArray(o, minLen) {
- if (!o) return;
- if (typeof o === "string") return arrayLikeToArray(o, minLen);
- var n = Object.prototype.toString.call(o).slice(8, -1);
- if (n === "Object" && o.constructor) n = o.constructor.name;
- if (n === "Map" || n === "Set") return Array.from(o);
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen);
- }
- module.exports = _unsupportedIterableToArray;
- module.exports["default"] = module.exports, module.exports.__esModule = true;
- });
- var nonIterableSpread = createCommonjsModule(function (module) {
- function _nonIterableSpread() {
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
- }
- module.exports = _nonIterableSpread;
- module.exports["default"] = module.exports, module.exports.__esModule = true;
- });
- var toConsumableArray = createCommonjsModule(function (module) {
- function _toConsumableArray(arr) {
- return arrayWithoutHoles(arr) || iterableToArray(arr) || unsupportedIterableToArray(arr) || nonIterableSpread();
- }
- module.exports = _toConsumableArray;
- module.exports["default"] = module.exports, module.exports.__esModule = true;
- });
- var _toConsumableArray = /*@__PURE__*/getDefaultExportFromCjs(toConsumableArray);
- var _typeof_1 = createCommonjsModule(function (module) {
- function _typeof(obj) {
- "@babel/helpers - typeof";
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
- module.exports = _typeof = function _typeof(obj) {
- return typeof obj;
- };
- module.exports["default"] = module.exports, module.exports.__esModule = true;
- } else {
- module.exports = _typeof = function _typeof(obj) {
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
- };
- module.exports["default"] = module.exports, module.exports.__esModule = true;
- }
- return _typeof(obj);
- }
- module.exports = _typeof;
- module.exports["default"] = module.exports, module.exports.__esModule = true;
- });
- var _typeof = /*@__PURE__*/getDefaultExportFromCjs(_typeof_1);
- var defineProperty = createCommonjsModule(function (module) {
- function _defineProperty(obj, key, value) {
- if (key in obj) {
- Object.defineProperty(obj, key, {
- value: value,
- enumerable: true,
- configurable: true,
- writable: true
- });
- } else {
- obj[key] = value;
- }
- return obj;
- }
- module.exports = _defineProperty;
- module.exports["default"] = module.exports, module.exports.__esModule = true;
- });
- var _defineProperty = /*@__PURE__*/getDefaultExportFromCjs(defineProperty);
- var objectSpread2 = createCommonjsModule(function (module) {
- function ownKeys(object, enumerableOnly) {
- var keys = Object.keys(object);
- if (Object.getOwnPropertySymbols) {
- var symbols = Object.getOwnPropertySymbols(object);
- if (enumerableOnly) {
- symbols = symbols.filter(function (sym) {
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
- });
- }
- keys.push.apply(keys, symbols);
- }
- return keys;
- }
- function _objectSpread2(target) {
- for (var i = 1; i < arguments.length; i++) {
- var source = arguments[i] != null ? arguments[i] : {};
- if (i % 2) {
- ownKeys(Object(source), true).forEach(function (key) {
- defineProperty(target, key, source[key]);
- });
- } else if (Object.getOwnPropertyDescriptors) {
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
- } else {
- ownKeys(Object(source)).forEach(function (key) {
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
- });
- }
- }
- return target;
- }
- module.exports = _objectSpread2;
- module.exports["default"] = module.exports, module.exports.__esModule = true;
- });
- var _objectSpread = /*@__PURE__*/getDefaultExportFromCjs(objectSpread2);
- /* single-spa@5.9.3 - ESM - prod */
- 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);
- /**
- * Appends the elements of `values` to `array`.
- *
- * @private
- * @param {Array} array The array to modify.
- * @param {Array} values The values to append.
- * @returns {Array} Returns `array`.
- */
- function arrayPush(array, values) {
- var index = -1,
- length = values.length,
- offset = array.length;
- while (++index < length) {
- array[offset + index] = values[index];
- }
- return array;
- }
- var _arrayPush = arrayPush;
- /** Detect free variable `global` from Node.js. */
- var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
- var _freeGlobal = freeGlobal;
- /** Detect free variable `self`. */
- var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
- /** Used as a reference to the global object. */
- var root = _freeGlobal || freeSelf || Function('return this')();
- var _root = root;
- /** Built-in value references. */
- var Symbol$1 = _root.Symbol;
- var _Symbol = Symbol$1;
- /** Used for built-in method references. */
- var objectProto = Object.prototype;
- /** Used to check objects for own properties. */
- var hasOwnProperty = objectProto.hasOwnProperty;
- /**
- * Used to resolve the
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
- * of values.
- */
- var nativeObjectToString = objectProto.toString;
- /** Built-in value references. */
- var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined;
- /**
- * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
- *
- * @private
- * @param {*} value The value to query.
- * @returns {string} Returns the raw `toStringTag`.
- */
- function getRawTag(value) {
- var isOwn = hasOwnProperty.call(value, symToStringTag),
- tag = value[symToStringTag];
- try {
- value[symToStringTag] = undefined;
- var unmasked = true;
- } catch (e) {}
- var result = nativeObjectToString.call(value);
- if (unmasked) {
- if (isOwn) {
- value[symToStringTag] = tag;
- } else {
- delete value[symToStringTag];
- }
- }
- return result;
- }
- var _getRawTag = getRawTag;
- /** Used for built-in method references. */
- var objectProto$1 = Object.prototype;
- /**
- * Used to resolve the
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
- * of values.
- */
- var nativeObjectToString$1 = objectProto$1.toString;
- /**
- * Converts `value` to a string using `Object.prototype.toString`.
- *
- * @private
- * @param {*} value The value to convert.
- * @returns {string} Returns the converted string.
- */
- function objectToString(value) {
- return nativeObjectToString$1.call(value);
- }
- var _objectToString = objectToString;
- /** `Object#toString` result references. */
- var nullTag = '[object Null]',
- undefinedTag = '[object Undefined]';
- /** Built-in value references. */
- var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined;
- /**
- * The base implementation of `getTag` without fallbacks for buggy environments.
- *
- * @private
- * @param {*} value The value to query.
- * @returns {string} Returns the `toStringTag`.
- */
- function baseGetTag(value) {
- if (value == null) {
- return value === undefined ? undefinedTag : nullTag;
- }
- return (symToStringTag$1 && symToStringTag$1 in Object(value))
- ? _getRawTag(value)
- : _objectToString(value);
- }
- var _baseGetTag = baseGetTag;
- /**
- * Checks if `value` is object-like. A value is object-like if it's not `null`
- * and has a `typeof` result of "object".
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
- * @example
- *
- * _.isObjectLike({});
- * // => true
- *
- * _.isObjectLike([1, 2, 3]);
- * // => true
- *
- * _.isObjectLike(_.noop);
- * // => false
- *
- * _.isObjectLike(null);
- * // => false
- */
- function isObjectLike(value) {
- return value != null && typeof value == 'object';
- }
- var isObjectLike_1 = isObjectLike;
- /** `Object#toString` result references. */
- var argsTag = '[object Arguments]';
- /**
- * The base implementation of `_.isArguments`.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
- */
- function baseIsArguments(value) {
- return isObjectLike_1(value) && _baseGetTag(value) == argsTag;
- }
- var _baseIsArguments = baseIsArguments;
- /** Used for built-in method references. */
- var objectProto$2 = Object.prototype;
- /** Used to check objects for own properties. */
- var hasOwnProperty$1 = objectProto$2.hasOwnProperty;
- /** Built-in value references. */
- var propertyIsEnumerable = objectProto$2.propertyIsEnumerable;
- /**
- * Checks if `value` is likely an `arguments` object.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
- * else `false`.
- * @example
- *
- * _.isArguments(function() { return arguments; }());
- * // => true
- *
- * _.isArguments([1, 2, 3]);
- * // => false
- */
- var isArguments = _baseIsArguments(function() { return arguments; }()) ? _baseIsArguments : function(value) {
- return isObjectLike_1(value) && hasOwnProperty$1.call(value, 'callee') &&
- !propertyIsEnumerable.call(value, 'callee');
- };
- var isArguments_1 = isArguments;
- /**
- * Checks if `value` is classified as an `Array` object.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is an array, else `false`.
- * @example
- *
- * _.isArray([1, 2, 3]);
- * // => true
- *
- * _.isArray(document.body.children);
- * // => false
- *
- * _.isArray('abc');
- * // => false
- *
- * _.isArray(_.noop);
- * // => false
- */
- var isArray = Array.isArray;
- var isArray_1 = isArray;
- /** Built-in value references. */
- var spreadableSymbol = _Symbol ? _Symbol.isConcatSpreadable : undefined;
- /**
- * Checks if `value` is a flattenable `arguments` object or array.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
- */
- function isFlattenable(value) {
- return isArray_1(value) || isArguments_1(value) ||
- !!(spreadableSymbol && value && value[spreadableSymbol]);
- }
- var _isFlattenable = isFlattenable;
- /**
- * The base implementation of `_.flatten` with support for restricting flattening.
- *
- * @private
- * @param {Array} array The array to flatten.
- * @param {number} depth The maximum recursion depth.
- * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
- * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
- * @param {Array} [result=[]] The initial result value.
- * @returns {Array} Returns the new flattened array.
- */
- function baseFlatten(array, depth, predicate, isStrict, result) {
- var index = -1,
- length = array.length;
- predicate || (predicate = _isFlattenable);
- result || (result = []);
- while (++index < length) {
- var value = array[index];
- if (depth > 0 && predicate(value)) {
- if (depth > 1) {
- // Recursively flatten arrays (susceptible to call stack limits).
- baseFlatten(value, depth - 1, predicate, isStrict, result);
- } else {
- _arrayPush(result, value);
- }
- } else if (!isStrict) {
- result[result.length] = value;
- }
- }
- return result;
- }
- var _baseFlatten = baseFlatten;
- /**
- * Copies the values of `source` to `array`.
- *
- * @private
- * @param {Array} source The array to copy values from.
- * @param {Array} [array=[]] The array to copy values to.
- * @returns {Array} Returns `array`.
- */
- function copyArray(source, array) {
- var index = -1,
- length = source.length;
- array || (array = Array(length));
- while (++index < length) {
- array[index] = source[index];
- }
- return array;
- }
- var _copyArray = copyArray;
- /**
- * Creates a new array concatenating `array` with any additional arrays
- * and/or values.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Array
- * @param {Array} array The array to concatenate.
- * @param {...*} [values] The values to concatenate.
- * @returns {Array} Returns the new concatenated array.
- * @example
- *
- * var array = [1];
- * var other = _.concat(array, 2, [3], [[4]]);
- *
- * console.log(other);
- * // => [1, 2, 3, [4]]
- *
- * console.log(array);
- * // => [1]
- */
- function concat() {
- var length = arguments.length;
- if (!length) {
- return [];
- }
- var args = Array(length - 1),
- array = arguments[0],
- index = length;
- while (index--) {
- args[index - 1] = arguments[index];
- }
- return _arrayPush(isArray_1(array) ? _copyArray(array) : [array], _baseFlatten(args, 1));
- }
- var concat_1 = concat;
- /**
- * Removes all key-value entries from the list cache.
- *
- * @private
- * @name clear
- * @memberOf ListCache
- */
- function listCacheClear() {
- this.__data__ = [];
- this.size = 0;
- }
- var _listCacheClear = listCacheClear;
- /**
- * Performs a
- * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
- * comparison between two values to determine if they are equivalent.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to compare.
- * @param {*} other The other value to compare.
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
- * @example
- *
- * var object = { 'a': 1 };
- * var other = { 'a': 1 };
- *
- * _.eq(object, object);
- * // => true
- *
- * _.eq(object, other);
- * // => false
- *
- * _.eq('a', 'a');
- * // => true
- *
- * _.eq('a', Object('a'));
- * // => false
- *
- * _.eq(NaN, NaN);
- * // => true
- */
- function eq(value, other) {
- return value === other || (value !== value && other !== other);
- }
- var eq_1 = eq;
- /**
- * Gets the index at which the `key` is found in `array` of key-value pairs.
- *
- * @private
- * @param {Array} array The array to inspect.
- * @param {*} key The key to search for.
- * @returns {number} Returns the index of the matched value, else `-1`.
- */
- function assocIndexOf(array, key) {
- var length = array.length;
- while (length--) {
- if (eq_1(array[length][0], key)) {
- return length;
- }
- }
- return -1;
- }
- var _assocIndexOf = assocIndexOf;
- /** Used for built-in method references. */
- var arrayProto = Array.prototype;
- /** Built-in value references. */
- var splice = arrayProto.splice;
- /**
- * Removes `key` and its value from the list cache.
- *
- * @private
- * @name delete
- * @memberOf ListCache
- * @param {string} key The key of the value to remove.
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
- */
- function listCacheDelete(key) {
- var data = this.__data__,
- index = _assocIndexOf(data, key);
- if (index < 0) {
- return false;
- }
- var lastIndex = data.length - 1;
- if (index == lastIndex) {
- data.pop();
- } else {
- splice.call(data, index, 1);
- }
- --this.size;
- return true;
- }
- var _listCacheDelete = listCacheDelete;
- /**
- * Gets the list cache value for `key`.
- *
- * @private
- * @name get
- * @memberOf ListCache
- * @param {string} key The key of the value to get.
- * @returns {*} Returns the entry value.
- */
- function listCacheGet(key) {
- var data = this.__data__,
- index = _assocIndexOf(data, key);
- return index < 0 ? undefined : data[index][1];
- }
- var _listCacheGet = listCacheGet;
- /**
- * Checks if a list cache value for `key` exists.
- *
- * @private
- * @name has
- * @memberOf ListCache
- * @param {string} key The key of the entry to check.
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
- */
- function listCacheHas(key) {
- return _assocIndexOf(this.__data__, key) > -1;
- }
- var _listCacheHas = listCacheHas;
- /**
- * Sets the list cache `key` to `value`.
- *
- * @private
- * @name set
- * @memberOf ListCache
- * @param {string} key The key of the value to set.
- * @param {*} value The value to set.
- * @returns {Object} Returns the list cache instance.
- */
- function listCacheSet(key, value) {
- var data = this.__data__,
- index = _assocIndexOf(data, key);
- if (index < 0) {
- ++this.size;
- data.push([key, value]);
- } else {
- data[index][1] = value;
- }
- return this;
- }
- var _listCacheSet = listCacheSet;
- /**
- * Creates an list cache object.
- *
- * @private
- * @constructor
- * @param {Array} [entries] The key-value pairs to cache.
- */
- function ListCache(entries) {
- var index = -1,
- length = entries == null ? 0 : entries.length;
- this.clear();
- while (++index < length) {
- var entry = entries[index];
- this.set(entry[0], entry[1]);
- }
- }
- // Add methods to `ListCache`.
- ListCache.prototype.clear = _listCacheClear;
- ListCache.prototype['delete'] = _listCacheDelete;
- ListCache.prototype.get = _listCacheGet;
- ListCache.prototype.has = _listCacheHas;
- ListCache.prototype.set = _listCacheSet;
- var _ListCache = ListCache;
- /**
- * Removes all key-value entries from the stack.
- *
- * @private
- * @name clear
- * @memberOf Stack
- */
- function stackClear() {
- this.__data__ = new _ListCache;
- this.size = 0;
- }
- var _stackClear = stackClear;
- /**
- * Removes `key` and its value from the stack.
- *
- * @private
- * @name delete
- * @memberOf Stack
- * @param {string} key The key of the value to remove.
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
- */
- function stackDelete(key) {
- var data = this.__data__,
- result = data['delete'](key);
- this.size = data.size;
- return result;
- }
- var _stackDelete = stackDelete;
- /**
- * Gets the stack value for `key`.
- *
- * @private
- * @name get
- * @memberOf Stack
- * @param {string} key The key of the value to get.
- * @returns {*} Returns the entry value.
- */
- function stackGet(key) {
- return this.__data__.get(key);
- }
- var _stackGet = stackGet;
- /**
- * Checks if a stack value for `key` exists.
- *
- * @private
- * @name has
- * @memberOf Stack
- * @param {string} key The key of the entry to check.
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
- */
- function stackHas(key) {
- return this.__data__.has(key);
- }
- var _stackHas = stackHas;
- /**
- * Checks if `value` is the
- * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
- * @example
- *
- * _.isObject({});
- * // => true
- *
- * _.isObject([1, 2, 3]);
- * // => true
- *
- * _.isObject(_.noop);
- * // => true
- *
- * _.isObject(null);
- * // => false
- */
- function isObject(value) {
- var type = typeof value;
- return value != null && (type == 'object' || type == 'function');
- }
- var isObject_1 = isObject;
- /** `Object#toString` result references. */
- var asyncTag = '[object AsyncFunction]',
- funcTag = '[object Function]',
- genTag = '[object GeneratorFunction]',
- proxyTag = '[object Proxy]';
- /**
- * Checks if `value` is classified as a `Function` object.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a function, else `false`.
- * @example
- *
- * _.isFunction(_);
- * // => true
- *
- * _.isFunction(/abc/);
- * // => false
- */
- function isFunction(value) {
- if (!isObject_1(value)) {
- return false;
- }
- // The use of `Object#toString` avoids issues with the `typeof` operator
- // in Safari 9 which returns 'object' for typed arrays and other constructors.
- var tag = _baseGetTag(value);
- return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
- }
- var isFunction_1 = isFunction;
- /** Used to detect overreaching core-js shims. */
- var coreJsData = _root['__core-js_shared__'];
- var _coreJsData = coreJsData;
- /** Used to detect methods masquerading as native. */
- var maskSrcKey = (function() {
- var uid = /[^.]+$/.exec(_coreJsData && _coreJsData.keys && _coreJsData.keys.IE_PROTO || '');
- return uid ? ('Symbol(src)_1.' + uid) : '';
- }());
- /**
- * Checks if `func` has its source masked.
- *
- * @private
- * @param {Function} func The function to check.
- * @returns {boolean} Returns `true` if `func` is masked, else `false`.
- */
- function isMasked(func) {
- return !!maskSrcKey && (maskSrcKey in func);
- }
- var _isMasked = isMasked;
- /** Used for built-in method references. */
- var funcProto = Function.prototype;
- /** Used to resolve the decompiled source of functions. */
- var funcToString = funcProto.toString;
- /**
- * Converts `func` to its source code.
- *
- * @private
- * @param {Function} func The function to convert.
- * @returns {string} Returns the source code.
- */
- function toSource(func) {
- if (func != null) {
- try {
- return funcToString.call(func);
- } catch (e) {}
- try {
- return (func + '');
- } catch (e) {}
- }
- return '';
- }
- var _toSource = toSource;
- /**
- * Used to match `RegExp`
- * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
- */
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
- /** Used to detect host constructors (Safari). */
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
- /** Used for built-in method references. */
- var funcProto$1 = Function.prototype,
- objectProto$3 = Object.prototype;
- /** Used to resolve the decompiled source of functions. */
- var funcToString$1 = funcProto$1.toString;
- /** Used to check objects for own properties. */
- var hasOwnProperty$2 = objectProto$3.hasOwnProperty;
- /** Used to detect if a method is native. */
- var reIsNative = RegExp('^' +
- funcToString$1.call(hasOwnProperty$2).replace(reRegExpChar, '\\$&')
- .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
- );
- /**
- * The base implementation of `_.isNative` without bad shim checks.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a native function,
- * else `false`.
- */
- function baseIsNative(value) {
- if (!isObject_1(value) || _isMasked(value)) {
- return false;
- }
- var pattern = isFunction_1(value) ? reIsNative : reIsHostCtor;
- return pattern.test(_toSource(value));
- }
- var _baseIsNative = baseIsNative;
- /**
- * Gets the value at `key` of `object`.
- *
- * @private
- * @param {Object} [object] The object to query.
- * @param {string} key The key of the property to get.
- * @returns {*} Returns the property value.
- */
- function getValue(object, key) {
- return object == null ? undefined : object[key];
- }
- var _getValue = getValue;
- /**
- * Gets the native function at `key` of `object`.
- *
- * @private
- * @param {Object} object The object to query.
- * @param {string} key The key of the method to get.
- * @returns {*} Returns the function if it's native, else `undefined`.
- */
- function getNative(object, key) {
- var value = _getValue(object, key);
- return _baseIsNative(value) ? value : undefined;
- }
- var _getNative = getNative;
- /* Built-in method references that are verified to be native. */
- var Map$1 = _getNative(_root, 'Map');
- var _Map = Map$1;
- /* Built-in method references that are verified to be native. */
- var nativeCreate = _getNative(Object, 'create');
- var _nativeCreate = nativeCreate;
- /**
- * Removes all key-value entries from the hash.
- *
- * @private
- * @name clear
- * @memberOf Hash
- */
- function hashClear() {
- this.__data__ = _nativeCreate ? _nativeCreate(null) : {};
- this.size = 0;
- }
- var _hashClear = hashClear;
- /**
- * Removes `key` and its value from the hash.
- *
- * @private
- * @name delete
- * @memberOf Hash
- * @param {Object} hash The hash to modify.
- * @param {string} key The key of the value to remove.
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
- */
- function hashDelete(key) {
- var result = this.has(key) && delete this.__data__[key];
- this.size -= result ? 1 : 0;
- return result;
- }
- var _hashDelete = hashDelete;
- /** Used to stand-in for `undefined` hash values. */
- var HASH_UNDEFINED = '__lodash_hash_undefined__';
- /** Used for built-in method references. */
- var objectProto$4 = Object.prototype;
- /** Used to check objects for own properties. */
- var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
- /**
- * Gets the hash value for `key`.
- *
- * @private
- * @name get
- * @memberOf Hash
- * @param {string} key The key of the value to get.
- * @returns {*} Returns the entry value.
- */
- function hashGet(key) {
- var data = this.__data__;
- if (_nativeCreate) {
- var result = data[key];
- return result === HASH_UNDEFINED ? undefined : result;
- }
- return hasOwnProperty$3.call(data, key) ? data[key] : undefined;
- }
- var _hashGet = hashGet;
- /** Used for built-in method references. */
- var objectProto$5 = Object.prototype;
- /** Used to check objects for own properties. */
- var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
- /**
- * Checks if a hash value for `key` exists.
- *
- * @private
- * @name has
- * @memberOf Hash
- * @param {string} key The key of the entry to check.
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
- */
- function hashHas(key) {
- var data = this.__data__;
- return _nativeCreate ? (data[key] !== undefined) : hasOwnProperty$4.call(data, key);
- }
- var _hashHas = hashHas;
- /** Used to stand-in for `undefined` hash values. */
- var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
- /**
- * Sets the hash `key` to `value`.
- *
- * @private
- * @name set
- * @memberOf Hash
- * @param {string} key The key of the value to set.
- * @param {*} value The value to set.
- * @returns {Object} Returns the hash instance.
- */
- function hashSet(key, value) {
- var data = this.__data__;
- this.size += this.has(key) ? 0 : 1;
- data[key] = (_nativeCreate && value === undefined) ? HASH_UNDEFINED$1 : value;
- return this;
- }
- var _hashSet = hashSet;
- /**
- * Creates a hash object.
- *
- * @private
- * @constructor
- * @param {Array} [entries] The key-value pairs to cache.
- */
- function Hash(entries) {
- var index = -1,
- length = entries == null ? 0 : entries.length;
- this.clear();
- while (++index < length) {
- var entry = entries[index];
- this.set(entry[0], entry[1]);
- }
- }
- // Add methods to `Hash`.
- Hash.prototype.clear = _hashClear;
- Hash.prototype['delete'] = _hashDelete;
- Hash.prototype.get = _hashGet;
- Hash.prototype.has = _hashHas;
- Hash.prototype.set = _hashSet;
- var _Hash = Hash;
- /**
- * Removes all key-value entries from the map.
- *
- * @private
- * @name clear
- * @memberOf MapCache
- */
- function mapCacheClear() {
- this.size = 0;
- this.__data__ = {
- 'hash': new _Hash,
- 'map': new (_Map || _ListCache),
- 'string': new _Hash
- };
- }
- var _mapCacheClear = mapCacheClear;
- /**
- * Checks if `value` is suitable for use as unique object key.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
- */
- function isKeyable(value) {
- var type = typeof value;
- return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
- ? (value !== '__proto__')
- : (value === null);
- }
- var _isKeyable = isKeyable;
- /**
- * Gets the data for `map`.
- *
- * @private
- * @param {Object} map The map to query.
- * @param {string} key The reference key.
- * @returns {*} Returns the map data.
- */
- function getMapData(map, key) {
- var data = map.__data__;
- return _isKeyable(key)
- ? data[typeof key == 'string' ? 'string' : 'hash']
- : data.map;
- }
- var _getMapData = getMapData;
- /**
- * Removes `key` and its value from the map.
- *
- * @private
- * @name delete
- * @memberOf MapCache
- * @param {string} key The key of the value to remove.
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
- */
- function mapCacheDelete(key) {
- var result = _getMapData(this, key)['delete'](key);
- this.size -= result ? 1 : 0;
- return result;
- }
- var _mapCacheDelete = mapCacheDelete;
- /**
- * Gets the map value for `key`.
- *
- * @private
- * @name get
- * @memberOf MapCache
- * @param {string} key The key of the value to get.
- * @returns {*} Returns the entry value.
- */
- function mapCacheGet(key) {
- return _getMapData(this, key).get(key);
- }
- var _mapCacheGet = mapCacheGet;
- /**
- * Checks if a map value for `key` exists.
- *
- * @private
- * @name has
- * @memberOf MapCache
- * @param {string} key The key of the entry to check.
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
- */
- function mapCacheHas(key) {
- return _getMapData(this, key).has(key);
- }
- var _mapCacheHas = mapCacheHas;
- /**
- * Sets the map `key` to `value`.
- *
- * @private
- * @name set
- * @memberOf MapCache
- * @param {string} key The key of the value to set.
- * @param {*} value The value to set.
- * @returns {Object} Returns the map cache instance.
- */
- function mapCacheSet(key, value) {
- var data = _getMapData(this, key),
- size = data.size;
- data.set(key, value);
- this.size += data.size == size ? 0 : 1;
- return this;
- }
- var _mapCacheSet = mapCacheSet;
- /**
- * Creates a map cache object to store key-value pairs.
- *
- * @private
- * @constructor
- * @param {Array} [entries] The key-value pairs to cache.
- */
- function MapCache(entries) {
- var index = -1,
- length = entries == null ? 0 : entries.length;
- this.clear();
- while (++index < length) {
- var entry = entries[index];
- this.set(entry[0], entry[1]);
- }
- }
- // Add methods to `MapCache`.
- MapCache.prototype.clear = _mapCacheClear;
- MapCache.prototype['delete'] = _mapCacheDelete;
- MapCache.prototype.get = _mapCacheGet;
- MapCache.prototype.has = _mapCacheHas;
- MapCache.prototype.set = _mapCacheSet;
- var _MapCache = MapCache;
- /** Used as the size to enable large array optimizations. */
- var LARGE_ARRAY_SIZE = 200;
- /**
- * Sets the stack `key` to `value`.
- *
- * @private
- * @name set
- * @memberOf Stack
- * @param {string} key The key of the value to set.
- * @param {*} value The value to set.
- * @returns {Object} Returns the stack cache instance.
- */
- function stackSet(key, value) {
- var data = this.__data__;
- if (data instanceof _ListCache) {
- var pairs = data.__data__;
- if (!_Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
- pairs.push([key, value]);
- this.size = ++data.size;
- return this;
- }
- data = this.__data__ = new _MapCache(pairs);
- }
- data.set(key, value);
- this.size = data.size;
- return this;
- }
- var _stackSet = stackSet;
- /**
- * Creates a stack cache object to store key-value pairs.
- *
- * @private
- * @constructor
- * @param {Array} [entries] The key-value pairs to cache.
- */
- function Stack(entries) {
- var data = this.__data__ = new _ListCache(entries);
- this.size = data.size;
- }
- // Add methods to `Stack`.
- Stack.prototype.clear = _stackClear;
- Stack.prototype['delete'] = _stackDelete;
- Stack.prototype.get = _stackGet;
- Stack.prototype.has = _stackHas;
- Stack.prototype.set = _stackSet;
- var _Stack = Stack;
- var defineProperty$1 = (function() {
- try {
- var func = _getNative(Object, 'defineProperty');
- func({}, '', {});
- return func;
- } catch (e) {}
- }());
- var _defineProperty$1 = defineProperty$1;
- /**
- * The base implementation of `assignValue` and `assignMergeValue` without
- * value checks.
- *
- * @private
- * @param {Object} object The object to modify.
- * @param {string} key The key of the property to assign.
- * @param {*} value The value to assign.
- */
- function baseAssignValue(object, key, value) {
- if (key == '__proto__' && _defineProperty$1) {
- _defineProperty$1(object, key, {
- 'configurable': true,
- 'enumerable': true,
- 'value': value,
- 'writable': true
- });
- } else {
- object[key] = value;
- }
- }
- var _baseAssignValue = baseAssignValue;
- /**
- * This function is like `assignValue` except that it doesn't assign
- * `undefined` values.
- *
- * @private
- * @param {Object} object The object to modify.
- * @param {string} key The key of the property to assign.
- * @param {*} value The value to assign.
- */
- function assignMergeValue(object, key, value) {
- if ((value !== undefined && !eq_1(object[key], value)) ||
- (value === undefined && !(key in object))) {
- _baseAssignValue(object, key, value);
- }
- }
- var _assignMergeValue = assignMergeValue;
- /**
- * Creates a base function for methods like `_.forIn` and `_.forOwn`.
- *
- * @private
- * @param {boolean} [fromRight] Specify iterating from right to left.
- * @returns {Function} Returns the new base function.
- */
- function createBaseFor(fromRight) {
- return function(object, iteratee, keysFunc) {
- var index = -1,
- iterable = Object(object),
- props = keysFunc(object),
- length = props.length;
- while (length--) {
- var key = props[fromRight ? length : ++index];
- if (iteratee(iterable[key], key, iterable) === false) {
- break;
- }
- }
- return object;
- };
- }
- var _createBaseFor = createBaseFor;
- /**
- * The base implementation of `baseForOwn` which iterates over `object`
- * properties returned by `keysFunc` and invokes `iteratee` for each property.
- * Iteratee functions may exit iteration early by explicitly returning `false`.
- *
- * @private
- * @param {Object} object The object to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @param {Function} keysFunc The function to get the keys of `object`.
- * @returns {Object} Returns `object`.
- */
- var baseFor = _createBaseFor();
- var _baseFor = baseFor;
- var _cloneBuffer = createCommonjsModule(function (module, exports) {
- /** Detect free variable `exports`. */
- var freeExports = exports && !exports.nodeType && exports;
- /** Detect free variable `module`. */
- var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
- /** Detect the popular CommonJS extension `module.exports`. */
- var moduleExports = freeModule && freeModule.exports === freeExports;
- /** Built-in value references. */
- var Buffer = moduleExports ? _root.Buffer : undefined,
- allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined;
- /**
- * Creates a clone of `buffer`.
- *
- * @private
- * @param {Buffer} buffer The buffer to clone.
- * @param {boolean} [isDeep] Specify a deep clone.
- * @returns {Buffer} Returns the cloned buffer.
- */
- function cloneBuffer(buffer, isDeep) {
- if (isDeep) {
- return buffer.slice();
- }
- var length = buffer.length,
- result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
- buffer.copy(result);
- return result;
- }
- module.exports = cloneBuffer;
- });
- /** Built-in value references. */
- var Uint8Array = _root.Uint8Array;
- var _Uint8Array = Uint8Array;
- /**
- * Creates a clone of `arrayBuffer`.
- *
- * @private
- * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
- * @returns {ArrayBuffer} Returns the cloned array buffer.
- */
- function cloneArrayBuffer(arrayBuffer) {
- var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
- new _Uint8Array(result).set(new _Uint8Array(arrayBuffer));
- return result;
- }
- var _cloneArrayBuffer = cloneArrayBuffer;
- /**
- * Creates a clone of `typedArray`.
- *
- * @private
- * @param {Object} typedArray The typed array to clone.
- * @param {boolean} [isDeep] Specify a deep clone.
- * @returns {Object} Returns the cloned typed array.
- */
- function cloneTypedArray(typedArray, isDeep) {
- var buffer = isDeep ? _cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
- return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
- }
- var _cloneTypedArray = cloneTypedArray;
- /** Built-in value references. */
- var objectCreate = Object.create;
- /**
- * The base implementation of `_.create` without support for assigning
- * properties to the created object.
- *
- * @private
- * @param {Object} proto The object to inherit from.
- * @returns {Object} Returns the new object.
- */
- var baseCreate = (function() {
- function object() {}
- return function(proto) {
- if (!isObject_1(proto)) {
- return {};
- }
- if (objectCreate) {
- return objectCreate(proto);
- }
- object.prototype = proto;
- var result = new object;
- object.prototype = undefined;
- return result;
- };
- }());
- var _baseCreate = baseCreate;
- /**
- * Creates a unary function that invokes `func` with its argument transformed.
- *
- * @private
- * @param {Function} func The function to wrap.
- * @param {Function} transform The argument transform.
- * @returns {Function} Returns the new function.
- */
- function overArg(func, transform) {
- return function(arg) {
- return func(transform(arg));
- };
- }
- var _overArg = overArg;
- /** Built-in value references. */
- var getPrototype = _overArg(Object.getPrototypeOf, Object);
- var _getPrototype = getPrototype;
- /** Used for built-in method references. */
- var objectProto$6 = Object.prototype;
- /**
- * Checks if `value` is likely a prototype object.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
- */
- function isPrototype(value) {
- var Ctor = value && value.constructor,
- proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$6;
- return value === proto;
- }
- var _isPrototype = isPrototype;
- /**
- * Initializes an object clone.
- *
- * @private
- * @param {Object} object The object to clone.
- * @returns {Object} Returns the initialized clone.
- */
- function initCloneObject(object) {
- return (typeof object.constructor == 'function' && !_isPrototype(object))
- ? _baseCreate(_getPrototype(object))
- : {};
- }
- var _initCloneObject = initCloneObject;
- /** Used as references for various `Number` constants. */
- var MAX_SAFE_INTEGER = 9007199254740991;
- /**
- * Checks if `value` is a valid array-like length.
- *
- * **Note:** This method is loosely based on
- * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
- * @example
- *
- * _.isLength(3);
- * // => true
- *
- * _.isLength(Number.MIN_VALUE);
- * // => false
- *
- * _.isLength(Infinity);
- * // => false
- *
- * _.isLength('3');
- * // => false
- */
- function isLength(value) {
- return typeof value == 'number' &&
- value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
- }
- var isLength_1 = isLength;
- /**
- * Checks if `value` is array-like. A value is considered array-like if it's
- * not a function and has a `value.length` that's an integer greater than or
- * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
- * @example
- *
- * _.isArrayLike([1, 2, 3]);
- * // => true
- *
- * _.isArrayLike(document.body.children);
- * // => true
- *
- * _.isArrayLike('abc');
- * // => true
- *
- * _.isArrayLike(_.noop);
- * // => false
- */
- function isArrayLike(value) {
- return value != null && isLength_1(value.length) && !isFunction_1(value);
- }
- var isArrayLike_1 = isArrayLike;
- /**
- * This method is like `_.isArrayLike` except that it also checks if `value`
- * is an object.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is an array-like object,
- * else `false`.
- * @example
- *
- * _.isArrayLikeObject([1, 2, 3]);
- * // => true
- *
- * _.isArrayLikeObject(document.body.children);
- * // => true
- *
- * _.isArrayLikeObject('abc');
- * // => false
- *
- * _.isArrayLikeObject(_.noop);
- * // => false
- */
- function isArrayLikeObject(value) {
- return isObjectLike_1(value) && isArrayLike_1(value);
- }
- var isArrayLikeObject_1 = isArrayLikeObject;
- /**
- * This method returns `false`.
- *
- * @static
- * @memberOf _
- * @since 4.13.0
- * @category Util
- * @returns {boolean} Returns `false`.
- * @example
- *
- * _.times(2, _.stubFalse);
- * // => [false, false]
- */
- function stubFalse() {
- return false;
- }
- var stubFalse_1 = stubFalse;
- var isBuffer_1 = createCommonjsModule(function (module, exports) {
- /** Detect free variable `exports`. */
- var freeExports = exports && !exports.nodeType && exports;
- /** Detect free variable `module`. */
- var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
- /** Detect the popular CommonJS extension `module.exports`. */
- var moduleExports = freeModule && freeModule.exports === freeExports;
- /** Built-in value references. */
- var Buffer = moduleExports ? _root.Buffer : undefined;
- /* Built-in method references for those with the same name as other `lodash` methods. */
- var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
- /**
- * Checks if `value` is a buffer.
- *
- * @static
- * @memberOf _
- * @since 4.3.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
- * @example
- *
- * _.isBuffer(new Buffer(2));
- * // => true
- *
- * _.isBuffer(new Uint8Array(2));
- * // => false
- */
- var isBuffer = nativeIsBuffer || stubFalse_1;
- module.exports = isBuffer;
- });
- /** `Object#toString` result references. */
- var objectTag = '[object Object]';
- /** Used for built-in method references. */
- var funcProto$2 = Function.prototype,
- objectProto$7 = Object.prototype;
- /** Used to resolve the decompiled source of functions. */
- var funcToString$2 = funcProto$2.toString;
- /** Used to check objects for own properties. */
- var hasOwnProperty$5 = objectProto$7.hasOwnProperty;
- /** Used to infer the `Object` constructor. */
- var objectCtorString = funcToString$2.call(Object);
- /**
- * Checks if `value` is a plain object, that is, an object created by the
- * `Object` constructor or one with a `[[Prototype]]` of `null`.
- *
- * @static
- * @memberOf _
- * @since 0.8.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
- * @example
- *
- * function Foo() {
- * this.a = 1;
- * }
- *
- * _.isPlainObject(new Foo);
- * // => false
- *
- * _.isPlainObject([1, 2, 3]);
- * // => false
- *
- * _.isPlainObject({ 'x': 0, 'y': 0 });
- * // => true
- *
- * _.isPlainObject(Object.create(null));
- * // => true
- */
- function isPlainObject(value) {
- if (!isObjectLike_1(value) || _baseGetTag(value) != objectTag) {
- return false;
- }
- var proto = _getPrototype(value);
- if (proto === null) {
- return true;
- }
- var Ctor = hasOwnProperty$5.call(proto, 'constructor') && proto.constructor;
- return typeof Ctor == 'function' && Ctor instanceof Ctor &&
- funcToString$2.call(Ctor) == objectCtorString;
- }
- var isPlainObject_1 = isPlainObject;
- /** `Object#toString` result references. */
- var argsTag$1 = '[object Arguments]',
- arrayTag = '[object Array]',
- boolTag = '[object Boolean]',
- dateTag = '[object Date]',
- errorTag = '[object Error]',
- funcTag$1 = '[object Function]',
- mapTag = '[object Map]',
- numberTag = '[object Number]',
- objectTag$1 = '[object Object]',
- regexpTag = '[object RegExp]',
- setTag = '[object Set]',
- stringTag = '[object String]',
- weakMapTag = '[object WeakMap]';
- var arrayBufferTag = '[object ArrayBuffer]',
- dataViewTag = '[object DataView]',
- float32Tag = '[object Float32Array]',
- float64Tag = '[object Float64Array]',
- int8Tag = '[object Int8Array]',
- int16Tag = '[object Int16Array]',
- int32Tag = '[object Int32Array]',
- uint8Tag = '[object Uint8Array]',
- uint8ClampedTag = '[object Uint8ClampedArray]',
- uint16Tag = '[object Uint16Array]',
- uint32Tag = '[object Uint32Array]';
- /** Used to identify `toStringTag` values of typed arrays. */
- var typedArrayTags = {};
- typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
- typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
- typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
- typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
- typedArrayTags[uint32Tag] = true;
- typedArrayTags[argsTag$1] = typedArrayTags[arrayTag] =
- typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
- typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
- typedArrayTags[errorTag] = typedArrayTags[funcTag$1] =
- typedArrayTags[mapTag] = typedArrayTags[numberTag] =
- typedArrayTags[objectTag$1] = typedArrayTags[regexpTag] =
- typedArrayTags[setTag] = typedArrayTags[stringTag] =
- typedArrayTags[weakMapTag] = false;
- /**
- * The base implementation of `_.isTypedArray` without Node.js optimizations.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
- */
- function baseIsTypedArray(value) {
- return isObjectLike_1(value) &&
- isLength_1(value.length) && !!typedArrayTags[_baseGetTag(value)];
- }
- var _baseIsTypedArray = baseIsTypedArray;
- /**
- * The base implementation of `_.unary` without support for storing metadata.
- *
- * @private
- * @param {Function} func The function to cap arguments for.
- * @returns {Function} Returns the new capped function.
- */
- function baseUnary(func) {
- return function(value) {
- return func(value);
- };
- }
- var _baseUnary = baseUnary;
- var _nodeUtil = createCommonjsModule(function (module, exports) {
- /** Detect free variable `exports`. */
- var freeExports = exports && !exports.nodeType && exports;
- /** Detect free variable `module`. */
- var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
- /** Detect the popular CommonJS extension `module.exports`. */
- var moduleExports = freeModule && freeModule.exports === freeExports;
- /** Detect free variable `process` from Node.js. */
- var freeProcess = moduleExports && _freeGlobal.process;
- /** Used to access faster Node.js helpers. */
- var nodeUtil = (function() {
- try {
- // Use `util.types` for Node.js 10+.
- var types = freeModule && freeModule.require && freeModule.require('util').types;
- if (types) {
- return types;
- }
- // Legacy `process.binding('util')` for Node.js < 10.
- return freeProcess && freeProcess.binding && freeProcess.binding('util');
- } catch (e) {}
- }());
- module.exports = nodeUtil;
- });
- /* Node.js helper references. */
- var nodeIsTypedArray = _nodeUtil && _nodeUtil.isTypedArray;
- /**
- * Checks if `value` is classified as a typed array.
- *
- * @static
- * @memberOf _
- * @since 3.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
- * @example
- *
- * _.isTypedArray(new Uint8Array);
- * // => true
- *
- * _.isTypedArray([]);
- * // => false
- */
- var isTypedArray = nodeIsTypedArray ? _baseUnary(nodeIsTypedArray) : _baseIsTypedArray;
- var isTypedArray_1 = isTypedArray;
- /**
- * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
- *
- * @private
- * @param {Object} object The object to query.
- * @param {string} key The key of the property to get.
- * @returns {*} Returns the property value.
- */
- function safeGet(object, key) {
- if (key === 'constructor' && typeof object[key] === 'function') {
- return;
- }
- if (key == '__proto__') {
- return;
- }
- return object[key];
- }
- var _safeGet = safeGet;
- /** Used for built-in method references. */
- var objectProto$8 = Object.prototype;
- /** Used to check objects for own properties. */
- var hasOwnProperty$6 = objectProto$8.hasOwnProperty;
- /**
- * Assigns `value` to `key` of `object` if the existing value is not equivalent
- * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
- * for equality comparisons.
- *
- * @private
- * @param {Object} object The object to modify.
- * @param {string} key The key of the property to assign.
- * @param {*} value The value to assign.
- */
- function assignValue(object, key, value) {
- var objValue = object[key];
- if (!(hasOwnProperty$6.call(object, key) && eq_1(objValue, value)) ||
- (value === undefined && !(key in object))) {
- _baseAssignValue(object, key, value);
- }
- }
- var _assignValue = assignValue;
- /**
- * Copies properties of `source` to `object`.
- *
- * @private
- * @param {Object} source The object to copy properties from.
- * @param {Array} props The property identifiers to copy.
- * @param {Object} [object={}] The object to copy properties to.
- * @param {Function} [customizer] The function to customize copied values.
- * @returns {Object} Returns `object`.
- */
- function copyObject(source, props, object, customizer) {
- var isNew = !object;
- object || (object = {});
- var index = -1,
- length = props.length;
- while (++index < length) {
- var key = props[index];
- var newValue = customizer
- ? customizer(object[key], source[key], key, object, source)
- : undefined;
- if (newValue === undefined) {
- newValue = source[key];
- }
- if (isNew) {
- _baseAssignValue(object, key, newValue);
- } else {
- _assignValue(object, key, newValue);
- }
- }
- return object;
- }
- var _copyObject = copyObject;
- /**
- * The base implementation of `_.times` without support for iteratee shorthands
- * or max array length checks.
- *
- * @private
- * @param {number} n The number of times to invoke `iteratee`.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Array} Returns the array of results.
- */
- function baseTimes(n, iteratee) {
- var index = -1,
- result = Array(n);
- while (++index < n) {
- result[index] = iteratee(index);
- }
- return result;
- }
- var _baseTimes = baseTimes;
- /** Used as references for various `Number` constants. */
- var MAX_SAFE_INTEGER$1 = 9007199254740991;
- /** Used to detect unsigned integer values. */
- var reIsUint = /^(?:0|[1-9]\d*)$/;
- /**
- * Checks if `value` is a valid array-like index.
- *
- * @private
- * @param {*} value The value to check.
- * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
- * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
- */
- function isIndex(value, length) {
- var type = typeof value;
- length = length == null ? MAX_SAFE_INTEGER$1 : length;
- return !!length &&
- (type == 'number' ||
- (type != 'symbol' && reIsUint.test(value))) &&
- (value > -1 && value % 1 == 0 && value < length);
- }
- var _isIndex = isIndex;
- /** Used for built-in method references. */
- var objectProto$9 = Object.prototype;
- /** Used to check objects for own properties. */
- var hasOwnProperty$7 = objectProto$9.hasOwnProperty;
- /**
- * Creates an array of the enumerable property names of the array-like `value`.
- *
- * @private
- * @param {*} value The value to query.
- * @param {boolean} inherited Specify returning inherited property names.
- * @returns {Array} Returns the array of property names.
- */
- function arrayLikeKeys(value, inherited) {
- var isArr = isArray_1(value),
- isArg = !isArr && isArguments_1(value),
- isBuff = !isArr && !isArg && isBuffer_1(value),
- isType = !isArr && !isArg && !isBuff && isTypedArray_1(value),
- skipIndexes = isArr || isArg || isBuff || isType,
- result = skipIndexes ? _baseTimes(value.length, String) : [],
- length = result.length;
- for (var key in value) {
- if ((inherited || hasOwnProperty$7.call(value, key)) &&
- !(skipIndexes && (
- // Safari 9 has enumerable `arguments.length` in strict mode.
- key == 'length' ||
- // Node.js 0.10 has enumerable non-index properties on buffers.
- (isBuff && (key == 'offset' || key == 'parent')) ||
- // PhantomJS 2 has enumerable non-index properties on typed arrays.
- (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
- // Skip index properties.
- _isIndex(key, length)
- ))) {
- result.push(key);
- }
- }
- return result;
- }
- var _arrayLikeKeys = arrayLikeKeys;
- /**
- * This function is like
- * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
- * except that it includes inherited enumerable properties.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of property names.
- */
- function nativeKeysIn(object) {
- var result = [];
- if (object != null) {
- for (var key in Object(object)) {
- result.push(key);
- }
- }
- return result;
- }
- var _nativeKeysIn = nativeKeysIn;
- /** Used for built-in method references. */
- var objectProto$a = Object.prototype;
- /** Used to check objects for own properties. */
- var hasOwnProperty$8 = objectProto$a.hasOwnProperty;
- /**
- * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of property names.
- */
- function baseKeysIn(object) {
- if (!isObject_1(object)) {
- return _nativeKeysIn(object);
- }
- var isProto = _isPrototype(object),
- result = [];
- for (var key in object) {
- if (!(key == 'constructor' && (isProto || !hasOwnProperty$8.call(object, key)))) {
- result.push(key);
- }
- }
- return result;
- }
- var _baseKeysIn = baseKeysIn;
- /**
- * Creates an array of the own and inherited enumerable property names of `object`.
- *
- * **Note:** Non-object values are coerced to objects.
- *
- * @static
- * @memberOf _
- * @since 3.0.0
- * @category Object
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of property names.
- * @example
- *
- * function Foo() {
- * this.a = 1;
- * this.b = 2;
- * }
- *
- * Foo.prototype.c = 3;
- *
- * _.keysIn(new Foo);
- * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
- */
- function keysIn(object) {
- return isArrayLike_1(object) ? _arrayLikeKeys(object, true) : _baseKeysIn(object);
- }
- var keysIn_1 = keysIn;
- /**
- * Converts `value` to a plain object flattening inherited enumerable string
- * keyed properties of `value` to own properties of the plain object.
- *
- * @static
- * @memberOf _
- * @since 3.0.0
- * @category Lang
- * @param {*} value The value to convert.
- * @returns {Object} Returns the converted plain object.
- * @example
- *
- * function Foo() {
- * this.b = 2;
- * }
- *
- * Foo.prototype.c = 3;
- *
- * _.assign({ 'a': 1 }, new Foo);
- * // => { 'a': 1, 'b': 2 }
- *
- * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
- * // => { 'a': 1, 'b': 2, 'c': 3 }
- */
- function toPlainObject(value) {
- return _copyObject(value, keysIn_1(value));
- }
- var toPlainObject_1 = toPlainObject;
- /**
- * A specialized version of `baseMerge` for arrays and objects which performs
- * deep merges and tracks traversed objects enabling objects with circular
- * references to be merged.
- *
- * @private
- * @param {Object} object The destination object.
- * @param {Object} source The source object.
- * @param {string} key The key of the value to merge.
- * @param {number} srcIndex The index of `source`.
- * @param {Function} mergeFunc The function to merge values.
- * @param {Function} [customizer] The function to customize assigned values.
- * @param {Object} [stack] Tracks traversed source values and their merged
- * counterparts.
- */
- function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
- var objValue = _safeGet(object, key),
- srcValue = _safeGet(source, key),
- stacked = stack.get(srcValue);
- if (stacked) {
- _assignMergeValue(object, key, stacked);
- return;
- }
- var newValue = customizer
- ? customizer(objValue, srcValue, (key + ''), object, source, stack)
- : undefined;
- var isCommon = newValue === undefined;
- if (isCommon) {
- var isArr = isArray_1(srcValue),
- isBuff = !isArr && isBuffer_1(srcValue),
- isTyped = !isArr && !isBuff && isTypedArray_1(srcValue);
- newValue = srcValue;
- if (isArr || isBuff || isTyped) {
- if (isArray_1(objValue)) {
- newValue = objValue;
- }
- else if (isArrayLikeObject_1(objValue)) {
- newValue = _copyArray(objValue);
- }
- else if (isBuff) {
- isCommon = false;
- newValue = _cloneBuffer(srcValue, true);
- }
- else if (isTyped) {
- isCommon = false;
- newValue = _cloneTypedArray(srcValue, true);
- }
- else {
- newValue = [];
- }
- }
- else if (isPlainObject_1(srcValue) || isArguments_1(srcValue)) {
- newValue = objValue;
- if (isArguments_1(objValue)) {
- newValue = toPlainObject_1(objValue);
- }
- else if (!isObject_1(objValue) || isFunction_1(objValue)) {
- newValue = _initCloneObject(srcValue);
- }
- }
- else {
- isCommon = false;
- }
- }
- if (isCommon) {
- // Recursively merge objects and arrays (susceptible to call stack limits).
- stack.set(srcValue, newValue);
- mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
- stack['delete'](srcValue);
- }
- _assignMergeValue(object, key, newValue);
- }
- var _baseMergeDeep = baseMergeDeep;
- /**
- * The base implementation of `_.merge` without support for multiple sources.
- *
- * @private
- * @param {Object} object The destination object.
- * @param {Object} source The source object.
- * @param {number} srcIndex The index of `source`.
- * @param {Function} [customizer] The function to customize merged values.
- * @param {Object} [stack] Tracks traversed source values and their merged
- * counterparts.
- */
- function baseMerge(object, source, srcIndex, customizer, stack) {
- if (object === source) {
- return;
- }
- _baseFor(source, function(srcValue, key) {
- stack || (stack = new _Stack);
- if (isObject_1(srcValue)) {
- _baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
- }
- else {
- var newValue = customizer
- ? customizer(_safeGet(object, key), srcValue, (key + ''), object, source, stack)
- : undefined;
- if (newValue === undefined) {
- newValue = srcValue;
- }
- _assignMergeValue(object, key, newValue);
- }
- }, keysIn_1);
- }
- var _baseMerge = baseMerge;
- /**
- * This method returns the first argument it receives.
- *
- * @static
- * @since 0.1.0
- * @memberOf _
- * @category Util
- * @param {*} value Any value.
- * @returns {*} Returns `value`.
- * @example
- *
- * var object = { 'a': 1 };
- *
- * console.log(_.identity(object) === object);
- * // => true
- */
- function identity(value) {
- return value;
- }
- var identity_1 = identity;
- /**
- * A faster alternative to `Function#apply`, this function invokes `func`
- * with the `this` binding of `thisArg` and the arguments of `args`.
- *
- * @private
- * @param {Function} func The function to invoke.
- * @param {*} thisArg The `this` binding of `func`.
- * @param {Array} args The arguments to invoke `func` with.
- * @returns {*} Returns the result of `func`.
- */
- function apply(func, thisArg, args) {
- switch (args.length) {
- case 0: return func.call(thisArg);
- case 1: return func.call(thisArg, args[0]);
- case 2: return func.call(thisArg, args[0], args[1]);
- case 3: return func.call(thisArg, args[0], args[1], args[2]);
- }
- return func.apply(thisArg, args);
- }
- var _apply = apply;
- /* Built-in method references for those with the same name as other `lodash` methods. */
- var nativeMax = Math.max;
- /**
- * A specialized version of `baseRest` which transforms the rest array.
- *
- * @private
- * @param {Function} func The function to apply a rest parameter to.
- * @param {number} [start=func.length-1] The start position of the rest parameter.
- * @param {Function} transform The rest array transform.
- * @returns {Function} Returns the new function.
- */
- function overRest(func, start, transform) {
- start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
- return function() {
- var args = arguments,
- index = -1,
- length = nativeMax(args.length - start, 0),
- array = Array(length);
- while (++index < length) {
- array[index] = args[start + index];
- }
- index = -1;
- var otherArgs = Array(start + 1);
- while (++index < start) {
- otherArgs[index] = args[index];
- }
- otherArgs[start] = transform(array);
- return _apply(func, this, otherArgs);
- };
- }
- var _overRest = overRest;
- /**
- * Creates a function that returns `value`.
- *
- * @static
- * @memberOf _
- * @since 2.4.0
- * @category Util
- * @param {*} value The value to return from the new function.
- * @returns {Function} Returns the new constant function.
- * @example
- *
- * var objects = _.times(2, _.constant({ 'a': 1 }));
- *
- * console.log(objects);
- * // => [{ 'a': 1 }, { 'a': 1 }]
- *
- * console.log(objects[0] === objects[1]);
- * // => true
- */
- function constant(value) {
- return function() {
- return value;
- };
- }
- var constant_1 = constant;
- /**
- * The base implementation of `setToString` without support for hot loop shorting.
- *
- * @private
- * @param {Function} func The function to modify.
- * @param {Function} string The `toString` result.
- * @returns {Function} Returns `func`.
- */
- var baseSetToString = !_defineProperty$1 ? identity_1 : function(func, string) {
- return _defineProperty$1(func, 'toString', {
- 'configurable': true,
- 'enumerable': false,
- 'value': constant_1(string),
- 'writable': true
- });
- };
- var _baseSetToString = baseSetToString;
- /** Used to detect hot functions by number of calls within a span of milliseconds. */
- var HOT_COUNT = 800,
- HOT_SPAN = 16;
- /* Built-in method references for those with the same name as other `lodash` methods. */
- var nativeNow = Date.now;
- /**
- * Creates a function that'll short out and invoke `identity` instead
- * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
- * milliseconds.
- *
- * @private
- * @param {Function} func The function to restrict.
- * @returns {Function} Returns the new shortable function.
- */
- function shortOut(func) {
- var count = 0,
- lastCalled = 0;
- return function() {
- var stamp = nativeNow(),
- remaining = HOT_SPAN - (stamp - lastCalled);
- lastCalled = stamp;
- if (remaining > 0) {
- if (++count >= HOT_COUNT) {
- return arguments[0];
- }
- } else {
- count = 0;
- }
- return func.apply(undefined, arguments);
- };
- }
- var _shortOut = shortOut;
- /**
- * Sets the `toString` method of `func` to return `string`.
- *
- * @private
- * @param {Function} func The function to modify.
- * @param {Function} string The `toString` result.
- * @returns {Function} Returns `func`.
- */
- var setToString = _shortOut(_baseSetToString);
- var _setToString = setToString;
- /**
- * The base implementation of `_.rest` which doesn't validate or coerce arguments.
- *
- * @private
- * @param {Function} func The function to apply a rest parameter to.
- * @param {number} [start=func.length-1] The start position of the rest parameter.
- * @returns {Function} Returns the new function.
- */
- function baseRest(func, start) {
- return _setToString(_overRest(func, start, identity_1), func + '');
- }
- var _baseRest = baseRest;
- /**
- * Checks if the given arguments are from an iteratee call.
- *
- * @private
- * @param {*} value The potential iteratee value argument.
- * @param {*} index The potential iteratee index or key argument.
- * @param {*} object The potential iteratee object argument.
- * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
- * else `false`.
- */
- function isIterateeCall(value, index, object) {
- if (!isObject_1(object)) {
- return false;
- }
- var type = typeof index;
- if (type == 'number'
- ? (isArrayLike_1(object) && _isIndex(index, object.length))
- : (type == 'string' && index in object)
- ) {
- return eq_1(object[index], value);
- }
- return false;
- }
- var _isIterateeCall = isIterateeCall;
- /**
- * Creates a function like `_.assign`.
- *
- * @private
- * @param {Function} assigner The function to assign values.
- * @returns {Function} Returns the new assigner function.
- */
- function createAssigner(assigner) {
- return _baseRest(function(object, sources) {
- var index = -1,
- length = sources.length,
- customizer = length > 1 ? sources[length - 1] : undefined,
- guard = length > 2 ? sources[2] : undefined;
- customizer = (assigner.length > 3 && typeof customizer == 'function')
- ? (length--, customizer)
- : undefined;
- if (guard && _isIterateeCall(sources[0], sources[1], guard)) {
- customizer = length < 3 ? undefined : customizer;
- length = 1;
- }
- object = Object(object);
- while (++index < length) {
- var source = sources[index];
- if (source) {
- assigner(object, source, index, customizer);
- }
- }
- return object;
- });
- }
- var _createAssigner = createAssigner;
- /**
- * This method is like `_.merge` except that it accepts `customizer` which
- * is invoked to produce the merged values of the destination and source
- * properties. If `customizer` returns `undefined`, merging is handled by the
- * method instead. The `customizer` is invoked with six arguments:
- * (objValue, srcValue, key, object, source, stack).
- *
- * **Note:** This method mutates `object`.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Object
- * @param {Object} object The destination object.
- * @param {...Object} sources The source objects.
- * @param {Function} customizer The function to customize assigned values.
- * @returns {Object} Returns `object`.
- * @example
- *
- * function customizer(objValue, srcValue) {
- * if (_.isArray(objValue)) {
- * return objValue.concat(srcValue);
- * }
- * }
- *
- * var object = { 'a': [1], 'b': [2] };
- * var other = { 'a': [3], 'b': [4] };
- *
- * _.mergeWith(object, other, customizer);
- * // => { 'a': [1, 3], 'b': [2, 4] }
- */
- var mergeWith = _createAssigner(function(object, source, srcIndex, customizer) {
- _baseMerge(object, source, srcIndex, customizer);
- });
- var mergeWith_1 = mergeWith;
- /**
- * A specialized version of `_.forEach` for arrays without support for
- * iteratee shorthands.
- *
- * @private
- * @param {Array} [array] The array to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Array} Returns `array`.
- */
- function arrayEach(array, iteratee) {
- var index = -1,
- length = array == null ? 0 : array.length;
- while (++index < length) {
- if (iteratee(array[index], index, array) === false) {
- break;
- }
- }
- return array;
- }
- var _arrayEach = arrayEach;
- /* Built-in method references for those with the same name as other `lodash` methods. */
- var nativeKeys = _overArg(Object.keys, Object);
- var _nativeKeys = nativeKeys;
- /** Used for built-in method references. */
- var objectProto$b = Object.prototype;
- /** Used to check objects for own properties. */
- var hasOwnProperty$9 = objectProto$b.hasOwnProperty;
- /**
- * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of property names.
- */
- function baseKeys(object) {
- if (!_isPrototype(object)) {
- return _nativeKeys(object);
- }
- var result = [];
- for (var key in Object(object)) {
- if (hasOwnProperty$9.call(object, key) && key != 'constructor') {
- result.push(key);
- }
- }
- return result;
- }
- var _baseKeys = baseKeys;
- /**
- * Creates an array of the own enumerable property names of `object`.
- *
- * **Note:** Non-object values are coerced to objects. See the
- * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
- * for more details.
- *
- * @static
- * @since 0.1.0
- * @memberOf _
- * @category Object
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of property names.
- * @example
- *
- * function Foo() {
- * this.a = 1;
- * this.b = 2;
- * }
- *
- * Foo.prototype.c = 3;
- *
- * _.keys(new Foo);
- * // => ['a', 'b'] (iteration order is not guaranteed)
- *
- * _.keys('hi');
- * // => ['0', '1']
- */
- function keys(object) {
- return isArrayLike_1(object) ? _arrayLikeKeys(object) : _baseKeys(object);
- }
- var keys_1 = keys;
- /**
- * The base implementation of `_.forOwn` without support for iteratee shorthands.
- *
- * @private
- * @param {Object} object The object to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Object} Returns `object`.
- */
- function baseForOwn(object, iteratee) {
- return object && _baseFor(object, iteratee, keys_1);
- }
- var _baseForOwn = baseForOwn;
- /**
- * Creates a `baseEach` or `baseEachRight` function.
- *
- * @private
- * @param {Function} eachFunc The function to iterate over a collection.
- * @param {boolean} [fromRight] Specify iterating from right to left.
- * @returns {Function} Returns the new base function.
- */
- function createBaseEach(eachFunc, fromRight) {
- return function(collection, iteratee) {
- if (collection == null) {
- return collection;
- }
- if (!isArrayLike_1(collection)) {
- return eachFunc(collection, iteratee);
- }
- var length = collection.length,
- index = fromRight ? length : -1,
- iterable = Object(collection);
- while ((fromRight ? index-- : ++index < length)) {
- if (iteratee(iterable[index], index, iterable) === false) {
- break;
- }
- }
- return collection;
- };
- }
- var _createBaseEach = createBaseEach;
- /**
- * The base implementation of `_.forEach` without support for iteratee shorthands.
- *
- * @private
- * @param {Array|Object} collection The collection to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Array|Object} Returns `collection`.
- */
- var baseEach = _createBaseEach(_baseForOwn);
- var _baseEach = baseEach;
- /**
- * Casts `value` to `identity` if it's not a function.
- *
- * @private
- * @param {*} value The value to inspect.
- * @returns {Function} Returns cast function.
- */
- function castFunction(value) {
- return typeof value == 'function' ? value : identity_1;
- }
- var _castFunction = castFunction;
- /**
- * Iterates over elements of `collection` and invokes `iteratee` for each element.
- * The iteratee is invoked with three arguments: (value, index|key, collection).
- * Iteratee functions may exit iteration early by explicitly returning `false`.
- *
- * **Note:** As with other "Collections" methods, objects with a "length"
- * property are iterated like arrays. To avoid this behavior use `_.forIn`
- * or `_.forOwn` for object iteration.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @alias each
- * @category Collection
- * @param {Array|Object} collection The collection to iterate over.
- * @param {Function} [iteratee=_.identity] The function invoked per iteration.
- * @returns {Array|Object} Returns `collection`.
- * @see _.forEachRight
- * @example
- *
- * _.forEach([1, 2], function(value) {
- * console.log(value);
- * });
- * // => Logs `1` then `2`.
- *
- * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
- * console.log(key);
- * });
- * // => Logs 'a' then 'b' (iteration order is not guaranteed).
- */
- function forEach(collection, iteratee) {
- var func = isArray_1(collection) ? _arrayEach : _baseEach;
- return func(collection, _castFunction(iteratee));
- }
- var forEach_1 = forEach;
- var arrayWithHoles = createCommonjsModule(function (module) {
- function _arrayWithHoles(arr) {
- if (Array.isArray(arr)) return arr;
- }
- module.exports = _arrayWithHoles;
- module.exports["default"] = module.exports, module.exports.__esModule = true;
- });
- var iterableToArrayLimit = createCommonjsModule(function (module) {
- function _iterableToArrayLimit(arr, i) {
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
- if (_i == null) return;
- var _arr = [];
- var _n = true;
- var _d = false;
- var _s, _e;
- try {
- for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
- _arr.push(_s.value);
- if (i && _arr.length === i) break;
- }
- } catch (err) {
- _d = true;
- _e = err;
- } finally {
- try {
- if (!_n && _i["return"] != null) _i["return"]();
- } finally {
- if (_d) throw _e;
- }
- }
- return _arr;
- }
- module.exports = _iterableToArrayLimit;
- module.exports["default"] = module.exports, module.exports.__esModule = true;
- });
- var nonIterableRest = createCommonjsModule(function (module) {
- function _nonIterableRest() {
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
- }
- module.exports = _nonIterableRest;
- module.exports["default"] = module.exports, module.exports.__esModule = true;
- });
- var slicedToArray = createCommonjsModule(function (module) {
- function _slicedToArray(arr, i) {
- return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest();
- }
- module.exports = _slicedToArray;
- module.exports["default"] = module.exports, module.exports.__esModule = true;
- });
- var _slicedToArray = /*@__PURE__*/getDefaultExportFromCjs(slicedToArray);
- /**
- * @author Kuitos
- * @homepage https://github.com/kuitos/
- * @since 2019-02-25
- * fork from https://github.com/systemjs/systemjs/blob/master/src/extras/global.js
- */
- var isIE11 = typeof navigator !== 'undefined' && navigator.userAgent.indexOf('Trident') !== -1;
- function shouldSkipProperty(global, p) {
- if (!global.hasOwnProperty(p) || !isNaN(p) && p < global.length) return true;
- if (isIE11) {
- // https://github.com/kuitos/import-html-entry/pull/32,最小化 try 范围
- try {
- return global[p] && typeof window !== 'undefined' && global[p].parent === window;
- } catch (err) {
- return true;
- }
- } else {
- return false;
- }
- } // safari unpredictably lists some new globals first or second in object order
- var firstGlobalProp, secondGlobalProp, lastGlobalProp;
- function getGlobalProp(global) {
- var cnt = 0;
- var lastProp;
- var hasIframe = false;
- for (var p in global) {
- if (shouldSkipProperty(global, p)) continue; // 遍历 iframe,检查 window 上的属性值是否是 iframe,是则跳过后面的 first 和 second 判断
- for (var i = 0; i < window.frames.length && !hasIframe; i++) {
- var frame = window.frames[i];
- if (frame === global[p]) {
- hasIframe = true;
- break;
- }
- }
- if (!hasIframe && (cnt === 0 && p !== firstGlobalProp || cnt === 1 && p !== secondGlobalProp)) return p;
- cnt++;
- lastProp = p;
- }
- if (lastProp !== lastGlobalProp) return lastProp;
- }
- function noteGlobalProps(global) {
- // alternatively Object.keys(global).pop()
- // but this may be faster (pending benchmarks)
- firstGlobalProp = secondGlobalProp = undefined;
- for (var p in global) {
- if (shouldSkipProperty(global, p)) continue;
- if (!firstGlobalProp) firstGlobalProp = p;else if (!secondGlobalProp) secondGlobalProp = p;
- lastGlobalProp = p;
- }
- return lastGlobalProp;
- }
- function getInlineCode(match) {
- var start = match.indexOf('>') + 1;
- var end = match.lastIndexOf('<');
- return match.substring(start, end);
- }
- function defaultGetPublicPath(entry) {
- if (_typeof(entry) === 'object') {
- return '/';
- }
- try {
- // URL 构造函数不支持使用 // 前缀的 url
- var _URL = new URL(entry.startsWith('//') ? "".concat(location.protocol).concat(entry) : entry, location.href),
- origin = _URL.origin,
- pathname = _URL.pathname;
- var paths = pathname.split('/'); // 移除最后一个元素
- paths.pop();
- return "".concat(origin).concat(paths.join('/'), "/");
- } catch (e) {
- console.warn(e);
- return '';
- }
- } // Detect whether browser supports `<script type=module>` or not
- function isModuleScriptSupported() {
- var s = document.createElement('script');
- return 'noModule' in s;
- } // RIC and shim for browsers setTimeout() without it
- var requestIdleCallback = window.requestIdleCallback || function requestIdleCallback(cb) {
- var start = Date.now();
- return setTimeout(function () {
- cb({
- didTimeout: false,
- timeRemaining: function timeRemaining() {
- return Math.max(0, 50 - (Date.now() - start));
- }
- });
- }, 1);
- };
- function readResAsString(response, autoDetectCharset) {
- // 未启用自动检测
- if (!autoDetectCharset) {
- return response.text();
- } // 如果没headers,发生在test环境下的mock数据,为兼容原有测试用例
- if (!response.headers) {
- return response.text();
- } // 如果没返回content-type,走默认逻辑
- var contentType = response.headers.get('Content-Type');
- if (!contentType) {
- return response.text();
- } // 解析content-type内的charset
- // Content-Type: text/html; charset=utf-8
- // Content-Type: multipart/form-data; boundary=something
- // GET请求下不会出现第二种content-type
- var charset = 'utf-8';
- var parts = contentType.split(';');
- if (parts.length === 2) {
- var _parts$1$split = parts[1].split('='),
- _parts$1$split2 = _slicedToArray(_parts$1$split, 2),
- value = _parts$1$split2[1];
- var encoding = value && value.trim();
- if (encoding) {
- charset = encoding;
- }
- } // 如果还是utf-8,那么走默认,兼容原有逻辑,这段代码删除也应该工作
- if (charset.toUpperCase() === 'UTF-8') {
- return response.text();
- } // 走流读取,编码可能是gbk,gb2312等,比如sofa 3默认是gbk编码
- return response.blob().then(function (file) {
- return new Promise(function (resolve, reject) {
- var reader = new window.FileReader();
- reader.onload = function () {
- resolve(reader.result);
- };
- reader.onerror = reject;
- reader.readAsText(file, charset);
- });
- });
- }
- var ALL_SCRIPT_REGEX = /(<script[\s\S]*?>)[\s\S]*?<\/script>/gi;
- 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;
- var SCRIPT_SRC_REGEX = /.*\ssrc=('|")?([^>'"\s]+)/;
- var SCRIPT_TYPE_REGEX = /.*\stype=('|")?([^>'"\s]+)/;
- var SCRIPT_ENTRY_REGEX = /.*\sentry\s*.*/;
- var SCRIPT_ASYNC_REGEX = /.*\sasync\s*.*/;
- var SCRIPT_NO_MODULE_REGEX = /.*\snomodule\s*.*/;
- var SCRIPT_MODULE_REGEX = /.*\stype=('|")?module('|")?\s*.*/;
- var LINK_TAG_REGEX = /<(link)[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+[\s\S]*?>/ig;
- var LINK_PRELOAD_OR_PREFETCH_REGEX = /\srel=('|")?(preload|prefetch)\1/;
- var LINK_HREF_REGEX = /.*\shref=('|")?([^>'"\s]+)/;
- var LINK_AS_FONT = /.*\sas=('|")?font\1.*/;
- var STYLE_TAG_REGEX = /<style[^>]*>[\s\S]*?<\/style>/gi;
- var STYLE_TYPE_REGEX = /\s+rel=('|")?stylesheet\1.*/;
- var STYLE_HREF_REGEX = /.*\shref=('|")?([^>'"\s]+)/;
- var HTML_COMMENT_REGEX = /<!--([\s\S]*?)-->/g;
- 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;
- 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;
- 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;
- function hasProtocol(url) {
- return url.startsWith('//') || url.startsWith('http://') || url.startsWith('https://');
- }
- function getEntirePath(path, baseURI) {
- return new URL(path, baseURI).toString();
- }
- function isValidJavaScriptType(type) {
- var handleTypes = ['text/javascript', 'module', 'application/javascript', 'text/ecmascript', 'application/ecmascript'];
- return !type || handleTypes.indexOf(type) !== -1;
- }
- var genLinkReplaceSymbol = function genLinkReplaceSymbol(linkHref) {
- var preloadOrPrefetch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
- return "<!-- ".concat(preloadOrPrefetch ? 'prefetch/preload' : '', " link ").concat(linkHref, " replaced by import-html-entry -->");
- };
- var genScriptReplaceSymbol = function genScriptReplaceSymbol(scriptSrc) {
- var async = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
- return "<!-- ".concat(async ? 'async' : '', " script ").concat(scriptSrc, " replaced by import-html-entry -->");
- };
- var inlineScriptReplaceSymbol = "<!-- inline scripts replaced by import-html-entry -->";
- var genIgnoreAssetReplaceSymbol = function genIgnoreAssetReplaceSymbol(url) {
- return "<!-- ignore asset ".concat(url || 'file', " replaced by import-html-entry -->");
- };
- var genModuleScriptReplaceSymbol = function genModuleScriptReplaceSymbol(scriptSrc, moduleSupport) {
- return "<!-- ".concat(moduleSupport ? 'nomodule' : 'module', " script ").concat(scriptSrc, " ignored by import-html-entry -->");
- };
- /**
- * parse the script link from the template
- * 1. collect stylesheets
- * 2. use global eval to evaluate the inline scripts
- * see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function#Difference_between_Function_constructor_and_function_declaration
- * see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval#Do_not_ever_use_eval!
- * @param tpl
- * @param baseURI
- * @stripStyles whether to strip the css links
- * @returns {{template: void | string | *, scripts: *[], entry: *}}
- */
- function processTpl(tpl, baseURI) {
- var scripts = [];
- var styles = [];
- var entry = null;
- var moduleSupport = isModuleScriptSupported();
- var template = tpl
- /*
- remove html comment first
- */
- .replace(HTML_COMMENT_REGEX, '').replace(LINK_TAG_REGEX, function (match) {
- /*
- change the css link
- */
- var styleType = !!match.match(STYLE_TYPE_REGEX);
- if (styleType) {
- var styleHref = match.match(STYLE_HREF_REGEX);
- var styleIgnore = match.match(LINK_IGNORE_REGEX);
- if (styleHref) {
- var href = styleHref && styleHref[2];
- var newHref = href;
- if (href && !hasProtocol(href)) {
- newHref = getEntirePath(href, baseURI);
- }
- if (styleIgnore) {
- return genIgnoreAssetReplaceSymbol(newHref);
- }
- styles.push(newHref);
- return genLinkReplaceSymbol(newHref);
- }
- }
- var preloadOrPrefetchType = match.match(LINK_PRELOAD_OR_PREFETCH_REGEX) && match.match(LINK_HREF_REGEX) && !match.match(LINK_AS_FONT);
- if (preloadOrPrefetchType) {
- var _match$match = match.match(LINK_HREF_REGEX),
- _match$match2 = _slicedToArray(_match$match, 3),
- linkHref = _match$match2[2];
- return genLinkReplaceSymbol(linkHref, true);
- }
- return match;
- }).replace(STYLE_TAG_REGEX, function (match) {
- if (STYLE_IGNORE_REGEX.test(match)) {
- return genIgnoreAssetReplaceSymbol('style file');
- }
- return match;
- }).replace(ALL_SCRIPT_REGEX, function (match, scriptTag) {
- var scriptIgnore = scriptTag.match(SCRIPT_IGNORE_REGEX);
- 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
- var matchedScriptTypeMatch = scriptTag.match(SCRIPT_TYPE_REGEX);
- var matchedScriptType = matchedScriptTypeMatch && matchedScriptTypeMatch[2];
- if (!isValidJavaScriptType(matchedScriptType)) {
- return match;
- } // if it is a external script
- if (SCRIPT_TAG_REGEX.test(match) && scriptTag.match(SCRIPT_SRC_REGEX)) {
- /*
- collect scripts and replace the ref
- */
- var matchedScriptEntry = scriptTag.match(SCRIPT_ENTRY_REGEX);
- var matchedScriptSrcMatch = scriptTag.match(SCRIPT_SRC_REGEX);
- var matchedScriptSrc = matchedScriptSrcMatch && matchedScriptSrcMatch[2];
- if (entry && matchedScriptEntry) {
- throw new SyntaxError('You should not set multiply entry script!');
- } else {
- // append the domain while the script not have an protocol prefix
- if (matchedScriptSrc && !hasProtocol(matchedScriptSrc)) {
- matchedScriptSrc = getEntirePath(matchedScriptSrc, baseURI);
- }
- entry = entry || matchedScriptEntry && matchedScriptSrc;
- }
- if (scriptIgnore) {
- return genIgnoreAssetReplaceSymbol(matchedScriptSrc || 'js file');
- }
- if (moduleScriptIgnore) {
- return genModuleScriptReplaceSymbol(matchedScriptSrc || 'js file', moduleSupport);
- }
- if (matchedScriptSrc) {
- var asyncScript = !!scriptTag.match(SCRIPT_ASYNC_REGEX);
- scripts.push(asyncScript ? {
- async: true,
- src: matchedScriptSrc
- } : matchedScriptSrc);
- return genScriptReplaceSymbol(matchedScriptSrc, asyncScript);
- }
- return match;
- } else {
- if (scriptIgnore) {
- return genIgnoreAssetReplaceSymbol('js file');
- }
- if (moduleScriptIgnore) {
- return genModuleScriptReplaceSymbol('js file', moduleSupport);
- } // if it is an inline script
- var code = getInlineCode(match); // remove script blocks when all of these lines are comments.
- var isPureCommentBlock = code.split(/[\r\n]+/).every(function (line) {
- return !line.trim() || line.trim().startsWith('//');
- });
- if (!isPureCommentBlock) {
- scripts.push(match);
- }
- return inlineScriptReplaceSymbol;
- }
- });
- scripts = scripts.filter(function (script) {
- // filter empty script
- return !!script;
- });
- return {
- template: template,
- scripts: scripts,
- styles: styles,
- // set the last script as entry if have not set
- entry: entry || scripts[scripts.length - 1]
- };
- }
- /**
- * @author Kuitos
- * @homepage https://github.com/kuitos/
- * @since 2018-08-15 11:37
- */
- var styleCache = {};
- var scriptCache = {};
- var embedHTMLCache = {};
- if (!window.fetch) {
- throw new Error('[import-html-entry] Here is no "fetch" on the window env, you need to polyfill it');
- }
- var defaultFetch = window.fetch.bind(window);
- function defaultGetTemplate(tpl) {
- return tpl;
- }
- /**
- * convert external css link to inline style for performance optimization
- * @param template
- * @param styles
- * @param opts
- * @return embedHTML
- */
- function getEmbedHTML(template, styles) {
- var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
- var _opts$fetch = opts.fetch,
- fetch = _opts$fetch === void 0 ? defaultFetch : _opts$fetch;
- var embedHTML = template;
- return _getExternalStyleSheets(styles, fetch).then(function (styleSheets) {
- embedHTML = styles.reduce(function (html, styleSrc, i) {
- html = html.replace(genLinkReplaceSymbol(styleSrc), "<style>/* ".concat(styleSrc, " */").concat(styleSheets[i], "</style>"));
- return html;
- }, embedHTML);
- return embedHTML;
- });
- }
- var isInlineCode = function isInlineCode(code) {
- return code.startsWith('<');
- };
- function getExecutableScript(scriptSrc, scriptText, proxy, strictGlobal) {
- var sourceUrl = isInlineCode(scriptSrc) ? '' : "//# sourceURL=".concat(scriptSrc, "\n"); // 通过这种方式获取全局 window,因为 script 也是在全局作用域下运行的,所以我们通过 window.proxy 绑定时也必须确保绑定到全局 window 上
- // 否则在嵌套场景下, window.proxy 设置的是内层应用的 window,而代码其实是在全局作用域运行的,会导致闭包里的 window.proxy 取的是最外层的微应用的 proxy
- var globalWindow = (0, eval)('window');
- globalWindow.proxy = proxy; // TODO 通过 strictGlobal 方式切换切换 with 闭包,待 with 方式坑趟平后再合并
- 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);");
- } // for prefetch
- function _getExternalStyleSheets(styles) {
- var fetch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultFetch;
- return Promise.all(styles.map(function (styleLink) {
- if (isInlineCode(styleLink)) {
- // if it is inline style
- return getInlineCode(styleLink);
- } else {
- // external styles
- return styleCache[styleLink] || (styleCache[styleLink] = fetch(styleLink).then(function (response) {
- return response.text();
- }));
- }
- }));
- } // for prefetch
- function _getExternalScripts(scripts) {
- var fetch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultFetch;
- var errorCallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {};
- var fetchScript = function fetchScript(scriptUrl) {
- return scriptCache[scriptUrl] || (scriptCache[scriptUrl] = fetch(scriptUrl).then(function (response) {
- // usually browser treats 4xx and 5xx response of script loading as an error and will fire a script error event
- // https://stackoverflow.com/questions/5625420/what-http-headers-responses-trigger-the-onerror-handler-on-a-script-tag/5625603
- if (response.status >= 400) {
- errorCallback();
- throw new Error("".concat(scriptUrl, " load failed with status ").concat(response.status));
- }
- return response.text();
- }));
- };
- return Promise.all(scripts.map(function (script) {
- if (typeof script === 'string') {
- if (isInlineCode(script)) {
- // if it is inline script
- return getInlineCode(script);
- } else {
- // external script
- return fetchScript(script);
- }
- } else {
- // use idle time to load async script
- var src = script.src,
- async = script.async;
- if (async) {
- return {
- src: src,
- async: true,
- content: new Promise(function (resolve, reject) {
- return requestIdleCallback(function () {
- return fetchScript(src).then(resolve, reject);
- });
- })
- };
- }
- return fetchScript(src);
- }
- }));
- }
- function throwNonBlockingError(error, msg) {
- setTimeout(function () {
- console.error(msg);
- throw error;
- });
- }
- var supportsUserTiming = typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function';
- /**
- * FIXME to consistent with browser behavior, we should only provide callback way to invoke success and error event
- * @param entry
- * @param scripts
- * @param proxy
- * @param opts
- * @returns {Promise<unknown>}
- */
- function _execScripts(entry, scripts) {
- var proxy = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : window;
- var opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
- var _opts$fetch2 = opts.fetch,
- fetch = _opts$fetch2 === void 0 ? defaultFetch : _opts$fetch2,
- _opts$strictGlobal = opts.strictGlobal,
- strictGlobal = _opts$strictGlobal === void 0 ? false : _opts$strictGlobal,
- success = opts.success,
- _opts$error = opts.error,
- error = _opts$error === void 0 ? function () {} : _opts$error,
- _opts$beforeExec = opts.beforeExec,
- beforeExec = _opts$beforeExec === void 0 ? function () {} : _opts$beforeExec,
- _opts$afterExec = opts.afterExec,
- afterExec = _opts$afterExec === void 0 ? function () {} : _opts$afterExec;
- return _getExternalScripts(scripts, fetch, error).then(function (scriptsText) {
- var geval = function geval(scriptSrc, inlineScript) {
- var rawCode = beforeExec(inlineScript, scriptSrc) || inlineScript;
- var code = getExecutableScript(scriptSrc, rawCode, proxy, strictGlobal);
- (0, eval)(code);
- afterExec(inlineScript, scriptSrc);
- };
- function exec(scriptSrc, inlineScript, resolve) {
- var markName = "Evaluating script ".concat(scriptSrc);
- var measureName = "Evaluating Time Consuming: ".concat(scriptSrc);
- if ( supportsUserTiming) {
- performance.mark(markName);
- }
- if (scriptSrc === entry) {
- noteGlobalProps(strictGlobal ? proxy : window);
- try {
- // bind window.proxy to change `this` reference in script
- geval(scriptSrc, inlineScript);
- var exports = proxy[getGlobalProp(strictGlobal ? proxy : window)] || {};
- resolve(exports);
- } catch (e) {
- // entry error must be thrown to make the promise settled
- console.error("[import-html-entry]: error occurs while executing entry script ".concat(scriptSrc));
- throw e;
- }
- } else {
- if (typeof inlineScript === 'string') {
- try {
- // bind window.proxy to change `this` reference in script
- geval(scriptSrc, inlineScript);
- } catch (e) {
- // consistent with browser behavior, any independent script evaluation error should not block the others
- throwNonBlockingError(e, "[import-html-entry]: error occurs while executing normal script ".concat(scriptSrc));
- }
- } else {
- // external script marked with async
- inlineScript.async && (inlineScript === null || inlineScript === void 0 ? void 0 : inlineScript.content.then(function (downloadedScriptText) {
- return geval(inlineScript.src, downloadedScriptText);
- })["catch"](function (e) {
- throwNonBlockingError(e, "[import-html-entry]: error occurs while executing async script ".concat(inlineScript.src));
- }));
- }
- }
- if ( supportsUserTiming) {
- performance.measure(measureName, markName);
- performance.clearMarks(markName);
- performance.clearMeasures(measureName);
- }
- }
- function schedule(i, resolvePromise) {
- if (i < scripts.length) {
- var scriptSrc = scripts[i];
- var inlineScript = scriptsText[i];
- exec(scriptSrc, inlineScript, resolvePromise); // resolve the promise while the last script executed and entry not provided
- if (!entry && i === scripts.length - 1) {
- resolvePromise();
- } else {
- schedule(i + 1, resolvePromise);
- }
- }
- }
- return new Promise(function (resolve) {
- return schedule(0, success || resolve);
- });
- });
- }
- function importHTML(url) {
- var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
- var fetch = defaultFetch;
- var autoDecodeResponse = false;
- var getPublicPath = defaultGetPublicPath;
- var getTemplate = defaultGetTemplate; // compatible with the legacy importHTML api
- if (typeof opts === 'function') {
- fetch = opts;
- } else {
- // fetch option is availble
- if (opts.fetch) {
- // fetch is a funciton
- if (typeof opts.fetch === 'function') {
- fetch = opts.fetch;
- } else {
- // configuration
- fetch = opts.fetch.fn || defaultFetch;
- autoDecodeResponse = !!opts.fetch.autoDecodeResponse;
- }
- }
- getPublicPath = opts.getPublicPath || opts.getDomain || defaultGetPublicPath;
- getTemplate = opts.getTemplate || defaultGetTemplate;
- }
- return embedHTMLCache[url] || (embedHTMLCache[url] = fetch(url).then(function (response) {
- return readResAsString(response, autoDecodeResponse);
- }).then(function (html) {
- var assetPublicPath = getPublicPath(url);
- var _processTpl = processTpl(getTemplate(html), assetPublicPath),
- template = _processTpl.template,
- scripts = _processTpl.scripts,
- entry = _processTpl.entry,
- styles = _processTpl.styles;
- return getEmbedHTML(template, styles, {
- fetch: fetch
- }).then(function (embedHTML) {
- return {
- template: embedHTML,
- assetPublicPath: assetPublicPath,
- getExternalScripts: function getExternalScripts() {
- return _getExternalScripts(scripts, fetch);
- },
- getExternalStyleSheets: function getExternalStyleSheets() {
- return _getExternalStyleSheets(styles, fetch);
- },
- execScripts: function execScripts(proxy, strictGlobal) {
- var execScriptsHooks = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
- if (!scripts.length) {
- return Promise.resolve();
- }
- return _execScripts(entry, scripts, proxy, {
- fetch: fetch,
- strictGlobal: strictGlobal,
- beforeExec: execScriptsHooks.beforeExec,
- afterExec: execScriptsHooks.afterExec
- });
- }
- };
- });
- }));
- }
- function importEntry(entry) {
- var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
- var _opts$fetch3 = opts.fetch,
- fetch = _opts$fetch3 === void 0 ? defaultFetch : _opts$fetch3,
- _opts$getTemplate = opts.getTemplate,
- getTemplate = _opts$getTemplate === void 0 ? defaultGetTemplate : _opts$getTemplate;
- var getPublicPath = opts.getPublicPath || opts.getDomain || defaultGetPublicPath;
- if (!entry) {
- throw new SyntaxError('entry should not be empty!');
- } // html entry
- if (typeof entry === 'string') {
- return importHTML(entry, {
- fetch: fetch,
- getPublicPath: getPublicPath,
- getTemplate: getTemplate
- });
- } // config entry
- if (Array.isArray(entry.scripts) || Array.isArray(entry.styles)) {
- var _entry$scripts = entry.scripts,
- scripts = _entry$scripts === void 0 ? [] : _entry$scripts,
- _entry$styles = entry.styles,
- styles = _entry$styles === void 0 ? [] : _entry$styles,
- _entry$html = entry.html,
- html = _entry$html === void 0 ? '' : _entry$html;
- var setStylePlaceholder2HTML = function setStylePlaceholder2HTML(tpl) {
- return styles.reduceRight(function (html, styleSrc) {
- return "".concat(genLinkReplaceSymbol(styleSrc)).concat(html);
- }, tpl);
- };
- var setScriptPlaceholder2HTML = function setScriptPlaceholder2HTML(tpl) {
- return scripts.reduce(function (html, scriptSrc) {
- return "".concat(html).concat(genScriptReplaceSymbol(scriptSrc));
- }, tpl);
- };
- return getEmbedHTML(getTemplate(setScriptPlaceholder2HTML(setStylePlaceholder2HTML(html))), styles, {
- fetch: fetch
- }).then(function (embedHTML) {
- return {
- template: embedHTML,
- assetPublicPath: getPublicPath(entry),
- getExternalScripts: function getExternalScripts() {
- return _getExternalScripts(scripts, fetch);
- },
- getExternalStyleSheets: function getExternalStyleSheets() {
- return _getExternalStyleSheets(styles, fetch);
- },
- execScripts: function execScripts(proxy, strictGlobal) {
- var execScriptsHooks = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
- if (!scripts.length) {
- return Promise.resolve();
- }
- return _execScripts(scripts[scripts.length - 1], scripts, proxy, {
- fetch: fetch,
- strictGlobal: strictGlobal,
- beforeExec: execScriptsHooks.beforeExec,
- afterExec: execScriptsHooks.afterExec
- });
- }
- };
- });
- } else {
- throw new SyntaxError('entry scripts or styles should be array!');
- }
- }
- var rawPublicPath = window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__;
- function getAddOn(global) {
- var publicPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '/';
- var hasMountedOnce = false;
- return {
- beforeLoad: function beforeLoad() {
- return _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
- return regenerator.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- // eslint-disable-next-line no-param-reassign
- global.__INJECTED_PUBLIC_PATH_BY_QIANKUN__ = publicPath;
- case 1:
- case "end":
- return _context.stop();
- }
- }
- }, _callee);
- }))();
- },
- beforeMount: function beforeMount() {
- return _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
- return regenerator.wrap(function _callee2$(_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- if (hasMountedOnce) {
- // eslint-disable-next-line no-param-reassign
- global.__INJECTED_PUBLIC_PATH_BY_QIANKUN__ = publicPath;
- }
- case 1:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee2);
- }))();
- },
- beforeUnmount: function beforeUnmount() {
- return _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
- return regenerator.wrap(function _callee3$(_context3) {
- while (1) {
- switch (_context3.prev = _context3.next) {
- case 0:
- if (rawPublicPath === undefined) {
- // eslint-disable-next-line no-param-reassign
- delete global.__INJECTED_PUBLIC_PATH_BY_QIANKUN__;
- } else {
- // eslint-disable-next-line no-param-reassign
- global.__INJECTED_PUBLIC_PATH_BY_QIANKUN__ = rawPublicPath;
- }
- hasMountedOnce = true;
- case 2:
- case "end":
- return _context3.stop();
- }
- }
- }, _callee3);
- }))();
- }
- };
- }
- /**
- * @author Kuitos
- * @since 2020-05-15
- */
- function getAddOn$1(global) {
- return {
- beforeLoad: function beforeLoad() {
- return _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
- return regenerator.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- // eslint-disable-next-line no-param-reassign
- global.__POWERED_BY_QIANKUN__ = true;
- case 1:
- case "end":
- return _context.stop();
- }
- }
- }, _callee);
- }))();
- },
- beforeMount: function beforeMount() {
- return _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
- return regenerator.wrap(function _callee2$(_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- // eslint-disable-next-line no-param-reassign
- global.__POWERED_BY_QIANKUN__ = true;
- case 1:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee2);
- }))();
- },
- beforeUnmount: function beforeUnmount() {
- return _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
- return regenerator.wrap(function _callee3$(_context3) {
- while (1) {
- switch (_context3.prev = _context3.next) {
- case 0:
- // eslint-disable-next-line no-param-reassign
- delete global.__POWERED_BY_QIANKUN__;
- case 1:
- case "end":
- return _context3.stop();
- }
- }
- }, _callee3);
- }))();
- }
- };
- }
- function getAddOns(global, publicPath) {
- return mergeWith_1({}, getAddOn$1(global), getAddOn(global, publicPath), function (v1, v2) {
- return concat_1(v1 !== null && v1 !== void 0 ? v1 : [], v2 !== null && v2 !== void 0 ? v2 : []);
- });
- }
- var classCallCheck = createCommonjsModule(function (module) {
- function _classCallCheck(instance, Constructor) {
- if (!(instance instanceof Constructor)) {
- throw new TypeError("Cannot call a class as a function");
- }
- }
- module.exports = _classCallCheck;
- module.exports["default"] = module.exports, module.exports.__esModule = true;
- });
- var _classCallCheck = /*@__PURE__*/getDefaultExportFromCjs(classCallCheck);
- var setPrototypeOf = createCommonjsModule(function (module) {
- function _setPrototypeOf(o, p) {
- module.exports = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
- o.__proto__ = p;
- return o;
- };
- module.exports["default"] = module.exports, module.exports.__esModule = true;
- return _setPrototypeOf(o, p);
- }
- module.exports = _setPrototypeOf;
- module.exports["default"] = module.exports, module.exports.__esModule = true;
- });
- var inherits = createCommonjsModule(function (module) {
- function _inherits(subClass, superClass) {
- if (typeof superClass !== "function" && superClass !== null) {
- throw new TypeError("Super expression must either be null or a function");
- }
- subClass.prototype = Object.create(superClass && superClass.prototype, {
- constructor: {
- value: subClass,
- writable: true,
- configurable: true
- }
- });
- if (superClass) setPrototypeOf(subClass, superClass);
- }
- module.exports = _inherits;
- module.exports["default"] = module.exports, module.exports.__esModule = true;
- });
- var _inherits = /*@__PURE__*/getDefaultExportFromCjs(inherits);
- var getPrototypeOf = createCommonjsModule(function (module) {
- function _getPrototypeOf(o) {
- module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
- return o.__proto__ || Object.getPrototypeOf(o);
- };
- module.exports["default"] = module.exports, module.exports.__esModule = true;
- return _getPrototypeOf(o);
- }
- module.exports = _getPrototypeOf;
- module.exports["default"] = module.exports, module.exports.__esModule = true;
- });
- var isNativeReflectConstruct = createCommonjsModule(function (module) {
- function _isNativeReflectConstruct() {
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
- if (Reflect.construct.sham) return false;
- if (typeof Proxy === "function") return true;
- try {
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
- return true;
- } catch (e) {
- return false;
- }
- }
- module.exports = _isNativeReflectConstruct;
- module.exports["default"] = module.exports, module.exports.__esModule = true;
- });
- var assertThisInitialized = createCommonjsModule(function (module) {
- function _assertThisInitialized(self) {
- if (self === void 0) {
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
- }
- return self;
- }
- module.exports = _assertThisInitialized;
- module.exports["default"] = module.exports, module.exports.__esModule = true;
- });
- var possibleConstructorReturn = createCommonjsModule(function (module) {
- var _typeof = _typeof_1["default"];
- function _possibleConstructorReturn(self, call) {
- if (call && (_typeof(call) === "object" || typeof call === "function")) {
- return call;
- } else if (call !== void 0) {
- throw new TypeError("Derived constructors may only return object or undefined");
- }
- return assertThisInitialized(self);
- }
- module.exports = _possibleConstructorReturn;
- module.exports["default"] = module.exports, module.exports.__esModule = true;
- });
- var createSuper = createCommonjsModule(function (module) {
- function _createSuper(Derived) {
- var hasNativeReflectConstruct = isNativeReflectConstruct();
- return function _createSuperInternal() {
- var Super = getPrototypeOf(Derived),
- result;
- if (hasNativeReflectConstruct) {
- var NewTarget = getPrototypeOf(this).constructor;
- result = Reflect.construct(Super, arguments, NewTarget);
- } else {
- result = Super.apply(this, arguments);
- }
- return possibleConstructorReturn(this, result);
- };
- }
- module.exports = _createSuper;
- module.exports["default"] = module.exports, module.exports.__esModule = true;
- });
- var _createSuper = /*@__PURE__*/getDefaultExportFromCjs(createSuper);
- var isNativeFunction = createCommonjsModule(function (module) {
- function _isNativeFunction(fn) {
- return Function.toString.call(fn).indexOf("[native code]") !== -1;
- }
- module.exports = _isNativeFunction;
- module.exports["default"] = module.exports, module.exports.__esModule = true;
- });
- var construct = createCommonjsModule(function (module) {
- function _construct(Parent, args, Class) {
- if (isNativeReflectConstruct()) {
- module.exports = _construct = Reflect.construct;
- module.exports["default"] = module.exports, module.exports.__esModule = true;
- } else {
- module.exports = _construct = function _construct(Parent, args, Class) {
- var a = [null];
- a.push.apply(a, args);
- var Constructor = Function.bind.apply(Parent, a);
- var instance = new Constructor();
- if (Class) setPrototypeOf(instance, Class.prototype);
- return instance;
- };
- module.exports["default"] = module.exports, module.exports.__esModule = true;
- }
- return _construct.apply(null, arguments);
- }
- module.exports = _construct;
- module.exports["default"] = module.exports, module.exports.__esModule = true;
- });
- var wrapNativeSuper = createCommonjsModule(function (module) {
- function _wrapNativeSuper(Class) {
- var _cache = typeof Map === "function" ? new Map() : undefined;
- module.exports = _wrapNativeSuper = function _wrapNativeSuper(Class) {
- if (Class === null || !isNativeFunction(Class)) return Class;
- if (typeof Class !== "function") {
- throw new TypeError("Super expression must either be null or a function");
- }
- if (typeof _cache !== "undefined") {
- if (_cache.has(Class)) return _cache.get(Class);
- _cache.set(Class, Wrapper);
- }
- function Wrapper() {
- return construct(Class, arguments, getPrototypeOf(this).constructor);
- }
- Wrapper.prototype = Object.create(Class.prototype, {
- constructor: {
- value: Wrapper,
- enumerable: false,
- writable: true,
- configurable: true
- }
- });
- return setPrototypeOf(Wrapper, Class);
- };
- module.exports["default"] = module.exports, module.exports.__esModule = true;
- return _wrapNativeSuper(Class);
- }
- module.exports = _wrapNativeSuper;
- module.exports["default"] = module.exports, module.exports.__esModule = true;
- });
- var _wrapNativeSuper = /*@__PURE__*/getDefaultExportFromCjs(wrapNativeSuper);
- var QiankunError = /*#__PURE__*/function (_Error) {
- _inherits(QiankunError, _Error);
- var _super = _createSuper(QiankunError);
- function QiankunError(message) {
- _classCallCheck(this, QiankunError);
- return _super.call(this, "[qiankun]: ".concat(message));
- }
- return QiankunError;
- }( /*#__PURE__*/_wrapNativeSuper(Error));
- /**
- * The base implementation of `_.assign` without support for multiple sources
- * or `customizer` functions.
- *
- * @private
- * @param {Object} object The destination object.
- * @param {Object} source The source object.
- * @returns {Object} Returns `object`.
- */
- function baseAssign(object, source) {
- return object && _copyObject(source, keys_1(source), object);
- }
- var _baseAssign = baseAssign;
- /**
- * The base implementation of `_.assignIn` without support for multiple sources
- * or `customizer` functions.
- *
- * @private
- * @param {Object} object The destination object.
- * @param {Object} source The source object.
- * @returns {Object} Returns `object`.
- */
- function baseAssignIn(object, source) {
- return object && _copyObject(source, keysIn_1(source), object);
- }
- var _baseAssignIn = baseAssignIn;
- /**
- * A specialized version of `_.filter` for arrays without support for
- * iteratee shorthands.
- *
- * @private
- * @param {Array} [array] The array to iterate over.
- * @param {Function} predicate The function invoked per iteration.
- * @returns {Array} Returns the new filtered array.
- */
- function arrayFilter(array, predicate) {
- var index = -1,
- length = array == null ? 0 : array.length,
- resIndex = 0,
- result = [];
- while (++index < length) {
- var value = array[index];
- if (predicate(value, index, array)) {
- result[resIndex++] = value;
- }
- }
- return result;
- }
- var _arrayFilter = arrayFilter;
- /**
- * This method returns a new empty array.
- *
- * @static
- * @memberOf _
- * @since 4.13.0
- * @category Util
- * @returns {Array} Returns the new empty array.
- * @example
- *
- * var arrays = _.times(2, _.stubArray);
- *
- * console.log(arrays);
- * // => [[], []]
- *
- * console.log(arrays[0] === arrays[1]);
- * // => false
- */
- function stubArray() {
- return [];
- }
- var stubArray_1 = stubArray;
- /** Used for built-in method references. */
- var objectProto$c = Object.prototype;
- /** Built-in value references. */
- var propertyIsEnumerable$1 = objectProto$c.propertyIsEnumerable;
- /* Built-in method references for those with the same name as other `lodash` methods. */
- var nativeGetSymbols = Object.getOwnPropertySymbols;
- /**
- * Creates an array of the own enumerable symbols of `object`.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of symbols.
- */
- var getSymbols = !nativeGetSymbols ? stubArray_1 : function(object) {
- if (object == null) {
- return [];
- }
- object = Object(object);
- return _arrayFilter(nativeGetSymbols(object), function(symbol) {
- return propertyIsEnumerable$1.call(object, symbol);
- });
- };
- var _getSymbols = getSymbols;
- /**
- * Copies own symbols of `source` to `object`.
- *
- * @private
- * @param {Object} source The object to copy symbols from.
- * @param {Object} [object={}] The object to copy symbols to.
- * @returns {Object} Returns `object`.
- */
- function copySymbols(source, object) {
- return _copyObject(source, _getSymbols(source), object);
- }
- var _copySymbols = copySymbols;
- /* Built-in method references for those with the same name as other `lodash` methods. */
- var nativeGetSymbols$1 = Object.getOwnPropertySymbols;
- /**
- * Creates an array of the own and inherited enumerable symbols of `object`.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of symbols.
- */
- var getSymbolsIn = !nativeGetSymbols$1 ? stubArray_1 : function(object) {
- var result = [];
- while (object) {
- _arrayPush(result, _getSymbols(object));
- object = _getPrototype(object);
- }
- return result;
- };
- var _getSymbolsIn = getSymbolsIn;
- /**
- * Copies own and inherited symbols of `source` to `object`.
- *
- * @private
- * @param {Object} source The object to copy symbols from.
- * @param {Object} [object={}] The object to copy symbols to.
- * @returns {Object} Returns `object`.
- */
- function copySymbolsIn(source, object) {
- return _copyObject(source, _getSymbolsIn(source), object);
- }
- var _copySymbolsIn = copySymbolsIn;
- /**
- * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
- * `keysFunc` and `symbolsFunc` to get the enumerable property names and
- * symbols of `object`.
- *
- * @private
- * @param {Object} object The object to query.
- * @param {Function} keysFunc The function to get the keys of `object`.
- * @param {Function} symbolsFunc The function to get the symbols of `object`.
- * @returns {Array} Returns the array of property names and symbols.
- */
- function baseGetAllKeys(object, keysFunc, symbolsFunc) {
- var result = keysFunc(object);
- return isArray_1(object) ? result : _arrayPush(result, symbolsFunc(object));
- }
- var _baseGetAllKeys = baseGetAllKeys;
- /**
- * Creates an array of own enumerable property names and symbols of `object`.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of property names and symbols.
- */
- function getAllKeys(object) {
- return _baseGetAllKeys(object, keys_1, _getSymbols);
- }
- var _getAllKeys = getAllKeys;
- /**
- * Creates an array of own and inherited enumerable property names and
- * symbols of `object`.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of property names and symbols.
- */
- function getAllKeysIn(object) {
- return _baseGetAllKeys(object, keysIn_1, _getSymbolsIn);
- }
- var _getAllKeysIn = getAllKeysIn;
- /* Built-in method references that are verified to be native. */
- var DataView = _getNative(_root, 'DataView');
- var _DataView = DataView;
- /* Built-in method references that are verified to be native. */
- var Promise$1 = _getNative(_root, 'Promise');
- var _Promise = Promise$1;
- /* Built-in method references that are verified to be native. */
- var Set$1 = _getNative(_root, 'Set');
- var _Set = Set$1;
- /* Built-in method references that are verified to be native. */
- var WeakMap$1 = _getNative(_root, 'WeakMap');
- var _WeakMap = WeakMap$1;
- /** `Object#toString` result references. */
- var mapTag$1 = '[object Map]',
- objectTag$2 = '[object Object]',
- promiseTag = '[object Promise]',
- setTag$1 = '[object Set]',
- weakMapTag$1 = '[object WeakMap]';
- var dataViewTag$1 = '[object DataView]';
- /** Used to detect maps, sets, and weakmaps. */
- var dataViewCtorString = _toSource(_DataView),
- mapCtorString = _toSource(_Map),
- promiseCtorString = _toSource(_Promise),
- setCtorString = _toSource(_Set),
- weakMapCtorString = _toSource(_WeakMap);
- /**
- * Gets the `toStringTag` of `value`.
- *
- * @private
- * @param {*} value The value to query.
- * @returns {string} Returns the `toStringTag`.
- */
- var getTag = _baseGetTag;
- // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
- if ((_DataView && getTag(new _DataView(new ArrayBuffer(1))) != dataViewTag$1) ||
- (_Map && getTag(new _Map) != mapTag$1) ||
- (_Promise && getTag(_Promise.resolve()) != promiseTag) ||
- (_Set && getTag(new _Set) != setTag$1) ||
- (_WeakMap && getTag(new _WeakMap) != weakMapTag$1)) {
- getTag = function(value) {
- var result = _baseGetTag(value),
- Ctor = result == objectTag$2 ? value.constructor : undefined,
- ctorString = Ctor ? _toSource(Ctor) : '';
- if (ctorString) {
- switch (ctorString) {
- case dataViewCtorString: return dataViewTag$1;
- case mapCtorString: return mapTag$1;
- case promiseCtorString: return promiseTag;
- case setCtorString: return setTag$1;
- case weakMapCtorString: return weakMapTag$1;
- }
- }
- return result;
- };
- }
- var _getTag = getTag;
- /** Used for built-in method references. */
- var objectProto$d = Object.prototype;
- /** Used to check objects for own properties. */
- var hasOwnProperty$a = objectProto$d.hasOwnProperty;
- /**
- * Initializes an array clone.
- *
- * @private
- * @param {Array} array The array to clone.
- * @returns {Array} Returns the initialized clone.
- */
- function initCloneArray(array) {
- var length = array.length,
- result = new array.constructor(length);
- // Add properties assigned by `RegExp#exec`.
- if (length && typeof array[0] == 'string' && hasOwnProperty$a.call(array, 'index')) {
- result.index = array.index;
- result.input = array.input;
- }
- return result;
- }
- var _initCloneArray = initCloneArray;
- /**
- * Creates a clone of `dataView`.
- *
- * @private
- * @param {Object} dataView The data view to clone.
- * @param {boolean} [isDeep] Specify a deep clone.
- * @returns {Object} Returns the cloned data view.
- */
- function cloneDataView(dataView, isDeep) {
- var buffer = isDeep ? _cloneArrayBuffer(dataView.buffer) : dataView.buffer;
- return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
- }
- var _cloneDataView = cloneDataView;
- /** Used to match `RegExp` flags from their coerced string values. */
- var reFlags = /\w*$/;
- /**
- * Creates a clone of `regexp`.
- *
- * @private
- * @param {Object} regexp The regexp to clone.
- * @returns {Object} Returns the cloned regexp.
- */
- function cloneRegExp(regexp) {
- var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
- result.lastIndex = regexp.lastIndex;
- return result;
- }
- var _cloneRegExp = cloneRegExp;
- /** Used to convert symbols to primitives and strings. */
- var symbolProto = _Symbol ? _Symbol.prototype : undefined,
- symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
- /**
- * Creates a clone of the `symbol` object.
- *
- * @private
- * @param {Object} symbol The symbol object to clone.
- * @returns {Object} Returns the cloned symbol object.
- */
- function cloneSymbol(symbol) {
- return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
- }
- var _cloneSymbol = cloneSymbol;
- /** `Object#toString` result references. */
- var boolTag$1 = '[object Boolean]',
- dateTag$1 = '[object Date]',
- mapTag$2 = '[object Map]',
- numberTag$1 = '[object Number]',
- regexpTag$1 = '[object RegExp]',
- setTag$2 = '[object Set]',
- stringTag$1 = '[object String]',
- symbolTag = '[object Symbol]';
- var arrayBufferTag$1 = '[object ArrayBuffer]',
- dataViewTag$2 = '[object DataView]',
- float32Tag$1 = '[object Float32Array]',
- float64Tag$1 = '[object Float64Array]',
- int8Tag$1 = '[object Int8Array]',
- int16Tag$1 = '[object Int16Array]',
- int32Tag$1 = '[object Int32Array]',
- uint8Tag$1 = '[object Uint8Array]',
- uint8ClampedTag$1 = '[object Uint8ClampedArray]',
- uint16Tag$1 = '[object Uint16Array]',
- uint32Tag$1 = '[object Uint32Array]';
- /**
- * Initializes an object clone based on its `toStringTag`.
- *
- * **Note:** This function only supports cloning values with tags of
- * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
- *
- * @private
- * @param {Object} object The object to clone.
- * @param {string} tag The `toStringTag` of the object to clone.
- * @param {boolean} [isDeep] Specify a deep clone.
- * @returns {Object} Returns the initialized clone.
- */
- function initCloneByTag(object, tag, isDeep) {
- var Ctor = object.constructor;
- switch (tag) {
- case arrayBufferTag$1:
- return _cloneArrayBuffer(object);
- case boolTag$1:
- case dateTag$1:
- return new Ctor(+object);
- case dataViewTag$2:
- return _cloneDataView(object, isDeep);
- case float32Tag$1: case float64Tag$1:
- case int8Tag$1: case int16Tag$1: case int32Tag$1:
- case uint8Tag$1: case uint8ClampedTag$1: case uint16Tag$1: case uint32Tag$1:
- return _cloneTypedArray(object, isDeep);
- case mapTag$2:
- return new Ctor;
- case numberTag$1:
- case stringTag$1:
- return new Ctor(object);
- case regexpTag$1:
- return _cloneRegExp(object);
- case setTag$2:
- return new Ctor;
- case symbolTag:
- return _cloneSymbol(object);
- }
- }
- var _initCloneByTag = initCloneByTag;
- /** `Object#toString` result references. */
- var mapTag$3 = '[object Map]';
- /**
- * The base implementation of `_.isMap` without Node.js optimizations.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a map, else `false`.
- */
- function baseIsMap(value) {
- return isObjectLike_1(value) && _getTag(value) == mapTag$3;
- }
- var _baseIsMap = baseIsMap;
- /* Node.js helper references. */
- var nodeIsMap = _nodeUtil && _nodeUtil.isMap;
- /**
- * Checks if `value` is classified as a `Map` object.
- *
- * @static
- * @memberOf _
- * @since 4.3.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a map, else `false`.
- * @example
- *
- * _.isMap(new Map);
- * // => true
- *
- * _.isMap(new WeakMap);
- * // => false
- */
- var isMap = nodeIsMap ? _baseUnary(nodeIsMap) : _baseIsMap;
- var isMap_1 = isMap;
- /** `Object#toString` result references. */
- var setTag$3 = '[object Set]';
- /**
- * The base implementation of `_.isSet` without Node.js optimizations.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a set, else `false`.
- */
- function baseIsSet(value) {
- return isObjectLike_1(value) && _getTag(value) == setTag$3;
- }
- var _baseIsSet = baseIsSet;
- /* Node.js helper references. */
- var nodeIsSet = _nodeUtil && _nodeUtil.isSet;
- /**
- * Checks if `value` is classified as a `Set` object.
- *
- * @static
- * @memberOf _
- * @since 4.3.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a set, else `false`.
- * @example
- *
- * _.isSet(new Set);
- * // => true
- *
- * _.isSet(new WeakSet);
- * // => false
- */
- var isSet = nodeIsSet ? _baseUnary(nodeIsSet) : _baseIsSet;
- var isSet_1 = isSet;
- /** Used to compose bitmasks for cloning. */
- var CLONE_DEEP_FLAG = 1,
- CLONE_FLAT_FLAG = 2,
- CLONE_SYMBOLS_FLAG = 4;
- /** `Object#toString` result references. */
- var argsTag$2 = '[object Arguments]',
- arrayTag$1 = '[object Array]',
- boolTag$2 = '[object Boolean]',
- dateTag$2 = '[object Date]',
- errorTag$1 = '[object Error]',
- funcTag$2 = '[object Function]',
- genTag$1 = '[object GeneratorFunction]',
- mapTag$4 = '[object Map]',
- numberTag$2 = '[object Number]',
- objectTag$3 = '[object Object]',
- regexpTag$2 = '[object RegExp]',
- setTag$4 = '[object Set]',
- stringTag$2 = '[object String]',
- symbolTag$1 = '[object Symbol]',
- weakMapTag$2 = '[object WeakMap]';
- var arrayBufferTag$2 = '[object ArrayBuffer]',
- dataViewTag$3 = '[object DataView]',
- float32Tag$2 = '[object Float32Array]',
- float64Tag$2 = '[object Float64Array]',
- int8Tag$2 = '[object Int8Array]',
- int16Tag$2 = '[object Int16Array]',
- int32Tag$2 = '[object Int32Array]',
- uint8Tag$2 = '[object Uint8Array]',
- uint8ClampedTag$2 = '[object Uint8ClampedArray]',
- uint16Tag$2 = '[object Uint16Array]',
- uint32Tag$2 = '[object Uint32Array]';
- /** Used to identify `toStringTag` values supported by `_.clone`. */
- var cloneableTags = {};
- cloneableTags[argsTag$2] = cloneableTags[arrayTag$1] =
- cloneableTags[arrayBufferTag$2] = cloneableTags[dataViewTag$3] =
- cloneableTags[boolTag$2] = cloneableTags[dateTag$2] =
- cloneableTags[float32Tag$2] = cloneableTags[float64Tag$2] =
- cloneableTags[int8Tag$2] = cloneableTags[int16Tag$2] =
- cloneableTags[int32Tag$2] = cloneableTags[mapTag$4] =
- cloneableTags[numberTag$2] = cloneableTags[objectTag$3] =
- cloneableTags[regexpTag$2] = cloneableTags[setTag$4] =
- cloneableTags[stringTag$2] = cloneableTags[symbolTag$1] =
- cloneableTags[uint8Tag$2] = cloneableTags[uint8ClampedTag$2] =
- cloneableTags[uint16Tag$2] = cloneableTags[uint32Tag$2] = true;
- cloneableTags[errorTag$1] = cloneableTags[funcTag$2] =
- cloneableTags[weakMapTag$2] = false;
- /**
- * The base implementation of `_.clone` and `_.cloneDeep` which tracks
- * traversed objects.
- *
- * @private
- * @param {*} value The value to clone.
- * @param {boolean} bitmask The bitmask flags.
- * 1 - Deep clone
- * 2 - Flatten inherited properties
- * 4 - Clone symbols
- * @param {Function} [customizer] The function to customize cloning.
- * @param {string} [key] The key of `value`.
- * @param {Object} [object] The parent object of `value`.
- * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
- * @returns {*} Returns the cloned value.
- */
- function baseClone(value, bitmask, customizer, key, object, stack) {
- var result,
- isDeep = bitmask & CLONE_DEEP_FLAG,
- isFlat = bitmask & CLONE_FLAT_FLAG,
- isFull = bitmask & CLONE_SYMBOLS_FLAG;
- if (customizer) {
- result = object ? customizer(value, key, object, stack) : customizer(value);
- }
- if (result !== undefined) {
- return result;
- }
- if (!isObject_1(value)) {
- return value;
- }
- var isArr = isArray_1(value);
- if (isArr) {
- result = _initCloneArray(value);
- if (!isDeep) {
- return _copyArray(value, result);
- }
- } else {
- var tag = _getTag(value),
- isFunc = tag == funcTag$2 || tag == genTag$1;
- if (isBuffer_1(value)) {
- return _cloneBuffer(value, isDeep);
- }
- if (tag == objectTag$3 || tag == argsTag$2 || (isFunc && !object)) {
- result = (isFlat || isFunc) ? {} : _initCloneObject(value);
- if (!isDeep) {
- return isFlat
- ? _copySymbolsIn(value, _baseAssignIn(result, value))
- : _copySymbols(value, _baseAssign(result, value));
- }
- } else {
- if (!cloneableTags[tag]) {
- return object ? value : {};
- }
- result = _initCloneByTag(value, tag, isDeep);
- }
- }
- // Check for circular references and return its corresponding clone.
- stack || (stack = new _Stack);
- var stacked = stack.get(value);
- if (stacked) {
- return stacked;
- }
- stack.set(value, result);
- if (isSet_1(value)) {
- value.forEach(function(subValue) {
- result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
- });
- } else if (isMap_1(value)) {
- value.forEach(function(subValue, key) {
- result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
- });
- }
- var keysFunc = isFull
- ? (isFlat ? _getAllKeysIn : _getAllKeys)
- : (isFlat ? keysIn_1 : keys_1);
- var props = isArr ? undefined : keysFunc(value);
- _arrayEach(props || value, function(subValue, key) {
- if (props) {
- key = subValue;
- subValue = value[key];
- }
- // Recursively populate clone (susceptible to call stack limits).
- _assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
- });
- return result;
- }
- var _baseClone = baseClone;
- /** Used to compose bitmasks for cloning. */
- var CLONE_DEEP_FLAG$1 = 1,
- CLONE_SYMBOLS_FLAG$1 = 4;
- /**
- * This method is like `_.clone` except that it recursively clones `value`.
- *
- * @static
- * @memberOf _
- * @since 1.0.0
- * @category Lang
- * @param {*} value The value to recursively clone.
- * @returns {*} Returns the deep cloned value.
- * @see _.clone
- * @example
- *
- * var objects = [{ 'a': 1 }, { 'b': 2 }];
- *
- * var deep = _.cloneDeep(objects);
- * console.log(deep[0] === objects[0]);
- * // => false
- */
- function cloneDeep(value) {
- return _baseClone(value, CLONE_DEEP_FLAG$1 | CLONE_SYMBOLS_FLAG$1);
- }
- var cloneDeep_1 = cloneDeep;
- var globalState = {};
- var deps = {}; // 触发全局监听
- function emitGlobal(state, prevState) {
- Object.keys(deps).forEach(function (id) {
- if (deps[id] instanceof Function) {
- deps[id](cloneDeep_1(state), cloneDeep_1(prevState));
- }
- });
- }
- function initGlobalState() {
- var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
- {
- console.warn("[qiankun] globalState tools will be removed in 3.0, pls don't use it!");
- }
- if (state === globalState) {
- console.warn('[qiankun] state has not changed!');
- } else {
- var prevGlobalState = cloneDeep_1(globalState);
- globalState = cloneDeep_1(state);
- emitGlobal(globalState, prevGlobalState);
- }
- return getMicroAppStateActions("global-".concat(+new Date()), true);
- }
- function getMicroAppStateActions(id, isMaster) {
- return {
- /**
- * onGlobalStateChange 全局依赖监听
- *
- * 收集 setState 时所需要触发的依赖
- *
- * 限制条件:每个子应用只有一个激活状态的全局监听,新监听覆盖旧监听,若只是监听部分属性,请使用 onGlobalStateChange
- *
- * 这么设计是为了减少全局监听滥用导致的内存爆炸
- *
- * 依赖数据结构为:
- * {
- * {id}: callback
- * }
- *
- * @param callback
- * @param fireImmediately
- */
- onGlobalStateChange: function onGlobalStateChange(callback, fireImmediately) {
- if (!(callback instanceof Function)) {
- console.error('[qiankun] callback must be function!');
- return;
- }
- if (deps[id]) {
- console.warn("[qiankun] '".concat(id, "' global listener already exists before this, new listener will overwrite it."));
- }
- deps[id] = callback;
- if (fireImmediately) {
- var cloneState = cloneDeep_1(globalState);
- callback(cloneState, cloneState);
- }
- },
- /**
- * setGlobalState 更新 store 数据
- *
- * 1. 对输入 state 的第一层属性做校验,只有初始化时声明过的第一层(bucket)属性才会被更改
- * 2. 修改 store 并触发全局监听
- *
- * @param state
- */
- setGlobalState: function setGlobalState() {
- var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
- if (state === globalState) {
- console.warn('[qiankun] state has not changed!');
- return false;
- }
- var changeKeys = [];
- var prevGlobalState = cloneDeep_1(globalState);
- globalState = cloneDeep_1(Object.keys(state).reduce(function (_globalState, changeKey) {
- if (isMaster || _globalState.hasOwnProperty(changeKey)) {
- changeKeys.push(changeKey);
- return Object.assign(_globalState, _defineProperty({}, changeKey, state[changeKey]));
- }
- console.warn("[qiankun] '".concat(changeKey, "' not declared when init state\uFF01"));
- return _globalState;
- }, globalState));
- if (changeKeys.length === 0) {
- console.warn('[qiankun] state has not changed!');
- return false;
- }
- emitGlobal(globalState, prevGlobalState);
- return true;
- },
- // 注销该应用下的依赖
- offGlobalStateChange: function offGlobalStateChange() {
- delete deps[id];
- return true;
- }
- };
- }
- var createClass = createCommonjsModule(function (module) {
- function _defineProperties(target, props) {
- for (var i = 0; i < props.length; i++) {
- var descriptor = props[i];
- descriptor.enumerable = descriptor.enumerable || false;
- descriptor.configurable = true;
- if ("value" in descriptor) descriptor.writable = true;
- Object.defineProperty(target, descriptor.key, descriptor);
- }
- }
- function _createClass(Constructor, protoProps, staticProps) {
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
- if (staticProps) _defineProperties(Constructor, staticProps);
- return Constructor;
- }
- module.exports = _createClass;
- module.exports["default"] = module.exports, module.exports.__esModule = true;
- });
- var _createClass = /*@__PURE__*/getDefaultExportFromCjs(createClass);
- (function (SandBoxType) {
- SandBoxType["Proxy"] = "Proxy";
- SandBoxType["Snapshot"] = "Snapshot"; // for legacy sandbox
- // https://github.com/umijs/qiankun/blob/0d1d3f0c5ed1642f01854f96c3fabf0a2148bd26/src/sandbox/legacy/sandbox.ts#L22...L25
- SandBoxType["LegacyProxy"] = "LegacyProxy";
- })(exports.SandBoxType || (exports.SandBoxType = {}));
- /** Used to match a single whitespace character. */
- var reWhitespace = /\s/;
- /**
- * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
- * character of `string`.
- *
- * @private
- * @param {string} string The string to inspect.
- * @returns {number} Returns the index of the last non-whitespace character.
- */
- function trimmedEndIndex(string) {
- var index = string.length;
- while (index-- && reWhitespace.test(string.charAt(index))) {}
- return index;
- }
- var _trimmedEndIndex = trimmedEndIndex;
- /** Used to match leading whitespace. */
- var reTrimStart = /^\s+/;
- /**
- * The base implementation of `_.trim`.
- *
- * @private
- * @param {string} string The string to trim.
- * @returns {string} Returns the trimmed string.
- */
- function baseTrim(string) {
- return string
- ? string.slice(0, _trimmedEndIndex(string) + 1).replace(reTrimStart, '')
- : string;
- }
- var _baseTrim = baseTrim;
- /** `Object#toString` result references. */
- var symbolTag$2 = '[object Symbol]';
- /**
- * Checks if `value` is classified as a `Symbol` primitive or object.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
- * @example
- *
- * _.isSymbol(Symbol.iterator);
- * // => true
- *
- * _.isSymbol('abc');
- * // => false
- */
- function isSymbol(value) {
- return typeof value == 'symbol' ||
- (isObjectLike_1(value) && _baseGetTag(value) == symbolTag$2);
- }
- var isSymbol_1 = isSymbol;
- /** Used as references for various `Number` constants. */
- var NAN = 0 / 0;
- /** Used to detect bad signed hexadecimal string values. */
- var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
- /** Used to detect binary string values. */
- var reIsBinary = /^0b[01]+$/i;
- /** Used to detect octal string values. */
- var reIsOctal = /^0o[0-7]+$/i;
- /** Built-in method references without a dependency on `root`. */
- var freeParseInt = parseInt;
- /**
- * Converts `value` to a number.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to process.
- * @returns {number} Returns the number.
- * @example
- *
- * _.toNumber(3.2);
- * // => 3.2
- *
- * _.toNumber(Number.MIN_VALUE);
- * // => 5e-324
- *
- * _.toNumber(Infinity);
- * // => Infinity
- *
- * _.toNumber('3.2');
- * // => 3.2
- */
- function toNumber(value) {
- if (typeof value == 'number') {
- return value;
- }
- if (isSymbol_1(value)) {
- return NAN;
- }
- if (isObject_1(value)) {
- var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
- value = isObject_1(other) ? (other + '') : other;
- }
- if (typeof value != 'string') {
- return value === 0 ? value : +value;
- }
- value = _baseTrim(value);
- var isBinary = reIsBinary.test(value);
- return (isBinary || reIsOctal.test(value))
- ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
- : (reIsBadHex.test(value) ? NAN : +value);
- }
- var toNumber_1 = toNumber;
- /** Used as references for various `Number` constants. */
- var INFINITY = 1 / 0,
- MAX_INTEGER = 1.7976931348623157e+308;
- /**
- * Converts `value` to a finite number.
- *
- * @static
- * @memberOf _
- * @since 4.12.0
- * @category Lang
- * @param {*} value The value to convert.
- * @returns {number} Returns the converted number.
- * @example
- *
- * _.toFinite(3.2);
- * // => 3.2
- *
- * _.toFinite(Number.MIN_VALUE);
- * // => 5e-324
- *
- * _.toFinite(Infinity);
- * // => 1.7976931348623157e+308
- *
- * _.toFinite('3.2');
- * // => 3.2
- */
- function toFinite(value) {
- if (!value) {
- return value === 0 ? value : 0;
- }
- value = toNumber_1(value);
- if (value === INFINITY || value === -INFINITY) {
- var sign = (value < 0 ? -1 : 1);
- return sign * MAX_INTEGER;
- }
- return value === value ? value : 0;
- }
- var toFinite_1 = toFinite;
- /**
- * Converts `value` to an integer.
- *
- * **Note:** This method is loosely based on
- * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to convert.
- * @returns {number} Returns the converted integer.
- * @example
- *
- * _.toInteger(3.2);
- * // => 3
- *
- * _.toInteger(Number.MIN_VALUE);
- * // => 0
- *
- * _.toInteger(Infinity);
- * // => 1.7976931348623157e+308
- *
- * _.toInteger('3.2');
- * // => 3
- */
- function toInteger(value) {
- var result = toFinite_1(value),
- remainder = result % 1;
- return result === result ? (remainder ? result - remainder : result) : 0;
- }
- var toInteger_1 = toInteger;
- /** Error message constants. */
- var FUNC_ERROR_TEXT = 'Expected a function';
- /**
- * Creates a function that invokes `func`, with the `this` binding and arguments
- * of the created function, while it's called less than `n` times. Subsequent
- * calls to the created function return the result of the last `func` invocation.
- *
- * @static
- * @memberOf _
- * @since 3.0.0
- * @category Function
- * @param {number} n The number of calls at which `func` is no longer invoked.
- * @param {Function} func The function to restrict.
- * @returns {Function} Returns the new restricted function.
- * @example
- *
- * jQuery(element).on('click', _.before(5, addContactToList));
- * // => Allows adding up to 4 contacts to the list.
- */
- function before(n, func) {
- var result;
- if (typeof func != 'function') {
- throw new TypeError(FUNC_ERROR_TEXT);
- }
- n = toInteger_1(n);
- return function() {
- if (--n > 0) {
- result = func.apply(this, arguments);
- }
- if (n <= 1) {
- func = undefined;
- }
- return result;
- };
- }
- var before_1 = before;
- /**
- * Creates a function that is restricted to invoking `func` once. Repeat calls
- * to the function return the value of the first invocation. The `func` is
- * invoked with the `this` binding and arguments of the created function.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Function
- * @param {Function} func The function to restrict.
- * @returns {Function} Returns the new restricted function.
- * @example
- *
- * var initialize = _.once(createApplication);
- * initialize();
- * initialize();
- * // => `createApplication` is invoked once
- */
- function once(func) {
- return before_1(2, func);
- }
- var once_1 = once;
- /**
- * A specialized version of `_.reduce` for arrays without support for
- * iteratee shorthands.
- *
- * @private
- * @param {Array} [array] The array to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @param {*} [accumulator] The initial value.
- * @param {boolean} [initAccum] Specify using the first element of `array` as
- * the initial value.
- * @returns {*} Returns the accumulated value.
- */
- function arrayReduce(array, iteratee, accumulator, initAccum) {
- var index = -1,
- length = array == null ? 0 : array.length;
- if (initAccum && length) {
- accumulator = array[++index];
- }
- while (++index < length) {
- accumulator = iteratee(accumulator, array[index], index, array);
- }
- return accumulator;
- }
- var _arrayReduce = arrayReduce;
- /**
- * The base implementation of `_.propertyOf` without support for deep paths.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {Function} Returns the new accessor function.
- */
- function basePropertyOf(object) {
- return function(key) {
- return object == null ? undefined : object[key];
- };
- }
- var _basePropertyOf = basePropertyOf;
- /** Used to map Latin Unicode letters to basic Latin letters. */
- var deburredLetters = {
- // Latin-1 Supplement block.
- '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
- '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
- '\xc7': 'C', '\xe7': 'c',
- '\xd0': 'D', '\xf0': 'd',
- '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
- '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
- '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
- '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
- '\xd1': 'N', '\xf1': 'n',
- '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
- '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
- '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
- '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
- '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
- '\xc6': 'Ae', '\xe6': 'ae',
- '\xde': 'Th', '\xfe': 'th',
- '\xdf': 'ss',
- // Latin Extended-A block.
- '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
- '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
- '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
- '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
- '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
- '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
- '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
- '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
- '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
- '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
- '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
- '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
- '\u0134': 'J', '\u0135': 'j',
- '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
- '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
- '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
- '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
- '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
- '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
- '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
- '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
- '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
- '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
- '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
- '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
- '\u0163': 't', '\u0165': 't', '\u0167': 't',
- '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
- '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
- '\u0174': 'W', '\u0175': 'w',
- '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
- '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
- '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
- '\u0132': 'IJ', '\u0133': 'ij',
- '\u0152': 'Oe', '\u0153': 'oe',
- '\u0149': "'n", '\u017f': 's'
- };
- /**
- * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
- * letters to basic Latin letters.
- *
- * @private
- * @param {string} letter The matched letter to deburr.
- * @returns {string} Returns the deburred letter.
- */
- var deburrLetter = _basePropertyOf(deburredLetters);
- var _deburrLetter = deburrLetter;
- /**
- * A specialized version of `_.map` for arrays without support for iteratee
- * shorthands.
- *
- * @private
- * @param {Array} [array] The array to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Array} Returns the new mapped array.
- */
- function arrayMap(array, iteratee) {
- var index = -1,
- length = array == null ? 0 : array.length,
- result = Array(length);
- while (++index < length) {
- result[index] = iteratee(array[index], index, array);
- }
- return result;
- }
- var _arrayMap = arrayMap;
- /** Used as references for various `Number` constants. */
- var INFINITY$1 = 1 / 0;
- /** Used to convert symbols to primitives and strings. */
- var symbolProto$1 = _Symbol ? _Symbol.prototype : undefined,
- symbolToString = symbolProto$1 ? symbolProto$1.toString : undefined;
- /**
- * The base implementation of `_.toString` which doesn't convert nullish
- * values to empty strings.
- *
- * @private
- * @param {*} value The value to process.
- * @returns {string} Returns the string.
- */
- function baseToString(value) {
- // Exit early for strings to avoid a performance hit in some environments.
- if (typeof value == 'string') {
- return value;
- }
- if (isArray_1(value)) {
- // Recursively convert values (susceptible to call stack limits).
- return _arrayMap(value, baseToString) + '';
- }
- if (isSymbol_1(value)) {
- return symbolToString ? symbolToString.call(value) : '';
- }
- var result = (value + '');
- return (result == '0' && (1 / value) == -INFINITY$1) ? '-0' : result;
- }
- var _baseToString = baseToString;
- /**
- * Converts `value` to a string. An empty string is returned for `null`
- * and `undefined` values. The sign of `-0` is preserved.
- *
- * @static
- * @memberOf _
- * @since 4.0.0
- * @category Lang
- * @param {*} value The value to convert.
- * @returns {string} Returns the converted string.
- * @example
- *
- * _.toString(null);
- * // => ''
- *
- * _.toString(-0);
- * // => '-0'
- *
- * _.toString([1, 2, 3]);
- * // => '1,2,3'
- */
- function toString(value) {
- return value == null ? '' : _baseToString(value);
- }
- var toString_1 = toString;
- /** Used to match Latin Unicode letters (excluding mathematical operators). */
- var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
- /** Used to compose unicode character classes. */
- var rsComboMarksRange = '\\u0300-\\u036f',
- reComboHalfMarksRange = '\\ufe20-\\ufe2f',
- rsComboSymbolsRange = '\\u20d0-\\u20ff',
- rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange;
- /** Used to compose unicode capture groups. */
- var rsCombo = '[' + rsComboRange + ']';
- /**
- * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
- * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
- */
- var reComboMark = RegExp(rsCombo, 'g');
- /**
- * Deburrs `string` by converting
- * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
- * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
- * letters to basic Latin letters and removing
- * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
- *
- * @static
- * @memberOf _
- * @since 3.0.0
- * @category String
- * @param {string} [string=''] The string to deburr.
- * @returns {string} Returns the deburred string.
- * @example
- *
- * _.deburr('déjà vu');
- * // => 'deja vu'
- */
- function deburr(string) {
- string = toString_1(string);
- return string && string.replace(reLatin, _deburrLetter).replace(reComboMark, '');
- }
- var deburr_1 = deburr;
- /** Used to match words composed of alphanumeric characters. */
- var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
- /**
- * Splits an ASCII `string` into an array of its words.
- *
- * @private
- * @param {string} The string to inspect.
- * @returns {Array} Returns the words of `string`.
- */
- function asciiWords(string) {
- return string.match(reAsciiWord) || [];
- }
- var _asciiWords = asciiWords;
- /** Used to detect strings that need a more robust regexp to match words. */
- 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 ]/;
- /**
- * Checks if `string` contains a word composed of Unicode symbols.
- *
- * @private
- * @param {string} string The string to inspect.
- * @returns {boolean} Returns `true` if a word is found, else `false`.
- */
- function hasUnicodeWord(string) {
- return reHasUnicodeWord.test(string);
- }
- var _hasUnicodeWord = hasUnicodeWord;
- /** Used to compose unicode character classes. */
- var rsAstralRange = '\\ud800-\\udfff',
- rsComboMarksRange$1 = '\\u0300-\\u036f',
- reComboHalfMarksRange$1 = '\\ufe20-\\ufe2f',
- rsComboSymbolsRange$1 = '\\u20d0-\\u20ff',
- rsComboRange$1 = rsComboMarksRange$1 + reComboHalfMarksRange$1 + rsComboSymbolsRange$1,
- rsDingbatRange = '\\u2700-\\u27bf',
- rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
- rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
- rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
- rsPunctuationRange = '\\u2000-\\u206f',
- 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',
- rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
- rsVarRange = '\\ufe0e\\ufe0f',
- rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
- /** Used to compose unicode capture groups. */
- var rsApos = "['\u2019]",
- rsBreak = '[' + rsBreakRange + ']',
- rsCombo$1 = '[' + rsComboRange$1 + ']',
- rsDigits = '\\d+',
- rsDingbat = '[' + rsDingbatRange + ']',
- rsLower = '[' + rsLowerRange + ']',
- rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
- rsFitz = '\\ud83c[\\udffb-\\udfff]',
- rsModifier = '(?:' + rsCombo$1 + '|' + rsFitz + ')',
- rsNonAstral = '[^' + rsAstralRange + ']',
- rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
- rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
- rsUpper = '[' + rsUpperRange + ']',
- rsZWJ = '\\u200d';
- /** Used to compose unicode regexes. */
- var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
- rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
- rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
- rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
- reOptMod = rsModifier + '?',
- rsOptVar = '[' + rsVarRange + ']?',
- rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
- rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
- rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
- rsSeq = rsOptVar + reOptMod + rsOptJoin,
- rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq;
- /** Used to match complex or compound words. */
- var reUnicodeWord = RegExp([
- rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
- rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
- rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
- rsUpper + '+' + rsOptContrUpper,
- rsOrdUpper,
- rsOrdLower,
- rsDigits,
- rsEmoji
- ].join('|'), 'g');
- /**
- * Splits a Unicode `string` into an array of its words.
- *
- * @private
- * @param {string} The string to inspect.
- * @returns {Array} Returns the words of `string`.
- */
- function unicodeWords(string) {
- return string.match(reUnicodeWord) || [];
- }
- var _unicodeWords = unicodeWords;
- /**
- * Splits `string` into an array of its words.
- *
- * @static
- * @memberOf _
- * @since 3.0.0
- * @category String
- * @param {string} [string=''] The string to inspect.
- * @param {RegExp|string} [pattern] The pattern to match words.
- * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
- * @returns {Array} Returns the words of `string`.
- * @example
- *
- * _.words('fred, barney, & pebbles');
- * // => ['fred', 'barney', 'pebbles']
- *
- * _.words('fred, barney, & pebbles', /[^, ]+/g);
- * // => ['fred', 'barney', '&', 'pebbles']
- */
- function words(string, pattern, guard) {
- string = toString_1(string);
- pattern = guard ? undefined : pattern;
- if (pattern === undefined) {
- return _hasUnicodeWord(string) ? _unicodeWords(string) : _asciiWords(string);
- }
- return string.match(pattern) || [];
- }
- var words_1 = words;
- /** Used to compose unicode capture groups. */
- var rsApos$1 = "['\u2019]";
- /** Used to match apostrophes. */
- var reApos = RegExp(rsApos$1, 'g');
- /**
- * Creates a function like `_.camelCase`.
- *
- * @private
- * @param {Function} callback The function to combine each word.
- * @returns {Function} Returns the new compounder function.
- */
- function createCompounder(callback) {
- return function(string) {
- return _arrayReduce(words_1(deburr_1(string).replace(reApos, '')), callback, '');
- };
- }
- var _createCompounder = createCompounder;
- /**
- * Converts `string` to
- * [snake case](https://en.wikipedia.org/wiki/Snake_case).
- *
- * @static
- * @memberOf _
- * @since 3.0.0
- * @category String
- * @param {string} [string=''] The string to convert.
- * @returns {string} Returns the snake cased string.
- * @example
- *
- * _.snakeCase('Foo Bar');
- * // => 'foo_bar'
- *
- * _.snakeCase('fooBar');
- * // => 'foo_bar'
- *
- * _.snakeCase('--FOO-BAR--');
- * // => 'foo_bar'
- */
- var snakeCase = _createCompounder(function(result, word, index) {
- return result + (index ? '_' : '') + word.toLowerCase();
- });
- var snakeCase_1 = snakeCase;
- var version = '2.6.3';
- function toArray(array) {
- return Array.isArray(array) ? array : [array];
- }
- var nextTick = typeof window.Zone === 'function' ? setTimeout : function (cb) {
- return Promise.resolve().then(cb);
- };
- var globalTaskPending = false;
- /**
- * Run a callback before next task executing, and the invocation is idempotent in every singular task
- * That means even we called nextTask multi times in one task, only the first callback will be pushed to nextTick to be invoked.
- * @param cb
- */
- function nextTask(cb) {
- if (!globalTaskPending) {
- globalTaskPending = true;
- nextTick(function () {
- cb();
- globalTaskPending = false;
- });
- }
- }
- var fnRegexCheckCacheMap = new WeakMap();
- function isConstructable(fn) {
- // prototype methods might be changed while code running, so we need check it every time
- var hasPrototypeMethods = fn.prototype && fn.prototype.constructor === fn && Object.getOwnPropertyNames(fn.prototype).length > 1;
- if (hasPrototypeMethods) return true;
- if (fnRegexCheckCacheMap.has(fn)) {
- return fnRegexCheckCacheMap.get(fn);
- }
- /*
- 1. 有 prototype 并且 prototype 上有定义一系列非 constructor 属性
- 2. 函数名大写开头
- 3. class 函数
- 满足其一则可认定为构造函数
- */
- var constructable = hasPrototypeMethods;
- if (!constructable) {
- // fn.toString has a significant performance overhead, if hasPrototypeMethods check not passed, we will check the function string with regex
- var fnString = fn.toString();
- var constructableFunctionRegex = /^function\b\s[A-Z].*/;
- var classRegex = /^class\b/;
- constructable = constructableFunctionRegex.test(fnString) || classRegex.test(fnString);
- }
- fnRegexCheckCacheMap.set(fn, constructable);
- return constructable;
- }
- /**
- * in safari
- * typeof document.all === 'undefined' // true
- * typeof document.all === 'function' // true
- * We need to discriminate safari for better performance
- */
- var naughtySafari = typeof document.all === 'function' && typeof document.all === 'undefined';
- var callableFnCacheMap = new WeakMap();
- var isCallable = function isCallable(fn) {
- if (callableFnCacheMap.has(fn)) {
- return true;
- }
- var callable = naughtySafari ? typeof fn === 'function' && typeof fn !== 'undefined' : typeof fn === 'function';
- if (callable) {
- callableFnCacheMap.set(fn, callable);
- }
- return callable;
- };
- var boundedMap = new WeakMap();
- function isBoundedFunction(fn) {
- if (boundedMap.has(fn)) {
- return boundedMap.get(fn);
- }
- /*
- indexOf is faster than startsWith
- see https://jsperf.com/string-startswith/72
- */
- var bounded = fn.name.indexOf('bound ') === 0 && !fn.hasOwnProperty('prototype');
- boundedMap.set(fn, bounded);
- return bounded;
- }
- function getDefaultTplWrapper(name) {
- return function (tpl) {
- return "<div id=\"".concat(getWrapperId(name), "\" data-name=\"").concat(name, "\" data-version=\"").concat(version, "\">").concat(tpl, "</div>");
- };
- }
- function getWrapperId(name) {
- return "__qiankun_microapp_wrapper_for_".concat(snakeCase_1(name), "__");
- }
- var nativeGlobal = new Function('return this')();
- var getGlobalAppInstanceMap = once_1(function () {
- if (!nativeGlobal.hasOwnProperty('__app_instance_name_map__')) {
- Object.defineProperty(nativeGlobal, '__app_instance_name_map__', {
- enumerable: false,
- configurable: true,
- writable: true,
- value: {}
- });
- }
- return nativeGlobal.__app_instance_name_map__;
- });
- /**
- * Get app instance name with the auto-increment approach
- * @param appName
- */
- var genAppInstanceIdByName = function genAppInstanceIdByName(appName) {
- var globalAppInstanceMap = getGlobalAppInstanceMap();
- if (!(appName in globalAppInstanceMap)) {
- nativeGlobal.__app_instance_name_map__[appName] = 0;
- return appName;
- }
- globalAppInstanceMap[appName]++;
- return "".concat(appName, "_").concat(globalAppInstanceMap[appName]);
- };
- /** 校验子应用导出的 生命周期 对象是否正确 */
- function validateExportLifecycle(exports) {
- var _ref = exports !== null && exports !== void 0 ? exports : {},
- bootstrap = _ref.bootstrap,
- mount = _ref.mount,
- unmount = _ref.unmount;
- return isFunction_1(bootstrap) && isFunction_1(mount) && isFunction_1(unmount);
- }
- var Deferred = function Deferred() {
- var _this = this;
- _classCallCheck(this, Deferred);
- this.promise = void 0;
- this.resolve = void 0;
- this.reject = void 0;
- this.promise = new Promise(function (resolve, reject) {
- _this.resolve = resolve;
- _this.reject = reject;
- });
- };
- 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';
- function performanceGetEntriesByName(markName, type) {
- var marks = null;
- if (supportsUserTiming$1) {
- marks = performance.getEntriesByName(markName, type);
- }
- return marks;
- }
- function performanceMark(markName) {
- if (supportsUserTiming$1) {
- performance.mark(markName);
- }
- }
- function performanceMeasure(measureName, markName) {
- if (supportsUserTiming$1 && performance.getEntriesByName(markName, 'mark').length) {
- performance.measure(measureName, markName);
- performance.clearMarks(markName);
- performance.clearMeasures(measureName);
- }
- }
- function isEnableScopedCSS(sandbox) {
- if (_typeof(sandbox) !== 'object') {
- return false;
- }
- if (sandbox.strictStyleIsolation) {
- return false;
- }
- return !!sandbox.experimentalStyleIsolation;
- }
- /**
- * copy from https://developer.mozilla.org/zh-CN/docs/Using_XPath
- * @param el
- * @param document
- */
- function getXPathForElement(el, document) {
- // not support that if el not existed in document yet(such as it not append to document before it mounted)
- if (!document.body.contains(el)) {
- return undefined;
- }
- var xpath = '';
- var pos;
- var tmpEle;
- var element = el;
- while (element !== document.documentElement) {
- pos = 0;
- tmpEle = element;
- while (tmpEle) {
- if (tmpEle.nodeType === 1 && tmpEle.nodeName === element.nodeName) {
- // If it is ELEMENT_NODE of the same name
- pos += 1;
- }
- tmpEle = tmpEle.previousSibling;
- }
- xpath = "*[name()='".concat(element.nodeName, "'][").concat(pos, "]/").concat(xpath);
- element = element.parentNode;
- }
- xpath = "/*[name()='".concat(document.documentElement.nodeName, "']/").concat(xpath);
- xpath = xpath.replace(/\/$/, '');
- return xpath;
- }
- function getContainer(container) {
- return typeof container === 'string' ? document.querySelector(container) : container;
- }
- function getContainerXPath(container) {
- if (container) {
- var containerElement = getContainer(container);
- if (containerElement) {
- return getXPathForElement(containerElement, document);
- }
- }
- return undefined;
- }
- var currentRunningApp = null;
- /**
- * get the app that running tasks at current tick
- */
- function getCurrentRunningApp() {
- return currentRunningApp;
- }
- function setCurrentRunningApp(appInstance) {
- // 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
- currentRunningApp = appInstance;
- }
- var functionBoundedValueMap = new WeakMap();
- function getTargetValue(target, _value) {
- /*
- 仅绑定 isCallable && !isBoundedFunction && !isConstructable 的函数对象,如 window.console、window.atob 这类,不然微应用中调用时会抛出 Illegal invocation 异常
- 目前没有完美的检测方式,这里通过 prototype 中是否还有可枚举的拓展方法的方式来判断
- @warning 这里不要随意替换成别的判断方式,因为可能触发一些 edge case(比如在 lodash.isFunction 在 iframe 上下文中可能由于调用了 top window 对象触发的安全异常)
- */
- if (isCallable(_value) && !isBoundedFunction(_value) && !isConstructable(_value)) {
- var cachedBoundFunction = functionBoundedValueMap.get(_value);
- if (cachedBoundFunction) {
- return cachedBoundFunction;
- }
- 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.
- // use for..in rather than Object.keys.forEach for performance reason
- // eslint-disable-next-line guard-for-in,no-restricted-syntax
- for (var key in _value) {
- boundValue[key] = _value[key];
- } // copy prototype if bound function not have but target one have
- // as prototype is non-enumerable mostly, we need to copy it from target function manually
- if (_value.hasOwnProperty('prototype') && !boundValue.hasOwnProperty('prototype')) {
- // we should not use assignment operator to set boundValue prototype like `boundValue.prototype = value.prototype`
- // as the assignment will also look up prototype chain while it hasn't own prototype property,
- // 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
- // see https://github.com/umijs/qiankun/issues/1121
- Object.defineProperty(boundValue, 'prototype', {
- value: _value.prototype,
- enumerable: false,
- writable: true
- });
- } // Some util, like `function isNative() { return typeof Ctor === 'function' && /native code/.test(Ctor.toString()) }` relies on the original `toString()` result
- // but bound functions will always return "function() {[native code]}" for `toString`, which is misleading
- if (typeof _value.toString === 'function') {
- var valueHasInstanceToString = _value.hasOwnProperty('toString') && !boundValue.hasOwnProperty('toString');
- var boundValueHasPrototypeToString = boundValue.toString === Function.prototype.toString;
- if (valueHasInstanceToString || boundValueHasPrototypeToString) {
- var originToStringDescriptor = Object.getOwnPropertyDescriptor(valueHasInstanceToString ? _value : Function.prototype, 'toString');
- Object.defineProperty(boundValue, 'toString', _objectSpread(_objectSpread({}, originToStringDescriptor), (originToStringDescriptor === null || originToStringDescriptor === void 0 ? void 0 : originToStringDescriptor.get) ? null : {
- value: function value() {
- return _value.toString();
- }
- }));
- }
- }
- functionBoundedValueMap.set(_value, boundValue);
- return boundValue;
- }
- return _value;
- }
- function isPropConfigurable(target, prop) {
- var descriptor = Object.getOwnPropertyDescriptor(target, prop);
- return descriptor ? descriptor.configurable : true;
- }
- /**
- * 基于 Proxy 实现的沙箱
- * TODO: 为了兼容性 singular 模式下依旧使用该沙箱,等新沙箱稳定之后再切换
- */
- var LegacySandbox = /*#__PURE__*/function () {
- function LegacySandbox(name) {
- var _this = this;
- var globalContext = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window;
- _classCallCheck(this, LegacySandbox);
- this.addedPropsMapInSandbox = new Map();
- this.modifiedPropsOriginalValueMapInSandbox = new Map();
- this.currentUpdatedPropsValueMap = new Map();
- this.name = void 0;
- this.proxy = void 0;
- this.globalContext = void 0;
- this.type = void 0;
- this.sandboxRunning = true;
- this.latestSetProp = null;
- this.name = name;
- this.globalContext = globalContext;
- this.type = exports.SandBoxType.LegacyProxy;
- var addedPropsMapInSandbox = this.addedPropsMapInSandbox,
- modifiedPropsOriginalValueMapInSandbox = this.modifiedPropsOriginalValueMapInSandbox,
- currentUpdatedPropsValueMap = this.currentUpdatedPropsValueMap;
- var rawWindow = globalContext;
- var fakeWindow = Object.create(null);
- var setTrap = function setTrap(p, value, originalValue) {
- var sync2Window = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
- if (_this.sandboxRunning) {
- if (!rawWindow.hasOwnProperty(p)) {
- addedPropsMapInSandbox.set(p, value);
- } else if (!modifiedPropsOriginalValueMapInSandbox.has(p)) {
- // 如果当前 window 对象存在该属性,且 record map 中未记录过,则记录该属性初始值
- modifiedPropsOriginalValueMapInSandbox.set(p, originalValue);
- }
- currentUpdatedPropsValueMap.set(p, value);
- if (sync2Window) {
- // 必须重新设置 window 对象保证下次 get 时能拿到已更新的数据
- rawWindow[p] = value;
- }
- _this.latestSetProp = p;
- return true;
- }
- {
- console.warn("[qiankun] Set window.".concat(p.toString(), " while sandbox destroyed or inactive in ").concat(name, "!"));
- } // 在 strict-mode 下,Proxy 的 handler.set 返回 false 会抛出 TypeError,在沙箱卸载的情况下应该忽略错误
- return true;
- };
- var proxy = new Proxy(fakeWindow, {
- set: function set(_, p, value) {
- var originalValue = rawWindow[p];
- return setTrap(p, value, originalValue, true);
- },
- get: function get(_, p) {
- // avoid who using window.window or window.self to escape the sandbox environment to touch the really window
- // or use window.top to check if an iframe context
- // see https://github.com/eligrey/FileSaver.js/blob/master/src/FileSaver.js#L13
- if (p === 'top' || p === 'parent' || p === 'window' || p === 'self') {
- return proxy;
- }
- var value = rawWindow[p];
- return getTargetValue(rawWindow, value);
- },
- // trap in operator
- // see https://github.com/styled-components/styled-components/blob/master/packages/styled-components/src/constants.js#L12
- has: function has(_, p) {
- return p in rawWindow;
- },
- getOwnPropertyDescriptor: function getOwnPropertyDescriptor(_, p) {
- 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
- if (descriptor && !descriptor.configurable) {
- descriptor.configurable = true;
- }
- return descriptor;
- },
- defineProperty: function defineProperty(_, p, attributes) {
- var originalValue = rawWindow[p];
- var done = Reflect.defineProperty(rawWindow, p, attributes);
- var value = rawWindow[p];
- setTrap(p, value, originalValue, false);
- return done;
- }
- });
- this.proxy = proxy;
- }
- _createClass(LegacySandbox, [{
- key: "setWindowProp",
- value:
- /** 沙箱期间新增的全局变量 */
- /** 沙箱期间更新的全局变量 */
- /** 持续记录更新的(新增和修改的)全局变量的 map,用于在任意时刻做 snapshot */
- function setWindowProp(prop, value, toDelete) {
- if (value === undefined && toDelete) {
- // eslint-disable-next-line no-param-reassign
- delete this.globalContext[prop];
- } else if (isPropConfigurable(this.globalContext, prop) && _typeof(prop) !== 'symbol') {
- Object.defineProperty(this.globalContext, prop, {
- writable: true,
- configurable: true
- }); // eslint-disable-next-line no-param-reassign
- this.globalContext[prop] = value;
- }
- }
- }, {
- key: "active",
- value: function active() {
- var _this2 = this;
- if (!this.sandboxRunning) {
- this.currentUpdatedPropsValueMap.forEach(function (v, p) {
- return _this2.setWindowProp(p, v);
- });
- }
- this.sandboxRunning = true;
- }
- }, {
- key: "inactive",
- value: function inactive() {
- var _this3 = this;
- {
- console.info("[qiankun:sandbox] ".concat(this.name, " modified global properties restore..."), [].concat(_toConsumableArray(this.addedPropsMapInSandbox.keys()), _toConsumableArray(this.modifiedPropsOriginalValueMapInSandbox.keys())));
- } // renderSandboxSnapshot = snapshot(currentUpdatedPropsValueMapForSnapshot);
- // restore global props to initial snapshot
- this.modifiedPropsOriginalValueMapInSandbox.forEach(function (v, p) {
- return _this3.setWindowProp(p, v);
- });
- this.addedPropsMapInSandbox.forEach(function (_, p) {
- return _this3.setWindowProp(p, undefined, true);
- });
- this.sandboxRunning = false;
- }
- }]);
- return LegacySandbox;
- }();
- /**
- * @author Saviio
- * @since 2020-4-19
- */
- // https://developer.mozilla.org/en-US/docs/Web/API/CSSRule
- var RuleType;
- (function (RuleType) {
- // type: rule will be rewrote
- RuleType[RuleType["STYLE"] = 1] = "STYLE";
- RuleType[RuleType["MEDIA"] = 4] = "MEDIA";
- RuleType[RuleType["SUPPORTS"] = 12] = "SUPPORTS"; // type: value will be kept
- RuleType[RuleType["IMPORT"] = 3] = "IMPORT";
- RuleType[RuleType["FONT_FACE"] = 5] = "FONT_FACE";
- RuleType[RuleType["PAGE"] = 6] = "PAGE";
- RuleType[RuleType["KEYFRAMES"] = 7] = "KEYFRAMES";
- RuleType[RuleType["KEYFRAME"] = 8] = "KEYFRAME";
- })(RuleType || (RuleType = {}));
- var arrayify = function arrayify(list) {
- return [].slice.call(list, 0);
- };
- var rawDocumentBodyAppend = HTMLBodyElement.prototype.appendChild;
- var ScopedCSS = /*#__PURE__*/function () {
- function ScopedCSS() {
- _classCallCheck(this, ScopedCSS);
- this.sheet = void 0;
- this.swapNode = void 0;
- var styleNode = document.createElement('style');
- rawDocumentBodyAppend.call(document.body, styleNode);
- this.swapNode = styleNode;
- this.sheet = styleNode.sheet;
- this.sheet.disabled = true;
- }
- _createClass(ScopedCSS, [{
- key: "process",
- value: function process(styleNode) {
- var _this = this;
- var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
- if (styleNode.textContent !== '') {
- var _sheet$cssRules;
- var textNode = document.createTextNode(styleNode.textContent || '');
- this.swapNode.appendChild(textNode);
- var sheet = this.swapNode.sheet; // type is missing
- var rules = arrayify((_sheet$cssRules = sheet === null || sheet === void 0 ? void 0 : sheet.cssRules) !== null && _sheet$cssRules !== void 0 ? _sheet$cssRules : []);
- var css = this.rewrite(rules, prefix); // eslint-disable-next-line no-param-reassign
- styleNode.textContent = css; // cleanup
- this.swapNode.removeChild(textNode);
- return;
- }
- var mutator = new MutationObserver(function (mutations) {
- for (var i = 0; i < mutations.length; i += 1) {
- var mutation = mutations[i];
- if (ScopedCSS.ModifiedTag in styleNode) {
- return;
- }
- if (mutation.type === 'childList') {
- var _sheet$cssRules2;
- var _sheet = styleNode.sheet;
- var _rules = arrayify((_sheet$cssRules2 = _sheet === null || _sheet === void 0 ? void 0 : _sheet.cssRules) !== null && _sheet$cssRules2 !== void 0 ? _sheet$cssRules2 : []);
- var _css = _this.rewrite(_rules, prefix); // eslint-disable-next-line no-param-reassign
- styleNode.textContent = _css; // eslint-disable-next-line no-param-reassign
- styleNode[ScopedCSS.ModifiedTag] = true;
- }
- }
- }); // since observer will be deleted when node be removed
- // we dont need create a cleanup function manually
- // see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver/disconnect
- mutator.observe(styleNode, {
- childList: true
- });
- }
- }, {
- key: "rewrite",
- value: function rewrite(rules) {
- var _this2 = this;
- var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
- var css = '';
- rules.forEach(function (rule) {
- switch (rule.type) {
- case RuleType.STYLE:
- css += _this2.ruleStyle(rule, prefix);
- break;
- case RuleType.MEDIA:
- css += _this2.ruleMedia(rule, prefix);
- break;
- case RuleType.SUPPORTS:
- css += _this2.ruleSupport(rule, prefix);
- break;
- default:
- css += "".concat(rule.cssText);
- break;
- }
- });
- return css;
- } // handle case:
- // .app-main {}
- // html, body {}
- // eslint-disable-next-line class-methods-use-this
- }, {
- key: "ruleStyle",
- value: function ruleStyle(rule, prefix) {
- var rootSelectorRE = /((?:[^\w\-.#]|^)(body|html|:root))/gm;
- var rootCombinationRE = /(html[^\w{[]+)/gm;
- var selector = rule.selectorText.trim();
- var cssText = rule.cssText; // handle html { ... }
- // handle body { ... }
- // handle :root { ... }
- if (selector === 'html' || selector === 'body' || selector === ':root') {
- return cssText.replace(rootSelectorRE, prefix);
- } // handle html body { ... }
- // handle html > body { ... }
- if (rootCombinationRE.test(rule.selectorText)) {
- var siblingSelectorRE = /(html[^\w{]+)(\+|~)/gm; // since html + body is a non-standard rule for html
- // transformer will ignore it
- if (!siblingSelectorRE.test(rule.selectorText)) {
- cssText = cssText.replace(rootCombinationRE, '');
- }
- } // handle grouping selector, a,span,p,div { ... }
- cssText = cssText.replace(/^[\s\S]+{/, function (selectors) {
- return selectors.replace(/(^|,\n?)([^,]+)/g, function (item, p, s) {
- // handle div,body,span { ... }
- if (rootSelectorRE.test(item)) {
- return item.replace(rootSelectorRE, function (m) {
- // do not discard valid previous character, such as body,html or *:not(:root)
- var whitePrevChars = [',', '('];
- if (m && whitePrevChars.includes(m[0])) {
- return "".concat(m[0]).concat(prefix);
- } // replace root selector with prefix
- return prefix;
- });
- }
- return "".concat(p).concat(prefix, " ").concat(s.replace(/^ */, ''));
- });
- });
- return cssText;
- } // handle case:
- // @media screen and (max-width: 300px) {}
- }, {
- key: "ruleMedia",
- value: function ruleMedia(rule, prefix) {
- var css = this.rewrite(arrayify(rule.cssRules), prefix);
- return "@media ".concat(rule.conditionText, " {").concat(css, "}");
- } // handle case:
- // @supports (display: grid) {}
- }, {
- key: "ruleSupport",
- value: function ruleSupport(rule, prefix) {
- var css = this.rewrite(arrayify(rule.cssRules), prefix);
- return "@supports ".concat(rule.conditionText, " {").concat(css, "}");
- }
- }]);
- return ScopedCSS;
- }();
- ScopedCSS.ModifiedTag = 'Symbol(style-modified-qiankun)';
- var processor;
- var QiankunCSSRewriteAttr = 'data-qiankun';
- var process = function process(appWrapper, stylesheetElement, appName) {
- // lazy singleton pattern
- if (!processor) {
- processor = new ScopedCSS();
- }
- if (stylesheetElement.tagName === 'LINK') {
- console.warn('Feature: sandbox.experimentalStyleIsolation is not support for link element yet.');
- }
- var mountDOM = appWrapper;
- if (!mountDOM) {
- return;
- }
- var tag = (mountDOM.tagName || '').toLowerCase();
- if (tag && stylesheetElement.tagName === 'STYLE') {
- var prefix = "".concat(tag, "[").concat(QiankunCSSRewriteAttr, "=\"").concat(appName, "\"]");
- processor.process(stylesheetElement, prefix);
- }
- };
- var rawHeadAppendChild = HTMLHeadElement.prototype.appendChild;
- var rawHeadRemoveChild = HTMLHeadElement.prototype.removeChild;
- var rawBodyAppendChild = HTMLBodyElement.prototype.appendChild;
- var rawBodyRemoveChild = HTMLBodyElement.prototype.removeChild;
- var rawHeadInsertBefore = HTMLHeadElement.prototype.insertBefore;
- var rawRemoveChild = HTMLElement.prototype.removeChild;
- var SCRIPT_TAG_NAME = 'SCRIPT';
- var LINK_TAG_NAME = 'LINK';
- var STYLE_TAG_NAME = 'STYLE';
- function isHijackingTag(tagName) {
- 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;
- }
- /**
- * Check if a style element is a styled-component liked.
- * A styled-components liked element is which not have textContext but keep the rules in its styleSheet.cssRules.
- * Such as the style element generated by styled-components and emotion.
- * @param element
- */
- function isStyledComponentsLike(element) {
- var _element$sheet, _getStyledElementCSSR;
- 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));
- }
- function patchCustomEvent(e, elementGetter) {
- Object.defineProperties(e, {
- srcElement: {
- get: elementGetter
- },
- target: {
- get: elementGetter
- }
- });
- return e;
- }
- function manualInvokeElementOnLoad(element) {
- // we need to invoke the onload event manually to notify the event listener that the script was completed
- // here are the two typical ways of dynamic script loading
- // 1. element.onload callback way, which webpack and loadjs used, see https://github.com/muicss/loadjs/blob/master/src/loadjs.js#L138
- // 2. addEventListener way, which toast-loader used, see https://github.com/pyrsmk/toast/blob/master/src/Toast.ts#L64
- var loadEvent = new CustomEvent('load');
- var patchedEvent = patchCustomEvent(loadEvent, function () {
- return element;
- });
- if (isFunction_1(element.onload)) {
- element.onload(patchedEvent);
- } else {
- element.dispatchEvent(patchedEvent);
- }
- }
- function manualInvokeElementOnError(element) {
- var errorEvent = new CustomEvent('error');
- var patchedEvent = patchCustomEvent(errorEvent, function () {
- return element;
- });
- if (isFunction_1(element.onerror)) {
- element.onerror(patchedEvent);
- } else {
- element.dispatchEvent(patchedEvent);
- }
- }
- function convertLinkAsStyle(element, postProcess) {
- var fetchFn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : fetch;
- var styleElement = document.createElement('style');
- var href = element.href; // add source link element href
- styleElement.dataset.qiankunHref = href;
- fetchFn(href).then(function (res) {
- return res.text();
- }).then(function (styleContext) {
- styleElement.appendChild(document.createTextNode(styleContext));
- postProcess(styleElement);
- manualInvokeElementOnLoad(element);
- }).catch(function () {
- return manualInvokeElementOnError(element);
- });
- return styleElement;
- }
- var styledComponentCSSRulesMap = new WeakMap();
- var dynamicScriptAttachedCommentMap = new WeakMap();
- var dynamicLinkAttachedInlineStyleMap = new WeakMap();
- function recordStyledComponentsCSSRules(styleElements) {
- styleElements.forEach(function (styleElement) {
- /*
- With a styled-components generated style element, we need to record its cssRules for restore next re-mounting time.
- 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.
- see https://www.w3.org/TR/cssom-1/#associated-css-style-sheet
- */
- if (styleElement instanceof HTMLStyleElement && isStyledComponentsLike(styleElement)) {
- if (styleElement.sheet) {
- // record the original css rules of the style element for restore
- styledComponentCSSRulesMap.set(styleElement, styleElement.sheet.cssRules);
- }
- }
- });
- }
- function getStyledElementCSSRules(styledElement) {
- return styledComponentCSSRulesMap.get(styledElement);
- }
- function getOverwrittenAppendChildOrInsertBefore(opts) {
- return function appendChildOrInsertBefore(newChild) {
- var refChild = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
- var element = newChild;
- var rawDOMAppendOrInsertBefore = opts.rawDOMAppendOrInsertBefore,
- isInvokedByMicroApp = opts.isInvokedByMicroApp,
- containerConfigGetter = opts.containerConfigGetter;
- if (!isHijackingTag(element.tagName) || !isInvokedByMicroApp(element)) {
- return rawDOMAppendOrInsertBefore.call(this, element, refChild);
- }
- if (element.tagName) {
- var containerConfig = containerConfigGetter(element);
- var appName = containerConfig.appName,
- appWrapperGetter = containerConfig.appWrapperGetter,
- proxy = containerConfig.proxy,
- strictGlobal = containerConfig.strictGlobal,
- dynamicStyleSheetElements = containerConfig.dynamicStyleSheetElements,
- scopedCSS = containerConfig.scopedCSS,
- excludeAssetFilter = containerConfig.excludeAssetFilter;
- switch (element.tagName) {
- case LINK_TAG_NAME:
- case STYLE_TAG_NAME:
- {
- var stylesheetElement = newChild;
- var _stylesheetElement = stylesheetElement,
- href = _stylesheetElement.href;
- if (excludeAssetFilter && href && excludeAssetFilter(href)) {
- return rawDOMAppendOrInsertBefore.call(this, element, refChild);
- }
- var mountDOM = appWrapperGetter();
- if (scopedCSS) {
- var _element$tagName;
- // exclude link elements like <link rel="icon" href="favicon.ico">
- var linkElementUsingStylesheet = ((_element$tagName = element.tagName) === null || _element$tagName === void 0 ? void 0 : _element$tagName.toUpperCase()) === LINK_TAG_NAME && element.rel === 'stylesheet' && element.href;
- if (linkElementUsingStylesheet) {
- var _frameworkConfigurati;
- var _fetch = typeof frameworkConfiguration.fetch === 'function' ? frameworkConfiguration.fetch : (_frameworkConfigurati = frameworkConfiguration.fetch) === null || _frameworkConfigurati === void 0 ? void 0 : _frameworkConfigurati.fn;
- stylesheetElement = convertLinkAsStyle(element, function (styleElement) {
- return process(mountDOM, styleElement, appName);
- }, _fetch);
- dynamicLinkAttachedInlineStyleMap.set(element, stylesheetElement);
- } else {
- process(mountDOM, stylesheetElement, appName);
- }
- } // eslint-disable-next-line no-shadow
- dynamicStyleSheetElements.push(stylesheetElement);
- var referenceNode = mountDOM.contains(refChild) ? refChild : null;
- return rawDOMAppendOrInsertBefore.call(mountDOM, stylesheetElement, referenceNode);
- }
- case SCRIPT_TAG_NAME:
- {
- var _element = element,
- src = _element.src,
- text = _element.text; // some script like jsonp maybe not support cors which should't use execScripts
- if (excludeAssetFilter && src && excludeAssetFilter(src)) {
- return rawDOMAppendOrInsertBefore.call(this, element, refChild);
- }
- var _mountDOM = appWrapperGetter();
- var _fetch2 = frameworkConfiguration.fetch;
- var _referenceNode = _mountDOM.contains(refChild) ? refChild : null;
- if (src) {
- _execScripts(null, [src], proxy, {
- fetch: _fetch2,
- strictGlobal: strictGlobal,
- beforeExec: function beforeExec() {
- var isCurrentScriptConfigurable = function isCurrentScriptConfigurable() {
- var descriptor = Object.getOwnPropertyDescriptor(document, 'currentScript');
- return !descriptor || descriptor.configurable;
- };
- if (isCurrentScriptConfigurable()) {
- Object.defineProperty(document, 'currentScript', {
- get: function get() {
- return element;
- },
- configurable: true
- });
- }
- },
- success: function success() {
- manualInvokeElementOnLoad(element);
- element = null;
- },
- error: function error() {
- manualInvokeElementOnError(element);
- element = null;
- }
- });
- var dynamicScriptCommentElement = document.createComment("dynamic script ".concat(src, " replaced by qiankun"));
- dynamicScriptAttachedCommentMap.set(element, dynamicScriptCommentElement);
- return rawDOMAppendOrInsertBefore.call(_mountDOM, dynamicScriptCommentElement, _referenceNode);
- } // inline script never trigger the onload and onerror event
- _execScripts(null, ["<script>".concat(text, "</script>")], proxy, {
- strictGlobal: strictGlobal
- });
- var dynamicInlineScriptCommentElement = document.createComment('dynamic inline script replaced by qiankun');
- dynamicScriptAttachedCommentMap.set(element, dynamicInlineScriptCommentElement);
- return rawDOMAppendOrInsertBefore.call(_mountDOM, dynamicInlineScriptCommentElement, _referenceNode);
- }
- }
- }
- return rawDOMAppendOrInsertBefore.call(this, element, refChild);
- };
- }
- function getNewRemoveChild(headOrBodyRemoveChild, appWrapperGetterGetter) {
- return function removeChild(child) {
- var tagName = child.tagName;
- if (!isHijackingTag(tagName)) return headOrBodyRemoveChild.call(this, child);
- try {
- var attachedElement;
- switch (tagName) {
- case LINK_TAG_NAME:
- {
- attachedElement = dynamicLinkAttachedInlineStyleMap.get(child) || child;
- break;
- }
- case SCRIPT_TAG_NAME:
- {
- attachedElement = dynamicScriptAttachedCommentMap.get(child) || child;
- break;
- }
- default:
- {
- attachedElement = child;
- }
- } // container may had been removed while app unmounting if the removeChild action was async
- var appWrapperGetter = appWrapperGetterGetter(child);
- var container = appWrapperGetter();
- if (container.contains(attachedElement)) {
- return rawRemoveChild.call(container, attachedElement);
- }
- } catch (e) {
- console.warn(e);
- }
- return headOrBodyRemoveChild.call(this, child);
- };
- }
- function patchHTMLDynamicAppendPrototypeFunctions(isInvokedByMicroApp, containerConfigGetter) {
- // Just overwrite it while it have not been overwrite
- if (HTMLHeadElement.prototype.appendChild === rawHeadAppendChild && HTMLBodyElement.prototype.appendChild === rawBodyAppendChild && HTMLHeadElement.prototype.insertBefore === rawHeadInsertBefore) {
- HTMLHeadElement.prototype.appendChild = getOverwrittenAppendChildOrInsertBefore({
- rawDOMAppendOrInsertBefore: rawHeadAppendChild,
- containerConfigGetter: containerConfigGetter,
- isInvokedByMicroApp: isInvokedByMicroApp
- });
- HTMLBodyElement.prototype.appendChild = getOverwrittenAppendChildOrInsertBefore({
- rawDOMAppendOrInsertBefore: rawBodyAppendChild,
- containerConfigGetter: containerConfigGetter,
- isInvokedByMicroApp: isInvokedByMicroApp
- });
- HTMLHeadElement.prototype.insertBefore = getOverwrittenAppendChildOrInsertBefore({
- rawDOMAppendOrInsertBefore: rawHeadInsertBefore,
- containerConfigGetter: containerConfigGetter,
- isInvokedByMicroApp: isInvokedByMicroApp
- });
- } // Just overwrite it while it have not been overwrite
- if (HTMLHeadElement.prototype.removeChild === rawHeadRemoveChild && HTMLBodyElement.prototype.removeChild === rawBodyRemoveChild) {
- HTMLHeadElement.prototype.removeChild = getNewRemoveChild(rawHeadRemoveChild, function (element) {
- return containerConfigGetter(element).appWrapperGetter;
- });
- HTMLBodyElement.prototype.removeChild = getNewRemoveChild(rawBodyRemoveChild, function (element) {
- return containerConfigGetter(element).appWrapperGetter;
- });
- }
- return function unpatch() {
- HTMLHeadElement.prototype.appendChild = rawHeadAppendChild;
- HTMLHeadElement.prototype.removeChild = rawHeadRemoveChild;
- HTMLBodyElement.prototype.appendChild = rawBodyAppendChild;
- HTMLBodyElement.prototype.removeChild = rawBodyRemoveChild;
- HTMLHeadElement.prototype.insertBefore = rawHeadInsertBefore;
- };
- }
- function rebuildCSSRules(styleSheetElements, reAppendElement) {
- styleSheetElements.forEach(function (stylesheetElement) {
- // re-append the dynamic stylesheet to sub-app container
- var appendSuccess = reAppendElement(stylesheetElement);
- if (appendSuccess) {
- /*
- get the stored css rules from styled-components generated element, and the re-insert rules for them.
- note that we must do this after style element had been added to document, which stylesheet would be associated to the document automatically.
- check the spec https://www.w3.org/TR/cssom-1/#associated-css-style-sheet
- */
- if (stylesheetElement instanceof HTMLStyleElement && isStyledComponentsLike(stylesheetElement)) {
- var cssRules = getStyledElementCSSRules(stylesheetElement);
- if (cssRules) {
- // eslint-disable-next-line no-plusplus
- for (var i = 0; i < cssRules.length; i++) {
- var cssRule = cssRules[i];
- var cssStyleSheetElement = stylesheetElement.sheet;
- cssStyleSheetElement.insertRule(cssRule.cssText, cssStyleSheetElement.cssRules.length);
- }
- }
- }
- }
- });
- }
- /**
- * @author Kuitos
- * @since 2020-10-13
- */
- var bootstrappingPatchCount = 0;
- var mountingPatchCount = 0;
- /**
- * Just hijack dynamic head append, that could avoid accidentally hijacking the insertion of elements except in head.
- * Such a case: ReactDOM.createPortal(<style>.test{color:blue}</style>, container),
- * 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.
- * @param appName
- * @param appWrapperGetter
- * @param proxy
- * @param mounting
- * @param scopedCSS
- * @param excludeAssetFilter
- */
- function patchLooseSandbox(appName, appWrapperGetter, proxy) {
- var mounting = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
- var scopedCSS = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
- var excludeAssetFilter = arguments.length > 5 ? arguments[5] : undefined;
- var dynamicStyleSheetElements = [];
- var unpatchDynamicAppendPrototypeFunctions = patchHTMLDynamicAppendPrototypeFunctions(
- /*
- check if the currently specified application is active
- While we switch page from qiankun app to a normal react routing page, the normal one may load stylesheet dynamically while page rendering,
- but the url change listener must to wait until the current call stack is flushed.
- This scenario may cause we record the stylesheet from react routing page dynamic injection,
- and remove them after the url change triggered and qiankun app is unmouting
- see https://github.com/ReactTraining/history/blob/master/modules/createHashHistory.js#L222-L230
- */
- function () {
- return bt(window.location).some(function (name) {
- return name === appName;
- });
- }, function () {
- return {
- appName: appName,
- appWrapperGetter: appWrapperGetter,
- proxy: proxy,
- strictGlobal: false,
- scopedCSS: scopedCSS,
- dynamicStyleSheetElements: dynamicStyleSheetElements,
- excludeAssetFilter: excludeAssetFilter
- };
- });
- if (!mounting) bootstrappingPatchCount++;
- if (mounting) mountingPatchCount++;
- return function free() {
- // bootstrap patch just called once but its freer will be called multiple times
- if (!mounting && bootstrappingPatchCount !== 0) bootstrappingPatchCount--;
- if (mounting) mountingPatchCount--;
- var allMicroAppUnmounted = mountingPatchCount === 0 && bootstrappingPatchCount === 0; // release the overwrite prototype after all the micro apps unmounted
- if (allMicroAppUnmounted) unpatchDynamicAppendPrototypeFunctions();
- recordStyledComponentsCSSRules(dynamicStyleSheetElements); // As now the sub app content all wrapped with a special id container,
- // the dynamic style sheet would be removed automatically while unmoutting
- return function rebuild() {
- rebuildCSSRules(dynamicStyleSheetElements, function (stylesheetElement) {
- var appWrapper = appWrapperGetter();
- if (!appWrapper.contains(stylesheetElement)) {
- // Using document.head.appendChild ensures that appendChild invocation can also directly use the HTMLHeadElement.prototype.appendChild method which is overwritten at mounting phase
- document.head.appendChild.call(appWrapper, stylesheetElement);
- return true;
- }
- return false;
- }); // As the patcher will be invoked every mounting phase, we could release the cache for gc after rebuilding
- if (mounting) {
- dynamicStyleSheetElements = [];
- }
- };
- };
- }
- /**
- * @author Kuitos
- * @since 2020-10-13
- */
- Object.defineProperty(nativeGlobal, '__proxyAttachContainerConfigMap__', {
- enumerable: false,
- writable: true
- }); // Share proxyAttachContainerConfigMap between multiple qiankun instance, thus they could access the same record
- nativeGlobal.__proxyAttachContainerConfigMap__ = nativeGlobal.__proxyAttachContainerConfigMap__ || new WeakMap();
- var proxyAttachContainerConfigMap = nativeGlobal.__proxyAttachContainerConfigMap__;
- var elementAttachContainerConfigMap = new WeakMap();
- var docCreatePatchedMap = new WeakMap();
- function patchDocumentCreateElement() {
- var docCreateElementFnBeforeOverwrite = docCreatePatchedMap.get(document.createElement);
- if (!docCreateElementFnBeforeOverwrite) {
- var rawDocumentCreateElement = document.createElement;
- Document.prototype.createElement = function createElement(tagName, options) {
- var element = rawDocumentCreateElement.call(this, tagName, options);
- if (isHijackingTag(tagName)) {
- var _ref = getCurrentRunningApp() || {},
- currentRunningSandboxProxy = _ref.window;
- if (currentRunningSandboxProxy) {
- var proxyContainerConfig = proxyAttachContainerConfigMap.get(currentRunningSandboxProxy);
- if (proxyContainerConfig) {
- elementAttachContainerConfigMap.set(element, proxyContainerConfig);
- }
- }
- }
- return element;
- }; // It means it have been overwritten while createElement is an own property of document
- if (document.hasOwnProperty('createElement')) {
- document.createElement = Document.prototype.createElement;
- }
- docCreatePatchedMap.set(Document.prototype.createElement, rawDocumentCreateElement);
- }
- return function unpatch() {
- if (docCreateElementFnBeforeOverwrite) {
- Document.prototype.createElement = docCreateElementFnBeforeOverwrite;
- document.createElement = docCreateElementFnBeforeOverwrite;
- }
- };
- }
- var bootstrappingPatchCount$1 = 0;
- var mountingPatchCount$1 = 0;
- function patchStrictSandbox(appName, appWrapperGetter, proxy) {
- var mounting = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
- var scopedCSS = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
- var excludeAssetFilter = arguments.length > 5 ? arguments[5] : undefined;
- var containerConfig = proxyAttachContainerConfigMap.get(proxy);
- if (!containerConfig) {
- containerConfig = {
- appName: appName,
- proxy: proxy,
- appWrapperGetter: appWrapperGetter,
- dynamicStyleSheetElements: [],
- strictGlobal: true,
- excludeAssetFilter: excludeAssetFilter,
- scopedCSS: scopedCSS
- };
- proxyAttachContainerConfigMap.set(proxy, containerConfig);
- } // all dynamic style sheets are stored in proxy container
- var _containerConfig = containerConfig,
- dynamicStyleSheetElements = _containerConfig.dynamicStyleSheetElements;
- var unpatchDocumentCreate = patchDocumentCreateElement();
- var unpatchDynamicAppendPrototypeFunctions = patchHTMLDynamicAppendPrototypeFunctions(function (element) {
- return elementAttachContainerConfigMap.has(element);
- }, function (element) {
- return elementAttachContainerConfigMap.get(element);
- });
- if (!mounting) bootstrappingPatchCount$1++;
- if (mounting) mountingPatchCount$1++;
- return function free() {
- // bootstrap patch just called once but its freer will be called multiple times
- if (!mounting && bootstrappingPatchCount$1 !== 0) bootstrappingPatchCount$1--;
- if (mounting) mountingPatchCount$1--;
- var allMicroAppUnmounted = mountingPatchCount$1 === 0 && bootstrappingPatchCount$1 === 0; // release the overwrite prototype after all the micro apps unmounted
- if (allMicroAppUnmounted) {
- unpatchDynamicAppendPrototypeFunctions();
- unpatchDocumentCreate();
- }
- recordStyledComponentsCSSRules(dynamicStyleSheetElements); // As now the sub app content all wrapped with a special id container,
- // the dynamic style sheet would be removed automatically while unmoutting
- return function rebuild() {
- rebuildCSSRules(dynamicStyleSheetElements, function (stylesheetElement) {
- var appWrapper = appWrapperGetter();
- if (!appWrapper.contains(stylesheetElement)) {
- rawHeadAppendChild.call(appWrapper, stylesheetElement);
- return true;
- }
- return false;
- });
- };
- };
- }
- function patch() {
- // FIXME umi unmount feature request
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- var rawHistoryListen = function rawHistoryListen(_) {
- return noop_1;
- };
- var historyListeners = [];
- var historyUnListens = [];
- if (window.g_history && isFunction_1(window.g_history.listen)) {
- rawHistoryListen = window.g_history.listen.bind(window.g_history);
- window.g_history.listen = function (listener) {
- historyListeners.push(listener);
- var unListen = rawHistoryListen(listener);
- historyUnListens.push(unListen);
- return function () {
- unListen();
- historyUnListens.splice(historyUnListens.indexOf(unListen), 1);
- historyListeners.splice(historyListeners.indexOf(listener), 1);
- };
- };
- }
- return function free() {
- var rebuild = noop_1;
- /*
- 还存在余量 listener 表明未被卸载,存在两种情况
- 1. 应用在 unmout 时未正确卸载 listener
- 2. listener 是应用 mount 之前绑定的,
- 第二种情况下应用在下次 mount 之前需重新绑定该 listener
- */
- if (historyListeners.length) {
- rebuild = function rebuild() {
- // 必须使用 window.g_history.listen 的方式重新绑定 listener,从而能保证 rebuild 这部分也能被捕获到,否则在应用卸载后无法正确的移除这部分副作用
- historyListeners.forEach(function (listener) {
- return window.g_history.listen(listener);
- });
- };
- } // 卸载余下的 listener
- historyUnListens.forEach(function (unListen) {
- return unListen();
- }); // restore
- if (window.g_history && isFunction_1(window.g_history.listen)) {
- window.g_history.listen = rawHistoryListen;
- }
- return rebuild;
- };
- }
- var rawWindowInterval = window.setInterval;
- var rawWindowClearInterval = window.clearInterval;
- function patch$1(global) {
- var intervals = [];
- global.clearInterval = function (intervalId) {
- intervals = intervals.filter(function (id) {
- return id !== intervalId;
- });
- return rawWindowClearInterval.call(window, intervalId);
- };
- global.setInterval = function (handler, timeout) {
- for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
- args[_key - 2] = arguments[_key];
- }
- var intervalId = rawWindowInterval.apply(void 0, [handler, timeout].concat(args));
- intervals = [].concat(_toConsumableArray(intervals), [intervalId]);
- return intervalId;
- };
- return function free() {
- intervals.forEach(function (id) {
- return global.clearInterval(id);
- });
- global.setInterval = rawWindowInterval;
- global.clearInterval = rawWindowClearInterval;
- return noop_1;
- };
- }
- var rawAddEventListener = window.addEventListener;
- var rawRemoveEventListener = window.removeEventListener;
- function patch$2(global) {
- var listenerMap = new Map();
- global.addEventListener = function (type, listener, options) {
- var listeners = listenerMap.get(type) || [];
- listenerMap.set(type, [].concat(_toConsumableArray(listeners), [listener]));
- return rawAddEventListener.call(window, type, listener, options);
- };
- global.removeEventListener = function (type, listener, options) {
- var storedTypeListeners = listenerMap.get(type);
- if (storedTypeListeners && storedTypeListeners.length && storedTypeListeners.indexOf(listener) !== -1) {
- storedTypeListeners.splice(storedTypeListeners.indexOf(listener), 1);
- }
- return rawRemoveEventListener.call(window, type, listener, options);
- };
- return function free() {
- listenerMap.forEach(function (listeners, type) {
- return _toConsumableArray(listeners).forEach(function (listener) {
- return global.removeEventListener(type, listener);
- });
- });
- global.addEventListener = rawAddEventListener;
- global.removeEventListener = rawRemoveEventListener;
- return noop_1;
- };
- }
- function patchAtMounting(appName, elementGetter, sandbox, scopedCSS, excludeAssetFilter) {
- var _patchersInSandbox, _patchersInSandbox$sa;
- var basePatchers = [function () {
- return patch$1(sandbox.proxy);
- }, function () {
- return patch$2(sandbox.proxy);
- }, function () {
- return patch();
- }];
- var patchersInSandbox = (_patchersInSandbox = {}, _defineProperty(_patchersInSandbox, exports.SandBoxType.LegacyProxy, [].concat(basePatchers, [function () {
- return patchLooseSandbox(appName, elementGetter, sandbox.proxy, true, scopedCSS, excludeAssetFilter);
- }])), _defineProperty(_patchersInSandbox, exports.SandBoxType.Proxy, [].concat(basePatchers, [function () {
- return patchStrictSandbox(appName, elementGetter, sandbox.proxy, true, scopedCSS, excludeAssetFilter);
- }])), _defineProperty(_patchersInSandbox, exports.SandBoxType.Snapshot, [].concat(basePatchers, [function () {
- return patchLooseSandbox(appName, elementGetter, sandbox.proxy, true, scopedCSS, excludeAssetFilter);
- }])), _patchersInSandbox);
- return (_patchersInSandbox$sa = patchersInSandbox[sandbox.type]) === null || _patchersInSandbox$sa === void 0 ? void 0 : _patchersInSandbox$sa.map(function (patch) {
- return patch();
- });
- }
- function patchAtBootstrapping(appName, elementGetter, sandbox, scopedCSS, excludeAssetFilter) {
- var _patchersInSandbox2, _patchersInSandbox$sa2;
- var patchersInSandbox = (_patchersInSandbox2 = {}, _defineProperty(_patchersInSandbox2, exports.SandBoxType.LegacyProxy, [function () {
- return patchLooseSandbox(appName, elementGetter, sandbox.proxy, false, scopedCSS, excludeAssetFilter);
- }]), _defineProperty(_patchersInSandbox2, exports.SandBoxType.Proxy, [function () {
- return patchStrictSandbox(appName, elementGetter, sandbox.proxy, false, scopedCSS, excludeAssetFilter);
- }]), _defineProperty(_patchersInSandbox2, exports.SandBoxType.Snapshot, [function () {
- return patchLooseSandbox(appName, elementGetter, sandbox.proxy, false, scopedCSS, excludeAssetFilter);
- }]), _patchersInSandbox2);
- return (_patchersInSandbox$sa2 = patchersInSandbox[sandbox.type]) === null || _patchersInSandbox$sa2 === void 0 ? void 0 : _patchersInSandbox$sa2.map(function (patch) {
- return patch();
- });
- }
- /**
- * fastest(at most time) unique array method
- * @see https://jsperf.com/array-filter-unique/30
- */
- function uniq(array) {
- return array.filter(function filter(element) {
- return element in this ? false : this[element] = true;
- }, Object.create(null));
- } // zone.js will overwrite Object.defineProperty
- var rawObjectDefineProperty = Object.defineProperty;
- var variableWhiteListInDev = [// for react hot reload
- // see https://github.com/facebook/create-react-app/blob/66bf7dfc43350249e2f09d138a20840dae8a0a4a/packages/react-error-overlay/src/index.js#L180
- '__REACT_ERROR_OVERLAY_GLOBAL_HOOK__'] ; // who could escape the sandbox
- var variableWhiteList = [// FIXME System.js used a indirect call with eval, which would make it scope escape to global
- // To make System.js works well, we write it back to global window temporary
- // see https://github.com/systemjs/systemjs/blob/457f5b7e8af6bd120a279540477552a07d5de086/src/evaluate.js#L106
- 'System', // see https://github.com/systemjs/systemjs/blob/457f5b7e8af6bd120a279540477552a07d5de086/src/instantiate.js#L357
- '__cjsWrapper'].concat(variableWhiteListInDev);
- /*
- variables who are impossible to be overwrite need to be escaped from proxy sandbox for performance reasons
- */
- var unscopables = {
- undefined: true,
- Array: true,
- Object: true,
- String: true,
- Boolean: true,
- Math: true,
- Number: true,
- Symbol: true,
- parseFloat: true,
- Float32Array: true,
- isNaN: true,
- Infinity: true,
- Reflect: true,
- Float64Array: true,
- Function: true,
- Map: true,
- NaN: true,
- Promise: true,
- Proxy: true,
- Set: true,
- parseInt: true,
- requestAnimationFrame: true
- };
- var useNativeWindowForBindingsProps = new Map([['fetch', true], ['mockDomAPIInBlackList', "development" === 'test']]);
- function createFakeWindow(globalContext) {
- // map always has the fastest performance in has check scenario
- // see https://jsperf.com/array-indexof-vs-set-has/23
- var propertiesWithGetter = new Map();
- var fakeWindow = {};
- /*
- copy the non-configurable property of global to fakeWindow
- see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/getOwnPropertyDescriptor
- > 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.
- */
- Object.getOwnPropertyNames(globalContext).filter(function (p) {
- var descriptor = Object.getOwnPropertyDescriptor(globalContext, p);
- return !(descriptor === null || descriptor === void 0 ? void 0 : descriptor.configurable);
- }).forEach(function (p) {
- var descriptor = Object.getOwnPropertyDescriptor(globalContext, p);
- if (descriptor) {
- var hasGetter = Object.prototype.hasOwnProperty.call(descriptor, 'get');
- /*
- make top/self/window property configurable and writable, otherwise it will cause TypeError while get trap return.
- see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/get
- > 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.
- */
- if (p === 'top' || p === 'parent' || p === 'self' || p === 'window' || "development" === 'test' ) {
- descriptor.configurable = true;
- /*
- 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
- Example:
- Safari/FF: Object.getOwnPropertyDescriptor(window, 'top') -> {get: function, set: undefined, enumerable: true, configurable: false}
- Chrome: Object.getOwnPropertyDescriptor(window, 'top') -> {value: Window, writable: false, enumerable: true, configurable: false}
- */
- if (!hasGetter) {
- descriptor.writable = true;
- }
- }
- if (hasGetter) propertiesWithGetter.set(p, true); // freeze the descriptor to avoid being modified by zone.js
- // see https://github.com/angular/zone.js/blob/a5fe09b0fac27ac5df1fa746042f96f05ccb6a00/lib/browser/define-property.ts#L71
- rawObjectDefineProperty(fakeWindow, p, Object.freeze(descriptor));
- }
- });
- return {
- fakeWindow: fakeWindow,
- propertiesWithGetter: propertiesWithGetter
- };
- }
- var activeSandboxCount = 0;
- /**
- * 基于 Proxy 实现的沙箱
- */
- var ProxySandbox = /*#__PURE__*/function () {
- function ProxySandbox(name) {
- var _this = this;
- var globalContext = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window;
- _classCallCheck(this, ProxySandbox);
- this.updatedValueSet = new Set();
- this.name = void 0;
- this.type = void 0;
- this.proxy = void 0;
- this.globalContext = void 0;
- this.sandboxRunning = true;
- this.latestSetProp = null;
- this.name = name;
- this.globalContext = globalContext;
- this.type = exports.SandBoxType.Proxy;
- var updatedValueSet = this.updatedValueSet;
- var _createFakeWindow = createFakeWindow(globalContext),
- fakeWindow = _createFakeWindow.fakeWindow,
- propertiesWithGetter = _createFakeWindow.propertiesWithGetter;
- var descriptorTargetMap = new Map();
- var hasOwnProperty = function hasOwnProperty(key) {
- return fakeWindow.hasOwnProperty(key) || globalContext.hasOwnProperty(key);
- };
- var proxy = new Proxy(fakeWindow, {
- set: function set(target, p, value) {
- if (_this.sandboxRunning) {
- _this.registerRunningApp(name, proxy); // We must kept its description while the property existed in globalContext before
- if (!target.hasOwnProperty(p) && globalContext.hasOwnProperty(p)) {
- var descriptor = Object.getOwnPropertyDescriptor(globalContext, p);
- var writable = descriptor.writable,
- configurable = descriptor.configurable,
- enumerable = descriptor.enumerable;
- if (writable) {
- Object.defineProperty(target, p, {
- configurable: configurable,
- enumerable: enumerable,
- writable: writable,
- value: value
- });
- }
- } else {
- // @ts-ignore
- target[p] = value;
- }
- if (variableWhiteList.indexOf(p) !== -1) {
- // @ts-ignore
- globalContext[p] = value;
- }
- updatedValueSet.add(p);
- _this.latestSetProp = p;
- return true;
- }
- {
- console.warn("[qiankun] Set window.".concat(p.toString(), " while sandbox destroyed or inactive in ").concat(name, "!"));
- } // 在 strict-mode 下,Proxy 的 handler.set 返回 false 会抛出 TypeError,在沙箱卸载的情况下应该忽略错误
- return true;
- },
- get: function get(target, p) {
- _this.registerRunningApp(name, proxy);
- if (p === Symbol.unscopables) return unscopables; // avoid who using window.window or window.self to escape the sandbox environment to touch the really window
- // see https://github.com/eligrey/FileSaver.js/blob/master/src/FileSaver.js#L13
- if (p === 'window' || p === 'self') {
- return proxy;
- } // hijack globalWindow accessing with globalThis keyword
- if (p === 'globalThis') {
- return proxy;
- }
- if (p === 'top' || p === 'parent' || "development" === 'test' ) {
- // if your master app in an iframe context, allow these props escape the sandbox
- if (globalContext === globalContext.parent) {
- return proxy;
- }
- return globalContext[p];
- } // proxy.hasOwnProperty would invoke getter firstly, then its value represented as globalContext.hasOwnProperty
- if (p === 'hasOwnProperty') {
- return hasOwnProperty;
- }
- if (p === 'document') {
- return document;
- }
- if (p === 'eval') {
- return eval;
- }
- var value = propertiesWithGetter.has(p) ? globalContext[p] : p in target ? target[p] : globalContext[p];
- /* Some dom api must be bound to native window, otherwise it would cause exception like 'TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation'
- See this code:
- const proxy = new Proxy(window, {});
- const proxyFetch = fetch.bind(proxy);
- proxyFetch('https://qiankun.com');
- */
- var boundTarget = useNativeWindowForBindingsProps.get(p) ? nativeGlobal : globalContext;
- return getTargetValue(boundTarget, value);
- },
- // trap in operator
- // see https://github.com/styled-components/styled-components/blob/master/packages/styled-components/src/constants.js#L12
- has: function has(target, p) {
- return p in unscopables || p in target || p in globalContext;
- },
- getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, p) {
- /*
- 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
- see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/getOwnPropertyDescriptor
- > 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.
- */
- if (target.hasOwnProperty(p)) {
- var descriptor = Object.getOwnPropertyDescriptor(target, p);
- descriptorTargetMap.set(p, 'target');
- return descriptor;
- }
- if (globalContext.hasOwnProperty(p)) {
- var _descriptor = Object.getOwnPropertyDescriptor(globalContext, p);
- 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
- if (_descriptor && !_descriptor.configurable) {
- _descriptor.configurable = true;
- }
- return _descriptor;
- }
- return undefined;
- },
- // trap to support iterator with sandbox
- ownKeys: function ownKeys(target) {
- return uniq(Reflect.ownKeys(globalContext).concat(Reflect.ownKeys(target)));
- },
- defineProperty: function defineProperty(target, p, attributes) {
- var from = descriptorTargetMap.get(p);
- /*
- Descriptor must be defined to native window while it comes from native window via Object.getOwnPropertyDescriptor(window, p),
- otherwise it would cause a TypeError with illegal invocation.
- */
- switch (from) {
- case 'globalContext':
- return Reflect.defineProperty(globalContext, p, attributes);
- default:
- return Reflect.defineProperty(target, p, attributes);
- }
- },
- deleteProperty: function deleteProperty(target, p) {
- _this.registerRunningApp(name, proxy);
- if (target.hasOwnProperty(p)) {
- // @ts-ignore
- delete target[p];
- updatedValueSet.delete(p);
- return true;
- }
- return true;
- },
- // makes sure `window instanceof Window` returns truthy in micro app
- getPrototypeOf: function getPrototypeOf() {
- return Reflect.getPrototypeOf(globalContext);
- }
- });
- this.proxy = proxy;
- activeSandboxCount++;
- }
- _createClass(ProxySandbox, [{
- key: "registerRunningApp",
- value:
- /** window 值变更记录 */
- function registerRunningApp(name, proxy) {
- if (this.sandboxRunning) {
- var currentRunningApp = getCurrentRunningApp();
- if (!currentRunningApp || currentRunningApp.name !== name) {
- setCurrentRunningApp({
- name: name,
- window: proxy
- });
- } // FIXME if you have any other good ideas
- // remove the mark in next tick, thus we can identify whether it in micro app or not
- // 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
- nextTask(function () {
- setCurrentRunningApp(null);
- });
- }
- }
- }, {
- key: "active",
- value: function active() {
- if (!this.sandboxRunning) activeSandboxCount++;
- this.sandboxRunning = true;
- }
- }, {
- key: "inactive",
- value: function inactive() {
- var _this2 = this;
- {
- console.info("[qiankun:sandbox] ".concat(this.name, " modified global properties restore..."), _toConsumableArray(this.updatedValueSet.keys()));
- }
- if (--activeSandboxCount === 0) {
- variableWhiteList.forEach(function (p) {
- if (_this2.proxy.hasOwnProperty(p)) {
- // @ts-ignore
- delete _this2.globalContext[p];
- }
- });
- }
- this.sandboxRunning = false;
- }
- }]);
- return ProxySandbox;
- }();
- function iter(obj, callbackFn) {
- // eslint-disable-next-line guard-for-in, no-restricted-syntax
- for (var prop in obj) {
- // patch for clearInterval for compatible reason, see #1490
- if (obj.hasOwnProperty(prop) || prop === 'clearInterval') {
- callbackFn(prop);
- }
- }
- }
- /**
- * 基于 diff 方式实现的沙箱,用于不支持 Proxy 的低版本浏览器
- */
- var SnapshotSandbox = /*#__PURE__*/function () {
- function SnapshotSandbox(name) {
- _classCallCheck(this, SnapshotSandbox);
- this.proxy = void 0;
- this.name = void 0;
- this.type = void 0;
- this.sandboxRunning = true;
- this.windowSnapshot = void 0;
- this.modifyPropsMap = {};
- this.name = name;
- this.proxy = window;
- this.type = exports.SandBoxType.Snapshot;
- }
- _createClass(SnapshotSandbox, [{
- key: "active",
- value: function active() {
- var _this = this;
- // 记录当前快照
- this.windowSnapshot = {};
- iter(window, function (prop) {
- _this.windowSnapshot[prop] = window[prop];
- }); // 恢复之前的变更
- Object.keys(this.modifyPropsMap).forEach(function (p) {
- window[p] = _this.modifyPropsMap[p];
- });
- this.sandboxRunning = true;
- }
- }, {
- key: "inactive",
- value: function inactive() {
- var _this2 = this;
- this.modifyPropsMap = {};
- iter(window, function (prop) {
- if (window[prop] !== _this2.windowSnapshot[prop]) {
- // 记录变更,恢复环境
- _this2.modifyPropsMap[prop] = window[prop];
- window[prop] = _this2.windowSnapshot[prop];
- }
- });
- {
- console.info("[qiankun:sandbox] ".concat(this.name, " origin window restore..."), Object.keys(this.modifyPropsMap));
- }
- this.sandboxRunning = false;
- }
- }]);
- return SnapshotSandbox;
- }();
- /**
- * 生成应用运行时沙箱
- *
- * 沙箱分两个类型:
- * 1. app 环境沙箱
- * app 环境沙箱是指应用初始化过之后,应用会在什么样的上下文环境运行。每个应用的环境沙箱只会初始化一次,因为子应用只会触发一次 bootstrap 。
- * 子应用在切换时,实际上切换的是 app 环境沙箱。
- * 2. render 沙箱
- * 子应用在 app mount 开始前生成好的的沙箱。每次子应用切换过后,render 沙箱都会重现初始化。
- *
- * 这么设计的目的是为了保证每个子应用切换回来之后,还能运行在应用 bootstrap 之后的环境下。
- *
- * @param appName
- * @param elementGetter
- * @param scopedCSS
- * @param useLooseSandbox
- * @param excludeAssetFilter
- * @param globalContext
- */
- function createSandboxContainer(appName, elementGetter, scopedCSS, useLooseSandbox, excludeAssetFilter, globalContext) {
- var sandbox;
- if (window.Proxy) {
- sandbox = useLooseSandbox ? new LegacySandbox(appName, globalContext) : new ProxySandbox(appName, globalContext);
- } else {
- sandbox = new SnapshotSandbox(appName);
- } // some side effect could be be invoked while bootstrapping, such as dynamic stylesheet injection with style-loader, especially during the development phase
- var bootstrappingFreers = patchAtBootstrapping(appName, elementGetter, sandbox, scopedCSS, excludeAssetFilter); // mounting freers are one-off and should be re-init at every mounting time
- var mountingFreers = [];
- var sideEffectsRebuilders = [];
- return {
- instance: sandbox,
- /**
- * 沙箱被 mount
- * 可能是从 bootstrap 状态进入的 mount
- * 也可能是从 unmount 之后再次唤醒进入 mount
- */
- mount: function mount() {
- return _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
- var sideEffectsRebuildersAtBootstrapping, sideEffectsRebuildersAtMounting;
- return regenerator.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- /* ------------------------------------------ 因为有上下文依赖(window),以下代码执行顺序不能变 ------------------------------------------ */
- /* ------------------------------------------ 1. 启动/恢复 沙箱------------------------------------------ */
- sandbox.active();
- sideEffectsRebuildersAtBootstrapping = sideEffectsRebuilders.slice(0, bootstrappingFreers.length);
- sideEffectsRebuildersAtMounting = sideEffectsRebuilders.slice(bootstrappingFreers.length); // must rebuild the side effects which added at bootstrapping firstly to recovery to nature state
- if (sideEffectsRebuildersAtBootstrapping.length) {
- sideEffectsRebuildersAtBootstrapping.forEach(function (rebuild) {
- return rebuild();
- });
- }
- /* ------------------------------------------ 2. 开启全局变量补丁 ------------------------------------------*/
- // render 沙箱启动时开始劫持各类全局监听,尽量不要在应用初始化阶段有 事件监听/定时器 等副作用
- mountingFreers = patchAtMounting(appName, elementGetter, sandbox, scopedCSS, excludeAssetFilter);
- /* ------------------------------------------ 3. 重置一些初始化时的副作用 ------------------------------------------*/
- // 存在 rebuilder 则表明有些副作用需要重建
- if (sideEffectsRebuildersAtMounting.length) {
- sideEffectsRebuildersAtMounting.forEach(function (rebuild) {
- return rebuild();
- });
- } // clean up rebuilders
- sideEffectsRebuilders = [];
- case 7:
- case "end":
- return _context.stop();
- }
- }
- }, _callee);
- }))();
- },
- /**
- * 恢复 global 状态,使其能回到应用加载之前的状态
- */
- unmount: function unmount() {
- return _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
- return regenerator.wrap(function _callee2$(_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- // record the rebuilders of window side effects (event listeners or timers)
- // note that the frees of mounting phase are one-off as it will be re-init at next mounting
- sideEffectsRebuilders = [].concat(_toConsumableArray(bootstrappingFreers), _toConsumableArray(mountingFreers)).map(function (free) {
- return free();
- });
- sandbox.inactive();
- case 2:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee2);
- }))();
- }
- };
- }
- var _excluded = ["singular", "sandbox", "excludeAssetFilter", "globalContext"];
- function assertElementExist(element, msg) {
- if (!element) {
- if (msg) {
- throw new QiankunError(msg);
- }
- throw new QiankunError('element not existed!');
- }
- }
- function execHooksChain(hooks, app) {
- var global = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : window;
- if (hooks.length) {
- return hooks.reduce(function (chain, hook) {
- return chain.then(function () {
- return hook(app, global);
- });
- }, Promise.resolve());
- }
- return Promise.resolve();
- }
- function validateSingularMode(_x, _x2) {
- return _validateSingularMode.apply(this, arguments);
- } // @ts-ignore
- function _validateSingularMode() {
- _validateSingularMode = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(validate, app) {
- return regenerator.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- return _context.abrupt("return", typeof validate === 'function' ? validate(app) : !!validate);
- case 1:
- case "end":
- return _context.stop();
- }
- }
- }, _callee);
- }));
- return _validateSingularMode.apply(this, arguments);
- }
- var supportShadowDOM = document.head.attachShadow || document.head.createShadowRoot;
- function createElement(appContent, strictStyleIsolation, scopedCSS, appInstanceId) {
- var containerElement = document.createElement('div');
- containerElement.innerHTML = appContent; // appContent always wrapped with a singular div
- var appElement = containerElement.firstChild;
- if (strictStyleIsolation) {
- if (!supportShadowDOM) {
- console.warn('[qiankun]: As current browser not support shadow dom, your strictStyleIsolation configuration will be ignored!');
- } else {
- var innerHTML = appElement.innerHTML;
- appElement.innerHTML = '';
- var shadow;
- if (appElement.attachShadow) {
- shadow = appElement.attachShadow({
- mode: 'open'
- });
- } else {
- // createShadowRoot was proposed in initial spec, which has then been deprecated
- shadow = appElement.createShadowRoot();
- }
- shadow.innerHTML = innerHTML;
- }
- }
- if (scopedCSS) {
- var attr = appElement.getAttribute(QiankunCSSRewriteAttr);
- if (!attr) {
- appElement.setAttribute(QiankunCSSRewriteAttr, appInstanceId);
- }
- var styleNodes = appElement.querySelectorAll('style') || [];
- forEach_1(styleNodes, function (stylesheetElement) {
- process(appElement, stylesheetElement, appInstanceId);
- });
- }
- return appElement;
- }
- /** generate app wrapper dom getter */
- function getAppWrapperGetter(appInstanceId, useLegacyRender, strictStyleIsolation, scopedCSS, elementGetter) {
- return function () {
- if (useLegacyRender) {
- if (strictStyleIsolation) throw new QiankunError('strictStyleIsolation can not be used with legacy render!');
- if (scopedCSS) throw new QiankunError('experimentalStyleIsolation can not be used with legacy render!');
- var appWrapper = document.getElementById(getWrapperId(appInstanceId));
- assertElementExist(appWrapper, "Wrapper element for ".concat(appInstanceId, " is not existed!"));
- return appWrapper;
- }
- var element = elementGetter();
- assertElementExist(element, "Wrapper element for ".concat(appInstanceId, " is not existed!"));
- if (strictStyleIsolation && supportShadowDOM) {
- return element.shadowRoot;
- }
- return element;
- };
- }
- var rawAppendChild = HTMLElement.prototype.appendChild;
- var rawRemoveChild$1 = HTMLElement.prototype.removeChild;
- /**
- * Get the render function
- * If the legacy render function is provide, used as it, otherwise we will insert the app element to target container by qiankun
- * @param appInstanceId
- * @param appContent
- * @param legacyRender
- */
- function getRender(appInstanceId, appContent, legacyRender) {
- var render = function render(_ref, phase) {
- var element = _ref.element,
- loading = _ref.loading,
- container = _ref.container;
- if (legacyRender) {
- {
- console.error('[qiankun] Custom rendering function is deprecated and will be removed in 3.0, you can use the container element setting instead!');
- }
- return legacyRender({
- loading: loading,
- appContent: element ? appContent : ''
- });
- }
- var containerElement = getContainer(container); // The container might have be removed after micro app unmounted.
- // Such as the micro app unmount lifecycle called by a react componentWillUnmount lifecycle, after micro app unmounted, the react component might also be removed
- if (phase !== 'unmounted') {
- var errorMsg = function () {
- switch (phase) {
- case 'loading':
- case 'mounting':
- return "Target container with ".concat(container, " not existed while ").concat(appInstanceId, " ").concat(phase, "!");
- case 'mounted':
- return "Target container with ".concat(container, " not existed after ").concat(appInstanceId, " ").concat(phase, "!");
- default:
- return "Target container with ".concat(container, " not existed while ").concat(appInstanceId, " rendering!");
- }
- }();
- assertElementExist(containerElement, errorMsg);
- }
- if (containerElement && !containerElement.contains(element)) {
- // clear the container
- while (containerElement.firstChild) {
- rawRemoveChild$1.call(containerElement, containerElement.firstChild);
- } // append the element to container if it exist
- if (element) {
- rawAppendChild.call(containerElement, element);
- }
- }
- return undefined;
- };
- return render;
- }
- function getLifecyclesFromExports(scriptExports, appName, global, globalLatestSetProp) {
- if (validateExportLifecycle(scriptExports)) {
- return scriptExports;
- } // fallback to sandbox latest set property if it had
- if (globalLatestSetProp) {
- var lifecycles = global[globalLatestSetProp];
- if (validateExportLifecycle(lifecycles)) {
- return lifecycles;
- }
- }
- {
- console.warn("[qiankun] lifecycle not found from ".concat(appName, " entry exports, fallback to get from window['").concat(appName, "']"));
- } // fallback to global variable who named with ${appName} while module exports not found
- var globalVariableExports = global[appName];
- if (validateExportLifecycle(globalVariableExports)) {
- return globalVariableExports;
- }
- throw new QiankunError("You need to export lifecycle functions in ".concat(appName, " entry"));
- }
- var prevAppUnmountedDeferred;
- function loadApp(_x3) {
- return _loadApp.apply(this, arguments);
- }
- function _loadApp() {
- _loadApp = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee17(app) {
- var _sandboxContainer, _sandboxContainer$ins;
- var configuration,
- lifeCycles,
- entry,
- appName,
- appInstanceId,
- markName,
- _configuration$singul,
- singular,
- _configuration$sandbo,
- sandbox,
- excludeAssetFilter,
- _configuration$global,
- globalContext,
- importEntryOpts,
- _yield$importEntry,
- template,
- execScripts,
- assetPublicPath,
- appContent,
- strictStyleIsolation,
- scopedCSS,
- initialAppWrapperElement,
- initialContainer,
- legacyRender,
- render,
- initialAppWrapperGetter,
- global,
- mountSandbox,
- unmountSandbox,
- useLooseSandbox,
- sandboxContainer,
- _mergeWith,
- _mergeWith$beforeUnmo,
- beforeUnmount,
- _mergeWith$afterUnmou,
- afterUnmount,
- _mergeWith$afterMount,
- afterMount,
- _mergeWith$beforeMoun,
- beforeMount,
- _mergeWith$beforeLoad,
- beforeLoad,
- scriptExports,
- _getLifecyclesFromExp,
- bootstrap,
- mount,
- unmount,
- update,
- _getMicroAppStateActi,
- onGlobalStateChange,
- setGlobalState,
- offGlobalStateChange,
- syncAppWrapperElement2Sandbox,
- parcelConfigGetter,
- _args17 = arguments;
- return regenerator.wrap(function _callee17$(_context17) {
- while (1) {
- switch (_context17.prev = _context17.next) {
- case 0:
- configuration = _args17.length > 1 && _args17[1] !== undefined ? _args17[1] : {};
- lifeCycles = _args17.length > 2 ? _args17[2] : undefined;
- entry = app.entry, appName = app.name;
- appInstanceId = genAppInstanceIdByName(appName);
- markName = "[qiankun] App ".concat(appInstanceId, " Loading");
- {
- performanceMark(markName);
- }
- _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
- _context17.next = 9;
- return importEntry(entry, importEntryOpts);
- case 9:
- _yield$importEntry = _context17.sent;
- template = _yield$importEntry.template;
- execScripts = _yield$importEntry.execScripts;
- assetPublicPath = _yield$importEntry.assetPublicPath;
- _context17.next = 15;
- return validateSingularMode(singular, app);
- case 15:
- if (!_context17.sent) {
- _context17.next = 18;
- break;
- }
- _context17.next = 18;
- return prevAppUnmountedDeferred && prevAppUnmountedDeferred.promise;
- case 18:
- appContent = getDefaultTplWrapper(appInstanceId)(template);
- strictStyleIsolation = _typeof(sandbox) === 'object' && !!sandbox.strictStyleIsolation;
- if ( strictStyleIsolation) {
- console.warn("[qiankun] strictStyleIsolation configuration will be removed in 3.0, pls don't depend on it or use experimentalStyleIsolation instead!");
- }
- scopedCSS = isEnableScopedCSS(sandbox);
- initialAppWrapperElement = createElement(appContent, strictStyleIsolation, scopedCSS, appInstanceId);
- initialContainer = 'container' in app ? app.container : undefined;
- legacyRender = 'render' in app ? app.render : undefined;
- render = getRender(appInstanceId, appContent, legacyRender); // 第一次加载设置应用可见区域 dom 结构
- // 确保每次应用加载前容器 dom 结构已经设置完毕
- render({
- element: initialAppWrapperElement,
- loading: true,
- container: initialContainer
- }, 'loading');
- initialAppWrapperGetter = getAppWrapperGetter(appInstanceId, !!legacyRender, strictStyleIsolation, scopedCSS, function () {
- return initialAppWrapperElement;
- });
- global = globalContext;
- mountSandbox = function mountSandbox() {
- return Promise.resolve();
- };
- unmountSandbox = function unmountSandbox() {
- return Promise.resolve();
- };
- useLooseSandbox = _typeof(sandbox) === 'object' && !!sandbox.loose;
- if (sandbox) {
- sandboxContainer = createSandboxContainer(appInstanceId, // FIXME should use a strict sandbox logic while remount, see https://github.com/umijs/qiankun/issues/518
- initialAppWrapperGetter, scopedCSS, useLooseSandbox, excludeAssetFilter, global); // 用沙箱的代理对象作为接下来使用的全局对象
- global = sandboxContainer.instance.proxy;
- mountSandbox = sandboxContainer.mount;
- unmountSandbox = sandboxContainer.unmount;
- }
- _mergeWith = mergeWith_1({}, getAddOns(global, assetPublicPath), lifeCycles, function (v1, v2) {
- return concat_1(v1 !== null && v1 !== void 0 ? v1 : [], v2 !== null && v2 !== void 0 ? v2 : []);
- }), _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;
- _context17.next = 36;
- return execHooksChain(toArray(beforeLoad), app, global);
- case 36:
- _context17.next = 38;
- return execScripts(global, sandbox && !useLooseSandbox);
- case 38:
- scriptExports = _context17.sent;
- _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;
- _getMicroAppStateActi = getMicroAppStateActions(appInstanceId), onGlobalStateChange = _getMicroAppStateActi.onGlobalStateChange, setGlobalState = _getMicroAppStateActi.setGlobalState, offGlobalStateChange = _getMicroAppStateActi.offGlobalStateChange; // FIXME temporary way
- syncAppWrapperElement2Sandbox = function syncAppWrapperElement2Sandbox(element) {
- return initialAppWrapperElement = element;
- };
- parcelConfigGetter = function parcelConfigGetter() {
- var remountContainer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialContainer;
- var appWrapperElement;
- var appWrapperGetter;
- var parcelConfig = {
- name: appInstanceId,
- bootstrap: bootstrap,
- mount: [/*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
- var marks;
- return regenerator.wrap(function _callee2$(_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- {
- marks = performanceGetEntriesByName(markName, 'mark'); // mark length is zero means the app is remounting
- if (marks && !marks.length) {
- performanceMark(markName);
- }
- }
- case 1:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee2);
- })), /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
- return regenerator.wrap(function _callee3$(_context3) {
- while (1) {
- switch (_context3.prev = _context3.next) {
- case 0:
- _context3.next = 2;
- return validateSingularMode(singular, app);
- case 2:
- _context3.t0 = _context3.sent;
- if (!_context3.t0) {
- _context3.next = 5;
- break;
- }
- _context3.t0 = prevAppUnmountedDeferred;
- case 5:
- if (!_context3.t0) {
- _context3.next = 7;
- break;
- }
- return _context3.abrupt("return", prevAppUnmountedDeferred.promise);
- case 7:
- return _context3.abrupt("return", undefined);
- case 8:
- case "end":
- return _context3.stop();
- }
- }
- }, _callee3);
- })),
- /*#__PURE__*/
- // initial wrapper element before app mount/remount
- _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4() {
- return regenerator.wrap(function _callee4$(_context4) {
- while (1) {
- switch (_context4.prev = _context4.next) {
- case 0:
- appWrapperElement = initialAppWrapperElement;
- appWrapperGetter = getAppWrapperGetter(appInstanceId, !!legacyRender, strictStyleIsolation, scopedCSS, function () {
- return appWrapperElement;
- });
- case 2:
- case "end":
- return _context4.stop();
- }
- }
- }, _callee4);
- })),
- /*#__PURE__*/
- // 添加 mount hook, 确保每次应用加载前容器 dom 结构已经设置完毕
- _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5() {
- var useNewContainer;
- return regenerator.wrap(function _callee5$(_context5) {
- while (1) {
- switch (_context5.prev = _context5.next) {
- case 0:
- useNewContainer = remountContainer !== initialContainer;
- if (useNewContainer || !appWrapperElement) {
- // element will be destroyed after unmounted, we need to recreate it if it not exist
- // or we try to remount into a new container
- appWrapperElement = createElement(appContent, strictStyleIsolation, scopedCSS, appInstanceId);
- syncAppWrapperElement2Sandbox(appWrapperElement);
- }
- render({
- element: appWrapperElement,
- loading: true,
- container: remountContainer
- }, 'mounting');
- case 3:
- case "end":
- return _context5.stop();
- }
- }
- }, _callee5);
- })), mountSandbox,
- /*#__PURE__*/
- // exec the chain after rendering to keep the behavior with beforeLoad
- _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee6() {
- return regenerator.wrap(function _callee6$(_context6) {
- while (1) {
- switch (_context6.prev = _context6.next) {
- case 0:
- return _context6.abrupt("return", execHooksChain(toArray(beforeMount), app, global));
- case 1:
- case "end":
- return _context6.stop();
- }
- }
- }, _callee6);
- })), /*#__PURE__*/function () {
- var _ref7 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee7(props) {
- return regenerator.wrap(function _callee7$(_context7) {
- while (1) {
- switch (_context7.prev = _context7.next) {
- case 0:
- return _context7.abrupt("return", mount(_objectSpread(_objectSpread({}, props), {}, {
- container: appWrapperGetter(),
- setGlobalState: setGlobalState,
- onGlobalStateChange: onGlobalStateChange
- })));
- case 1:
- case "end":
- return _context7.stop();
- }
- }
- }, _callee7);
- }));
- return function (_x4) {
- return _ref7.apply(this, arguments);
- };
- }(),
- /*#__PURE__*/
- // finish loading after app mounted
- _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee8() {
- return regenerator.wrap(function _callee8$(_context8) {
- while (1) {
- switch (_context8.prev = _context8.next) {
- case 0:
- return _context8.abrupt("return", render({
- element: appWrapperElement,
- loading: false,
- container: remountContainer
- }, 'mounted'));
- case 1:
- case "end":
- return _context8.stop();
- }
- }
- }, _callee8);
- })), /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9() {
- return regenerator.wrap(function _callee9$(_context9) {
- while (1) {
- switch (_context9.prev = _context9.next) {
- case 0:
- return _context9.abrupt("return", execHooksChain(toArray(afterMount), app, global));
- case 1:
- case "end":
- return _context9.stop();
- }
- }
- }, _callee9);
- })),
- /*#__PURE__*/
- // initialize the unmount defer after app mounted and resolve the defer after it unmounted
- _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee10() {
- return regenerator.wrap(function _callee10$(_context10) {
- while (1) {
- switch (_context10.prev = _context10.next) {
- case 0:
- _context10.next = 2;
- return validateSingularMode(singular, app);
- case 2:
- if (!_context10.sent) {
- _context10.next = 4;
- break;
- }
- prevAppUnmountedDeferred = new Deferred();
- case 4:
- case "end":
- return _context10.stop();
- }
- }
- }, _callee10);
- })), /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee11() {
- var measureName;
- return regenerator.wrap(function _callee11$(_context11) {
- while (1) {
- switch (_context11.prev = _context11.next) {
- case 0:
- {
- measureName = "[qiankun] App ".concat(appInstanceId, " Loading Consuming");
- performanceMeasure(measureName, markName);
- }
- case 1:
- case "end":
- return _context11.stop();
- }
- }
- }, _callee11);
- }))],
- unmount: [/*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee12() {
- return regenerator.wrap(function _callee12$(_context12) {
- while (1) {
- switch (_context12.prev = _context12.next) {
- case 0:
- return _context12.abrupt("return", execHooksChain(toArray(beforeUnmount), app, global));
- case 1:
- case "end":
- return _context12.stop();
- }
- }
- }, _callee12);
- })), /*#__PURE__*/function () {
- var _ref13 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee13(props) {
- return regenerator.wrap(function _callee13$(_context13) {
- while (1) {
- switch (_context13.prev = _context13.next) {
- case 0:
- return _context13.abrupt("return", unmount(_objectSpread(_objectSpread({}, props), {}, {
- container: appWrapperGetter()
- })));
- case 1:
- case "end":
- return _context13.stop();
- }
- }
- }, _callee13);
- }));
- return function (_x5) {
- return _ref13.apply(this, arguments);
- };
- }(), unmountSandbox, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee14() {
- return regenerator.wrap(function _callee14$(_context14) {
- while (1) {
- switch (_context14.prev = _context14.next) {
- case 0:
- return _context14.abrupt("return", execHooksChain(toArray(afterUnmount), app, global));
- case 1:
- case "end":
- return _context14.stop();
- }
- }
- }, _callee14);
- })), /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee15() {
- return regenerator.wrap(function _callee15$(_context15) {
- while (1) {
- switch (_context15.prev = _context15.next) {
- case 0:
- render({
- element: null,
- loading: false,
- container: remountContainer
- }, 'unmounted');
- offGlobalStateChange(appInstanceId); // for gc
- appWrapperElement = null;
- syncAppWrapperElement2Sandbox(appWrapperElement);
- case 4:
- case "end":
- return _context15.stop();
- }
- }
- }, _callee15);
- })), /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee16() {
- return regenerator.wrap(function _callee16$(_context16) {
- while (1) {
- switch (_context16.prev = _context16.next) {
- case 0:
- _context16.next = 2;
- return validateSingularMode(singular, app);
- case 2:
- _context16.t0 = _context16.sent;
- if (!_context16.t0) {
- _context16.next = 5;
- break;
- }
- _context16.t0 = prevAppUnmountedDeferred;
- case 5:
- if (!_context16.t0) {
- _context16.next = 7;
- break;
- }
- prevAppUnmountedDeferred.resolve();
- case 7:
- case "end":
- return _context16.stop();
- }
- }
- }, _callee16);
- }))]
- };
- if (typeof update === 'function') {
- parcelConfig.update = update;
- }
- return parcelConfig;
- };
- return _context17.abrupt("return", parcelConfigGetter);
- case 44:
- case "end":
- return _context17.stop();
- }
- }
- }, _callee17);
- }));
- return _loadApp.apply(this, arguments);
- }
- var requestIdleCallback$1 = window.requestIdleCallback || function requestIdleCallback(cb) {
- var start = Date.now();
- return setTimeout(function () {
- cb({
- didTimeout: false,
- timeRemaining: function timeRemaining() {
- return Math.max(0, 50 - (Date.now() - start));
- }
- });
- }, 1);
- };
- var isSlowNetwork = navigator.connection ? navigator.connection.saveData || navigator.connection.type !== 'wifi' && navigator.connection.type !== 'ethernet' && /([23])g/.test(navigator.connection.effectiveType) : false;
- /**
- * prefetch assets, do nothing while in mobile network
- * @param entry
- * @param opts
- */
- function prefetch(entry, opts) {
- if (!navigator.onLine || isSlowNetwork) {
- // Don't prefetch if in a slow network or offline
- return;
- }
- requestIdleCallback$1( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
- var _yield$importEntry, getExternalScripts, getExternalStyleSheets;
- return regenerator.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- _context.next = 2;
- return importEntry(entry, opts);
- case 2:
- _yield$importEntry = _context.sent;
- getExternalScripts = _yield$importEntry.getExternalScripts;
- getExternalStyleSheets = _yield$importEntry.getExternalStyleSheets;
- requestIdleCallback$1(getExternalStyleSheets);
- requestIdleCallback$1(getExternalScripts);
- case 7:
- case "end":
- return _context.stop();
- }
- }
- }, _callee);
- })));
- }
- function prefetchAfterFirstMounted(apps, opts) {
- window.addEventListener('single-spa:first-mount', function listener() {
- var notLoadedApps = apps.filter(function (app) {
- return Pt(app.name) === l;
- });
- {
- var mountedApps = Et();
- console.log("[qiankun] prefetch starting after ".concat(mountedApps, " mounted..."), notLoadedApps);
- }
- notLoadedApps.forEach(function (_ref2) {
- var entry = _ref2.entry;
- return prefetch(entry, opts);
- });
- window.removeEventListener('single-spa:first-mount', listener);
- });
- }
- function prefetchImmediately(apps, opts) {
- {
- console.log('[qiankun] prefetch starting for apps...', apps);
- }
- apps.forEach(function (_ref3) {
- var entry = _ref3.entry;
- return prefetch(entry, opts);
- });
- }
- function doPrefetchStrategy(apps, prefetchStrategy, importEntryOpts) {
- var appsName2Apps = function appsName2Apps(names) {
- return apps.filter(function (app) {
- return names.includes(app.name);
- });
- };
- if (Array.isArray(prefetchStrategy)) {
- prefetchAfterFirstMounted(appsName2Apps(prefetchStrategy), importEntryOpts);
- } else if (isFunction_1(prefetchStrategy)) {
- _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
- var _yield$prefetchStrate, _yield$prefetchStrate2, criticalAppNames, _yield$prefetchStrate3, minorAppsName;
- return regenerator.wrap(function _callee2$(_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- _context2.next = 2;
- return prefetchStrategy(apps);
- case 2:
- _yield$prefetchStrate = _context2.sent;
- _yield$prefetchStrate2 = _yield$prefetchStrate.criticalAppNames;
- criticalAppNames = _yield$prefetchStrate2 === void 0 ? [] : _yield$prefetchStrate2;
- _yield$prefetchStrate3 = _yield$prefetchStrate.minorAppsName;
- minorAppsName = _yield$prefetchStrate3 === void 0 ? [] : _yield$prefetchStrate3;
- prefetchImmediately(appsName2Apps(criticalAppNames), importEntryOpts);
- prefetchAfterFirstMounted(appsName2Apps(minorAppsName), importEntryOpts);
- case 9:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee2);
- }))();
- } else {
- switch (prefetchStrategy) {
- case true:
- prefetchAfterFirstMounted(apps, importEntryOpts);
- break;
- case 'all':
- prefetchImmediately(apps, importEntryOpts);
- break;
- }
- }
- }
- var _excluded$1 = ["name", "activeRule", "loader", "props"],
- _excluded2 = ["mount"],
- _excluded3 = ["prefetch", "sandbox", "singular", "urlRerouteOnly"];
- var microApps = [];
- var frameworkConfiguration = {};
- var started = false;
- var defaultUrlRerouteOnly = true;
- var frameworkStartedDefer = new Deferred();
- var autoDowngradeForLowVersionBrowser = function autoDowngradeForLowVersionBrowser(configuration) {
- var sandbox = configuration.sandbox,
- singular = configuration.singular;
- if (sandbox) {
- if (!window.Proxy) {
- console.warn('[qiankun] Miss window.Proxy, proxySandbox will degenerate into snapshotSandbox');
- if (singular === false) {
- console.warn('[qiankun] Setting singular as false may cause unexpected behavior while your browser not support window.Proxy');
- }
- return _objectSpread(_objectSpread({}, configuration), {}, {
- sandbox: _typeof(sandbox) === 'object' ? _objectSpread(_objectSpread({}, sandbox), {}, {
- loose: true
- }) : {
- loose: true
- }
- });
- }
- }
- return configuration;
- };
- function registerMicroApps(apps, lifeCycles) {
- // Each app only needs to be registered once
- var unregisteredApps = apps.filter(function (app) {
- return !microApps.some(function (registeredApp) {
- return registeredApp.name === app.name;
- });
- });
- microApps = [].concat(_toConsumableArray(microApps), _toConsumableArray(unregisteredApps));
- unregisteredApps.forEach(function (app) {
- var name = app.name,
- activeRule = app.activeRule,
- _app$loader = app.loader,
- loader = _app$loader === void 0 ? noop_1 : _app$loader,
- props = app.props,
- appConfig = _objectWithoutProperties(app, _excluded$1);
- Ot({
- name: name,
- app: function () {
- var _app = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
- var _yield$loadApp, mount, otherMicroAppConfigs;
- return regenerator.wrap(function _callee3$(_context3) {
- while (1) {
- switch (_context3.prev = _context3.next) {
- case 0:
- loader(true);
- _context3.next = 3;
- return frameworkStartedDefer.promise;
- case 3:
- _context3.next = 5;
- return loadApp(_objectSpread({
- name: name,
- props: props
- }, appConfig), frameworkConfiguration, lifeCycles);
- case 5:
- _context3.t0 = _context3.sent;
- _yield$loadApp = (0, _context3.t0)();
- mount = _yield$loadApp.mount;
- otherMicroAppConfigs = _objectWithoutProperties(_yield$loadApp, _excluded2);
- return _context3.abrupt("return", _objectSpread({
- mount: [/*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
- return regenerator.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- return _context.abrupt("return", loader(true));
- case 1:
- case "end":
- return _context.stop();
- }
- }
- }, _callee);
- }))].concat(_toConsumableArray(toArray(mount)), [/*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
- return regenerator.wrap(function _callee2$(_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- return _context2.abrupt("return", loader(false));
- case 1:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee2);
- }))])
- }, otherMicroAppConfigs));
- case 10:
- case "end":
- return _context3.stop();
- }
- }
- }, _callee3);
- }));
- function app() {
- return _app.apply(this, arguments);
- }
- return app;
- }(),
- activeWhen: activeRule,
- customProps: props
- });
- });
- }
- var appConfigPromiseGetterMap = new Map();
- var containerMicroAppsMap = new Map();
- function loadMicroApp(app, configuration, lifeCycles) {
- var props = app.props,
- name = app.name;
- var container = 'container' in app ? app.container : undefined; // Must compute the container xpath at beginning to keep it consist around app running
- // If we compute it every time, the container dom structure most probably been changed and result in a different xpath value
- var containerXPath = getContainerXPath(container);
- var appContainerXPathKey = "".concat(name, "-").concat(containerXPath);
- var microApp;
- var wrapParcelConfigForRemount = function wrapParcelConfigForRemount(config) {
- var microAppConfig = config;
- if (container) {
- if (containerXPath) {
- var containerMicroApps = containerMicroAppsMap.get(appContainerXPathKey);
- if (containerMicroApps === null || containerMicroApps === void 0 ? void 0 : containerMicroApps.length) {
- var mount = [/*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4() {
- var prevLoadMicroApps, prevLoadMicroAppsWhichNotBroken;
- return regenerator.wrap(function _callee4$(_context4) {
- while (1) {
- switch (_context4.prev = _context4.next) {
- case 0:
- // While there are multiple micro apps mounted on the same container, we must wait until the prev instances all had unmounted
- // Otherwise it will lead some concurrent issues
- prevLoadMicroApps = containerMicroApps.slice(0, containerMicroApps.indexOf(microApp));
- prevLoadMicroAppsWhichNotBroken = prevLoadMicroApps.filter(function (v) {
- return v.getStatus() !== 'LOAD_ERROR' && v.getStatus() !== 'SKIP_BECAUSE_BROKEN';
- });
- _context4.next = 4;
- return Promise.all(prevLoadMicroAppsWhichNotBroken.map(function (v) {
- return v.unmountPromise;
- }));
- case 4:
- case "end":
- return _context4.stop();
- }
- }
- }, _callee4);
- }))].concat(_toConsumableArray(toArray(microAppConfig.mount)));
- microAppConfig = _objectSpread(_objectSpread({}, config), {}, {
- mount: mount
- });
- }
- }
- }
- return _objectSpread(_objectSpread({}, microAppConfig), {}, {
- // empty bootstrap hook which should not run twice while it calling from cached micro app
- bootstrap: function bootstrap() {
- return Promise.resolve();
- }
- });
- };
- /**
- * using name + container xpath as the micro app instance id,
- * it means if you rendering a micro app to a dom which have been rendered before,
- * the micro app would not load and evaluate its lifecycles again
- */
- var memorizedLoadingFn = /*#__PURE__*/function () {
- var _ref4 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5() {
- var userConfiguration, $$cacheLifecycleByAppName, parcelConfigGetterPromise, _parcelConfigGetterPromise, parcelConfigObjectGetterPromise;
- return regenerator.wrap(function _callee5$(_context5) {
- while (1) {
- switch (_context5.prev = _context5.next) {
- case 0:
- userConfiguration = autoDowngradeForLowVersionBrowser(configuration !== null && configuration !== void 0 ? configuration : _objectSpread(_objectSpread({}, frameworkConfiguration), {}, {
- singular: false
- }));
- $$cacheLifecycleByAppName = userConfiguration.$$cacheLifecycleByAppName;
- if (!container) {
- _context5.next = 21;
- break;
- }
- if (!$$cacheLifecycleByAppName) {
- _context5.next = 12;
- break;
- }
- parcelConfigGetterPromise = appConfigPromiseGetterMap.get(name);
- if (!parcelConfigGetterPromise) {
- _context5.next = 12;
- break;
- }
- _context5.t0 = wrapParcelConfigForRemount;
- _context5.next = 9;
- return parcelConfigGetterPromise;
- case 9:
- _context5.t1 = _context5.sent;
- _context5.t2 = (0, _context5.t1)(container);
- return _context5.abrupt("return", (0, _context5.t0)(_context5.t2));
- case 12:
- if (!containerXPath) {
- _context5.next = 21;
- break;
- }
- _parcelConfigGetterPromise = appConfigPromiseGetterMap.get(appContainerXPathKey);
- if (!_parcelConfigGetterPromise) {
- _context5.next = 21;
- break;
- }
- _context5.t3 = wrapParcelConfigForRemount;
- _context5.next = 18;
- return _parcelConfigGetterPromise;
- case 18:
- _context5.t4 = _context5.sent;
- _context5.t5 = (0, _context5.t4)(container);
- return _context5.abrupt("return", (0, _context5.t3)(_context5.t5));
- case 21:
- parcelConfigObjectGetterPromise = loadApp(app, userConfiguration, lifeCycles);
- if (container) {
- if ($$cacheLifecycleByAppName) {
- appConfigPromiseGetterMap.set(name, parcelConfigObjectGetterPromise);
- } else if (containerXPath) appConfigPromiseGetterMap.set(appContainerXPathKey, parcelConfigObjectGetterPromise);
- }
- _context5.next = 25;
- return parcelConfigObjectGetterPromise;
- case 25:
- _context5.t6 = _context5.sent;
- return _context5.abrupt("return", (0, _context5.t6)(container));
- case 27:
- case "end":
- return _context5.stop();
- }
- }
- }, _callee5);
- }));
- return function memorizedLoadingFn() {
- return _ref4.apply(this, arguments);
- };
- }();
- if (!started && (configuration === null || configuration === void 0 ? void 0 : configuration.autoStart) !== false) {
- var _frameworkConfigurati;
- // We need to invoke start method of single-spa as the popstate event should be dispatched while the main app calling pushState/replaceState automatically,
- // but in single-spa it will check the start status before it dispatch popstate
- // see https://github.com/single-spa/single-spa/blob/f28b5963be1484583a072c8145ac0b5a28d91235/src/navigation/navigation-events.js#L101
- // ref https://github.com/umijs/qiankun/pull/1071
- xt({
- urlRerouteOnly: (_frameworkConfigurati = frameworkConfiguration.urlRerouteOnly) !== null && _frameworkConfigurati !== void 0 ? _frameworkConfigurati : defaultUrlRerouteOnly
- });
- }
- microApp = C(memorizedLoadingFn, _objectSpread({
- domElement: document.createElement('div')
- }, props));
- if (container) {
- if (containerXPath) {
- // Store the microApps which they mounted on the same container
- var microAppsRef = containerMicroAppsMap.get(appContainerXPathKey) || [];
- microAppsRef.push(microApp);
- containerMicroAppsMap.set(appContainerXPathKey, microAppsRef);
- var cleanup = function cleanup() {
- var index = microAppsRef.indexOf(microApp);
- microAppsRef.splice(index, 1); // @ts-ignore
- microApp = null;
- }; // gc after unmount
- microApp.unmountPromise.then(cleanup).catch(cleanup);
- }
- }
- return microApp;
- }
- function start() {
- var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
- frameworkConfiguration = _objectSpread({
- prefetch: true,
- singular: true,
- sandbox: true
- }, opts);
- var _frameworkConfigurati2 = frameworkConfiguration,
- prefetch = _frameworkConfigurati2.prefetch,
- sandbox = _frameworkConfigurati2.sandbox,
- singular = _frameworkConfigurati2.singular,
- _frameworkConfigurati3 = _frameworkConfigurati2.urlRerouteOnly,
- urlRerouteOnly = _frameworkConfigurati3 === void 0 ? defaultUrlRerouteOnly : _frameworkConfigurati3,
- importEntryOpts = _objectWithoutProperties(_frameworkConfigurati2, _excluded3);
- if (prefetch) {
- doPrefetchStrategy(microApps, prefetch, importEntryOpts);
- }
- frameworkConfiguration = autoDowngradeForLowVersionBrowser(frameworkConfiguration);
- xt({
- urlRerouteOnly: urlRerouteOnly
- });
- started = true;
- frameworkStartedDefer.resolve();
- }
- /**
- * @author Kuitos
- * @since 2020-02-21
- */
- function addGlobalUncaughtErrorHandler(errorHandler) {
- window.addEventListener('error', errorHandler);
- window.addEventListener('unhandledrejection', errorHandler);
- }
- function removeGlobalUncaughtErrorHandler(errorHandler) {
- window.removeEventListener('error', errorHandler);
- window.removeEventListener('unhandledrejection', errorHandler);
- }
- /**
- * @author Kuitos
- * @since 2019-02-19
- */
- var firstMountLogLabel = '[qiankun] first app mounted';
- {
- console.time(firstMountLogLabel);
- }
- function setDefaultMountApp(defaultAppLink) {
- // can not use addEventListener once option for ie support
- window.addEventListener('single-spa:no-app-change', function listener() {
- var mountedApps = Et();
- if (!mountedApps.length) {
- nt(defaultAppLink);
- }
- window.removeEventListener('single-spa:no-app-change', listener);
- });
- }
- function runDefaultMountEffects(defaultAppLink) {
- console.warn('[qiankun] runDefaultMountEffects will be removed in next version, please use setDefaultMountApp instead');
- setDefaultMountApp(defaultAppLink);
- }
- function runAfterFirstMounted(effect) {
- // can not use addEventListener once option for ie support
- window.addEventListener('single-spa:first-mount', function listener() {
- {
- console.timeEnd(firstMountLogLabel);
- }
- effect();
- window.removeEventListener('single-spa:first-mount', listener);
- });
- }
- exports.__internalGetCurrentRunningApp = getCurrentRunningApp;
- exports.addErrorHandler = a;
- exports.addGlobalUncaughtErrorHandler = addGlobalUncaughtErrorHandler;
- exports.initGlobalState = initGlobalState;
- exports.loadMicroApp = loadMicroApp;
- exports.prefetchApps = prefetchImmediately;
- exports.registerMicroApps = registerMicroApps;
- exports.removeErrorHandler = c;
- exports.removeGlobalUncaughtErrorHandler = removeGlobalUncaughtErrorHandler;
- exports.runAfterFirstMounted = runAfterFirstMounted;
- exports.runDefaultMountEffects = runDefaultMountEffects;
- exports.setDefaultMountApp = setDefaultMountApp;
- exports.start = start;
- Object.defineProperty(exports, '__esModule', { value: true });
- })));
- //# sourceMappingURL=index.umd.js.map
|