123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027 |
- /*!
- * static.js v0.2.0
- * (c) 2018-2022 mcli
- */
- (function (global, factory) {
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
- typeof define === 'function' && define.amd ? define(['exports'], factory) :
- (factory((global.mjs = {})));
- }(this, (function (exports) {
- 'use strict';
- function unwrapExports(x) {
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
- }
- function createCommonjsModule(fn, module) {
- return module = {exports: {}}, fn(module, module.exports), module.exports;
- }
- var runtime = 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.
- */
- !(function (global) {
- var Op = Object.prototype;
- var hasOwn = Op.hasOwnProperty;
- var undefined; // 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";
- var inModule = 'object' === "object";
- var runtime = global.regeneratorRuntime;
- if (runtime) {
- if (inModule) {
- // If regeneratorRuntime is defined globally and we're in a module,
- // make the exports object identical to regeneratorRuntime.
- module.exports = runtime;
- }
- // Don't bother evaluating the rest of this file if the runtime was
- // already defined globally.
- return;
- }
- // Define the runtime globally (as expected by generated code) as either
- // module.exports (if we're in a module) or a new, empty object.
- runtime = global.regeneratorRuntime = inModule ? module.exports : {};
- 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;
- }
- runtime.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 = {};
- 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 = Gp.constructor = GeneratorFunctionPrototype;
- GeneratorFunctionPrototype.constructor = GeneratorFunction;
- GeneratorFunctionPrototype[toStringTagSymbol] =
- GeneratorFunction.displayName = "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) {
- prototype[method] = function (arg) {
- return this._invoke(method, arg);
- };
- });
- }
- runtime.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;
- };
- runtime.mark = function (genFun) {
- if (Object.setPrototypeOf) {
- Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
- } else {
- genFun.__proto__ = GeneratorFunctionPrototype;
- if (!(toStringTagSymbol in genFun)) {
- 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.
- runtime.awrap = function (arg) {
- return {__await: arg};
- };
- function AsyncIterator(generator) {
- 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 Promise.resolve(value.__await).then(function (value) {
- invoke("next", value, resolve, reject);
- }, function (err) {
- invoke("throw", err, resolve, reject);
- });
- }
- return Promise.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. If the Promise is rejected, however, the
- // result for this iteration will be rejected with the same
- // reason. Note that rejections of yielded Promises are not
- // thrown back into the generator function, as is the case
- // when an awaited Promise is rejected. This difference in
- // behavior between yield and await is important, because it
- // allows the consumer to decide what to do with the yielded
- // rejection (swallow it and continue, manually .throw it back
- // into the generator, abandon iteration, whatever). With
- // await, by contrast, there is no opportunity to examine the
- // rejection reason outside the generator function, so the
- // only option is to throw it from the await expression, and
- // let the generator function handle the exception.
- result.value = unwrapped;
- resolve(result);
- }, reject);
- }
- }
- var previousPromise;
- function enqueue(method, arg) {
- function callInvokeWithMethodAndArg() {
- return new Promise(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);
- AsyncIterator.prototype[asyncIteratorSymbol] = function () {
- return this;
- };
- runtime.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.
- runtime.async = function (innerFn, outerFn, self, tryLocsList) {
- var iter = new AsyncIterator(
- wrap(innerFn, outerFn, self, tryLocsList)
- );
- return runtime.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) {
- // A .throw or .return when the delegate iterator has no .throw
- // method always terminates the yield* loop.
- context.delegate = null;
- if (context.method === "throw") {
- 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;
- 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;
- }
- } 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);
- 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.
- Gp[iteratorSymbol] = function () {
- return this;
- };
- 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);
- }
- runtime.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;
- next.done = true;
- return next;
- };
- return next.next = next;
- }
- }
- // Return an iterator with no values.
- return {next: doneResult};
- }
- runtime.values = values;
- function doneResult() {
- return {value: undefined, 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;
- this.done = false;
- this.delegate = null;
- this.method = "next";
- this.arg = undefined;
- 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;
- }
- }
- }
- },
- 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;
- }
- 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;
- }
- return ContinueSentinel;
- }
- };
- })(
- // In sloppy mode, unbound `this` refers to the global object, fallback to
- // Function constructor if we're in global strict mode. That is sadly a form
- // of indirect eval which violates Content Security Policy.
- (function () {
- return this
- })() || Function("return this")()
- );
- });
- /**
- * 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.
- */
- // This method of obtaining a reference to the global object needs to be
- // kept identical to the way it is obtained in runtime.js
- var g = (function () {
- return this
- })() || Function("return this")();
- // Use `getOwnPropertyNames` because not all browsers support calling
- // `hasOwnProperty` on the global `self` object in a worker. See #183.
- var hadRuntime = g.regeneratorRuntime &&
- Object.getOwnPropertyNames(g).indexOf("regeneratorRuntime") >= 0;
- // Save the old regeneratorRuntime in case it needs to be restored later.
- var oldRuntime = hadRuntime && g.regeneratorRuntime;
- // Force reevalutation of runtime.js.
- g.regeneratorRuntime = undefined;
- var runtimeModule = runtime;
- if (hadRuntime) {
- // Restore the original runtime.
- g.regeneratorRuntime = oldRuntime;
- } else {
- // Remove the global property added by runtime.js.
- try {
- delete g.regeneratorRuntime;
- } catch (e) {
- g.regeneratorRuntime = undefined;
- }
- }
- var regenerator = runtimeModule;
- // 7.1.4 ToInteger
- var ceil = Math.ceil;
- var floor = Math.floor;
- var _toInteger = function (it) {
- return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
- };
- // 7.2.1 RequireObjectCoercible(argument)
- var _defined = function (it) {
- if (it == undefined) throw TypeError("Can't call method on " + it);
- return it;
- };
- // true -> String#at
- // false -> String#codePointAt
- var _stringAt = function (TO_STRING) {
- return function (that, pos) {
- var s = String(_defined(that));
- var i = _toInteger(pos);
- var l = s.length;
- var a, b;
- if (i < 0 || i >= l) return TO_STRING ? '' : undefined;
- a = s.charCodeAt(i);
- return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
- ? TO_STRING ? s.charAt(i) : a
- : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
- };
- };
- var _library = true;
- var _global = createCommonjsModule(function (module) {
- // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
- var global = module.exports = typeof window != 'undefined' && window.Math == Math
- ? window : typeof self != 'undefined' && self.Math == Math ? self
- // eslint-disable-next-line no-new-func
- : Function('return this')();
- if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef
- });
- var _core = createCommonjsModule(function (module) {
- var core = module.exports = {version: '2.6.11'};
- if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef
- });
- var _core_1 = _core.version;
- var _aFunction = function (it) {
- if (typeof it != 'function') throw TypeError(it + ' is not a function!');
- return it;
- };
- // optional / simple context binding
- var _ctx = function (fn, that, length) {
- _aFunction(fn);
- if (that === undefined) return fn;
- switch (length) {
- case 1:
- return function (a) {
- return fn.call(that, a);
- };
- case 2:
- return function (a, b) {
- return fn.call(that, a, b);
- };
- case 3:
- return function (a, b, c) {
- return fn.call(that, a, b, c);
- };
- }
- return function (/* ...args */) {
- return fn.apply(that, arguments);
- };
- };
- var _isObject = function (it) {
- return typeof it === 'object' ? it !== null : typeof it === 'function';
- };
- var _anObject = function (it) {
- if (!_isObject(it)) throw TypeError(it + ' is not an object!');
- return it;
- };
- var _fails = function (exec) {
- try {
- return !!exec();
- } catch (e) {
- return true;
- }
- };
- // Thank's IE8 for his funny defineProperty
- var _descriptors = !_fails(function () {
- return Object.defineProperty({}, 'a', {
- get: function () {
- return 7;
- }
- }).a != 7;
- });
- var document$1 = _global.document;
- // typeof document.createElement is 'object' in old IE
- var is = _isObject(document$1) && _isObject(document$1.createElement);
- var _domCreate = function (it) {
- return is ? document$1.createElement(it) : {};
- };
- var _ie8DomDefine = !_descriptors && !_fails(function () {
- return Object.defineProperty(_domCreate('div'), 'a', {
- get: function () {
- return 7;
- }
- }).a != 7;
- });
- // 7.1.1 ToPrimitive(input [, PreferredType])
- // instead of the ES6 spec version, we didn't implement @@toPrimitive case
- // and the second argument - flag - preferred type is a string
- var _toPrimitive = function (it, S) {
- if (!_isObject(it)) return it;
- var fn, val;
- if (S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val;
- if (typeof (fn = it.valueOf) == 'function' && !_isObject(val = fn.call(it))) return val;
- if (!S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val;
- throw TypeError("Can't convert object to primitive value");
- };
- var dP = Object.defineProperty;
- var f = _descriptors ? Object.defineProperty : function defineProperty(O, P, Attributes) {
- _anObject(O);
- P = _toPrimitive(P, true);
- _anObject(Attributes);
- if (_ie8DomDefine) try {
- return dP(O, P, Attributes);
- } catch (e) { /* empty */
- }
- if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
- if ('value' in Attributes) O[P] = Attributes.value;
- return O;
- };
- var _objectDp = {
- f: f
- };
- var _propertyDesc = function (bitmap, value) {
- return {
- enumerable: !(bitmap & 1),
- configurable: !(bitmap & 2),
- writable: !(bitmap & 4),
- value: value
- };
- };
- var _hide = _descriptors ? function (object, key, value) {
- return _objectDp.f(object, key, _propertyDesc(1, value));
- } : function (object, key, value) {
- object[key] = value;
- return object;
- };
- var hasOwnProperty = {}.hasOwnProperty;
- var _has = function (it, key) {
- return hasOwnProperty.call(it, key);
- };
- var PROTOTYPE = 'prototype';
- var $export = function (type, name, source) {
- var IS_FORCED = type & $export.F;
- var IS_GLOBAL = type & $export.G;
- var IS_STATIC = type & $export.S;
- var IS_PROTO = type & $export.P;
- var IS_BIND = type & $export.B;
- var IS_WRAP = type & $export.W;
- var exports = IS_GLOBAL ? _core : _core[name] || (_core[name] = {});
- var expProto = exports[PROTOTYPE];
- var target = IS_GLOBAL ? _global : IS_STATIC ? _global[name] : (_global[name] || {})[PROTOTYPE];
- var key, own, out;
- if (IS_GLOBAL) source = name;
- for (key in source) {
- // contains in native
- own = !IS_FORCED && target && target[key] !== undefined;
- if (own && _has(exports, key)) continue;
- // export native or passed
- out = own ? target[key] : source[key];
- // prevent global pollution for namespaces
- exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key]
- // bind timers to global for call from export context
- : IS_BIND && own ? _ctx(out, _global)
- // wrap global constructors for prevent change them in library
- : IS_WRAP && target[key] == out ? (function (C) {
- var F = function (a, b, c) {
- if (this instanceof C) {
- switch (arguments.length) {
- case 0:
- return new C();
- case 1:
- return new C(a);
- case 2:
- return new C(a, b);
- }
- return new C(a, b, c);
- }
- return C.apply(this, arguments);
- };
- F[PROTOTYPE] = C[PROTOTYPE];
- return F;
- // make static versions for prototype methods
- })(out) : IS_PROTO && typeof out == 'function' ? _ctx(Function.call, out) : out;
- // export proto methods to core.%CONSTRUCTOR%.methods.%NAME%
- if (IS_PROTO) {
- (exports.virtual || (exports.virtual = {}))[key] = out;
- // export proto methods to core.%CONSTRUCTOR%.prototype.%NAME%
- if (type & $export.R && expProto && !expProto[key]) _hide(expProto, key, out);
- }
- }
- };
- // type bitmap
- $export.F = 1; // forced
- $export.G = 2; // global
- $export.S = 4; // static
- $export.P = 8; // proto
- $export.B = 16; // bind
- $export.W = 32; // wrap
- $export.U = 64; // safe
- $export.R = 128; // real proto method for `library`
- var _export = $export;
- var _redefine = _hide;
- var _iterators = {};
- var toString = {}.toString;
- var _cof = function (it) {
- return toString.call(it).slice(8, -1);
- };
- // fallback for non-array-like ES3 and non-enumerable old V8 strings
- // eslint-disable-next-line no-prototype-builtins
- var _iobject = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
- return _cof(it) == 'String' ? it.split('') : Object(it);
- };
- // to indexed object, toObject with fallback for non-array-like ES3 strings
- var _toIobject = function (it) {
- return _iobject(_defined(it));
- };
- // 7.1.15 ToLength
- var min = Math.min;
- var _toLength = function (it) {
- return it > 0 ? min(_toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
- };
- var max = Math.max;
- var min$1 = Math.min;
- var _toAbsoluteIndex = function (index, length) {
- index = _toInteger(index);
- return index < 0 ? max(index + length, 0) : min$1(index, length);
- };
- // false -> Array#indexOf
- // true -> Array#includes
- var _arrayIncludes = function (IS_INCLUDES) {
- return function ($this, el, fromIndex) {
- var O = _toIobject($this);
- var length = _toLength(O.length);
- var index = _toAbsoluteIndex(fromIndex, length);
- var value;
- // Array#includes uses SameValueZero equality algorithm
- // eslint-disable-next-line no-self-compare
- if (IS_INCLUDES && el != el) while (length > index) {
- value = O[index++];
- // eslint-disable-next-line no-self-compare
- if (value != value) return true;
- // Array#indexOf ignores holes, Array#includes - not
- } else for (; length > index; index++) if (IS_INCLUDES || index in O) {
- if (O[index] === el) return IS_INCLUDES || index || 0;
- }
- return !IS_INCLUDES && -1;
- };
- };
- var _shared = createCommonjsModule(function (module) {
- var SHARED = '__core-js_shared__';
- var store = _global[SHARED] || (_global[SHARED] = {});
- (module.exports = function (key, value) {
- return store[key] || (store[key] = value !== undefined ? value : {});
- })('versions', []).push({
- version: _core.version,
- mode: _library ? 'pure' : 'global',
- copyright: '© 2019 Denis Pushkarev (zloirock.ru)'
- });
- });
- var id = 0;
- var px = Math.random();
- var _uid = function (key) {
- return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
- };
- var shared = _shared('keys');
- var _sharedKey = function (key) {
- return shared[key] || (shared[key] = _uid(key));
- };
- var arrayIndexOf = _arrayIncludes(false);
- var IE_PROTO$1 = _sharedKey('IE_PROTO');
- var _objectKeysInternal = function (object, names) {
- var O = _toIobject(object);
- var i = 0;
- var result = [];
- var key;
- for (key in O) if (key != IE_PROTO$1) _has(O, key) && result.push(key);
- // Don't enum bug & hidden keys
- while (names.length > i) if (_has(O, key = names[i++])) {
- ~arrayIndexOf(result, key) || result.push(key);
- }
- return result;
- };
- // IE 8- don't enum bug keys
- var _enumBugKeys = (
- 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
- ).split(',');
- // 19.1.2.14 / 15.2.3.14 Object.keys(O)
- var _objectKeys = Object.keys || function keys(O) {
- return _objectKeysInternal(O, _enumBugKeys);
- };
- var _objectDps = _descriptors ? Object.defineProperties : function defineProperties(O, Properties) {
- _anObject(O);
- var keys = _objectKeys(Properties);
- var length = keys.length;
- var i = 0;
- var P;
- while (length > i) _objectDp.f(O, P = keys[i++], Properties[P]);
- return O;
- };
- var document$2 = _global.document;
- var _html = document$2 && document$2.documentElement;
- // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
- var IE_PROTO = _sharedKey('IE_PROTO');
- var Empty = function () { /* empty */
- };
- var PROTOTYPE$1 = 'prototype';
- // Create object with fake `null` prototype: use iframe Object with cleared prototype
- var createDict = function () {
- // Thrash, waste and sodomy: IE GC bug
- var iframe = _domCreate('iframe');
- var i = _enumBugKeys.length;
- var lt = '<';
- var gt = '>';
- var iframeDocument;
- iframe.style.display = 'none';
- _html.appendChild(iframe);
- iframe.src = 'javascript:'; // eslint-disable-line no-script-url
- // createDict = iframe.contentWindow.Object;
- // html.removeChild(iframe);
- iframeDocument = iframe.contentWindow.document;
- iframeDocument.open();
- iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
- iframeDocument.close();
- createDict = iframeDocument.F;
- while (i--) delete createDict[PROTOTYPE$1][_enumBugKeys[i]];
- return createDict();
- };
- var _objectCreate = Object.create || function create(O, Properties) {
- var result;
- if (O !== null) {
- Empty[PROTOTYPE$1] = _anObject(O);
- result = new Empty();
- Empty[PROTOTYPE$1] = null;
- // add "__proto__" for Object.getPrototypeOf polyfill
- result[IE_PROTO] = O;
- } else result = createDict();
- return Properties === undefined ? result : _objectDps(result, Properties);
- };
- var _wks = createCommonjsModule(function (module) {
- var store = _shared('wks');
- var Symbol = _global.Symbol;
- var USE_SYMBOL = typeof Symbol == 'function';
- var $exports = module.exports = function (name) {
- return store[name] || (store[name] =
- USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : _uid)('Symbol.' + name));
- };
- $exports.store = store;
- });
- var def = _objectDp.f;
- var TAG = _wks('toStringTag');
- var _setToStringTag = function (it, tag, stat) {
- if (it && !_has(it = stat ? it : it.prototype, TAG)) def(it, TAG, {configurable: true, value: tag});
- };
- var IteratorPrototype = {};
- // 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
- _hide(IteratorPrototype, _wks('iterator'), function () {
- return this;
- });
- var _iterCreate = function (Constructor, NAME, next) {
- Constructor.prototype = _objectCreate(IteratorPrototype, {next: _propertyDesc(1, next)});
- _setToStringTag(Constructor, NAME + ' Iterator');
- };
- // 7.1.13 ToObject(argument)
- var _toObject = function (it) {
- return Object(_defined(it));
- };
- // 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)
- var IE_PROTO$2 = _sharedKey('IE_PROTO');
- var ObjectProto = Object.prototype;
- var _objectGpo = Object.getPrototypeOf || function (O) {
- O = _toObject(O);
- if (_has(O, IE_PROTO$2)) return O[IE_PROTO$2];
- if (typeof O.constructor == 'function' && O instanceof O.constructor) {
- return O.constructor.prototype;
- }
- return O instanceof Object ? ObjectProto : null;
- };
- var ITERATOR = _wks('iterator');
- var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next`
- var FF_ITERATOR = '@@iterator';
- var KEYS = 'keys';
- var VALUES = 'values';
- var returnThis = function () {
- return this;
- };
- var _iterDefine = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
- _iterCreate(Constructor, NAME, next);
- var getMethod = function (kind) {
- if (!BUGGY && kind in proto) return proto[kind];
- switch (kind) {
- case KEYS:
- return function keys() {
- return new Constructor(this, kind);
- };
- case VALUES:
- return function values() {
- return new Constructor(this, kind);
- };
- }
- return function entries() {
- return new Constructor(this, kind);
- };
- };
- var TAG = NAME + ' Iterator';
- var DEF_VALUES = DEFAULT == VALUES;
- var VALUES_BUG = false;
- var proto = Base.prototype;
- var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
- var $default = $native || getMethod(DEFAULT);
- var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;
- var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;
- var methods, key, IteratorPrototype;
- // Fix native
- if ($anyNative) {
- IteratorPrototype = _objectGpo($anyNative.call(new Base()));
- if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
- // Set @@toStringTag to native iterators
- _setToStringTag(IteratorPrototype, TAG, true);
- // fix for some old engines
- if (!_library && typeof IteratorPrototype[ITERATOR] != 'function') _hide(IteratorPrototype, ITERATOR, returnThis);
- }
- }
- // fix Array#{values, @@iterator}.name in V8 / FF
- if (DEF_VALUES && $native && $native.name !== VALUES) {
- VALUES_BUG = true;
- $default = function values() {
- return $native.call(this);
- };
- }
- // Define iterator
- if ((!_library || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {
- _hide(proto, ITERATOR, $default);
- }
- // Plug for library
- _iterators[NAME] = $default;
- _iterators[TAG] = returnThis;
- if (DEFAULT) {
- methods = {
- values: DEF_VALUES ? $default : getMethod(VALUES),
- keys: IS_SET ? $default : getMethod(KEYS),
- entries: $entries
- };
- if (FORCED) for (key in methods) {
- if (!(key in proto)) _redefine(proto, key, methods[key]);
- } else _export(_export.P + _export.F * (BUGGY || VALUES_BUG), NAME, methods);
- }
- return methods;
- };
- var $at = _stringAt(true);
- // 21.1.3.27 String.prototype[@@iterator]()
- _iterDefine(String, 'String', function (iterated) {
- this._t = String(iterated); // target
- this._i = 0; // next index
- // 21.1.5.2.1 %StringIteratorPrototype%.next()
- }, function () {
- var O = this._t;
- var index = this._i;
- var point;
- if (index >= O.length) return {value: undefined, done: true};
- point = $at(O, index);
- this._i += point.length;
- return {value: point, done: false};
- });
- var _iterStep = function (done, value) {
- return {value: value, done: !!done};
- };
- // 22.1.3.4 Array.prototype.entries()
- // 22.1.3.13 Array.prototype.keys()
- // 22.1.3.29 Array.prototype.values()
- // 22.1.3.30 Array.prototype[@@iterator]()
- var es6_array_iterator = _iterDefine(Array, 'Array', function (iterated, kind) {
- this._t = _toIobject(iterated); // target
- this._i = 0; // next index
- this._k = kind; // kind
- // 22.1.5.2.1 %ArrayIteratorPrototype%.next()
- }, function () {
- var O = this._t;
- var kind = this._k;
- var index = this._i++;
- if (!O || index >= O.length) {
- this._t = undefined;
- return _iterStep(1);
- }
- if (kind == 'keys') return _iterStep(0, index);
- if (kind == 'values') return _iterStep(0, O[index]);
- return _iterStep(0, [index, O[index]]);
- }, 'values');
- // argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
- _iterators.Arguments = _iterators.Array;
- var TO_STRING_TAG = _wks('toStringTag');
- var DOMIterables = ('CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,' +
- 'DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,' +
- 'MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,' +
- 'SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,' +
- 'TextTrackList,TouchList').split(',');
- for (var i = 0; i < DOMIterables.length; i++) {
- var NAME = DOMIterables[i];
- var Collection = _global[NAME];
- var proto = Collection && Collection.prototype;
- if (proto && !proto[TO_STRING_TAG]) _hide(proto, TO_STRING_TAG, NAME);
- _iterators[NAME] = _iterators.Array;
- }
- // getting tag from 19.1.3.6 Object.prototype.toString()
- var TAG$1 = _wks('toStringTag');
- // ES3 wrong here
- var ARG = _cof(function () {
- return arguments;
- }()) == 'Arguments';
- // fallback for IE11 Script Access Denied error
- var tryGet = function (it, key) {
- try {
- return it[key];
- } catch (e) { /* empty */
- }
- };
- var _classof = function (it) {
- var O, T, B;
- return it === undefined ? 'Undefined' : it === null ? 'Null'
- // @@toStringTag case
- : typeof (T = tryGet(O = Object(it), TAG$1)) == 'string' ? T
- // builtinTag case
- : ARG ? _cof(O)
- // ES3 arguments fallback
- : (B = _cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
- };
- var _anInstance = function (it, Constructor, name, forbiddenField) {
- if (!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)) {
- throw TypeError(name + ': incorrect invocation!');
- }
- return it;
- };
- // call something on iterator step with safe closing on error
- var _iterCall = function (iterator, fn, value, entries) {
- try {
- return entries ? fn(_anObject(value)[0], value[1]) : fn(value);
- // 7.4.6 IteratorClose(iterator, completion)
- } catch (e) {
- var ret = iterator['return'];
- if (ret !== undefined) _anObject(ret.call(iterator));
- throw e;
- }
- };
- // check on default Array iterator
- var ITERATOR$1 = _wks('iterator');
- var ArrayProto = Array.prototype;
- var _isArrayIter = function (it) {
- return it !== undefined && (_iterators.Array === it || ArrayProto[ITERATOR$1] === it);
- };
- var ITERATOR$2 = _wks('iterator');
- var core_getIteratorMethod = _core.getIteratorMethod = function (it) {
- if (it != undefined) return it[ITERATOR$2]
- || it['@@iterator']
- || _iterators[_classof(it)];
- };
- var _forOf = createCommonjsModule(function (module) {
- var BREAK = {};
- var RETURN = {};
- var exports = module.exports = function (iterable, entries, fn, that, ITERATOR) {
- var iterFn = ITERATOR ? function () {
- return iterable;
- } : core_getIteratorMethod(iterable);
- var f = _ctx(fn, that, entries ? 2 : 1);
- var index = 0;
- var length, step, iterator, result;
- if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!');
- // fast case for arrays with default iterator
- if (_isArrayIter(iterFn)) for (length = _toLength(iterable.length); length > index; index++) {
- result = entries ? f(_anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
- if (result === BREAK || result === RETURN) return result;
- } else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) {
- result = _iterCall(iterator, f, step.value, entries);
- if (result === BREAK || result === RETURN) return result;
- }
- };
- exports.BREAK = BREAK;
- exports.RETURN = RETURN;
- });
- // 7.3.20 SpeciesConstructor(O, defaultConstructor)
- var SPECIES = _wks('species');
- var _speciesConstructor = function (O, D) {
- var C = _anObject(O).constructor;
- var S;
- return C === undefined || (S = _anObject(C)[SPECIES]) == undefined ? D : _aFunction(S);
- };
- // fast apply, http://jsperf.lnkit.com/fast-apply/5
- var _invoke = function (fn, args, that) {
- var un = that === undefined;
- switch (args.length) {
- case 0:
- return un ? fn()
- : fn.call(that);
- case 1:
- return un ? fn(args[0])
- : fn.call(that, args[0]);
- case 2:
- return un ? fn(args[0], args[1])
- : fn.call(that, args[0], args[1]);
- case 3:
- return un ? fn(args[0], args[1], args[2])
- : fn.call(that, args[0], args[1], args[2]);
- case 4:
- return un ? fn(args[0], args[1], args[2], args[3])
- : fn.call(that, args[0], args[1], args[2], args[3]);
- }
- return fn.apply(that, args);
- };
- var process$2 = _global.process;
- var setTask = _global.setImmediate;
- var clearTask = _global.clearImmediate;
- var MessageChannel = _global.MessageChannel;
- var Dispatch = _global.Dispatch;
- var counter = 0;
- var queue = {};
- var ONREADYSTATECHANGE = 'onreadystatechange';
- var defer;
- var channel;
- var port;
- var run = function () {
- var id = +this;
- // eslint-disable-next-line no-prototype-builtins
- if (queue.hasOwnProperty(id)) {
- var fn = queue[id];
- delete queue[id];
- fn();
- }
- };
- var listener = function (event) {
- run.call(event.data);
- };
- // Node.js 0.9+ & IE10+ has setImmediate, otherwise:
- if (!setTask || !clearTask) {
- setTask = function setImmediate(fn) {
- var args = [];
- var i = 1;
- while (arguments.length > i) args.push(arguments[i++]);
- queue[++counter] = function () {
- // eslint-disable-next-line no-new-func
- _invoke(typeof fn == 'function' ? fn : Function(fn), args);
- };
- defer(counter);
- return counter;
- };
- clearTask = function clearImmediate(id) {
- delete queue[id];
- };
- // Node.js 0.8-
- if (_cof(process$2) == 'process') {
- defer = function (id) {
- process$2.nextTick(_ctx(run, id, 1));
- };
- // Sphere (JS game engine) Dispatch API
- } else if (Dispatch && Dispatch.now) {
- defer = function (id) {
- Dispatch.now(_ctx(run, id, 1));
- };
- // Browsers with MessageChannel, includes WebWorkers
- } else if (MessageChannel) {
- channel = new MessageChannel();
- port = channel.port2;
- channel.port1.onmessage = listener;
- defer = _ctx(port.postMessage, port, 1);
- // Browsers with postMessage, skip WebWorkers
- // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
- } else if (_global.addEventListener && typeof postMessage == 'function' && !_global.importScripts) {
- defer = function (id) {
- _global.postMessage(id + '', '*');
- };
- _global.addEventListener('message', listener, false);
- // IE8-
- } else if (ONREADYSTATECHANGE in _domCreate('script')) {
- defer = function (id) {
- _html.appendChild(_domCreate('script'))[ONREADYSTATECHANGE] = function () {
- _html.removeChild(this);
- run.call(id);
- };
- };
- // Rest old browsers
- } else {
- defer = function (id) {
- setTimeout(_ctx(run, id, 1), 0);
- };
- }
- }
- var _task = {
- set: setTask,
- clear: clearTask
- };
- var macrotask = _task.set;
- var Observer = _global.MutationObserver || _global.WebKitMutationObserver;
- var process$3 = _global.process;
- var Promise$1 = _global.Promise;
- var isNode$1 = _cof(process$3) == 'process';
- var _microtask = function () {
- var head, last, notify;
- var flush = function () {
- var parent, fn;
- if (isNode$1 && (parent = process$3.domain)) parent.exit();
- while (head) {
- fn = head.fn;
- head = head.next;
- try {
- fn();
- } catch (e) {
- if (head) notify();
- else last = undefined;
- throw e;
- }
- }
- last = undefined;
- if (parent) parent.enter();
- };
- // Node.js
- if (isNode$1) {
- notify = function () {
- process$3.nextTick(flush);
- };
- // browsers with MutationObserver, except iOS Safari - https://github.com/zloirock/core-js/issues/339
- } else if (Observer && !(_global.navigator && _global.navigator.standalone)) {
- var toggle = true;
- var node = document.createTextNode('');
- new Observer(flush).observe(node, {characterData: true}); // eslint-disable-line no-new
- notify = function () {
- node.data = toggle = !toggle;
- };
- // environments with maybe non-completely correct, but existent Promise
- } else if (Promise$1 && Promise$1.resolve) {
- // Promise.resolve without an argument throws an error in LG WebOS 2
- var promise = Promise$1.resolve(undefined);
- notify = function () {
- promise.then(flush);
- };
- // for other environments - macrotask based on:
- // - setImmediate
- // - MessageChannel
- // - window.postMessag
- // - onreadystatechange
- // - setTimeout
- } else {
- notify = function () {
- // strange IE + webpack dev service bug - use .call(global)
- macrotask.call(_global, flush);
- };
- }
- return function (fn) {
- var task = {fn: fn, next: undefined};
- if (last) last.next = task;
- if (!head) {
- head = task;
- notify();
- }
- last = task;
- };
- };
- // 25.4.1.5 NewPromiseCapability(C)
- function PromiseCapability(C) {
- var resolve, reject;
- this.promise = new C(function ($$resolve, $$reject) {
- if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');
- resolve = $$resolve;
- reject = $$reject;
- });
- this.resolve = _aFunction(resolve);
- this.reject = _aFunction(reject);
- }
- var f$1 = function (C) {
- return new PromiseCapability(C);
- };
- var _newPromiseCapability = {
- f: f$1
- };
- var _perform = function (exec) {
- try {
- return {e: false, v: exec()};
- } catch (e) {
- return {e: true, v: e};
- }
- };
- var navigator$1 = _global.navigator;
- var _userAgent = navigator$1 && navigator$1.userAgent || '';
- var _promiseResolve = function (C, x) {
- _anObject(C);
- if (_isObject(x) && x.constructor === C) return x;
- var promiseCapability = _newPromiseCapability.f(C);
- var resolve = promiseCapability.resolve;
- resolve(x);
- return promiseCapability.promise;
- };
- var _redefineAll = function (target, src, safe) {
- for (var key in src) {
- if (safe && target[key]) target[key] = src[key];
- else _hide(target, key, src[key]);
- }
- return target;
- };
- var SPECIES$1 = _wks('species');
- var _setSpecies = function (KEY) {
- var C = typeof _core[KEY] == 'function' ? _core[KEY] : _global[KEY];
- if (_descriptors && C && !C[SPECIES$1]) _objectDp.f(C, SPECIES$1, {
- configurable: true,
- get: function () {
- return this;
- }
- });
- };
- var ITERATOR$3 = _wks('iterator');
- var SAFE_CLOSING = false;
- try {
- var riter = [7][ITERATOR$3]();
- riter['return'] = function () {
- SAFE_CLOSING = true;
- };
- // eslint-disable-next-line no-throw-literal
- } catch (e) { /* empty */
- }
- var _iterDetect = function (exec, skipClosing) {
- if (!skipClosing && !SAFE_CLOSING) return false;
- var safe = false;
- try {
- var arr = [7];
- var iter = arr[ITERATOR$3]();
- iter.next = function () {
- return {done: safe = true};
- };
- arr[ITERATOR$3] = function () {
- return iter;
- };
- exec(arr);
- } catch (e) { /* empty */
- }
- return safe;
- };
- var task = _task.set;
- var microtask = _microtask();
- var PROMISE = 'Promise';
- var TypeError$1 = _global.TypeError;
- var process$1 = _global.process;
- var versions = process$1 && process$1.versions;
- var v8 = versions && versions.v8 || '';
- var $Promise = _global[PROMISE];
- var isNode = _classof(process$1) == 'process';
- var empty = function () { /* empty */
- };
- var Internal;
- var newGenericPromiseCapability;
- var OwnPromiseCapability;
- var Wrapper;
- var newPromiseCapability = newGenericPromiseCapability = _newPromiseCapability.f;
- var USE_NATIVE = !!function () {
- try {
- // correct subclassing with @@species support
- var promise = $Promise.resolve(1);
- var FakePromise = (promise.constructor = {})[_wks('species')] = function (exec) {
- exec(empty, empty);
- };
- // unhandled rejections tracking support, NodeJS Promise without it fails @@species test
- return (isNode || typeof PromiseRejectionEvent == 'function')
- && promise.then(empty) instanceof FakePromise
- // v8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
- // https://bugs.chromium.org/p/chromium/issues/detail?id=830565
- // we can't detect it synchronously, so just check versions
- && v8.indexOf('6.6') !== 0
- && _userAgent.indexOf('Chrome/66') === -1;
- } catch (e) { /* empty */
- }
- }();
- // helpers
- var isThenable = function (it) {
- var then;
- return _isObject(it) && typeof (then = it.then) == 'function' ? then : false;
- };
- var notify = function (promise, isReject) {
- if (promise._n) return;
- promise._n = true;
- var chain = promise._c;
- microtask(function () {
- var value = promise._v;
- var ok = promise._s == 1;
- var i = 0;
- var run = function (reaction) {
- var handler = ok ? reaction.ok : reaction.fail;
- var resolve = reaction.resolve;
- var reject = reaction.reject;
- var domain = reaction.domain;
- var result, then, exited;
- try {
- if (handler) {
- if (!ok) {
- if (promise._h == 2) onHandleUnhandled(promise);
- promise._h = 1;
- }
- if (handler === true) result = value;
- else {
- if (domain) domain.enter();
- result = handler(value); // may throw
- if (domain) {
- domain.exit();
- exited = true;
- }
- }
- if (result === reaction.promise) {
- reject(TypeError$1('Promise-chain cycle'));
- } else if (then = isThenable(result)) {
- then.call(result, resolve, reject);
- } else resolve(result);
- } else reject(value);
- } catch (e) {
- if (domain && !exited) domain.exit();
- reject(e);
- }
- };
- while (chain.length > i) run(chain[i++]); // variable length - can't use forEach
- promise._c = [];
- promise._n = false;
- if (isReject && !promise._h) onUnhandled(promise);
- });
- };
- var onUnhandled = function (promise) {
- task.call(_global, function () {
- var value = promise._v;
- var unhandled = isUnhandled(promise);
- var result, handler, console;
- if (unhandled) {
- result = _perform(function () {
- if (isNode) {
- process$1.emit('unhandledRejection', value, promise);
- } else if (handler = _global.onunhandledrejection) {
- handler({promise: promise, reason: value});
- } else if ((console = _global.console) && console.error) {
- console.error('Unhandled promise rejection', value);
- }
- });
- // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
- promise._h = isNode || isUnhandled(promise) ? 2 : 1;
- }
- promise._a = undefined;
- if (unhandled && result.e) throw result.v;
- });
- };
- var isUnhandled = function (promise) {
- return promise._h !== 1 && (promise._a || promise._c).length === 0;
- };
- var onHandleUnhandled = function (promise) {
- task.call(_global, function () {
- var handler;
- if (isNode) {
- process$1.emit('rejectionHandled', promise);
- } else if (handler = _global.onrejectionhandled) {
- handler({promise: promise, reason: promise._v});
- }
- });
- };
- var $reject = function (value) {
- var promise = this;
- if (promise._d) return;
- promise._d = true;
- promise = promise._w || promise; // unwrap
- promise._v = value;
- promise._s = 2;
- if (!promise._a) promise._a = promise._c.slice();
- notify(promise, true);
- };
- var $resolve = function (value) {
- var promise = this;
- var then;
- if (promise._d) return;
- promise._d = true;
- promise = promise._w || promise; // unwrap
- try {
- if (promise === value) throw TypeError$1("Promise can't be resolved itself");
- if (then = isThenable(value)) {
- microtask(function () {
- var wrapper = {_w: promise, _d: false}; // wrap
- try {
- then.call(value, _ctx($resolve, wrapper, 1), _ctx($reject, wrapper, 1));
- } catch (e) {
- $reject.call(wrapper, e);
- }
- });
- } else {
- promise._v = value;
- promise._s = 1;
- notify(promise, false);
- }
- } catch (e) {
- $reject.call({_w: promise, _d: false}, e); // wrap
- }
- };
- // constructor polyfill
- if (!USE_NATIVE) {
- // 25.4.3.1 Promise(executor)
- $Promise = function Promise(executor) {
- _anInstance(this, $Promise, PROMISE, '_h');
- _aFunction(executor);
- Internal.call(this);
- try {
- executor(_ctx($resolve, this, 1), _ctx($reject, this, 1));
- } catch (err) {
- $reject.call(this, err);
- }
- };
- // eslint-disable-next-line no-unused-vars
- Internal = function Promise(executor) {
- this._c = []; // <- awaiting reactions
- this._a = undefined; // <- checked in isUnhandled reactions
- this._s = 0; // <- state
- this._d = false; // <- done
- this._v = undefined; // <- value
- this._h = 0; // <- rejection state, 0 - default, 1 - handled, 2 - unhandled
- this._n = false; // <- notify
- };
- Internal.prototype = _redefineAll($Promise.prototype, {
- // 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected)
- then: function then(onFulfilled, onRejected) {
- var reaction = newPromiseCapability(_speciesConstructor(this, $Promise));
- reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
- reaction.fail = typeof onRejected == 'function' && onRejected;
- reaction.domain = isNode ? process$1.domain : undefined;
- this._c.push(reaction);
- if (this._a) this._a.push(reaction);
- if (this._s) notify(this, false);
- return reaction.promise;
- },
- // 25.4.5.1 Promise.prototype.catch(onRejected)
- 'catch': function (onRejected) {
- return this.then(undefined, onRejected);
- }
- });
- OwnPromiseCapability = function () {
- var promise = new Internal();
- this.promise = promise;
- this.resolve = _ctx($resolve, promise, 1);
- this.reject = _ctx($reject, promise, 1);
- };
- _newPromiseCapability.f = newPromiseCapability = function (C) {
- return C === $Promise || C === Wrapper
- ? new OwnPromiseCapability(C)
- : newGenericPromiseCapability(C);
- };
- }
- _export(_export.G + _export.W + _export.F * !USE_NATIVE, {Promise: $Promise});
- _setToStringTag($Promise, PROMISE);
- _setSpecies(PROMISE);
- Wrapper = _core[PROMISE];
- // statics
- _export(_export.S + _export.F * !USE_NATIVE, PROMISE, {
- // 25.4.4.5 Promise.reject(r)
- reject: function reject(r) {
- var capability = newPromiseCapability(this);
- var $$reject = capability.reject;
- $$reject(r);
- return capability.promise;
- }
- });
- _export(_export.S + _export.F * (_library || !USE_NATIVE), PROMISE, {
- // 25.4.4.6 Promise.resolve(x)
- resolve: function resolve(x) {
- return _promiseResolve(_library && this === Wrapper ? $Promise : this, x);
- }
- });
- _export(_export.S + _export.F * !(USE_NATIVE && _iterDetect(function (iter) {
- $Promise.all(iter)['catch'](empty);
- })), PROMISE, {
- // 25.4.4.1 Promise.all(iterable)
- all: function all(iterable) {
- var C = this;
- var capability = newPromiseCapability(C);
- var resolve = capability.resolve;
- var reject = capability.reject;
- var result = _perform(function () {
- var values = [];
- var index = 0;
- var remaining = 1;
- _forOf(iterable, false, function (promise) {
- var $index = index++;
- var alreadyCalled = false;
- values.push(undefined);
- remaining++;
- C.resolve(promise).then(function (value) {
- if (alreadyCalled) return;
- alreadyCalled = true;
- values[$index] = value;
- --remaining || resolve(values);
- }, reject);
- });
- --remaining || resolve(values);
- });
- if (result.e) reject(result.v);
- return capability.promise;
- },
- // 25.4.4.4 Promise.race(iterable)
- race: function race(iterable) {
- var C = this;
- var capability = newPromiseCapability(C);
- var reject = capability.reject;
- var result = _perform(function () {
- _forOf(iterable, false, function (promise) {
- C.resolve(promise).then(capability.resolve, reject);
- });
- });
- if (result.e) reject(result.v);
- return capability.promise;
- }
- });
- _export(_export.P + _export.R, 'Promise', {
- 'finally': function (onFinally) {
- var C = _speciesConstructor(this, _core.Promise || _global.Promise);
- var isFunction = typeof onFinally == 'function';
- return this.then(
- isFunction ? function (x) {
- return _promiseResolve(C, onFinally()).then(function () {
- return x;
- });
- } : onFinally,
- isFunction ? function (e) {
- return _promiseResolve(C, onFinally()).then(function () {
- throw e;
- });
- } : onFinally
- );
- }
- });
- // https://github.com/tc39/proposal-promise-try
- _export(_export.S, 'Promise', {
- 'try': function (callbackfn) {
- var promiseCapability = _newPromiseCapability.f(this);
- var result = _perform(callbackfn);
- (result.e ? promiseCapability.reject : promiseCapability.resolve)(result.v);
- return promiseCapability.promise;
- }
- });
- var promise$1 = _core.Promise;
- var promise = createCommonjsModule(function (module) {
- module.exports = {"default": promise$1, __esModule: true};
- });
- var _Promise = unwrapExports(promise);
- var asyncToGenerator = createCommonjsModule(function (module, exports) {
- exports.__esModule = true;
- var _promise2 = _interopRequireDefault(promise);
- function _interopRequireDefault(obj) {
- return obj && obj.__esModule ? obj : {default: obj};
- }
- exports.default = function (fn) {
- return function () {
- var gen = fn.apply(this, arguments);
- return new _promise2.default(function (resolve, reject) {
- function step(key, arg) {
- try {
- var info = gen[key](arg);
- var value = info.value;
- } catch (error) {
- reject(error);
- return;
- }
- if (info.done) {
- resolve(value);
- } else {
- return _promise2.default.resolve(value).then(function (value) {
- step("next", value);
- }, function (err) {
- step("throw", err);
- });
- }
- }
- return step("next");
- });
- };
- };
- });
- var _asyncToGenerator = unwrapExports(asyncToGenerator);
- // import vConsole from "vconsole";
- // todo 动态加载vconsole
- function loadVConsole(isLoad) {
- // if (isLoad) new vConsole()
- }
- var auth = {};
- /** @授权成功后挂载API */
- auth.requestLib = function () {
- return new _Promise(function (resolve, reject) {
- var appType = pageConfig.appType || pageConfig.appKey;
- setTimeout(function () {
- var resp = {
- success: true,
- code: 200,
- message: "请求成功",
- msg: "success",
- data: {
- appType: appType,
- desc: "产品授权"
- }
- };
- resolve(resp);
- // const msg = `static load failure. ♨ 访问应用: ${resp.data.appType} ${resp.message} ©️ 版权请请联系: https://www.aliwork.com/o/mc`;
- // reject(msg);
- }, 750);
- });
- };
- /** @打开钉钉名片 */
- auth.contactNoDing = function (noDing) {
- window.open("dingtalk://dingtalkclient/action/sendmsg?dingtalk_id=" + noDing, // 燕江钉钉号
- "_self");
- };
- /** @钉钉名片牧语 */
- auth.contactUs = function () {
- window.open("dingtalk://dingtalkclient/action/sendmsg?dingtalk_id=yanjiangboy", // 燕江钉钉号
- "_self");
- };
- /** @钉钉商务名片 */
- auth.contactBusiness = function () {
- window.open("dingtalk://dingtalkclient/action/sendmsg?dingtalk_id=ipoduvc", // 曹龙英钉钉号
- "_self");
- };
- var com = {};
- // 页面环境: 0提交(其它),1查看,2编辑(审批)
- com.checkEnv = function () {
- var instanceData = mjs.$this.utils.getFormInstanceData();
- var _instanceData$flowDat = instanceData.flowData,
- flowData = _instanceData$flowDat === undefined ? {} : _instanceData$flowDat;
- var editMode = flowData.editMode,
- viewMode = flowData.viewMode;
- if (editMode) return 2; // 审批页面为2, 编辑状态
- if (viewMode) return 1;
- return 0;
- };
- // 冗余Toast提示方法
- com.showMessage = function (title) {
- var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "success";
- var size = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "medium";
- var duration = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "750";
- if (!title) return;
- mjs.$this.utils.toast({type: type, title: title, size: size, duration: duration});
- };
- // type: 'success', 'warning', 'error', 'notice', 'help', 'loading'
- com.showErrorMessage = function (title) {
- this.showMessage(title, "error");
- };
- // size: large, medium
- com.showSuccessMessage = function (title) {
- this.showMessage(title);
- };
- // 冗余显示全屏loading: 全局对象
- var G_DIALOG = void 0;
- com.showLoading = function () {
- var title = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "拼命加载中...";
- if (G_DIALOG) return; // 避免多次闪屏
- G_DIALOG = mjs.$this.utils.toast({
- type: "loading",
- title: title,
- closeable: false,
- footer: false,
- messageProps: {type: "loading"}
- });
- };
- // 冗余隐藏全屏loading: 全局对象
- com.hideLoading = function () {
- G_DIALOG && G_DIALOG();
- G_DIALOG = null;
- };
- // 弹出确认框
- com.showConfirm = function (title, content) {
- var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "confirm";
- if (!title && !content) {
- throw new Error(type + " => The title and content are empty.");
- }
- return new _Promise(function (resolve, reject) {
- mjs.$this.utils.dialog({
- type: type, title: title, content: content, /* 如需换行可传入 HTML/JSX 来实现 */
- onOk: function onOk() {
- return resolve();
- },
- onCancel: function onCancel() {
- return reject("用户取消了");
- }
- });
- });
- };
- // 获取当前地址的表单实例ID
- com.getFormInstIdByUrl = function () {
- if (mjs.$this) {
- // 智障的设计:流程从管理页面进入是 formInstId ,流程提交完成是 procInsId
- var query = mjs.$this.utils.router.getQuery();
- return query.procInsId || query.formInstId;
- }
- var url = window.location.href;
- if (url.includes("procInsId=")) {
- return url.split("procInsId=")[1].split("&")[0];
- }
- return url.split("formInstId=")[1].split("&")[0];
- };
- // const dom = {};
- // // 异常打印和评论按钮: 兼容BUG, 平台设置不生效
- // dom.removeMobInvalid = function (that) {
- // const doms = document.querySelectorAll(".flow-operation-button");
- // doms.forEach((ele) => {
- // if (["评论", "打印"].includes(ele.textContent)) ele.remove();
- // });
- // };
- // // 设置iframe组件, 并且加载;链接
- // dom.iframeLoadFullScreen = function (that, { compId, link, bottom = 44 }) {
- // document.getElementById(`frame_${compId}`).style.height =
- // window.screen.height - bottom + "px";
- // that.$(compId).set("src", link);
- // };
- // // 去除tab间距样式调整
- // dom.removeLayoutSpace = function (that) {
- // const doms = document.querySelectorAll(".next-tabs-content");
- // doms.forEach((elem) => elem.remove());
- // };
- // import ding from "../vendor/dingApi";
- // import bus from "../com.mcli.mcli.utils/bus";
- // // 审批页面: button事件的3种绑定方式以及触发逻辑:https://www.cnblogs.com/ooo0/p/7742214.html
- // dom.closeCurrentTabForApprove = function (that) {
- // if (zTool.env != 2) return;
- // // 关闭页面: 延迟体验
- // function closeTab (title) {
- // // 特别说明:在审批情况下,若实现了DOM_CALLBACK_APPROVE,将关闭决定移交
- // if (bus.DOM_CALLBACK_APPROVE) {
- // bus.DOM_CALLBACK_APPROVE(that, title);
- // return;
- // }
- // ding.closeNavigationForDomEvent(that);
- // }
- // // PC端
- // let doms = document.querySelectorAll(".next-btn.next-medium"); // 使用getElementsByClassName拿不到dom实体
- // if (doms.length) {
- // // 读取弹出框按钮: 延迟体验
- // const listenerDialog = function (title) {
- // setTimeout(() => {
- // const doms = document.querySelectorAll(".next-btn.next-small"); // 多个使用不需要添加空格
- // doms.forEach((ele) => {
- // if ("确认" == ele.innerText) {
- // ele.onclick = function () {
- // closeTab(title);
- // };
- // }
- // });
- // }, 200);
- // };
- // doms.forEach((ele) => {
- // // 目前退回为加签逻辑 ==> 退回页面环境为编辑态值2
- // if (["同意", "拒绝", "退回", "转交", "提交"].includes(ele.innerText)) {
- // ele.onclick = function () {
- // listenerDialog(ele.innerText);
- // };
- // }
- // });
- // return;
- // }
- // // 移动端
- // doms = document.querySelectorAll(".flow-operation-button");
- // // 读取弹出框按钮: 延迟体验
- // const listenerDialog = function (title) {
- // setTimeout(() => {
- // let doms = document.querySelectorAll(".t-button"); // 其它
- // if (!doms.length) doms = document.querySelectorAll(".mt-button"); // 退回
- // doms.forEach((ele) => {
- // if (["提交", "确认退回"] == ele.innerText) {
- // ele.onclick = function () {
- // closeTab(title);
- // };
- // }
- // });
- // }, 200);
- // };
- // doms.forEach((ele) => {
- // // 目前退回为加签逻辑 ==> 退回页面环境为编辑态值2
- // if (["同意", "拒绝", "退回", "转交", "提交"].includes(ele.innerText)) {
- // ele.onclick = function () {
- // listenerDialog(ele.innerText);
- // };
- // }
- // });
- // };
- // // 提交页面: button事件的3种绑定方式以及触发逻辑:https://www.cnblogs.com/ooo0/p/7742214.html
- // dom.closeCurrentTabForSubmit = function (that) {
- // // 退回再提交走审批事件, 目前退回为加签逻辑 ==> 退回页面环境为编辑态值2
- // if (static.env) return;
- // function closeTab () {
- // // 执行顺序: onclick > addEventListener > beforeSubmit
- // // 特别说明:在提交情况下,页面存在beforeSubmit,相关的逻辑在beforeSubmit下要手动调用,因为这里是直接触发若是有判断情况下决定权交给beforeSubmit处理
- // if (that.beforeSubmit) return;
- // // 异步不会等待
- // dom.closeTabCompatibilityBeforeSubmit(that);
- // }
- // // PC端 & 移动端
- // let doms = document.querySelectorAll(".deep-form-submit");
- // if (!doms.length) return
- // doms[0].addEventListener("click", closeTab, false);
- // };
- // // 兼容 beforeSubmit 情况下, 异步且在按钮事件之后的问题 执行顺序: onclick > addEventListener > beforeSubmit
- // dom.closeTabCompatibilityBeforeSubmit = function (that) {
- // bus.DOM_CALLBACK_SUBMIT(that);
- // // 关闭页面: 延迟体验
- // ding.closeNavigationForDomEvent(that);
- // };
- // export default dom;
- var dom = {
- // 隐藏tab空白
- removeTabLayoutContainer: function removeTabLayoutContainer() {
- var elemP = document.querySelectorAll(".next-tabs-content")[0];
- if (elemP) elemP.remove();
- },
- // 自定义页面全屏: pc
- removeSpaceForCustomPage: function removeSpaceForCustomPage() {
- var page = document.getElementsByClassName("vc-rootcontent");
- if (page.length) {
- page[0].style.margin = "0px";
- page[0].className = "";
- }
- }
- };
- // 公共配置 //
- /** mjava path: 开发dev, 生产prod, 测试test */
- var api = "";
- /** 设置为不超时 */
- var timeout = 0;
- /** 授权 */
- var token = "";
- /** 宜搭分页上限*/
- var pageSize = 100;
- /** 宜搭明细数据上限 */
- var detailCount = 500;
- /** 宜搭数据查询上限 */
- var upperLimit = 30000;
- /** 导出配置信息 */
- var config = {
- api: api,
- timeout: timeout,
- token: token,
- pageSize: pageSize,
- detailCount: detailCount,
- upperLimit: upperLimit
- };
- var f$2 = Object.getOwnPropertySymbols;
- var _objectGops = {
- f: f$2
- };
- var f$3 = {}.propertyIsEnumerable;
- var _objectPie = {
- f: f$3
- };
- // 19.1.2.1 Object.assign(target, source, ...)
- var $assign = Object.assign;
- // should work with symbols and should have deterministic property order (V8 bug)
- var _objectAssign = !$assign || _fails(function () {
- var A = {};
- var B = {};
- // eslint-disable-next-line no-undef
- var S = Symbol();
- var K = 'abcdefghijklmnopqrst';
- A[S] = 7;
- K.split('').forEach(function (k) {
- B[k] = k;
- });
- return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
- }) ? function assign(target, source) { // eslint-disable-line no-unused-vars
- var T = _toObject(target);
- var aLen = arguments.length;
- var index = 1;
- var getSymbols = _objectGops.f;
- var isEnum = _objectPie.f;
- while (aLen > index) {
- var S = _iobject(arguments[index++]);
- var keys = getSymbols ? _objectKeys(S).concat(getSymbols(S)) : _objectKeys(S);
- var length = keys.length;
- var j = 0;
- var key;
- while (length > j) {
- key = keys[j++];
- if (!_descriptors || isEnum.call(S, key)) T[key] = S[key];
- }
- }
- return T;
- } : $assign;
- // 19.1.3.1 Object.assign(target, source)
- _export(_export.S + _export.F, 'Object', {assign: _objectAssign});
- var assign$2 = _core.Object.assign;
- var assign = createCommonjsModule(function (module) {
- module.exports = {"default": assign$2, __esModule: true};
- });
- unwrapExports(assign);
- var _extends = createCommonjsModule(function (module, exports) {
- exports.__esModule = true;
- var _assign2 = _interopRequireDefault(assign);
- function _interopRequireDefault(obj) {
- return obj && obj.__esModule ? obj : {default: obj};
- }
- exports.default = _assign2.default || function (target) {
- for (var i = 1; i < arguments.length; i++) {
- var source = arguments[i];
- for (var key in source) {
- if (Object.prototype.hasOwnProperty.call(source, key)) {
- target[key] = source[key];
- }
- }
- }
- return target;
- };
- });
- var _extends$1 = unwrapExports(_extends);
- // 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes)
- _export(_export.S + _export.F * !_descriptors, 'Object', {defineProperty: _objectDp.f});
- var $Object = _core.Object;
- var defineProperty$3 = function defineProperty(it, key, desc) {
- return $Object.defineProperty(it, key, desc);
- };
- var defineProperty$1 = createCommonjsModule(function (module) {
- module.exports = {"default": defineProperty$3, __esModule: true};
- });
- unwrapExports(defineProperty$1);
- var defineProperty = createCommonjsModule(function (module, exports) {
- exports.__esModule = true;
- var _defineProperty2 = _interopRequireDefault(defineProperty$1);
- function _interopRequireDefault(obj) {
- return obj && obj.__esModule ? obj : {default: obj};
- }
- exports.default = function (obj, key, value) {
- if (key in obj) {
- (0, _defineProperty2.default)(obj, key, {
- value: value,
- enumerable: true,
- configurable: true,
- writable: true
- });
- } else {
- obj[key] = value;
- }
- return obj;
- };
- });
- var _defineProperty = unwrapExports(defineProperty);
- // most Object methods by ES6 should accept primitives
- var _objectSap = function (KEY, exec) {
- var fn = (_core.Object || {})[KEY] || Object[KEY];
- var exp = {};
- exp[KEY] = exec(fn);
- _export(_export.S + _export.F * _fails(function () {
- fn(1);
- }), 'Object', exp);
- };
- // 19.1.2.14 Object.keys(O)
- _objectSap('keys', function () {
- return function keys(it) {
- return _objectKeys(_toObject(it));
- };
- });
- var keys$1 = _core.Object.keys;
- var keys = createCommonjsModule(function (module) {
- module.exports = {"default": keys$1, __esModule: true};
- });
- var _Object$keys = unwrapExports(keys);
- var bind = function bind(fn, thisArg) {
- return function wrap() {
- var args = new Array(arguments.length);
- for (var i = 0; i < args.length; i++) {
- args[i] = arguments[i];
- }
- return fn.apply(thisArg, args);
- };
- };
- /*global toString:true*/
- // com.mcli.mcli.utils is a library of generic helper functions non-specific to axios
- var toString$1 = Object.prototype.toString;
- /**
- * Determine if a value is an Array
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is an Array, otherwise false
- */
- function isArray(val) {
- return toString$1.call(val) === '[object Array]';
- }
- /**
- * Determine if a value is undefined
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if the value is undefined, otherwise false
- */
- function isUndefined(val) {
- return typeof val === 'undefined';
- }
- /**
- * Determine if a value is a Buffer
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a Buffer, otherwise false
- */
- function isBuffer(val) {
- return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
- && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
- }
- /**
- * Determine if a value is an ArrayBuffer
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is an ArrayBuffer, otherwise false
- */
- function isArrayBuffer(val) {
- return toString$1.call(val) === '[object ArrayBuffer]';
- }
- /**
- * Determine if a value is a FormData
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is an FormData, otherwise false
- */
- function isFormData(val) {
- return (typeof FormData !== 'undefined') && (val instanceof FormData);
- }
- /**
- * Determine if a value is a view on an ArrayBuffer
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
- */
- function isArrayBufferView(val) {
- var result;
- if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
- result = ArrayBuffer.isView(val);
- } else {
- result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
- }
- return result;
- }
- /**
- * Determine if a value is a String
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a String, otherwise false
- */
- function isString(val) {
- return typeof val === 'string';
- }
- /**
- * Determine if a value is a Number
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a Number, otherwise false
- */
- function isNumber(val) {
- return typeof val === 'number';
- }
- /**
- * Determine if a value is an Object
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is an Object, otherwise false
- */
- function isObject$1(val) {
- return val !== null && typeof val === 'object';
- }
- /**
- * Determine if a value is a Date
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a Date, otherwise false
- */
- function isDate(val) {
- return toString$1.call(val) === '[object Date]';
- }
- /**
- * Determine if a value is a File
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a File, otherwise false
- */
- function isFile(val) {
- return toString$1.call(val) === '[object File]';
- }
- /**
- * Determine if a value is a Blob
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a Blob, otherwise false
- */
- function isBlob(val) {
- return toString$1.call(val) === '[object Blob]';
- }
- /**
- * Determine if a value is a Function
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a Function, otherwise false
- */
- function isFunction(val) {
- return toString$1.call(val) === '[object Function]';
- }
- /**
- * Determine if a value is a Stream
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a Stream, otherwise false
- */
- function isStream(val) {
- return isObject$1(val) && isFunction(val.pipe);
- }
- /**
- * Determine if a value is a URLSearchParams object
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a URLSearchParams object, otherwise false
- */
- function isURLSearchParams(val) {
- return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
- }
- /**
- * Trim excess whitespace off the beginning and end of a string
- *
- * @param {String} str The String to trim
- * @returns {String} The String freed of excess whitespace
- */
- function trim(str) {
- return str.replace(/^\s*/, '').replace(/\s*$/, '');
- }
- /**
- * Determine if we're running in a standard browser environment
- *
- * This allows axios to run in a web worker, and react-native.
- * Both environments support XMLHttpRequest, but not fully standard globals.
- *
- * web workers:
- * typeof window -> undefined
- * typeof document -> undefined
- *
- * react-native:
- * navigator.product -> 'ReactNative'
- * nativescript
- * navigator.product -> 'NativeScript' or 'NS'
- */
- function isStandardBrowserEnv() {
- if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
- navigator.product === 'NativeScript' ||
- navigator.product === 'NS')) {
- return false;
- }
- return (
- typeof window !== 'undefined' &&
- typeof document !== 'undefined'
- );
- }
- /**
- * Iterate over an Array or an Object invoking a function for each item.
- *
- * If `obj` is an Array callback will be called passing
- * the value, index, and complete array for each item.
- *
- * If 'obj' is an Object callback will be called passing
- * the value, key, and complete object for each property.
- *
- * @param {Object|Array} obj The object to iterate
- * @param {Function} fn The callback to invoke for each item
- */
- function forEach(obj, fn) {
- // Don't bother if no value provided
- if (obj === null || typeof obj === 'undefined') {
- return;
- }
- // Force an array if not already something iterable
- if (typeof obj !== 'object') {
- /*eslint no-param-reassign:0*/
- obj = [obj];
- }
- if (isArray(obj)) {
- // Iterate over array values
- for (var i = 0, l = obj.length; i < l; i++) {
- fn.call(null, obj[i], i, obj);
- }
- } else {
- // Iterate over object keys
- for (var key in obj) {
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
- fn.call(null, obj[key], key, obj);
- }
- }
- }
- }
- /**
- * Accepts varargs expecting each argument to be an object, then
- * immutably merges the properties of each object and returns result.
- *
- * When multiple objects contain the same key the later object in
- * the arguments list will take precedence.
- *
- * Example:
- *
- * ```js
- * var result = merge({foo: 123}, {foo: 456});
- * console.log(result.foo); // outputs 456
- * ```
- *
- * @param {Object} obj1 Object to merge
- * @returns {Object} Result of all merge properties
- */
- function merge(/* obj1, obj2, obj3, ... */) {
- var result = {};
- function assignValue(val, key) {
- if (typeof result[key] === 'object' && typeof val === 'object') {
- result[key] = merge(result[key], val);
- } else {
- result[key] = val;
- }
- }
- for (var i = 0, l = arguments.length; i < l; i++) {
- forEach(arguments[i], assignValue);
- }
- return result;
- }
- /**
- * Function equal to merge with the difference being that no reference
- * to original objects is kept.
- *
- * @see merge
- * @param {Object} obj1 Object to merge
- * @returns {Object} Result of all merge properties
- */
- function deepMerge(/* obj1, obj2, obj3, ... */) {
- var result = {};
- function assignValue(val, key) {
- if (typeof result[key] === 'object' && typeof val === 'object') {
- result[key] = deepMerge(result[key], val);
- } else if (typeof val === 'object') {
- result[key] = deepMerge({}, val);
- } else {
- result[key] = val;
- }
- }
- for (var i = 0, l = arguments.length; i < l; i++) {
- forEach(arguments[i], assignValue);
- }
- return result;
- }
- /**
- * Extends object a by mutably adding to it the properties of object b.
- *
- * @param {Object} a The object to be extended
- * @param {Object} b The object to copy properties from
- * @param {Object} thisArg The object to bind function to
- * @return {Object} The resulting value of object a
- */
- function extend(a, b, thisArg) {
- forEach(b, function assignValue(val, key) {
- if (thisArg && typeof val === 'function') {
- a[key] = bind(val, thisArg);
- } else {
- a[key] = val;
- }
- });
- return a;
- }
- var utils = {
- isArray: isArray,
- isArrayBuffer: isArrayBuffer,
- isBuffer: isBuffer,
- isFormData: isFormData,
- isArrayBufferView: isArrayBufferView,
- isString: isString,
- isNumber: isNumber,
- isObject: isObject$1,
- isUndefined: isUndefined,
- isDate: isDate,
- isFile: isFile,
- isBlob: isBlob,
- isFunction: isFunction,
- isStream: isStream,
- isURLSearchParams: isURLSearchParams,
- isStandardBrowserEnv: isStandardBrowserEnv,
- forEach: forEach,
- merge: merge,
- deepMerge: deepMerge,
- extend: extend,
- trim: trim
- };
- function encode(val) {
- return encodeURIComponent(val).replace(/%40/gi, '@').replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, '+').replace(/%5B/gi, '[').replace(/%5D/gi, ']');
- }
- /**
- * Build a URL by appending params to the end
- *
- * @param {string} url The base of the url (e.g., http://www.google.com)
- * @param {object} [params] The params to be appended
- * @returns {string} The formatted url
- */
- var buildURL = function buildURL(url, params, paramsSerializer) {
- /*eslint no-param-reassign:0*/
- if (!params) {
- return url;
- }
- var serializedParams;
- if (paramsSerializer) {
- serializedParams = paramsSerializer(params);
- } else if (utils.isURLSearchParams(params)) {
- serializedParams = params.toString();
- } else {
- var parts = [];
- utils.forEach(params, function serialize(val, key) {
- if (val === null || typeof val === 'undefined') {
- return;
- }
- if (utils.isArray(val)) {
- key = key + '[]';
- } else {
- val = [val];
- }
- utils.forEach(val, function parseValue(v) {
- if (utils.isDate(v)) {
- v = v.toISOString();
- } else if (utils.isObject(v)) {
- v = JSON.stringify(v);
- }
- parts.push(encode(key) + '=' + encode(v));
- });
- });
- serializedParams = parts.join('&');
- }
- if (serializedParams) {
- var hashmarkIndex = url.indexOf('#');
- if (hashmarkIndex !== -1) {
- url = url.slice(0, hashmarkIndex);
- }
- url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
- }
- return url;
- };
- function InterceptorManager() {
- this.handlers = [];
- }
- /**
- * Add a new interceptor to the stack
- *
- * @param {Function} fulfilled The function to handle `then` for a `Promise`
- * @param {Function} rejected The function to handle `reject` for a `Promise`
- *
- * @return {Number} An ID used to remove interceptor later
- */
- InterceptorManager.prototype.use = function use(fulfilled, rejected) {
- this.handlers.push({
- fulfilled: fulfilled,
- rejected: rejected
- });
- return this.handlers.length - 1;
- };
- /**
- * Remove an interceptor from the stack
- *
- * @param {Number} id The ID that was returned by `use`
- */
- InterceptorManager.prototype.eject = function eject(id) {
- if (this.handlers[id]) {
- this.handlers[id] = null;
- }
- };
- /**
- * Iterate over all the registered interceptors
- *
- * This method is particularly useful for skipping over any
- * interceptors that may have become `null` calling `eject`.
- *
- * @param {Function} fn The function to call for each interceptor
- */
- InterceptorManager.prototype.forEach = function forEach(fn) {
- utils.forEach(this.handlers, function forEachHandler(h) {
- if (h !== null) {
- fn(h);
- }
- });
- };
- var InterceptorManager_1 = InterceptorManager;
- /**
- * Transform the data for a request or a response
- *
- * @param {Object|String} data The data to be transformed
- * @param {Array} headers The headers for the request or response
- * @param {Array|Function} fns A single function or Array of functions
- * @returns {*} The resulting transformed data
- */
- var transformData = function transformData(data, headers, fns) {
- /*eslint no-param-reassign:0*/
- utils.forEach(fns, function transform(fn) {
- data = fn(data, headers);
- });
- return data;
- };
- var isCancel = function isCancel(value) {
- return !!(value && value.__CANCEL__);
- };
- var normalizeHeaderName = function normalizeHeaderName(headers, normalizedName) {
- utils.forEach(headers, function processHeader(value, name) {
- if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
- headers[normalizedName] = value;
- delete headers[name];
- }
- });
- };
- /**
- * Update an Error with the specified config, error code, and response.
- *
- * @param {Error} error The error to update.
- * @param {Object} config The config.
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
- * @param {Object} [request] The request.
- * @param {Object} [response] The response.
- * @returns {Error} The error.
- */
- var enhanceError = function enhanceError(error, config, code, request, response) {
- error.config = config;
- if (code) {
- error.code = code;
- }
- error.request = request;
- error.response = response;
- error.isAxiosError = true;
- error.toJSON = function () {
- return {
- // Standard
- message: this.message,
- name: this.name,
- // Microsoft
- description: this.description,
- number: this.number,
- // Mozilla
- fileName: this.fileName,
- lineNumber: this.lineNumber,
- columnNumber: this.columnNumber,
- stack: this.stack,
- // Axios
- config: this.config,
- code: this.code
- };
- };
- return error;
- };
- /**
- * Create an Error with the specified message, config, error code, request and response.
- *
- * @param {string} message The error message.
- * @param {Object} config The config.
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
- * @param {Object} [request] The request.
- * @param {Object} [response] The response.
- * @returns {Error} The created error.
- */
- var createError = function createError(message, config, code, request, response) {
- var error = new Error(message);
- return enhanceError(error, config, code, request, response);
- };
- /**
- * Resolve or reject a Promise based on response status.
- *
- * @param {Function} resolve A function that resolves the promise.
- * @param {Function} reject A function that rejects the promise.
- * @param {object} response The response.
- */
- var settle = function settle(resolve, reject, response) {
- var validateStatus = response.config.validateStatus;
- if (!validateStatus || validateStatus(response.status)) {
- resolve(response);
- } else {
- reject(createError(
- 'Request failed with status code ' + response.status,
- response.config,
- null,
- response.request,
- response
- ));
- }
- };
- /**
- * Determines whether the specified URL is absolute
- *
- * @param {string} url The URL to test
- * @returns {boolean} True if the specified URL is absolute, otherwise false
- */
- var isAbsoluteURL = function isAbsoluteURL(url) {
- // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
- // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
- // by any combination of letters, digits, plus, period, or hyphen.
- return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
- };
- /**
- * Creates a new URL by combining the specified URLs
- *
- * @param {string} baseURL The base URL
- * @param {string} relativeURL The relative URL
- * @returns {string} The combined URL
- */
- var combineURLs = function combineURLs(baseURL, relativeURL) {
- return relativeURL
- ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
- : baseURL;
- };
- /**
- * Creates a new URL by combining the baseURL with the requestedURL,
- * only when the requestedURL is not already an absolute URL.
- * If the requestURL is absolute, this function returns the requestedURL untouched.
- *
- * @param {string} baseURL The base URL
- * @param {string} requestedURL Absolute or relative URL to combine
- * @returns {string} The combined full path
- */
- var buildFullPath = function buildFullPath(baseURL, requestedURL) {
- if (baseURL && !isAbsoluteURL(requestedURL)) {
- return combineURLs(baseURL, requestedURL);
- }
- return requestedURL;
- };
- // Headers whose duplicates are ignored by node
- // c.f. https://nodejs.org/api/http.html#http_message_headers
- var ignoreDuplicateOf = [
- 'age', 'authorization', 'content-length', 'content-type', 'etag',
- 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
- 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
- 'referer', 'retry-after', 'user-agent'
- ];
- /**
- * Parse headers into an object
- *
- * ```
- * Date: Wed, 27 Aug 2014 08:58:49 GMT
- * Content-Type: application/json
- * Connection: keep-alive
- * Transfer-Encoding: chunked
- * ```
- *
- * @param {String} headers Headers needing to be parsed
- * @returns {Object} Headers parsed into an object
- */
- var parseHeaders = function parseHeaders(headers) {
- var parsed = {};
- var key;
- var val;
- var i;
- if (!headers) {
- return parsed;
- }
- utils.forEach(headers.split('\n'), function parser(line) {
- i = line.indexOf(':');
- key = utils.trim(line.substr(0, i)).toLowerCase();
- val = utils.trim(line.substr(i + 1));
- if (key) {
- if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
- return;
- }
- if (key === 'set-cookie') {
- parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
- } else {
- parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
- }
- }
- });
- return parsed;
- };
- var isURLSameOrigin = (
- utils.isStandardBrowserEnv() ?
- // Standard browser envs have full support of the APIs needed to test
- // whether the request URL is of the same origin as current location.
- (function standardBrowserEnv() {
- var msie = /(msie|trident)/i.test(navigator.userAgent);
- var urlParsingNode = document.createElement('a');
- var originURL;
- /**
- * Parse a URL to discover it's components
- *
- * @param {String} url The URL to be parsed
- * @returns {Object}
- */
- function resolveURL(url) {
- var href = url;
- if (msie) {
- // IE needs attribute set twice to normalize properties
- urlParsingNode.setAttribute('href', href);
- href = urlParsingNode.href;
- }
- urlParsingNode.setAttribute('href', href);
- // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
- return {
- href: urlParsingNode.href,
- protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
- host: urlParsingNode.host,
- search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
- hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
- hostname: urlParsingNode.hostname,
- port: urlParsingNode.port,
- pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
- urlParsingNode.pathname :
- '/' + urlParsingNode.pathname
- };
- }
- originURL = resolveURL(window.location.href);
- /**
- * Determine if a URL shares the same origin as the current location
- *
- * @param {String} requestURL The URL to test
- * @returns {boolean} True if URL shares the same origin, otherwise false
- */
- return function isURLSameOrigin(requestURL) {
- var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
- return (parsed.protocol === originURL.protocol &&
- parsed.host === originURL.host);
- };
- })() :
- // Non standard browser envs (web workers, react-native) lack needed support.
- (function nonStandardBrowserEnv() {
- return function isURLSameOrigin() {
- return true;
- };
- })()
- );
- var cookies = (
- utils.isStandardBrowserEnv() ?
- // Standard browser envs support document.cookie
- (function standardBrowserEnv() {
- return {
- write: function write(name, value, expires, path, domain, secure) {
- var cookie = [];
- cookie.push(name + '=' + encodeURIComponent(value));
- if (utils.isNumber(expires)) {
- cookie.push('expires=' + new Date(expires).toGMTString());
- }
- if (utils.isString(path)) {
- cookie.push('path=' + path);
- }
- if (utils.isString(domain)) {
- cookie.push('domain=' + domain);
- }
- if (secure === true) {
- cookie.push('secure');
- }
- document.cookie = cookie.join('; ');
- },
- read: function read(name) {
- var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
- return (match ? decodeURIComponent(match[3]) : null);
- },
- remove: function remove(name) {
- this.write(name, '', Date.now() - 86400000);
- }
- };
- })() :
- // Non standard browser env (web workers, react-native) lack needed support.
- (function nonStandardBrowserEnv() {
- return {
- write: function write() {
- },
- read: function read() {
- return null;
- },
- remove: function remove() {
- }
- };
- })()
- );
- var xhr$1 = function xhrAdapter(config) {
- return new Promise(function dispatchXhrRequest(resolve, reject) {
- var requestData = config.data;
- var requestHeaders = config.headers;
- if (utils.isFormData(requestData)) {
- delete requestHeaders['Content-Type']; // Let the browser set it
- }
- var request = new XMLHttpRequest();
- // HTTP basic authentication
- if (config.auth) {
- var username = config.auth.username || '';
- var password = config.auth.password || '';
- requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
- }
- var fullPath = buildFullPath(config.baseURL, config.url);
- request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
- // Set the request timeout in MS
- request.timeout = config.timeout;
- // Listen for ready state
- request.onreadystatechange = function handleLoad() {
- if (!request || request.readyState !== 4) {
- return;
- }
- // The request errored out and we didn't get a response, this will be
- // handled by onerror instead
- // With one exception: request that using file: protocol, most browsers
- // will return status as 0 even though it's a successful request
- if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
- return;
- }
- // Prepare the response
- var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
- var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
- var response = {
- data: responseData,
- status: request.status,
- statusText: request.statusText,
- headers: responseHeaders,
- config: config,
- request: request
- };
- settle(resolve, reject, response);
- // Clean up request
- request = null;
- };
- // Handle browser request cancellation (as opposed to a manual cancellation)
- request.onabort = function handleAbort() {
- if (!request) {
- return;
- }
- reject(createError('Request aborted', config, 'ECONNABORTED', request));
- // Clean up request
- request = null;
- };
- // Handle low level network errors
- request.onerror = function handleError() {
- // Real errors are hidden from us by the browser
- // onerror should only fire if it's a network error
- reject(createError('Network Error', config, null, request));
- // Clean up request
- request = null;
- };
- // Handle timeout
- request.ontimeout = function handleTimeout() {
- var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
- if (config.timeoutErrorMessage) {
- timeoutErrorMessage = config.timeoutErrorMessage;
- }
- reject(createError(timeoutErrorMessage, config, 'ECONNABORTED',
- request));
- // Clean up request
- request = null;
- };
- // Add xsrf header
- // This is only done if running in a standard browser environment.
- // Specifically not if we're in a web worker, or react-native.
- if (utils.isStandardBrowserEnv()) {
- var cookies$$1 = cookies;
- // Add xsrf header
- var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
- cookies$$1.read(config.xsrfCookieName) :
- undefined;
- if (xsrfValue) {
- requestHeaders[config.xsrfHeaderName] = xsrfValue;
- }
- }
- // Add headers to the request
- if ('setRequestHeader' in request) {
- utils.forEach(requestHeaders, function setRequestHeader(val, key) {
- if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
- // Remove Content-Type if data is undefined
- delete requestHeaders[key];
- } else {
- // Otherwise add header to the request
- request.setRequestHeader(key, val);
- }
- });
- }
- // Add withCredentials to request if needed
- if (!utils.isUndefined(config.withCredentials)) {
- request.withCredentials = !!config.withCredentials;
- }
- // Add responseType to request if needed
- if (config.responseType) {
- try {
- request.responseType = config.responseType;
- } catch (e) {
- // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.
- // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.
- if (config.responseType !== 'json') {
- throw e;
- }
- }
- }
- // Handle progress if needed
- if (typeof config.onDownloadProgress === 'function') {
- request.addEventListener('progress', config.onDownloadProgress);
- }
- // Not all browsers support upload events
- if (typeof config.onUploadProgress === 'function' && request.upload) {
- request.upload.addEventListener('progress', config.onUploadProgress);
- }
- if (config.cancelToken) {
- // Handle cancellation
- config.cancelToken.promise.then(function onCanceled(cancel) {
- if (!request) {
- return;
- }
- request.abort();
- reject(cancel);
- // Clean up request
- request = null;
- });
- }
- if (requestData === undefined) {
- requestData = null;
- }
- // Send the request
- request.send(requestData);
- });
- };
- var DEFAULT_CONTENT_TYPE = {
- 'Content-Type': 'application/x-www-form-urlencoded'
- };
- function setContentTypeIfUnset(headers, value) {
- if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
- headers['Content-Type'] = value;
- }
- }
- function getDefaultAdapter() {
- var adapter;
- if (typeof XMLHttpRequest !== 'undefined') {
- // For browsers use XHR adapter
- adapter = xhr$1;
- } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
- // For node use HTTP adapter
- adapter = xhr$1;
- }
- return adapter;
- }
- var defaults = {
- adapter: getDefaultAdapter(),
- transformRequest: [function transformRequest(data, headers) {
- normalizeHeaderName(headers, 'Accept');
- normalizeHeaderName(headers, 'Content-Type');
- if (utils.isFormData(data) ||
- utils.isArrayBuffer(data) ||
- utils.isBuffer(data) ||
- utils.isStream(data) ||
- utils.isFile(data) ||
- utils.isBlob(data)
- ) {
- return data;
- }
- if (utils.isArrayBufferView(data)) {
- return data.buffer;
- }
- if (utils.isURLSearchParams(data)) {
- setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
- return data.toString();
- }
- if (utils.isObject(data)) {
- setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
- return JSON.stringify(data);
- }
- return data;
- }],
- transformResponse: [function transformResponse(data) {
- /*eslint no-param-reassign:0*/
- if (typeof data === 'string') {
- try {
- data = JSON.parse(data);
- } catch (e) { /* Ignore */
- }
- }
- return data;
- }],
- /**
- * A timeout in milliseconds to abort a request. If set to 0 (default) a
- * timeout is not created.
- */
- timeout: 0,
- xsrfCookieName: 'XSRF-TOKEN',
- xsrfHeaderName: 'X-XSRF-TOKEN',
- maxContentLength: -1,
- validateStatus: function validateStatus(status) {
- return status >= 200 && status < 300;
- }
- };
- defaults.headers = {
- common: {
- 'Accept': 'application/json, text/plain, */*'
- }
- };
- utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
- defaults.headers[method] = {};
- });
- utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
- defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
- });
- var defaults_1 = defaults;
- /**
- * Throws a `Cancel` if cancellation has been requested.
- */
- function throwIfCancellationRequested(config) {
- if (config.cancelToken) {
- config.cancelToken.throwIfRequested();
- }
- }
- /**
- * Dispatch a request to the service using the configured adapter.
- *
- * @param {object} config The config that is to be used for the request
- * @returns {Promise} The Promise to be fulfilled
- */
- var dispatchRequest = function dispatchRequest(config) {
- throwIfCancellationRequested(config);
- // Ensure headers exist
- config.headers = config.headers || {};
- // Transform request data
- config.data = transformData(
- config.data,
- config.headers,
- config.transformRequest
- );
- // Flatten headers
- config.headers = utils.merge(
- config.headers.common || {},
- config.headers[config.method] || {},
- config.headers
- );
- utils.forEach(
- ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
- function cleanHeaderConfig(method) {
- delete config.headers[method];
- }
- );
- var adapter = config.adapter || defaults_1.adapter;
- return adapter(config).then(function onAdapterResolution(response) {
- throwIfCancellationRequested(config);
- // Transform response data
- response.data = transformData(
- response.data,
- response.headers,
- config.transformResponse
- );
- return response;
- }, function onAdapterRejection(reason) {
- if (!isCancel(reason)) {
- throwIfCancellationRequested(config);
- // Transform response data
- if (reason && reason.response) {
- reason.response.data = transformData(
- reason.response.data,
- reason.response.headers,
- config.transformResponse
- );
- }
- }
- return Promise.reject(reason);
- });
- };
- /**
- * Config-specific merge-function which creates a new config-object
- * by merging two configuration objects together.
- *
- * @param {Object} config1
- * @param {Object} config2
- * @returns {Object} New object resulting from merging config2 to config1
- */
- var mergeConfig = function mergeConfig(config1, config2) {
- // eslint-disable-next-line no-param-reassign
- config2 = config2 || {};
- var config = {};
- var valueFromConfig2Keys = ['url', 'method', 'params', 'data'];
- var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy'];
- var defaultToConfig2Keys = [
- 'baseURL', 'url', 'transformRequest', 'transformResponse', 'paramsSerializer',
- 'timeout', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
- 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress',
- 'maxContentLength', 'validateStatus', 'maxRedirects', 'httpAgent',
- 'httpsAgent', 'cancelToken', 'socketPath'
- ];
- utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
- if (typeof config2[prop] !== 'undefined') {
- config[prop] = config2[prop];
- }
- });
- utils.forEach(mergeDeepPropertiesKeys, function mergeDeepProperties(prop) {
- if (utils.isObject(config2[prop])) {
- config[prop] = utils.deepMerge(config1[prop], config2[prop]);
- } else if (typeof config2[prop] !== 'undefined') {
- config[prop] = config2[prop];
- } else if (utils.isObject(config1[prop])) {
- config[prop] = utils.deepMerge(config1[prop]);
- } else if (typeof config1[prop] !== 'undefined') {
- config[prop] = config1[prop];
- }
- });
- utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
- if (typeof config2[prop] !== 'undefined') {
- config[prop] = config2[prop];
- } else if (typeof config1[prop] !== 'undefined') {
- config[prop] = config1[prop];
- }
- });
- var axiosKeys = valueFromConfig2Keys
- .concat(mergeDeepPropertiesKeys)
- .concat(defaultToConfig2Keys);
- var otherKeys = Object
- .keys(config2)
- .filter(function filterAxiosKeys(key) {
- return axiosKeys.indexOf(key) === -1;
- });
- utils.forEach(otherKeys, function otherKeysDefaultToConfig2(prop) {
- if (typeof config2[prop] !== 'undefined') {
- config[prop] = config2[prop];
- } else if (typeof config1[prop] !== 'undefined') {
- config[prop] = config1[prop];
- }
- });
- return config;
- };
- /**
- * Create a new instance of Axios
- *
- * @param {Object} instanceConfig The default config for the instance
- */
- function Axios(instanceConfig) {
- this.defaults = instanceConfig;
- this.interceptors = {
- request: new InterceptorManager_1(),
- response: new InterceptorManager_1()
- };
- }
- /**
- * Dispatch a request
- *
- * @param {Object} config The config specific for this request (merged with this.defaults)
- */
- Axios.prototype.request = function request(config) {
- /*eslint no-param-reassign:0*/
- // Allow for axios('example/url'[, config]) a la fetch API
- if (typeof config === 'string') {
- config = arguments[1] || {};
- config.url = arguments[0];
- } else {
- config = config || {};
- }
- config = mergeConfig(this.defaults, config);
- // Set config.method
- if (config.method) {
- config.method = config.method.toLowerCase();
- } else if (this.defaults.method) {
- config.method = this.defaults.method.toLowerCase();
- } else {
- config.method = 'get';
- }
- // Hook up interceptors middleware
- var chain = [dispatchRequest, undefined];
- var promise = Promise.resolve(config);
- this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
- chain.unshift(interceptor.fulfilled, interceptor.rejected);
- });
- this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
- chain.push(interceptor.fulfilled, interceptor.rejected);
- });
- while (chain.length) {
- promise = promise.then(chain.shift(), chain.shift());
- }
- return promise;
- };
- Axios.prototype.getUri = function getUri(config) {
- config = mergeConfig(this.defaults, config);
- return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
- };
- // Provide aliases for supported request methods
- utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
- /*eslint func-names:0*/
- Axios.prototype[method] = function (url, config) {
- return this.request(utils.merge(config || {}, {
- method: method,
- url: url
- }));
- };
- });
- utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
- /*eslint func-names:0*/
- Axios.prototype[method] = function (url, data, config) {
- return this.request(utils.merge(config || {}, {
- method: method,
- url: url,
- data: data
- }));
- };
- });
- var Axios_1 = Axios;
- /**
- * A `Cancel` is an object that is thrown when an operation is canceled.
- *
- * @class
- * @param {string=} message The message.
- */
- function Cancel(message) {
- this.message = message;
- }
- Cancel.prototype.toString = function toString() {
- return 'Cancel' + (this.message ? ': ' + this.message : '');
- };
- Cancel.prototype.__CANCEL__ = true;
- var Cancel_1 = Cancel;
- /**
- * A `CancelToken` is an object that can be used to request cancellation of an operation.
- *
- * @class
- * @param {Function} executor The executor function.
- */
- function CancelToken(executor) {
- if (typeof executor !== 'function') {
- throw new TypeError('executor must be a function.');
- }
- var resolvePromise;
- this.promise = new Promise(function promiseExecutor(resolve) {
- resolvePromise = resolve;
- });
- var token = this;
- executor(function cancel(message) {
- if (token.reason) {
- // Cancellation has already been requested
- return;
- }
- token.reason = new Cancel_1(message);
- resolvePromise(token.reason);
- });
- }
- /**
- * Throws a `Cancel` if cancellation has been requested.
- */
- CancelToken.prototype.throwIfRequested = function throwIfRequested() {
- if (this.reason) {
- throw this.reason;
- }
- };
- /**
- * Returns an object that contains a new `CancelToken` and a function that, when called,
- * cancels the `CancelToken`.
- */
- CancelToken.source = function source() {
- var cancel;
- var token = new CancelToken(function executor(c) {
- cancel = c;
- });
- return {
- token: token,
- cancel: cancel
- };
- };
- var CancelToken_1 = CancelToken;
- /**
- * Syntactic sugar for invoking a function and expanding an array for arguments.
- *
- * Common use case would be to use `Function.prototype.apply`.
- *
- * ```js
- * function f(x, y, z) {}
- * var args = [1, 2, 3];
- * f.apply(null, args);
- * ```
- *
- * With `spread` this example can be re-written.
- *
- * ```js
- * spread(function(x, y, z) {})([1, 2, 3]);
- * ```
- *
- * @param {Function} callback
- * @returns {Function}
- */
- var spread = function spread(callback) {
- return function wrap(arr) {
- return callback.apply(null, arr);
- };
- };
- /**
- * Create an instance of Axios
- *
- * @param {Object} defaultConfig The default config for the instance
- * @return {Axios} A new instance of Axios
- */
- function createInstance(defaultConfig) {
- var context = new Axios_1(defaultConfig);
- var instance = bind(Axios_1.prototype.request, context);
- // Copy axios.prototype to instance
- utils.extend(instance, Axios_1.prototype, context);
- // Copy context to instance
- utils.extend(instance, context);
- return instance;
- }
- // Create the default instance to be exported
- var axios$2 = createInstance(defaults_1);
- // Expose Axios class to allow class inheritance
- axios$2.Axios = Axios_1;
- // Factory for creating new instances
- axios$2.create = function create(instanceConfig) {
- return createInstance(mergeConfig(axios$2.defaults, instanceConfig));
- };
- // Expose Cancel & CancelToken
- axios$2.Cancel = Cancel_1;
- axios$2.CancelToken = CancelToken_1;
- axios$2.isCancel = isCancel;
- // Expose all/spread
- axios$2.all = function all(promises) {
- return Promise.all(promises);
- };
- axios$2.spread = spread;
- var axios_1 = axios$2;
- // Allow use of default import syntax in TypeScript
- var default_1 = axios$2;
- axios_1.default = default_1;
- var axios = axios_1;
- var has$2 = Object.prototype.hasOwnProperty;
- var isArray$2 = Array.isArray;
- var hexTable = (function () {
- var array = [];
- for (var i = 0; i < 256; ++i) {
- array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());
- }
- return array;
- }());
- var compactQueue = function compactQueue(queue) {
- while (queue.length > 1) {
- var item = queue.pop();
- var obj = item.obj[item.prop];
- if (isArray$2(obj)) {
- var compacted = [];
- for (var j = 0; j < obj.length; ++j) {
- if (typeof obj[j] !== 'undefined') {
- compacted.push(obj[j]);
- }
- }
- item.obj[item.prop] = compacted;
- }
- }
- };
- var arrayToObject = function arrayToObject(source, options) {
- var obj = options && options.plainObjects ? Object.create(null) : {};
- for (var i = 0; i < source.length; ++i) {
- if (typeof source[i] !== 'undefined') {
- obj[i] = source[i];
- }
- }
- return obj;
- };
- var merge$1 = function merge(target, source, options) {
- /* eslint no-param-reassign: 0 */
- if (!source) {
- return target;
- }
- if (typeof source !== 'object') {
- if (isArray$2(target)) {
- target.push(source);
- } else if (target && typeof target === 'object') {
- if ((options && (options.plainObjects || options.allowPrototypes)) || !has$2.call(Object.prototype, source)) {
- target[source] = true;
- }
- } else {
- return [target, source];
- }
- return target;
- }
- if (!target || typeof target !== 'object') {
- return [target].concat(source);
- }
- var mergeTarget = target;
- if (isArray$2(target) && !isArray$2(source)) {
- mergeTarget = arrayToObject(target, options);
- }
- if (isArray$2(target) && isArray$2(source)) {
- source.forEach(function (item, i) {
- if (has$2.call(target, i)) {
- var targetItem = target[i];
- if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
- target[i] = merge(targetItem, item, options);
- } else {
- target.push(item);
- }
- } else {
- target[i] = item;
- }
- });
- return target;
- }
- return Object.keys(source).reduce(function (acc, key) {
- var value = source[key];
- if (has$2.call(acc, key)) {
- acc[key] = merge(acc[key], value, options);
- } else {
- acc[key] = value;
- }
- return acc;
- }, mergeTarget);
- };
- var assign$4 = function assignSingleSource(target, source) {
- return Object.keys(source).reduce(function (acc, key) {
- acc[key] = source[key];
- return acc;
- }, target);
- };
- var decode = function (str, decoder, charset) {
- var strWithoutPlus = str.replace(/\+/g, ' ');
- if (charset === 'iso-8859-1') {
- // unescape never throws, no try...catch needed:
- return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);
- }
- // utf-8
- try {
- return decodeURIComponent(strWithoutPlus);
- } catch (e) {
- return strWithoutPlus;
- }
- };
- var encode$1 = function encode(str, defaultEncoder, charset) {
- // This code was originally written by Brian White (mscdex) for the io.js core querystring library.
- // It has been adapted here for stricter adherence to RFC 3986
- if (str.length === 0) {
- return str;
- }
- var string = str;
- if (typeof str === 'symbol') {
- string = Symbol.prototype.toString.call(str);
- } else if (typeof str !== 'string') {
- string = String(str);
- }
- if (charset === 'iso-8859-1') {
- return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) {
- return '%26%23' + parseInt($0.slice(2), 16) + '%3B';
- });
- }
- var out = '';
- for (var i = 0; i < string.length; ++i) {
- var c = string.charCodeAt(i);
- if (
- c === 0x2D // -
- || c === 0x2E // .
- || c === 0x5F // _
- || c === 0x7E // ~
- || (c >= 0x30 && c <= 0x39) // 0-9
- || (c >= 0x41 && c <= 0x5A) // a-z
- || (c >= 0x61 && c <= 0x7A) // A-Z
- ) {
- out += string.charAt(i);
- continue;
- }
- if (c < 0x80) {
- out = out + hexTable[c];
- continue;
- }
- if (c < 0x800) {
- out = out + (hexTable[0xC0 | (c >> 6)] + hexTable[0x80 | (c & 0x3F)]);
- continue;
- }
- if (c < 0xD800 || c >= 0xE000) {
- out = out + (hexTable[0xE0 | (c >> 12)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]);
- continue;
- }
- i += 1;
- c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF));
- out += hexTable[0xF0 | (c >> 18)]
- + hexTable[0x80 | ((c >> 12) & 0x3F)]
- + hexTable[0x80 | ((c >> 6) & 0x3F)]
- + hexTable[0x80 | (c & 0x3F)];
- }
- return out;
- };
- var compact = function compact(value) {
- var queue = [{obj: {o: value}, prop: 'o'}];
- var refs = [];
- for (var i = 0; i < queue.length; ++i) {
- var item = queue[i];
- var obj = item.obj[item.prop];
- var keys = Object.keys(obj);
- for (var j = 0; j < keys.length; ++j) {
- var key = keys[j];
- var val = obj[key];
- if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {
- queue.push({obj: obj, prop: key});
- refs.push(val);
- }
- }
- }
- compactQueue(queue);
- return value;
- };
- var isRegExp = function isRegExp(obj) {
- return Object.prototype.toString.call(obj) === '[object RegExp]';
- };
- var isBuffer$1 = function isBuffer(obj) {
- if (!obj || typeof obj !== 'object') {
- return false;
- }
- return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
- };
- var combine = function combine(a, b) {
- return [].concat(a, b);
- };
- var maybeMap = function maybeMap(val, fn) {
- if (isArray$2(val)) {
- var mapped = [];
- for (var i = 0; i < val.length; i += 1) {
- mapped.push(fn(val[i]));
- }
- return mapped;
- }
- return fn(val);
- };
- var utils$3 = {
- arrayToObject: arrayToObject,
- assign: assign$4,
- combine: combine,
- compact: compact,
- decode: decode,
- encode: encode$1,
- isBuffer: isBuffer$1,
- isRegExp: isRegExp,
- maybeMap: maybeMap,
- merge: merge$1
- };
- var replace = String.prototype.replace;
- var percentTwenties = /%20/g;
- var Format = {
- RFC1738: 'RFC1738',
- RFC3986: 'RFC3986'
- };
- var formats = utils$3.assign(
- {
- 'default': Format.RFC3986,
- formatters: {
- RFC1738: function (value) {
- return replace.call(value, percentTwenties, '+');
- },
- RFC3986: function (value) {
- return String(value);
- }
- }
- },
- Format
- );
- var has$1 = Object.prototype.hasOwnProperty;
- var arrayPrefixGenerators = {
- brackets: function brackets(prefix) {
- return prefix + '[]';
- },
- comma: 'comma',
- indices: function indices(prefix, key) {
- return prefix + '[' + key + ']';
- },
- repeat: function repeat(prefix) {
- return prefix;
- }
- };
- var isArray$1 = Array.isArray;
- var push = Array.prototype.push;
- var pushToArray = function (arr, valueOrArray) {
- push.apply(arr, isArray$1(valueOrArray) ? valueOrArray : [valueOrArray]);
- };
- var toISO = Date.prototype.toISOString;
- var defaultFormat = formats['default'];
- var defaults$2 = {
- addQueryPrefix: false,
- allowDots: false,
- charset: 'utf-8',
- charsetSentinel: false,
- delimiter: '&',
- encode: true,
- encoder: utils$3.encode,
- encodeValuesOnly: false,
- format: defaultFormat,
- formatter: formats.formatters[defaultFormat],
- // deprecated
- indices: false,
- serializeDate: function serializeDate(date) {
- return toISO.call(date);
- },
- skipNulls: false,
- strictNullHandling: false
- };
- var isNonNullishPrimitive = function isNonNullishPrimitive(v) {
- return typeof v === 'string'
- || typeof v === 'number'
- || typeof v === 'boolean'
- || typeof v === 'symbol'
- || typeof v === 'bigint';
- };
- var stringify = function stringify(
- object,
- prefix,
- generateArrayPrefix,
- strictNullHandling,
- skipNulls,
- encoder,
- filter,
- sort,
- allowDots,
- serializeDate,
- formatter,
- encodeValuesOnly,
- charset
- ) {
- var obj = object;
- if (typeof filter === 'function') {
- obj = filter(prefix, obj);
- } else if (obj instanceof Date) {
- obj = serializeDate(obj);
- } else if (generateArrayPrefix === 'comma' && isArray$1(obj)) {
- obj = utils$3.maybeMap(obj, function (value) {
- if (value instanceof Date) {
- return serializeDate(value);
- }
- return value;
- }).join(',');
- }
- if (obj === null) {
- if (strictNullHandling) {
- return encoder && !encodeValuesOnly ? encoder(prefix, defaults$2.encoder, charset, 'key') : prefix;
- }
- obj = '';
- }
- if (isNonNullishPrimitive(obj) || utils$3.isBuffer(obj)) {
- if (encoder) {
- var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults$2.encoder, charset, 'key');
- return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults$2.encoder, charset, 'value'))];
- }
- return [formatter(prefix) + '=' + formatter(String(obj))];
- }
- var values = [];
- if (typeof obj === 'undefined') {
- return values;
- }
- var objKeys;
- if (isArray$1(filter)) {
- objKeys = filter;
- } else {
- var keys = Object.keys(obj);
- objKeys = sort ? keys.sort(sort) : keys;
- }
- for (var i = 0; i < objKeys.length; ++i) {
- var key = objKeys[i];
- var value = obj[key];
- if (skipNulls && value === null) {
- continue;
- }
- var keyPrefix = isArray$1(obj)
- ? typeof generateArrayPrefix === 'function' ? generateArrayPrefix(prefix, key) : prefix
- : prefix + (allowDots ? '.' + key : '[' + key + ']');
- pushToArray(values, stringify(
- value,
- keyPrefix,
- generateArrayPrefix,
- strictNullHandling,
- skipNulls,
- encoder,
- filter,
- sort,
- allowDots,
- serializeDate,
- formatter,
- encodeValuesOnly,
- charset
- ));
- }
- return values;
- };
- var normalizeStringifyOptions = function normalizeStringifyOptions(opts) {
- if (!opts) {
- return defaults$2;
- }
- if (opts.encoder !== null && opts.encoder !== undefined && typeof opts.encoder !== 'function') {
- throw new TypeError('Encoder has to be a function.');
- }
- var charset = opts.charset || defaults$2.charset;
- if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
- throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');
- }
- var format = formats['default'];
- if (typeof opts.format !== 'undefined') {
- if (!has$1.call(formats.formatters, opts.format)) {
- throw new TypeError('Unknown format option provided.');
- }
- format = opts.format;
- }
- var formatter = formats.formatters[format];
- var filter = defaults$2.filter;
- if (typeof opts.filter === 'function' || isArray$1(opts.filter)) {
- filter = opts.filter;
- }
- return {
- addQueryPrefix: typeof opts.addQueryPrefix === 'boolean' ? opts.addQueryPrefix : defaults$2.addQueryPrefix,
- allowDots: typeof opts.allowDots === 'undefined' ? defaults$2.allowDots : !!opts.allowDots,
- charset: charset,
- charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults$2.charsetSentinel,
- delimiter: typeof opts.delimiter === 'undefined' ? defaults$2.delimiter : opts.delimiter,
- encode: typeof opts.encode === 'boolean' ? opts.encode : defaults$2.encode,
- encoder: typeof opts.encoder === 'function' ? opts.encoder : defaults$2.encoder,
- encodeValuesOnly: typeof opts.encodeValuesOnly === 'boolean' ? opts.encodeValuesOnly : defaults$2.encodeValuesOnly,
- filter: filter,
- formatter: formatter,
- serializeDate: typeof opts.serializeDate === 'function' ? opts.serializeDate : defaults$2.serializeDate,
- skipNulls: typeof opts.skipNulls === 'boolean' ? opts.skipNulls : defaults$2.skipNulls,
- sort: typeof opts.sort === 'function' ? opts.sort : null,
- strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults$2.strictNullHandling
- };
- };
- var stringify_1 = function (object, opts) {
- var obj = object;
- var options = normalizeStringifyOptions(opts);
- var objKeys;
- var filter;
- if (typeof options.filter === 'function') {
- filter = options.filter;
- obj = filter('', obj);
- } else if (isArray$1(options.filter)) {
- filter = options.filter;
- objKeys = filter;
- }
- var keys = [];
- if (typeof obj !== 'object' || obj === null) {
- return '';
- }
- var arrayFormat;
- if (opts && opts.arrayFormat in arrayPrefixGenerators) {
- arrayFormat = opts.arrayFormat;
- } else if (opts && 'indices' in opts) {
- arrayFormat = opts.indices ? 'indices' : 'repeat';
- } else {
- arrayFormat = 'indices';
- }
- var generateArrayPrefix = arrayPrefixGenerators[arrayFormat];
- if (!objKeys) {
- objKeys = Object.keys(obj);
- }
- if (options.sort) {
- objKeys.sort(options.sort);
- }
- for (var i = 0; i < objKeys.length; ++i) {
- var key = objKeys[i];
- if (options.skipNulls && obj[key] === null) {
- continue;
- }
- pushToArray(keys, stringify(
- obj[key],
- key,
- generateArrayPrefix,
- options.strictNullHandling,
- options.skipNulls,
- options.encode ? options.encoder : null,
- options.filter,
- options.sort,
- options.allowDots,
- options.serializeDate,
- options.formatter,
- options.encodeValuesOnly,
- options.charset
- ));
- }
- var joined = keys.join(options.delimiter);
- var prefix = options.addQueryPrefix === true ? '?' : '';
- if (options.charsetSentinel) {
- if (options.charset === 'iso-8859-1') {
- // encodeURIComponent('✓'), the "numeric entity" representation of a checkmark
- prefix += 'utf8=%26%2310003%3B&';
- } else {
- // encodeURIComponent('✓')
- prefix += 'utf8=%E2%9C%93&';
- }
- }
- return joined.length > 0 ? prefix + joined : '';
- };
- var has$3 = Object.prototype.hasOwnProperty;
- var isArray$3 = Array.isArray;
- var defaults$3 = {
- allowDots: false,
- allowPrototypes: false,
- arrayLimit: 20,
- charset: 'utf-8',
- charsetSentinel: false,
- comma: false,
- decoder: utils$3.decode,
- delimiter: '&',
- depth: 5,
- ignoreQueryPrefix: false,
- interpretNumericEntities: false,
- parameterLimit: 1000,
- parseArrays: true,
- plainObjects: false,
- strictNullHandling: false
- };
- var interpretNumericEntities = function (str) {
- return str.replace(/&#(\d+);/g, function ($0, numberStr) {
- return String.fromCharCode(parseInt(numberStr, 10));
- });
- };
- var parseArrayValue = function (val, options) {
- if (val && typeof val === 'string' && options.comma && val.indexOf(',') > -1) {
- return val.split(',');
- }
- return val;
- };
- // This is what browsers will submit when the ✓ character occurs in an
- // application/x-www-form-urlencoded body and the encoding of the page containing
- // the form is iso-8859-1, or when the submitted form has an accept-charset
- // attribute of iso-8859-1. Presumably also with other charsets that do not contain
- // the ✓ character, such as us-ascii.
- var isoSentinel = 'utf8=%26%2310003%3B'; // encodeURIComponent('✓')
- // These are the percent-encoded utf-8 octets representing a checkmark, indicating that the request actually is utf-8 encoded.
- var charsetSentinel = 'utf8=%E2%9C%93'; // encodeURIComponent('✓')
- var parseValues = function parseQueryStringValues(str, options) {
- var obj = {};
- var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str;
- var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit;
- var parts = cleanStr.split(options.delimiter, limit);
- var skipIndex = -1; // Keep track of where the utf8 sentinel was found
- var i;
- var charset = options.charset;
- if (options.charsetSentinel) {
- for (i = 0; i < parts.length; ++i) {
- if (parts[i].indexOf('utf8=') === 0) {
- if (parts[i] === charsetSentinel) {
- charset = 'utf-8';
- } else if (parts[i] === isoSentinel) {
- charset = 'iso-8859-1';
- }
- skipIndex = i;
- i = parts.length; // The eslint settings do not allow break;
- }
- }
- }
- for (i = 0; i < parts.length; ++i) {
- if (i === skipIndex) {
- continue;
- }
- var part = parts[i];
- var bracketEqualsPos = part.indexOf(']=');
- var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1;
- var key, val;
- if (pos === -1) {
- key = options.decoder(part, defaults$3.decoder, charset, 'key');
- val = options.strictNullHandling ? null : '';
- } else {
- key = options.decoder(part.slice(0, pos), defaults$3.decoder, charset, 'key');
- val = utils$3.maybeMap(
- parseArrayValue(part.slice(pos + 1), options),
- function (encodedVal) {
- return options.decoder(encodedVal, defaults$3.decoder, charset, 'value');
- }
- );
- }
- if (val && options.interpretNumericEntities && charset === 'iso-8859-1') {
- val = interpretNumericEntities(val);
- }
- if (part.indexOf('[]=') > -1) {
- val = isArray$3(val) ? [val] : val;
- }
- if (has$3.call(obj, key)) {
- obj[key] = utils$3.combine(obj[key], val);
- } else {
- obj[key] = val;
- }
- }
- return obj;
- };
- var parseObject = function (chain, val, options, valuesParsed) {
- var leaf = valuesParsed ? val : parseArrayValue(val, options);
- for (var i = chain.length - 1; i >= 0; --i) {
- var obj;
- var root = chain[i];
- if (root === '[]' && options.parseArrays) {
- obj = [].concat(leaf);
- } else {
- obj = options.plainObjects ? Object.create(null) : {};
- var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root;
- var index = parseInt(cleanRoot, 10);
- if (!options.parseArrays && cleanRoot === '') {
- obj = {0: leaf};
- } else if (
- !isNaN(index)
- && root !== cleanRoot
- && String(index) === cleanRoot
- && index >= 0
- && (options.parseArrays && index <= options.arrayLimit)
- ) {
- obj = [];
- obj[index] = leaf;
- } else {
- obj[cleanRoot] = leaf;
- }
- }
- leaf = obj; // eslint-disable-line no-param-reassign
- }
- return leaf;
- };
- var parseKeys = function parseQueryStringKeys(givenKey, val, options, valuesParsed) {
- if (!givenKey) {
- return;
- }
- // Transform dot notation to bracket notation
- var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey;
- // The regex chunks
- var brackets = /(\[[^[\]]*])/;
- var child = /(\[[^[\]]*])/g;
- // Get the parent
- var segment = options.depth > 0 && brackets.exec(key);
- var parent = segment ? key.slice(0, segment.index) : key;
- // Stash the parent if it exists
- var keys = [];
- if (parent) {
- // If we aren't using plain objects, optionally prefix keys that would overwrite object prototype properties
- if (!options.plainObjects && has$3.call(Object.prototype, parent)) {
- if (!options.allowPrototypes) {
- return;
- }
- }
- keys.push(parent);
- }
- // Loop through children appending to the array until we hit depth
- var i = 0;
- while (options.depth > 0 && (segment = child.exec(key)) !== null && i < options.depth) {
- i += 1;
- if (!options.plainObjects && has$3.call(Object.prototype, segment[1].slice(1, -1))) {
- if (!options.allowPrototypes) {
- return;
- }
- }
- keys.push(segment[1]);
- }
- // If there's a remainder, just add whatever is left
- if (segment) {
- keys.push('[' + key.slice(segment.index) + ']');
- }
- return parseObject(keys, val, options, valuesParsed);
- };
- var normalizeParseOptions = function normalizeParseOptions(opts) {
- if (!opts) {
- return defaults$3;
- }
- if (opts.decoder !== null && opts.decoder !== undefined && typeof opts.decoder !== 'function') {
- throw new TypeError('Decoder has to be a function.');
- }
- if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
- throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');
- }
- var charset = typeof opts.charset === 'undefined' ? defaults$3.charset : opts.charset;
- return {
- allowDots: typeof opts.allowDots === 'undefined' ? defaults$3.allowDots : !!opts.allowDots,
- allowPrototypes: typeof opts.allowPrototypes === 'boolean' ? opts.allowPrototypes : defaults$3.allowPrototypes,
- arrayLimit: typeof opts.arrayLimit === 'number' ? opts.arrayLimit : defaults$3.arrayLimit,
- charset: charset,
- charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults$3.charsetSentinel,
- comma: typeof opts.comma === 'boolean' ? opts.comma : defaults$3.comma,
- decoder: typeof opts.decoder === 'function' ? opts.decoder : defaults$3.decoder,
- delimiter: typeof opts.delimiter === 'string' || utils$3.isRegExp(opts.delimiter) ? opts.delimiter : defaults$3.delimiter,
- // eslint-disable-next-line no-implicit-coercion, no-extra-parens
- depth: (typeof opts.depth === 'number' || opts.depth === false) ? +opts.depth : defaults$3.depth,
- ignoreQueryPrefix: opts.ignoreQueryPrefix === true,
- interpretNumericEntities: typeof opts.interpretNumericEntities === 'boolean' ? opts.interpretNumericEntities : defaults$3.interpretNumericEntities,
- parameterLimit: typeof opts.parameterLimit === 'number' ? opts.parameterLimit : defaults$3.parameterLimit,
- parseArrays: opts.parseArrays !== false,
- plainObjects: typeof opts.plainObjects === 'boolean' ? opts.plainObjects : defaults$3.plainObjects,
- strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults$3.strictNullHandling
- };
- };
- var parse = function (str, opts) {
- var options = normalizeParseOptions(opts);
- if (str === '' || str === null || typeof str === 'undefined') {
- return options.plainObjects ? Object.create(null) : {};
- }
- var tempObj = typeof str === 'string' ? parseValues(str, options) : str;
- var obj = options.plainObjects ? Object.create(null) : {};
- // Iterate over the keys and setup the new object
- var keys = Object.keys(tempObj);
- for (var i = 0; i < keys.length; ++i) {
- var key = keys[i];
- var newObj = parseKeys(key, tempObj[key], options, typeof str === 'string');
- obj = utils$3.merge(obj, newObj, options);
- }
- return utils$3.compact(obj);
- };
- var lib = {
- formats: formats,
- parse: parse,
- stringify: stringify_1
- };
- var _this = undefined;
- var CODE_SUCCESS = 200; // 状态正常
- var CODE_TOKEN_INVALID = 4002; // 登录失效
- // 没有权限
- ///////////////////////////////////////////////// 基础参数 /////////////////////////////////////////////////
- var request = {};
- // 默认配置: 内部变量, 兼容reject不能获取到请求conf配置, 设置全局变量记录
- var _conf = {
- mContentType: false, // 记录默认请求头格式
- countLoading: 0 // 使用计数 [拦截器失败重置]
- };
- // 网络请求
- var ContentType = ["application/json;charset=UTF-8", "application/x-www-form-urlencoded"];
- var http = axios.create({
- timeout: config.timeout,
- baseURL: ""
- });
- http.defaults.headers["Content-Type"] = ContentType[Number(_conf.mContentType)]; // 默认 Content-Type
- // 拦截器专用: 处理loading状态, 避免出现闪屏; 处理是否显示错误提示
- function _interceptorsError(error) {
- _conf.countLoading = 0;
- com.hideLoading();
- var errMsg = error ? error.message || "系统错误" : null;
- com.showErrorMessage(errMsg);
- return error;
- }
- // 请求拦截器
- http.interceptors.request.use(function (config$$1) {
- if (!config$$1.url.includes("http")) {
- config$$1.url = mjs.conf.api + config$$1.url;
- }
- // 无需删除conf属性: 不会提交到请求
- var conf = config$$1.conf;
- if (!conf[KEY_NO_LOADING]) {
- _conf.countLoading += 1;
- com.showLoading();
- }
- if (conf[KEY_M_CONTENT_TYPE]) {
- config$$1.headers["Content-Type"] = ContentType[Number(!_conf.mContentType)]; // // 修改 Content-Type: 取反
- }
- config$$1.headers["Authorization"] = mjs.conf.token;
- console.log('请求入参', config$$1);
- return config$$1;
- }, function (error) {
- return _interceptorsError(error);
- });
- // 将blob对象转化为json(文件类型调用ajax 取后端的返回值做特殊处理)
- function _fileToJson(file) {
- var data = {},
- message = "";
- function formatReturn() {
- return {data: data, message: message};
- }
- return new _Promise(function (resolve) {
- var reader = new FileReader();
- reader.onload = function (res) {
- var result = res.target.result; // 得到字符串
- try {
- // 解析成json对象
- data = JSON.parse(result);
- } catch (err) {
- message = err.message || err;
- }
- resolve(formatReturn());
- }; // 成功回调
- reader.onerror = function (err) {
- message = err.message || err;
- resolve(formatReturn());
- }; // 失败回调
- reader.readAsText(new Blob([file]), "utf-8"); // 按照utf-8编码解析
- });
- }
- // 响应拦截器
- http.interceptors.response.use(function () {
- var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(response) {
- var conf, rsp, fileName, msg, code, tip;
- return regenerator.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- console.log('请求响应', response);
- conf = response.config.conf;
- // loading处理
- if (!conf[KEY_NO_LOADING]) {
- _conf.countLoading -= 1;
- }
- if (!_conf.countLoading) {
- com.hideLoading();
- }
- if (!conf[KEY_IGNORE_RESPONSE]) {
- _context.next = 6;
- break;
- }
- return _context.abrupt("return", response);
- case 6:
- if (!response.config.conf[KEY_EXPORT_TYPE]) {
- _context.next = 15;
- break;
- }
- _context.next = 9;
- return _fileToJson(response.data);
- case 9:
- rsp = _context.sent;
- if (rsp.data.code) {
- _context.next = 14;
- break;
- }
- // 文件名称: 需要后端设置为可见, 否则 header 有, 但 js 取不到值
- fileName = void 0;
- if (response.headers["content-disposition"]) {
- fileName = decodeURIComponent(response.headers["content-disposition"].replace("attachment;filename=", "").replace("attachment;filename*=utf-8", ""));
- }
- return _context.abrupt("return", {data: response.data, fileName: fileName});
- case 14:
- // 赋值, 触发失败弹出框
- response.data = rsp.data;
- case 15:
- msg = response.data.msg || response.data.message;
- code = Number(response.data.code);
- if (!(code === CODE_SUCCESS || response.data.success)) {
- _context.next = 21;
- break;
- }
- tip = conf[KEY_SHOW_MESSAGE];
- if (tip) {
- // 需要show成功Message信息
- com.showSuccessMessage(typeof tip == "boolean" ? msg || "请求成功" : tip);
- }
- return _context.abrupt("return", response.data);
- case 21:
- // 登录失效跳转登录页面. NOTE: 注意可能导致循环调用
- if (code === CODE_TOKEN_INVALID) {
- com.showErrorMessage(msg);
- setTimeout(function () {
- com.invalidToken(msg);
- }, 350);
- }
- // 请求结束忽略error
- if (!conf[KEY_NO_ERROR_TIP]) {
- com.showErrorMessage(msg || '未知异常');
- }
- return _context.abrupt("return", _Promise.reject(msg));
- case 24:
- case "end":
- return _context.stop();
- }
- }
- }, _callee, _this);
- }));
- return function (_x) {
- return _ref.apply(this, arguments);
- };
- }(), function (error) {
- return _interceptorsError(error);
- });
- ///////////////////////////////////////////////// 请求配置 /////////////////////////////////////////////////
- /** @param Boolean: noLoading => 是否显示loading */
- var KEY_NO_LOADING = "noLoading";
- /** @param Boolean: noErrorTip => 是否显示错误提示框; */
- var KEY_NO_ERROR_TIP = "noErrorTip";
- /** @param Boolean: mContentType => 是否修改请求头类型 */
- var KEY_M_CONTENT_TYPE = "mContentType";
- /** @param Boolean: showMessage => 是否显示提示 */
- var KEY_SHOW_MESSAGE = "showMessage";
- /** @param Boolean: responseType => 导出文件流类型 */
- var KEY_EXPORT_TYPE = "responseType";
- /** @param Boolean: ignoreResponse => 返回数据不校验 */
- var KEY_IGNORE_RESPONSE = "ignoreResponse";
- /** @param Boolean: noLoadToken => 不传递token */
- /** 1.get: url上param, 后端取值@requestParam,也可用request.getParameterMap().get(“key”), 参数会被放入一个集合 */
- request.doGet = function (url) {
- var param = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
- var conf = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
- var params = lib.stringify(param);
- if (params) {
- var joint = url.includes("?") ? "&" : "?";
- url += joint + params;
- }
- return http({
- url: url,
- method: "GET",
- conf: conf
- });
- };
- /** 2.post: body内json, 后端取值@requestBody, Map 或转为实体 */
- request.doPost = function (url) {
- var param = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
- var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
- var conf = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
- var params = lib.stringify(param);
- if (params) {
- var joint = url.includes("?") ? "&" : "?";
- url += joint + params;
- }
- return http({
- url: url,
- method: "POST",
- data: data,
- conf: conf,
- responseType: conf[KEY_EXPORT_TYPE]
- });
- };
- /** 3.form: body内格式为form, 和content-type有关系, 需要为form格式后端才能读取: 不能使用@RequestBody,参数会自动解析到实体; 若不是实体通过方法转Map */
- request.doForm = function (url, param) {
- var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
- var conf = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
- // 变更请求头类型, 传递form
- conf[KEY_M_CONTENT_TYPE] = true;
- return this.doPost(url, param, data, conf);
- };
- /** 4.upload: body-formData, 一般用于文件上传, 追加数据流 */
- request.doUpload = function (url, param) {
- var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
- var conf = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
- var formData = new FormData();
- _Object$keys(data).forEach(function (prop) {
- formData.append(prop, data[prop]);
- });
- return this.doPost(url, param, formData, conf);
- };
- /** 5.并发多个请求优先(类方法) */
- request.doSpread = function (arrReq) {
- return axios.spread(arrReq);
- };
- /** 6.并发多个请求全部(类方法) */
- request.doAll = function (arrReq) {
- return axios.all(arrReq);
- };
- ///////////////////////////////////////////////// 服务配置 /////////////////////////////////////////////////
- /** 1.excel: 下载blob数据 */
- request.doDownload = function (blobData, fileName) {
- fileName = fileName || "导出文件_" + Date.now();
- var blob = new Blob([blobData], {
- type: "application/vnd.ms-excel;charset=UTF-8"
- });
- var link = document.createElement("a");
- link.style.display = "none";
- link.href = URL.createObjectURL(blob);
- link.download = fileName;
- document.body.appendChild(link);
- link.click();
- URL.revokeObjectURL(link.href);
- document.body.removeChild(link);
- };
- /** 2.Excel: 导出并下载blob数据 */
- request.doExport = function () {
- var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(url, param) {
- var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
- var rsp;
- return regenerator.wrap(function _callee2$(_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- _context2.next = 2;
- return request.doPost(url, param, data, _defineProperty({}, KEY_EXPORT_TYPE, "blob"));
- case 2:
- rsp = _context2.sent;
- // 若响应数据为流
- if (!rsp.code) {
- this.doDownload(rsp.data, rsp.fileName);
- }
- case 4:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee2, this);
- }));
- return function (_x11, _x12) {
- return _ref2.apply(this, arguments);
- };
- }();
- /** 3.Excel: 自定义导入, 自动下载失败记录 */
- request.doImport = function () {
- var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(url, file, param, data) {
- var rsp;
- return regenerator.wrap(function _callee3$(_context3) {
- while (1) {
- switch (_context3.prev = _context3.next) {
- case 0:
- _context3.next = 2;
- return request.doPostFormData(url, param, _extends$1({file: file}, data), _defineProperty({}, KEY_EXPORT_TYPE, "blob"));
- case 2:
- rsp = _context3.sent;
- if (rsp.code) {
- _context3.next = 7;
- break;
- }
- com.showErrorMessage("部分导入失败");
- this.doDownload(rsp.data, rsp.fileName);
- return _context3.abrupt("return");
- case 7:
- com.showSuccessMessage("全部导入成功");
- case 8:
- case "end":
- return _context3.stop();
- }
- }
- }, _callee3, this);
- }));
- return function (_x14, _x15, _x16, _x17) {
- return _ref3.apply(this, arguments);
- };
- }();
- /** 4.Excel:导入数据el-upload组件 */
- request.doElementUI = function (url) {
- var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
- var successHandle = arguments[2];
- return {
- action: url,
- fileList: [],
- data: data,
- onReady: function onReady() {
- com.showLoading();
- },
- success: function success(rsp) {
- com.hideLoading();
- if (rsp.code == CODE_SUCCESS) {
- com.showSuccessMessage("导入成功");
- successHandle && successHandle(rsp);
- } else {
- com.showErrorMessage(rsp.msg);
- }
- },
- failure: function failure() {
- com.hideLoading();
- com.showErrorMessage("导入失败");
- }
- };
- };
- var _createProperty = function (object, index, value) {
- if (index in object) _objectDp.f(object, index, _propertyDesc(0, value));
- else object[index] = value;
- };
- _export(_export.S + _export.F * !_iterDetect(function (iter) {
- }), 'Array', {
- // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined)
- from: function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
- var O = _toObject(arrayLike);
- var C = typeof this == 'function' ? this : Array;
- var aLen = arguments.length;
- var mapfn = aLen > 1 ? arguments[1] : undefined;
- var mapping = mapfn !== undefined;
- var index = 0;
- var iterFn = core_getIteratorMethod(O);
- var length, result, step, iterator;
- if (mapping) mapfn = _ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2);
- // if object isn't iterable or it's array with default iterator - use simple case
- if (iterFn != undefined && !(C == Array && _isArrayIter(iterFn))) {
- for (iterator = iterFn.call(O), result = new C(); !(step = iterator.next()).done; index++) {
- _createProperty(result, index, mapping ? _iterCall(iterator, mapfn, [step.value, index], true) : step.value);
- }
- } else {
- length = _toLength(O.length);
- for (result = new C(length); length > index; index++) {
- _createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]);
- }
- }
- result.length = index;
- return result;
- }
- });
- var from$2 = _core.Array.from;
- var from = createCommonjsModule(function (module) {
- module.exports = {"default": from$2, __esModule: true};
- });
- unwrapExports(from);
- var toConsumableArray = createCommonjsModule(function (module, exports) {
- exports.__esModule = true;
- var _from2 = _interopRequireDefault(from);
- function _interopRequireDefault(obj) {
- return obj && obj.__esModule ? obj : {default: obj};
- }
- exports.default = function (arr) {
- if (Array.isArray(arr)) {
- for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
- arr2[i] = arr[i];
- }
- return arr2;
- } else {
- return (0, _from2.default)(arr);
- }
- };
- });
- var _toConsumableArray = unwrapExports(toConsumableArray);
- var $JSON = _core.JSON || (_core.JSON = {stringify: JSON.stringify});
- var stringify$3 = function stringify(it) { // eslint-disable-line no-unused-vars
- return $JSON.stringify.apply($JSON, arguments);
- };
- var stringify$2 = createCommonjsModule(function (module) {
- module.exports = {"default": stringify$3, __esModule: true};
- });
- var _JSON$stringify = unwrapExports(stringify$2);
- // 组件数据处理
- // 接口返回取值到组件, 人员搜索框需要对象类型
- // 明细组件数据格式化, 接口服务人员搜索框需要集合的 json string
- // 查询条件兼容各种组件形式
- function __redundancy_query__(that, cur) {
- var value = "cur" in cur ? that.$(cur.cur).getValue() || cur.def : cur.def;
- // 兼容人员搜索框, 单选 + 多选
- if (cur.cur && cur.cur.includes("employeeField_")) {
- var arrEmp = [];
- var state = that.$(cur.cur).getValue() || [];
- // 单选
- if (state.length === undefined) {
- arrEmp.push(state.value);
- }
- // 多选且有值
- if (state.length) {
- arrEmp.push.apply(arrEmp, _toConsumableArray(state.map(function (emp) {
- return emp.value;
- })));
- }
- value = arrEmp;
- // 兼容匹配isAll, 避免被忽略
- if (!value.length) value = undefined;
- }
- // 兼容日期查询: 时间戳, cur为开始, end为默认, 若无则传def
- if (cur.src.includes("dateField_")) {
- var end = "end" in cur ? that.$(cur.end).getValue() || cur.def : cur.def;
- value = [value, end];
- // 兼容匹配isAll, 避免被忽略
- if (!value || !end) value = undefined;
- }
- // 兼容部门, 精确匹配, 兼容多选
- if (cur.cur && cur.cur.includes("departmentSelectField_")) {
- var depart = that.$(cur.cur).getValue();
- // 兼容匹配isAll, 避免被忽略
- if (!depart.length) {
- value = undefined;
- } else {
- value = depart.map(function (item) {
- return item.value;
- }).join(",");
- }
- }
- // 20.8.20 关联表单
- if (cur.cur && cur.cur.includes("associationFormField_") && value.length) {
- value = value.shift().title;
- }
- return value;
- }
- // 前端接口
- var dp = {};
- // 更新数据逻辑: 相对路径 `/${window.pageConfig.appType}/v1/form/searchFormDatas.json`
- dp.updateForm = function () {
- var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
- var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
- formInstId = _ref2.formInstId,
- updateData = _ref2.updateData,
- _ref2$dpRemote = _ref2.dpRemote,
- dpRemote = _ref2$dpRemote === undefined ? "updateForm" : _ref2$dpRemote,
- _ref2$isLoading = _ref2.isLoading,
- isLoading = _ref2$isLoading === undefined ? true : _ref2$isLoading,
- hideToast = _ref2.hideToast,
- _ref2$message = _ref2.message,
- message = _ref2$message === undefined ? "操作成功" : _ref2$message;
- var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
- title = _ref3.title,
- content = _ref3.content;
- var rsp;
- return regenerator.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- if (formInstId) {
- _context.next = 2;
- break;
- }
- throw new Error("The params of formInstId is empty.");
- case 2:
- if (!(title || content)) {
- _context.next = 5;
- break;
- }
- _context.next = 5;
- return mjs.com.showConfirm(title, content);
- case 5:
- if (isLoading) mjs.com.showLoading();
- _context.next = 8;
- return mjs.$this.dataSourceMap[dpRemote].load({
- formInstId: formInstId,
- updateFormDataJson: _JSON$stringify(updateData)
- }).catch(function (error) {
- if (!hideToast) mjs.com.showErrorMessage(error.message);
- });
- case 8:
- rsp = _context.sent;
- if (isLoading) mjs.com.hideLoading();
- if (rsp) {
- _context.next = 12;
- break;
- }
- return _context.abrupt("return");
- case 12:
- if (rsp && !hideToast) mjs.com.showMessage(message);
- case 13:
- case "end":
- return _context.stop();
- }
- }
- }, _callee, this);
- }));
- return function () {
- return _ref.apply(this, arguments);
- };
- }();
- // 查询实例列表逻辑: 相对路径 `/${window.pageConfig.appType}/v1/form/searchFormDatas.json`
- dp.queryForm = function () {
- var _ref4 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
- var _this = this;
- var _ref5 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
- formUuid = _ref5.formUuid,
- _ref5$conditions = _ref5.conditions,
- conditions = _ref5$conditions === undefined ? [] : _ref5$conditions,
- _ref5$dpRemote = _ref5.dpRemote,
- dpRemote = _ref5$dpRemote === undefined ? "queryForm" : _ref5$dpRemote,
- _ref5$isLoading = _ref5.isLoading,
- isLoading = _ref5$isLoading === undefined ? true : _ref5$isLoading,
- _ref5$hideToast = _ref5.hideToast,
- hideToast = _ref5$hideToast === undefined ? true : _ref5$hideToast,
- _ref5$matchAllConditi = _ref5.matchAllCondition,
- matchAllCondition = _ref5$matchAllConditi === undefined ? false : _ref5$matchAllConditi,
- _ref5$message = _ref5.message,
- message = _ref5$message === undefined ? "查询成功" : _ref5$message;
- var _ref6 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
- _ref6$currentPage = _ref6.currentPage,
- currentPage = _ref6$currentPage === undefined ? 1 : _ref6$currentPage,
- _ref6$pageSize = _ref6.pageSize,
- pageSize = _ref6$pageSize === undefined ? config.pageSize : _ref6$pageSize,
- queryAll = _ref6.queryAll;
- var searchCondition, searchLength, queryFunc, resp, list, pages, promiseReq, pageCount, index, respArr;
- return regenerator.wrap(function _callee3$(_context3) {
- while (1) {
- switch (_context3.prev = _context3.next) {
- case 0:
- // 查询条件格式化
- searchCondition = conditions.reduce(function (acc, cur) {
- var value = __redundancy_query__(mjs.$this, cur);
- if (value) {
- acc[cur.src] = value;
- }
- return acc;
- }, {});
- searchLength = _Object$keys(searchCondition).length;
- if (!(conditions.length && !searchLength)) {
- _context3.next = 4;
- break;
- }
- return _context3.abrupt("return", []);
- case 4:
- if (!(matchAllCondition && searchLength != conditions.length)) {
- _context3.next = 6;
- break;
- }
- return _context3.abrupt("return", []);
- case 6:
- queryFunc = function () {
- var _ref7 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(currentPage) {
- var params;
- return regenerator.wrap(function _callee2$(_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- params = {
- searchFieldJson: _JSON$stringify(searchCondition),
- currentPage: currentPage,
- pageSize: pageSize
- };
- // 兼容默认参数已设置FormUuid, 为空会被覆盖
- if (formUuid) params.formUuid = formUuid;
- _context2.next = 4;
- return mjs.$this.dataSourceMap[dpRemote].load(params).catch(function (error) {
- if (!hideToast) mjs.com.showErrorMessage(error.message);
- });
- case 4:
- return _context2.abrupt("return", _context2.sent);
- case 5:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee2, _this);
- }));
- return function queryFunc(_x5) {
- return _ref7.apply(this, arguments);
- };
- }();
- if (isLoading) mjs.com.showLoading();
- _context3.next = 10;
- return queryFunc(currentPage);
- case 10:
- resp = _context3.sent;
- list = resp.data;
- pages = Math.ceil(resp.totalCount / pageSize);
- if (!(queryAll && pages > currentPage)) {
- _context3.next = 21;
- break;
- }
- promiseReq = [];
- pageCount = Math.ceil(config.upperLimit / pageSize);
- for (index = currentPage + 1; index < pageCount + currentPage && index <= pages; index++) {
- promiseReq.push(queryFunc(index));
- }
- _context3.next = 19;
- return _Promise.all(promiseReq);
- case 19:
- respArr = _context3.sent;
- respArr.forEach(function (rsp) {
- list.push.apply(list, _toConsumableArray(rsp.data));
- });
- case 21:
- if (isLoading) mjs.com.hideLoading();
- if (resp && !hideToast) mjs.com.showMessage(message);
- return _context3.abrupt("return", {totalCount: resp.totalCount, data: list});
- case 24:
- case "end":
- return _context3.stop();
- }
- }
- }, _callee3, this);
- }));
- return function () {
- return _ref4.apply(this, arguments);
- };
- }();
- // 明细全量查询: Promise并发
- dp.queryDetail = function () {
- var _ref8 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee5() {
- var _this2 = this;
- var _ref9 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
- formUuid = _ref9.formUuid,
- _ref9$conditions = _ref9.conditions,
- conditions = _ref9$conditions === undefined ? {} : _ref9$conditions,
- _ref9$dpRemote = _ref9.dpRemote,
- dpRemote = _ref9$dpRemote === undefined ? "queryForm" : _ref9$dpRemote;
- var _ref10 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
- _ref10$currentPage = _ref10.currentPage,
- currentPage = _ref10$currentPage === undefined ? 1 : _ref10$currentPage,
- _ref10$pageSize = _ref10.pageSize,
- pageSize = _ref10$pageSize === undefined ? config.pageSize : _ref10$pageSize,
- _ref10$detailCount = _ref10.detailCount,
- detailCount = _ref10$detailCount === undefined ? config.detailCount : _ref10$detailCount;
- var searchCondition, queryFunc, resp, list, pages, promiseReq, pageCount, index, respArr;
- return regenerator.wrap(function _callee5$(_context5) {
- while (1) {
- switch (_context5.prev = _context5.next) {
- case 0:
- searchCondition = conditions.reduce(function (acc, cur) {
- var value = __redundancy_query__(mjs.$this, cur);
- if (value) {
- acc[cur.src] = value;
- }
- return acc;
- }, {});
- queryFunc = function () {
- var _ref11 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(currentPage) {
- var params;
- return regenerator.wrap(function _callee4$(_context4) {
- while (1) {
- switch (_context4.prev = _context4.next) {
- case 0:
- params = {
- searchFieldJson: _JSON$stringify(searchCondition),
- currentPage: currentPage,
- pageSize: pageSize
- };
- // 兼容默认参数已设置FormUuid, 为空会被覆盖
- if (formUuid) params.formUuid = formUuid;
- _context4.next = 4;
- return mjs.$this.dataSourceMap[dpRemote].load(params);
- case 4:
- return _context4.abrupt("return", _context4.sent);
- case 5:
- case "end":
- return _context4.stop();
- }
- }
- }, _callee4, _this2);
- }));
- return function queryFunc(_x8) {
- return _ref11.apply(this, arguments);
- };
- }();
- mjs.com.showLoading();
- _context5.next = 5;
- return queryFunc(currentPage);
- case 5:
- resp = _context5.sent;
- list = resp.data;
- pages = Math.ceil(resp.totalCount / pageSize);
- if (!(pages > currentPage)) {
- _context5.next = 16;
- break;
- }
- promiseReq = [];
- pageCount = Math.ceil(detailCount / pageSize);
- for (index = currentPage + 1; index < pageCount + currentPage && index <= pages; index++) {
- promiseReq.push(queryFunc(index));
- }
- _context5.next = 14;
- return _Promise.all(promiseReq);
- case 14:
- respArr = _context5.sent;
- respArr.forEach(function (res) {
- list.push.apply(list, _toConsumableArray(res.data));
- });
- case 16:
- mjs.com.hideLoading();
- return _context5.abrupt("return", {totalCount: resp.totalCount, data: list});
- case 18:
- case "end":
- return _context5.stop();
- }
- }
- }, _callee5, this);
- }));
- return function () {
- return _ref8.apply(this, arguments);
- };
- }();
- /**
- * @exports 返回变量型跨域
- * @returns 如获取ip: https://pv.sohu.com/cityjson?ie=utf-8, 返回值:var returnCitySN = {"cip": "124.79.25.204", "cid": "310101", "cname": "上海市黄浦区"};
- **/
- function crossDomainByScript(src, prop) {
- if (!src) _Promise.reject("地址不能为空");
- return new _Promise(function (resolve) {
- var script = document.createElement("script");
- script.setAttribute("type", "text/javascript");
- script.setAttribute("src", src);
- document.body.appendChild(script);
- script.onload = function () {
- resolve(window[prop]);
- };
- });
- }
- var core_getIterator = _core.getIterator = function (it) {
- var iterFn = core_getIteratorMethod(it);
- if (typeof iterFn != 'function') throw TypeError(it + ' is not iterable!');
- return _anObject(iterFn.call(it));
- };
- var getIterator$1 = core_getIterator;
- var getIterator = createCommonjsModule(function (module) {
- module.exports = {"default": getIterator$1, __esModule: true};
- });
- var _getIterator = unwrapExports(getIterator);
- /// 自定义页面bom展示效果 ///
- var bom = {
- compId: {
- parent: "",
- child: "",
- top: "", // 第一层
- name: ""
- },
- collectChildren: function collectChildren(dto, baseList) {
- var _this = this;
- var tempList = baseList.filter(function (d) {
- return dto[_this.compId.child] == d[_this.compId.parent];
- });
- if (tempList.length > 0) dto.children = tempList;
- var _iteratorNormalCompletion = true;
- var _didIteratorError = false;
- var _iteratorError = undefined;
- try {
- for (var _iterator = _getIterator(tempList), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
- var child = _step.value;
- this.collectChildren(child, baseList);
- }
- } catch (err) {
- _didIteratorError = true;
- _iteratorError = err;
- } finally {
- try {
- if (!_iteratorNormalCompletion && _iterator.return) {
- _iterator.return();
- }
- } finally {
- if (_didIteratorError) {
- throw _iteratorError;
- }
- }
- }
- },
- // 查询bom
- queryHierarchy: function queryHierarchy(_ref) {
- var _this2 = this;
- var dpRemote = _ref.dpRemote,
- formUuid = _ref.formUuid,
- conditions = _ref.conditions,
- compId_tree = _ref.compId_tree;
- return _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
- var rsp, dataList, topList, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2,
- _step2, dto;
- return regenerator.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- _context.next = 2;
- return mjs.request.dp.queryForm({
- formUuid: formUuid,
- conditions: conditions,
- dpRemote: dpRemote
- }, {queryAll: true});
- case 2:
- rsp = _context.sent;
- dataList = rsp.data.map(function (item) {
- return _extends$1({}, item.formData, {
- label: item.formData[_this2.compId.name],
- key: item.formData[_this2.compId.child],
- formInstId: item.formInstId
- });
- });
- topList = dataList.filter(function (d) {
- return _this2.compId.top == d[_this2.compId.parent];
- });
- _iteratorNormalCompletion2 = true;
- _didIteratorError2 = false;
- _iteratorError2 = undefined;
- _context.prev = 8;
- for (_iterator2 = _getIterator(topList); !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
- dto = _step2.value;
- _this2.collectChildren(dto, dataList);
- }
- _context.next = 16;
- break;
- case 12:
- _context.prev = 12;
- _context.t0 = _context["catch"](8);
- _didIteratorError2 = true;
- _iteratorError2 = _context.t0;
- case 16:
- _context.prev = 16;
- _context.prev = 17;
- if (!_iteratorNormalCompletion2 && _iterator2.return) {
- _iterator2.return();
- }
- case 19:
- _context.prev = 19;
- if (!_didIteratorError2) {
- _context.next = 22;
- break;
- }
- throw _iteratorError2;
- case 22:
- return _context.finish(19);
- case 23:
- return _context.finish(16);
- case 24:
- if (compId_tree) mjs.$this.$(compId_tree).set("dataSource", topList);
- return _context.abrupt("return", dataList);
- case 26:
- case "end":
- return _context.stop();
- }
- }
- }, _callee, _this2, [[8, 12, 16, 24], [17, , 19, 23]]);
- }))();
- }
- };
- /*** static 之 福氏钉钉SAP接口对接
- * 对接宜搭公共JavaScript库
- * 版权请联系:https://www.aliwork.com/o/mjs
- * 项目库地址: https://ding.practek.cn:38080/api/mjs/mjs.min.js
- ***/
- var fushi = {
- // 公共配置
- init: function init() {
- mjs.conf.api = "https://ding.practek.cn:38080/api/fushi";
- return this; // this 指向当前项目本身
- },
- // 定制配置
- SYNC_SUC_ALL: "全部成功",
- // 获取申请人部门层级
- getDepartmentCascade: function getDepartmentCascade(userId, compId) {
- var _this = this;
- return _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
- var rsp;
- return regenerator.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- _context.next = 2;
- return mjs.request.xhr.doPost("/user/department", {userId: userId}, null, _defineProperty({}, KEY_NO_LOADING, true));
- case 2:
- rsp = _context.sent;
- mjs.$this.$(compId).setValue(rsp.data.map(function (item) {
- return item.name;
- }).join(" / "));
- case 4:
- case "end":
- return _context.stop();
- }
- }
- }, _callee, _this);
- }))();
- },
- // mjs加载完成: 加载推送按钮
- purchaseLoad: function purchaseLoad() {
- var status = mjs.$this.$("textField_l2uot27h").getValue() == "同意" && mjs.$this.$('textareaField_l2lgyawc').getValue() != this.SYNC_SUC_ALL;
- mjs.$this.$('pageSection_l2uoi3fr').setBehavior(status ? "NORMAL" : "HIDDEN");
- },
- // mjs加载完成: 加载推送按钮
- paymentLoad: function paymentLoad() {
- var status = mjs.$this.$('radioField_l2og167t').getValue() == "是" && mjs.$this.$("textField_l2uot27h").getValue() == "同意" && mjs.$this.$('textareaField_l2lgyawc').getValue() != this.SYNC_SUC_ALL;
- mjs.$this.$('pageSection_l2uoi3fr').setBehavior(status ? "NORMAL" : "HIDDEN");
- },
- // 推送采购订单
- sapPurchase: function sapPurchase(compId) {
- var _this2 = this;
- return _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2() {
- return regenerator.wrap(function _callee2$(_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- _this2.doSap("/sap/purchase", compId);
- case 1:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee2, _this2);
- }))();
- },
- // 推送付款申请
- sapPayment: function sapPayment(compId) {
- this.doSap("/sap/payment", compId);
- },
- // 推送SAP
- doSap: function doSap(path, compId) {
- var _this3 = this;
- return _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
- var button, rsp;
- return regenerator.wrap(function _callee3$(_context3) {
- while (1) {
- switch (_context3.prev = _context3.next) {
- case 0:
- button = mjs.$this.$(compId);
- button.set("loading", true);
- _context3.next = 4;
- return mjs.request.xhr.doPost(path, {processInstanceId: mjs.com.getFormInstIdByUrl()}, null, _defineProperty({}, KEY_SHOW_MESSAGE, true));
- case 4:
- rsp = _context3.sent;
- if (!(rsp.message == _this3.SYNC_SUC_ALL)) {
- _context3.next = 8;
- break;
- }
- button.set("behavior", "HIDDEN");
- return _context3.abrupt("return");
- case 8:
- setTimeout(function () {
- location.reload();
- }, 750);
- case 9:
- case "end":
- return _context3.stop();
- }
- }
- }, _callee3, _this3);
- }))();
- }
- };
- /*** mc 系列之 static
- * 对接宜搭公共JavaScript库
- * 版权请联系:https://www.aliwork.com/o/mjs
- * 公共库地址:https://aliwork.zitoo.com.cn/mc/js/bom/mjs.min.js
- * 本地库地址: http://127.0.0.1:7001/dist/mjs.js
- ***/
- var init = function () {
- var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(_this) {
- var config$$1 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
- var msg;
- return regenerator.wrap(function _callee$(_context) {
- while (1) {
- switch (_context.prev = _context.next) {
- case 0:
- this.$this = _this; // this全局化
- this.env = com.checkEnv(); // 环境: 0提交(其它),1查看,2编辑(审批)
- loadVConsole(config$$1.vconsole);
- this.auth = auth; // 授权
- this.dom = dom; // 样式
- this.com = com; // 通用
- this.conf = config; // 配置
- this.request = {dp: dp, xhr: request, net: {crossDomainByScript: crossDomainByScript}}; // 请求
- this.bom = bom;
- this.corp = {
- fushi: fushi.init() // 福氏
- // 输出日志;
- };
- msg = "static load success. \u2668 \u8BBF\u95EE\u5E94\u7528: " + pageConfig.appType + " " + pageConfig.appName + " \xA9\uFE0F \u7248\u6743\u8BF7\u8BF7\u8054\u7CFB: https://www.aliwork.com/o/mc";
- console.log(msg, mjs, config$$1);
- case 12:
- case "end":
- return _context.stop();
- }
- }
- }, _callee, this);
- }));
- return function init(_x) {
- return _ref.apply(this, arguments);
- };
- }();
- exports.init = init;
- Object.defineProperty(exports, '__esModule', {value: true});
- })));
- //# sourceMappingURL=static.js.map
|