eventsource-polyfill.js 279 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088
  1. /******/ (function(modules) { // webpackBootstrap
  2. /******/ // The module cache
  3. /******/ var installedModules = {};
  4. /******/
  5. /******/ // The require function
  6. /******/ function __webpack_require__(moduleId) {
  7. /******/
  8. /******/ // Check if module is in cache
  9. /******/ if(installedModules[moduleId]) {
  10. /******/ return installedModules[moduleId].exports;
  11. /******/ }
  12. /******/ // Create a new module (and put it into the cache)
  13. /******/ var module = installedModules[moduleId] = {
  14. /******/ i: moduleId,
  15. /******/ l: false,
  16. /******/ exports: {}
  17. /******/ };
  18. /******/
  19. /******/ // Execute the module function
  20. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  21. /******/
  22. /******/ // Flag the module as loaded
  23. /******/ module.l = true;
  24. /******/
  25. /******/ // Return the exports of the module
  26. /******/ return module.exports;
  27. /******/ }
  28. /******/
  29. /******/
  30. /******/ // expose the modules object (__webpack_modules__)
  31. /******/ __webpack_require__.m = modules;
  32. /******/
  33. /******/ // expose the module cache
  34. /******/ __webpack_require__.c = installedModules;
  35. /******/
  36. /******/ // define getter function for harmony exports
  37. /******/ __webpack_require__.d = function(exports, name, getter) {
  38. /******/ if(!__webpack_require__.o(exports, name)) {
  39. /******/ Object.defineProperty(exports, name, {
  40. /******/ configurable: false,
  41. /******/ enumerable: true,
  42. /******/ get: getter
  43. /******/ });
  44. /******/ }
  45. /******/ };
  46. /******/
  47. /******/ // getDefaultExport function for compatibility with non-harmony modules
  48. /******/ __webpack_require__.n = function(module) {
  49. /******/ var getter = module && module.__esModule ?
  50. /******/ function getDefault() { return module['default']; } :
  51. /******/ function getModuleExports() { return module; };
  52. /******/ __webpack_require__.d(getter, 'a', getter);
  53. /******/ return getter;
  54. /******/ };
  55. /******/
  56. /******/ // Object.prototype.hasOwnProperty.call
  57. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  58. /******/
  59. /******/ // __webpack_public_path__
  60. /******/ __webpack_require__.p = "";
  61. /******/
  62. /******/ // Load entry module and return exports
  63. /******/ return __webpack_require__(__webpack_require__.s = 21);
  64. /******/ })
  65. /************************************************************************/
  66. /******/ ([
  67. /* 0 */
  68. /***/ (function(module, exports) {
  69. var g;
  70. // This works in non-strict mode
  71. g = (function() {
  72. return this;
  73. })();
  74. try {
  75. // This works if eval is allowed (see CSP)
  76. g = g || Function("return this")() || (1,eval)("this");
  77. } catch(e) {
  78. // This works if the window reference is available
  79. if(typeof window === "object")
  80. g = window;
  81. }
  82. // g can still be undefined, but nothing to do about it...
  83. // We return undefined, instead of nothing here, so it's
  84. // easier to handle this case. if(!global) { ...}
  85. module.exports = g;
  86. /***/ }),
  87. /* 1 */
  88. /***/ (function(module, exports) {
  89. // shim for using process in browser
  90. var process = module.exports = {};
  91. // cached from whatever global is present so that test runners that stub it
  92. // don't break things. But we need to wrap it in a try catch in case it is
  93. // wrapped in strict mode code which doesn't define any globals. It's inside a
  94. // function because try/catches deoptimize in certain engines.
  95. var cachedSetTimeout;
  96. var cachedClearTimeout;
  97. function defaultSetTimout() {
  98. throw new Error('setTimeout has not been defined');
  99. }
  100. function defaultClearTimeout () {
  101. throw new Error('clearTimeout has not been defined');
  102. }
  103. (function () {
  104. try {
  105. if (typeof setTimeout === 'function') {
  106. cachedSetTimeout = setTimeout;
  107. } else {
  108. cachedSetTimeout = defaultSetTimout;
  109. }
  110. } catch (e) {
  111. cachedSetTimeout = defaultSetTimout;
  112. }
  113. try {
  114. if (typeof clearTimeout === 'function') {
  115. cachedClearTimeout = clearTimeout;
  116. } else {
  117. cachedClearTimeout = defaultClearTimeout;
  118. }
  119. } catch (e) {
  120. cachedClearTimeout = defaultClearTimeout;
  121. }
  122. } ())
  123. function runTimeout(fun) {
  124. if (cachedSetTimeout === setTimeout) {
  125. //normal enviroments in sane situations
  126. return setTimeout(fun, 0);
  127. }
  128. // if setTimeout wasn't available but was latter defined
  129. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  130. cachedSetTimeout = setTimeout;
  131. return setTimeout(fun, 0);
  132. }
  133. try {
  134. // when when somebody has screwed with setTimeout but no I.E. maddness
  135. return cachedSetTimeout(fun, 0);
  136. } catch(e){
  137. try {
  138. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  139. return cachedSetTimeout.call(null, fun, 0);
  140. } catch(e){
  141. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
  142. return cachedSetTimeout.call(this, fun, 0);
  143. }
  144. }
  145. }
  146. function runClearTimeout(marker) {
  147. if (cachedClearTimeout === clearTimeout) {
  148. //normal enviroments in sane situations
  149. return clearTimeout(marker);
  150. }
  151. // if clearTimeout wasn't available but was latter defined
  152. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  153. cachedClearTimeout = clearTimeout;
  154. return clearTimeout(marker);
  155. }
  156. try {
  157. // when when somebody has screwed with setTimeout but no I.E. maddness
  158. return cachedClearTimeout(marker);
  159. } catch (e){
  160. try {
  161. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  162. return cachedClearTimeout.call(null, marker);
  163. } catch (e){
  164. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
  165. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  166. return cachedClearTimeout.call(this, marker);
  167. }
  168. }
  169. }
  170. var queue = [];
  171. var draining = false;
  172. var currentQueue;
  173. var queueIndex = -1;
  174. function cleanUpNextTick() {
  175. if (!draining || !currentQueue) {
  176. return;
  177. }
  178. draining = false;
  179. if (currentQueue.length) {
  180. queue = currentQueue.concat(queue);
  181. } else {
  182. queueIndex = -1;
  183. }
  184. if (queue.length) {
  185. drainQueue();
  186. }
  187. }
  188. function drainQueue() {
  189. if (draining) {
  190. return;
  191. }
  192. var timeout = runTimeout(cleanUpNextTick);
  193. draining = true;
  194. var len = queue.length;
  195. while(len) {
  196. currentQueue = queue;
  197. queue = [];
  198. while (++queueIndex < len) {
  199. if (currentQueue) {
  200. currentQueue[queueIndex].run();
  201. }
  202. }
  203. queueIndex = -1;
  204. len = queue.length;
  205. }
  206. currentQueue = null;
  207. draining = false;
  208. runClearTimeout(timeout);
  209. }
  210. process.nextTick = function (fun) {
  211. var args = new Array(arguments.length - 1);
  212. if (arguments.length > 1) {
  213. for (var i = 1; i < arguments.length; i++) {
  214. args[i - 1] = arguments[i];
  215. }
  216. }
  217. queue.push(new Item(fun, args));
  218. if (queue.length === 1 && !draining) {
  219. runTimeout(drainQueue);
  220. }
  221. };
  222. // v8 likes predictible objects
  223. function Item(fun, array) {
  224. this.fun = fun;
  225. this.array = array;
  226. }
  227. Item.prototype.run = function () {
  228. this.fun.apply(null, this.array);
  229. };
  230. process.title = 'browser';
  231. process.browser = true;
  232. process.env = {};
  233. process.argv = [];
  234. process.version = ''; // empty string to avoid regexp issues
  235. process.versions = {};
  236. function noop() {}
  237. process.on = noop;
  238. process.addListener = noop;
  239. process.once = noop;
  240. process.off = noop;
  241. process.removeListener = noop;
  242. process.removeAllListeners = noop;
  243. process.emit = noop;
  244. process.prependListener = noop;
  245. process.prependOnceListener = noop;
  246. process.listeners = function (name) { return [] }
  247. process.binding = function (name) {
  248. throw new Error('process.binding is not supported');
  249. };
  250. process.cwd = function () { return '/' };
  251. process.chdir = function (dir) {
  252. throw new Error('process.chdir is not supported');
  253. };
  254. process.umask = function() { return 0; };
  255. /***/ }),
  256. /* 2 */
  257. /***/ (function(module, exports, __webpack_require__) {
  258. "use strict";
  259. /* WEBPACK VAR INJECTION */(function(global) {/*!
  260. * The buffer module from node.js, for the browser.
  261. *
  262. * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
  263. * @license MIT
  264. */
  265. /* eslint-disable no-proto */
  266. var base64 = __webpack_require__(23)
  267. var ieee754 = __webpack_require__(24)
  268. var isArray = __webpack_require__(25)
  269. exports.Buffer = Buffer
  270. exports.SlowBuffer = SlowBuffer
  271. exports.INSPECT_MAX_BYTES = 50
  272. /**
  273. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  274. * === true Use Uint8Array implementation (fastest)
  275. * === false Use Object implementation (most compatible, even IE6)
  276. *
  277. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  278. * Opera 11.6+, iOS 4.2+.
  279. *
  280. * Due to various browser bugs, sometimes the Object implementation will be used even
  281. * when the browser supports typed arrays.
  282. *
  283. * Note:
  284. *
  285. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  286. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  287. *
  288. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  289. *
  290. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  291. * incorrect length in some situations.
  292. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  293. * get the Object implementation, which is slower but behaves correctly.
  294. */
  295. Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
  296. ? global.TYPED_ARRAY_SUPPORT
  297. : typedArraySupport()
  298. /*
  299. * Export kMaxLength after typed array support is determined.
  300. */
  301. exports.kMaxLength = kMaxLength()
  302. function typedArraySupport () {
  303. try {
  304. var arr = new Uint8Array(1)
  305. arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
  306. return arr.foo() === 42 && // typed array instances can be augmented
  307. typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
  308. arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
  309. } catch (e) {
  310. return false
  311. }
  312. }
  313. function kMaxLength () {
  314. return Buffer.TYPED_ARRAY_SUPPORT
  315. ? 0x7fffffff
  316. : 0x3fffffff
  317. }
  318. function createBuffer (that, length) {
  319. if (kMaxLength() < length) {
  320. throw new RangeError('Invalid typed array length')
  321. }
  322. if (Buffer.TYPED_ARRAY_SUPPORT) {
  323. // Return an augmented `Uint8Array` instance, for best performance
  324. that = new Uint8Array(length)
  325. that.__proto__ = Buffer.prototype
  326. } else {
  327. // Fallback: Return an object instance of the Buffer class
  328. if (that === null) {
  329. that = new Buffer(length)
  330. }
  331. that.length = length
  332. }
  333. return that
  334. }
  335. /**
  336. * The Buffer constructor returns instances of `Uint8Array` that have their
  337. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  338. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  339. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  340. * returns a single octet.
  341. *
  342. * The `Uint8Array` prototype remains unmodified.
  343. */
  344. function Buffer (arg, encodingOrOffset, length) {
  345. if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
  346. return new Buffer(arg, encodingOrOffset, length)
  347. }
  348. // Common case.
  349. if (typeof arg === 'number') {
  350. if (typeof encodingOrOffset === 'string') {
  351. throw new Error(
  352. 'If encoding is specified then the first argument must be a string'
  353. )
  354. }
  355. return allocUnsafe(this, arg)
  356. }
  357. return from(this, arg, encodingOrOffset, length)
  358. }
  359. Buffer.poolSize = 8192 // not used by this implementation
  360. // TODO: Legacy, not needed anymore. Remove in next major version.
  361. Buffer._augment = function (arr) {
  362. arr.__proto__ = Buffer.prototype
  363. return arr
  364. }
  365. function from (that, value, encodingOrOffset, length) {
  366. if (typeof value === 'number') {
  367. throw new TypeError('"value" argument must not be a number')
  368. }
  369. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  370. return fromArrayBuffer(that, value, encodingOrOffset, length)
  371. }
  372. if (typeof value === 'string') {
  373. return fromString(that, value, encodingOrOffset)
  374. }
  375. return fromObject(that, value)
  376. }
  377. /**
  378. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  379. * if value is a number.
  380. * Buffer.from(str[, encoding])
  381. * Buffer.from(array)
  382. * Buffer.from(buffer)
  383. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  384. **/
  385. Buffer.from = function (value, encodingOrOffset, length) {
  386. return from(null, value, encodingOrOffset, length)
  387. }
  388. if (Buffer.TYPED_ARRAY_SUPPORT) {
  389. Buffer.prototype.__proto__ = Uint8Array.prototype
  390. Buffer.__proto__ = Uint8Array
  391. if (typeof Symbol !== 'undefined' && Symbol.species &&
  392. Buffer[Symbol.species] === Buffer) {
  393. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  394. Object.defineProperty(Buffer, Symbol.species, {
  395. value: null,
  396. configurable: true
  397. })
  398. }
  399. }
  400. function assertSize (size) {
  401. if (typeof size !== 'number') {
  402. throw new TypeError('"size" argument must be a number')
  403. } else if (size < 0) {
  404. throw new RangeError('"size" argument must not be negative')
  405. }
  406. }
  407. function alloc (that, size, fill, encoding) {
  408. assertSize(size)
  409. if (size <= 0) {
  410. return createBuffer(that, size)
  411. }
  412. if (fill !== undefined) {
  413. // Only pay attention to encoding if it's a string. This
  414. // prevents accidentally sending in a number that would
  415. // be interpretted as a start offset.
  416. return typeof encoding === 'string'
  417. ? createBuffer(that, size).fill(fill, encoding)
  418. : createBuffer(that, size).fill(fill)
  419. }
  420. return createBuffer(that, size)
  421. }
  422. /**
  423. * Creates a new filled Buffer instance.
  424. * alloc(size[, fill[, encoding]])
  425. **/
  426. Buffer.alloc = function (size, fill, encoding) {
  427. return alloc(null, size, fill, encoding)
  428. }
  429. function allocUnsafe (that, size) {
  430. assertSize(size)
  431. that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
  432. if (!Buffer.TYPED_ARRAY_SUPPORT) {
  433. for (var i = 0; i < size; ++i) {
  434. that[i] = 0
  435. }
  436. }
  437. return that
  438. }
  439. /**
  440. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  441. * */
  442. Buffer.allocUnsafe = function (size) {
  443. return allocUnsafe(null, size)
  444. }
  445. /**
  446. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  447. */
  448. Buffer.allocUnsafeSlow = function (size) {
  449. return allocUnsafe(null, size)
  450. }
  451. function fromString (that, string, encoding) {
  452. if (typeof encoding !== 'string' || encoding === '') {
  453. encoding = 'utf8'
  454. }
  455. if (!Buffer.isEncoding(encoding)) {
  456. throw new TypeError('"encoding" must be a valid string encoding')
  457. }
  458. var length = byteLength(string, encoding) | 0
  459. that = createBuffer(that, length)
  460. var actual = that.write(string, encoding)
  461. if (actual !== length) {
  462. // Writing a hex string, for example, that contains invalid characters will
  463. // cause everything after the first invalid character to be ignored. (e.g.
  464. // 'abxxcd' will be treated as 'ab')
  465. that = that.slice(0, actual)
  466. }
  467. return that
  468. }
  469. function fromArrayLike (that, array) {
  470. var length = array.length < 0 ? 0 : checked(array.length) | 0
  471. that = createBuffer(that, length)
  472. for (var i = 0; i < length; i += 1) {
  473. that[i] = array[i] & 255
  474. }
  475. return that
  476. }
  477. function fromArrayBuffer (that, array, byteOffset, length) {
  478. array.byteLength // this throws if `array` is not a valid ArrayBuffer
  479. if (byteOffset < 0 || array.byteLength < byteOffset) {
  480. throw new RangeError('\'offset\' is out of bounds')
  481. }
  482. if (array.byteLength < byteOffset + (length || 0)) {
  483. throw new RangeError('\'length\' is out of bounds')
  484. }
  485. if (byteOffset === undefined && length === undefined) {
  486. array = new Uint8Array(array)
  487. } else if (length === undefined) {
  488. array = new Uint8Array(array, byteOffset)
  489. } else {
  490. array = new Uint8Array(array, byteOffset, length)
  491. }
  492. if (Buffer.TYPED_ARRAY_SUPPORT) {
  493. // Return an augmented `Uint8Array` instance, for best performance
  494. that = array
  495. that.__proto__ = Buffer.prototype
  496. } else {
  497. // Fallback: Return an object instance of the Buffer class
  498. that = fromArrayLike(that, array)
  499. }
  500. return that
  501. }
  502. function fromObject (that, obj) {
  503. if (Buffer.isBuffer(obj)) {
  504. var len = checked(obj.length) | 0
  505. that = createBuffer(that, len)
  506. if (that.length === 0) {
  507. return that
  508. }
  509. obj.copy(that, 0, 0, len)
  510. return that
  511. }
  512. if (obj) {
  513. if ((typeof ArrayBuffer !== 'undefined' &&
  514. obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
  515. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  516. return createBuffer(that, 0)
  517. }
  518. return fromArrayLike(that, obj)
  519. }
  520. if (obj.type === 'Buffer' && isArray(obj.data)) {
  521. return fromArrayLike(that, obj.data)
  522. }
  523. }
  524. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
  525. }
  526. function checked (length) {
  527. // Note: cannot use `length < kMaxLength()` here because that fails when
  528. // length is NaN (which is otherwise coerced to zero.)
  529. if (length >= kMaxLength()) {
  530. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  531. 'size: 0x' + kMaxLength().toString(16) + ' bytes')
  532. }
  533. return length | 0
  534. }
  535. function SlowBuffer (length) {
  536. if (+length != length) { // eslint-disable-line eqeqeq
  537. length = 0
  538. }
  539. return Buffer.alloc(+length)
  540. }
  541. Buffer.isBuffer = function isBuffer (b) {
  542. return !!(b != null && b._isBuffer)
  543. }
  544. Buffer.compare = function compare (a, b) {
  545. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  546. throw new TypeError('Arguments must be Buffers')
  547. }
  548. if (a === b) return 0
  549. var x = a.length
  550. var y = b.length
  551. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  552. if (a[i] !== b[i]) {
  553. x = a[i]
  554. y = b[i]
  555. break
  556. }
  557. }
  558. if (x < y) return -1
  559. if (y < x) return 1
  560. return 0
  561. }
  562. Buffer.isEncoding = function isEncoding (encoding) {
  563. switch (String(encoding).toLowerCase()) {
  564. case 'hex':
  565. case 'utf8':
  566. case 'utf-8':
  567. case 'ascii':
  568. case 'latin1':
  569. case 'binary':
  570. case 'base64':
  571. case 'ucs2':
  572. case 'ucs-2':
  573. case 'utf16le':
  574. case 'utf-16le':
  575. return true
  576. default:
  577. return false
  578. }
  579. }
  580. Buffer.concat = function concat (list, length) {
  581. if (!isArray(list)) {
  582. throw new TypeError('"list" argument must be an Array of Buffers')
  583. }
  584. if (list.length === 0) {
  585. return Buffer.alloc(0)
  586. }
  587. var i
  588. if (length === undefined) {
  589. length = 0
  590. for (i = 0; i < list.length; ++i) {
  591. length += list[i].length
  592. }
  593. }
  594. var buffer = Buffer.allocUnsafe(length)
  595. var pos = 0
  596. for (i = 0; i < list.length; ++i) {
  597. var buf = list[i]
  598. if (!Buffer.isBuffer(buf)) {
  599. throw new TypeError('"list" argument must be an Array of Buffers')
  600. }
  601. buf.copy(buffer, pos)
  602. pos += buf.length
  603. }
  604. return buffer
  605. }
  606. function byteLength (string, encoding) {
  607. if (Buffer.isBuffer(string)) {
  608. return string.length
  609. }
  610. if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
  611. (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
  612. return string.byteLength
  613. }
  614. if (typeof string !== 'string') {
  615. string = '' + string
  616. }
  617. var len = string.length
  618. if (len === 0) return 0
  619. // Use a for loop to avoid recursion
  620. var loweredCase = false
  621. for (;;) {
  622. switch (encoding) {
  623. case 'ascii':
  624. case 'latin1':
  625. case 'binary':
  626. return len
  627. case 'utf8':
  628. case 'utf-8':
  629. case undefined:
  630. return utf8ToBytes(string).length
  631. case 'ucs2':
  632. case 'ucs-2':
  633. case 'utf16le':
  634. case 'utf-16le':
  635. return len * 2
  636. case 'hex':
  637. return len >>> 1
  638. case 'base64':
  639. return base64ToBytes(string).length
  640. default:
  641. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  642. encoding = ('' + encoding).toLowerCase()
  643. loweredCase = true
  644. }
  645. }
  646. }
  647. Buffer.byteLength = byteLength
  648. function slowToString (encoding, start, end) {
  649. var loweredCase = false
  650. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  651. // property of a typed array.
  652. // This behaves neither like String nor Uint8Array in that we set start/end
  653. // to their upper/lower bounds if the value passed is out of range.
  654. // undefined is handled specially as per ECMA-262 6th Edition,
  655. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  656. if (start === undefined || start < 0) {
  657. start = 0
  658. }
  659. // Return early if start > this.length. Done here to prevent potential uint32
  660. // coercion fail below.
  661. if (start > this.length) {
  662. return ''
  663. }
  664. if (end === undefined || end > this.length) {
  665. end = this.length
  666. }
  667. if (end <= 0) {
  668. return ''
  669. }
  670. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  671. end >>>= 0
  672. start >>>= 0
  673. if (end <= start) {
  674. return ''
  675. }
  676. if (!encoding) encoding = 'utf8'
  677. while (true) {
  678. switch (encoding) {
  679. case 'hex':
  680. return hexSlice(this, start, end)
  681. case 'utf8':
  682. case 'utf-8':
  683. return utf8Slice(this, start, end)
  684. case 'ascii':
  685. return asciiSlice(this, start, end)
  686. case 'latin1':
  687. case 'binary':
  688. return latin1Slice(this, start, end)
  689. case 'base64':
  690. return base64Slice(this, start, end)
  691. case 'ucs2':
  692. case 'ucs-2':
  693. case 'utf16le':
  694. case 'utf-16le':
  695. return utf16leSlice(this, start, end)
  696. default:
  697. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  698. encoding = (encoding + '').toLowerCase()
  699. loweredCase = true
  700. }
  701. }
  702. }
  703. // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
  704. // Buffer instances.
  705. Buffer.prototype._isBuffer = true
  706. function swap (b, n, m) {
  707. var i = b[n]
  708. b[n] = b[m]
  709. b[m] = i
  710. }
  711. Buffer.prototype.swap16 = function swap16 () {
  712. var len = this.length
  713. if (len % 2 !== 0) {
  714. throw new RangeError('Buffer size must be a multiple of 16-bits')
  715. }
  716. for (var i = 0; i < len; i += 2) {
  717. swap(this, i, i + 1)
  718. }
  719. return this
  720. }
  721. Buffer.prototype.swap32 = function swap32 () {
  722. var len = this.length
  723. if (len % 4 !== 0) {
  724. throw new RangeError('Buffer size must be a multiple of 32-bits')
  725. }
  726. for (var i = 0; i < len; i += 4) {
  727. swap(this, i, i + 3)
  728. swap(this, i + 1, i + 2)
  729. }
  730. return this
  731. }
  732. Buffer.prototype.swap64 = function swap64 () {
  733. var len = this.length
  734. if (len % 8 !== 0) {
  735. throw new RangeError('Buffer size must be a multiple of 64-bits')
  736. }
  737. for (var i = 0; i < len; i += 8) {
  738. swap(this, i, i + 7)
  739. swap(this, i + 1, i + 6)
  740. swap(this, i + 2, i + 5)
  741. swap(this, i + 3, i + 4)
  742. }
  743. return this
  744. }
  745. Buffer.prototype.toString = function toString () {
  746. var length = this.length | 0
  747. if (length === 0) return ''
  748. if (arguments.length === 0) return utf8Slice(this, 0, length)
  749. return slowToString.apply(this, arguments)
  750. }
  751. Buffer.prototype.equals = function equals (b) {
  752. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  753. if (this === b) return true
  754. return Buffer.compare(this, b) === 0
  755. }
  756. Buffer.prototype.inspect = function inspect () {
  757. var str = ''
  758. var max = exports.INSPECT_MAX_BYTES
  759. if (this.length > 0) {
  760. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
  761. if (this.length > max) str += ' ... '
  762. }
  763. return '<Buffer ' + str + '>'
  764. }
  765. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  766. if (!Buffer.isBuffer(target)) {
  767. throw new TypeError('Argument must be a Buffer')
  768. }
  769. if (start === undefined) {
  770. start = 0
  771. }
  772. if (end === undefined) {
  773. end = target ? target.length : 0
  774. }
  775. if (thisStart === undefined) {
  776. thisStart = 0
  777. }
  778. if (thisEnd === undefined) {
  779. thisEnd = this.length
  780. }
  781. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  782. throw new RangeError('out of range index')
  783. }
  784. if (thisStart >= thisEnd && start >= end) {
  785. return 0
  786. }
  787. if (thisStart >= thisEnd) {
  788. return -1
  789. }
  790. if (start >= end) {
  791. return 1
  792. }
  793. start >>>= 0
  794. end >>>= 0
  795. thisStart >>>= 0
  796. thisEnd >>>= 0
  797. if (this === target) return 0
  798. var x = thisEnd - thisStart
  799. var y = end - start
  800. var len = Math.min(x, y)
  801. var thisCopy = this.slice(thisStart, thisEnd)
  802. var targetCopy = target.slice(start, end)
  803. for (var i = 0; i < len; ++i) {
  804. if (thisCopy[i] !== targetCopy[i]) {
  805. x = thisCopy[i]
  806. y = targetCopy[i]
  807. break
  808. }
  809. }
  810. if (x < y) return -1
  811. if (y < x) return 1
  812. return 0
  813. }
  814. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  815. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  816. //
  817. // Arguments:
  818. // - buffer - a Buffer to search
  819. // - val - a string, Buffer, or number
  820. // - byteOffset - an index into `buffer`; will be clamped to an int32
  821. // - encoding - an optional encoding, relevant is val is a string
  822. // - dir - true for indexOf, false for lastIndexOf
  823. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  824. // Empty buffer means no match
  825. if (buffer.length === 0) return -1
  826. // Normalize byteOffset
  827. if (typeof byteOffset === 'string') {
  828. encoding = byteOffset
  829. byteOffset = 0
  830. } else if (byteOffset > 0x7fffffff) {
  831. byteOffset = 0x7fffffff
  832. } else if (byteOffset < -0x80000000) {
  833. byteOffset = -0x80000000
  834. }
  835. byteOffset = +byteOffset // Coerce to Number.
  836. if (isNaN(byteOffset)) {
  837. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  838. byteOffset = dir ? 0 : (buffer.length - 1)
  839. }
  840. // Normalize byteOffset: negative offsets start from the end of the buffer
  841. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  842. if (byteOffset >= buffer.length) {
  843. if (dir) return -1
  844. else byteOffset = buffer.length - 1
  845. } else if (byteOffset < 0) {
  846. if (dir) byteOffset = 0
  847. else return -1
  848. }
  849. // Normalize val
  850. if (typeof val === 'string') {
  851. val = Buffer.from(val, encoding)
  852. }
  853. // Finally, search either indexOf (if dir is true) or lastIndexOf
  854. if (Buffer.isBuffer(val)) {
  855. // Special case: looking for empty string/buffer always fails
  856. if (val.length === 0) {
  857. return -1
  858. }
  859. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  860. } else if (typeof val === 'number') {
  861. val = val & 0xFF // Search for a byte value [0-255]
  862. if (Buffer.TYPED_ARRAY_SUPPORT &&
  863. typeof Uint8Array.prototype.indexOf === 'function') {
  864. if (dir) {
  865. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  866. } else {
  867. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  868. }
  869. }
  870. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  871. }
  872. throw new TypeError('val must be string, number or Buffer')
  873. }
  874. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  875. var indexSize = 1
  876. var arrLength = arr.length
  877. var valLength = val.length
  878. if (encoding !== undefined) {
  879. encoding = String(encoding).toLowerCase()
  880. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  881. encoding === 'utf16le' || encoding === 'utf-16le') {
  882. if (arr.length < 2 || val.length < 2) {
  883. return -1
  884. }
  885. indexSize = 2
  886. arrLength /= 2
  887. valLength /= 2
  888. byteOffset /= 2
  889. }
  890. }
  891. function read (buf, i) {
  892. if (indexSize === 1) {
  893. return buf[i]
  894. } else {
  895. return buf.readUInt16BE(i * indexSize)
  896. }
  897. }
  898. var i
  899. if (dir) {
  900. var foundIndex = -1
  901. for (i = byteOffset; i < arrLength; i++) {
  902. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  903. if (foundIndex === -1) foundIndex = i
  904. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  905. } else {
  906. if (foundIndex !== -1) i -= i - foundIndex
  907. foundIndex = -1
  908. }
  909. }
  910. } else {
  911. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  912. for (i = byteOffset; i >= 0; i--) {
  913. var found = true
  914. for (var j = 0; j < valLength; j++) {
  915. if (read(arr, i + j) !== read(val, j)) {
  916. found = false
  917. break
  918. }
  919. }
  920. if (found) return i
  921. }
  922. }
  923. return -1
  924. }
  925. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  926. return this.indexOf(val, byteOffset, encoding) !== -1
  927. }
  928. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  929. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  930. }
  931. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  932. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  933. }
  934. function hexWrite (buf, string, offset, length) {
  935. offset = Number(offset) || 0
  936. var remaining = buf.length - offset
  937. if (!length) {
  938. length = remaining
  939. } else {
  940. length = Number(length)
  941. if (length > remaining) {
  942. length = remaining
  943. }
  944. }
  945. // must be an even number of digits
  946. var strLen = string.length
  947. if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
  948. if (length > strLen / 2) {
  949. length = strLen / 2
  950. }
  951. for (var i = 0; i < length; ++i) {
  952. var parsed = parseInt(string.substr(i * 2, 2), 16)
  953. if (isNaN(parsed)) return i
  954. buf[offset + i] = parsed
  955. }
  956. return i
  957. }
  958. function utf8Write (buf, string, offset, length) {
  959. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  960. }
  961. function asciiWrite (buf, string, offset, length) {
  962. return blitBuffer(asciiToBytes(string), buf, offset, length)
  963. }
  964. function latin1Write (buf, string, offset, length) {
  965. return asciiWrite(buf, string, offset, length)
  966. }
  967. function base64Write (buf, string, offset, length) {
  968. return blitBuffer(base64ToBytes(string), buf, offset, length)
  969. }
  970. function ucs2Write (buf, string, offset, length) {
  971. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  972. }
  973. Buffer.prototype.write = function write (string, offset, length, encoding) {
  974. // Buffer#write(string)
  975. if (offset === undefined) {
  976. encoding = 'utf8'
  977. length = this.length
  978. offset = 0
  979. // Buffer#write(string, encoding)
  980. } else if (length === undefined && typeof offset === 'string') {
  981. encoding = offset
  982. length = this.length
  983. offset = 0
  984. // Buffer#write(string, offset[, length][, encoding])
  985. } else if (isFinite(offset)) {
  986. offset = offset | 0
  987. if (isFinite(length)) {
  988. length = length | 0
  989. if (encoding === undefined) encoding = 'utf8'
  990. } else {
  991. encoding = length
  992. length = undefined
  993. }
  994. // legacy write(string, encoding, offset, length) - remove in v0.13
  995. } else {
  996. throw new Error(
  997. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  998. )
  999. }
  1000. var remaining = this.length - offset
  1001. if (length === undefined || length > remaining) length = remaining
  1002. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  1003. throw new RangeError('Attempt to write outside buffer bounds')
  1004. }
  1005. if (!encoding) encoding = 'utf8'
  1006. var loweredCase = false
  1007. for (;;) {
  1008. switch (encoding) {
  1009. case 'hex':
  1010. return hexWrite(this, string, offset, length)
  1011. case 'utf8':
  1012. case 'utf-8':
  1013. return utf8Write(this, string, offset, length)
  1014. case 'ascii':
  1015. return asciiWrite(this, string, offset, length)
  1016. case 'latin1':
  1017. case 'binary':
  1018. return latin1Write(this, string, offset, length)
  1019. case 'base64':
  1020. // Warning: maxLength not taken into account in base64Write
  1021. return base64Write(this, string, offset, length)
  1022. case 'ucs2':
  1023. case 'ucs-2':
  1024. case 'utf16le':
  1025. case 'utf-16le':
  1026. return ucs2Write(this, string, offset, length)
  1027. default:
  1028. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  1029. encoding = ('' + encoding).toLowerCase()
  1030. loweredCase = true
  1031. }
  1032. }
  1033. }
  1034. Buffer.prototype.toJSON = function toJSON () {
  1035. return {
  1036. type: 'Buffer',
  1037. data: Array.prototype.slice.call(this._arr || this, 0)
  1038. }
  1039. }
  1040. function base64Slice (buf, start, end) {
  1041. if (start === 0 && end === buf.length) {
  1042. return base64.fromByteArray(buf)
  1043. } else {
  1044. return base64.fromByteArray(buf.slice(start, end))
  1045. }
  1046. }
  1047. function utf8Slice (buf, start, end) {
  1048. end = Math.min(buf.length, end)
  1049. var res = []
  1050. var i = start
  1051. while (i < end) {
  1052. var firstByte = buf[i]
  1053. var codePoint = null
  1054. var bytesPerSequence = (firstByte > 0xEF) ? 4
  1055. : (firstByte > 0xDF) ? 3
  1056. : (firstByte > 0xBF) ? 2
  1057. : 1
  1058. if (i + bytesPerSequence <= end) {
  1059. var secondByte, thirdByte, fourthByte, tempCodePoint
  1060. switch (bytesPerSequence) {
  1061. case 1:
  1062. if (firstByte < 0x80) {
  1063. codePoint = firstByte
  1064. }
  1065. break
  1066. case 2:
  1067. secondByte = buf[i + 1]
  1068. if ((secondByte & 0xC0) === 0x80) {
  1069. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  1070. if (tempCodePoint > 0x7F) {
  1071. codePoint = tempCodePoint
  1072. }
  1073. }
  1074. break
  1075. case 3:
  1076. secondByte = buf[i + 1]
  1077. thirdByte = buf[i + 2]
  1078. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  1079. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  1080. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  1081. codePoint = tempCodePoint
  1082. }
  1083. }
  1084. break
  1085. case 4:
  1086. secondByte = buf[i + 1]
  1087. thirdByte = buf[i + 2]
  1088. fourthByte = buf[i + 3]
  1089. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  1090. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  1091. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  1092. codePoint = tempCodePoint
  1093. }
  1094. }
  1095. }
  1096. }
  1097. if (codePoint === null) {
  1098. // we did not generate a valid codePoint so insert a
  1099. // replacement char (U+FFFD) and advance only 1 byte
  1100. codePoint = 0xFFFD
  1101. bytesPerSequence = 1
  1102. } else if (codePoint > 0xFFFF) {
  1103. // encode to utf16 (surrogate pair dance)
  1104. codePoint -= 0x10000
  1105. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  1106. codePoint = 0xDC00 | codePoint & 0x3FF
  1107. }
  1108. res.push(codePoint)
  1109. i += bytesPerSequence
  1110. }
  1111. return decodeCodePointsArray(res)
  1112. }
  1113. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  1114. // the lowest limit is Chrome, with 0x10000 args.
  1115. // We go 1 magnitude less, for safety
  1116. var MAX_ARGUMENTS_LENGTH = 0x1000
  1117. function decodeCodePointsArray (codePoints) {
  1118. var len = codePoints.length
  1119. if (len <= MAX_ARGUMENTS_LENGTH) {
  1120. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  1121. }
  1122. // Decode in chunks to avoid "call stack size exceeded".
  1123. var res = ''
  1124. var i = 0
  1125. while (i < len) {
  1126. res += String.fromCharCode.apply(
  1127. String,
  1128. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  1129. )
  1130. }
  1131. return res
  1132. }
  1133. function asciiSlice (buf, start, end) {
  1134. var ret = ''
  1135. end = Math.min(buf.length, end)
  1136. for (var i = start; i < end; ++i) {
  1137. ret += String.fromCharCode(buf[i] & 0x7F)
  1138. }
  1139. return ret
  1140. }
  1141. function latin1Slice (buf, start, end) {
  1142. var ret = ''
  1143. end = Math.min(buf.length, end)
  1144. for (var i = start; i < end; ++i) {
  1145. ret += String.fromCharCode(buf[i])
  1146. }
  1147. return ret
  1148. }
  1149. function hexSlice (buf, start, end) {
  1150. var len = buf.length
  1151. if (!start || start < 0) start = 0
  1152. if (!end || end < 0 || end > len) end = len
  1153. var out = ''
  1154. for (var i = start; i < end; ++i) {
  1155. out += toHex(buf[i])
  1156. }
  1157. return out
  1158. }
  1159. function utf16leSlice (buf, start, end) {
  1160. var bytes = buf.slice(start, end)
  1161. var res = ''
  1162. for (var i = 0; i < bytes.length; i += 2) {
  1163. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
  1164. }
  1165. return res
  1166. }
  1167. Buffer.prototype.slice = function slice (start, end) {
  1168. var len = this.length
  1169. start = ~~start
  1170. end = end === undefined ? len : ~~end
  1171. if (start < 0) {
  1172. start += len
  1173. if (start < 0) start = 0
  1174. } else if (start > len) {
  1175. start = len
  1176. }
  1177. if (end < 0) {
  1178. end += len
  1179. if (end < 0) end = 0
  1180. } else if (end > len) {
  1181. end = len
  1182. }
  1183. if (end < start) end = start
  1184. var newBuf
  1185. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1186. newBuf = this.subarray(start, end)
  1187. newBuf.__proto__ = Buffer.prototype
  1188. } else {
  1189. var sliceLen = end - start
  1190. newBuf = new Buffer(sliceLen, undefined)
  1191. for (var i = 0; i < sliceLen; ++i) {
  1192. newBuf[i] = this[i + start]
  1193. }
  1194. }
  1195. return newBuf
  1196. }
  1197. /*
  1198. * Need to make sure that buffer isn't trying to write out of bounds.
  1199. */
  1200. function checkOffset (offset, ext, length) {
  1201. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  1202. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  1203. }
  1204. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  1205. offset = offset | 0
  1206. byteLength = byteLength | 0
  1207. if (!noAssert) checkOffset(offset, byteLength, this.length)
  1208. var val = this[offset]
  1209. var mul = 1
  1210. var i = 0
  1211. while (++i < byteLength && (mul *= 0x100)) {
  1212. val += this[offset + i] * mul
  1213. }
  1214. return val
  1215. }
  1216. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  1217. offset = offset | 0
  1218. byteLength = byteLength | 0
  1219. if (!noAssert) {
  1220. checkOffset(offset, byteLength, this.length)
  1221. }
  1222. var val = this[offset + --byteLength]
  1223. var mul = 1
  1224. while (byteLength > 0 && (mul *= 0x100)) {
  1225. val += this[offset + --byteLength] * mul
  1226. }
  1227. return val
  1228. }
  1229. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  1230. if (!noAssert) checkOffset(offset, 1, this.length)
  1231. return this[offset]
  1232. }
  1233. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  1234. if (!noAssert) checkOffset(offset, 2, this.length)
  1235. return this[offset] | (this[offset + 1] << 8)
  1236. }
  1237. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  1238. if (!noAssert) checkOffset(offset, 2, this.length)
  1239. return (this[offset] << 8) | this[offset + 1]
  1240. }
  1241. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  1242. if (!noAssert) checkOffset(offset, 4, this.length)
  1243. return ((this[offset]) |
  1244. (this[offset + 1] << 8) |
  1245. (this[offset + 2] << 16)) +
  1246. (this[offset + 3] * 0x1000000)
  1247. }
  1248. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  1249. if (!noAssert) checkOffset(offset, 4, this.length)
  1250. return (this[offset] * 0x1000000) +
  1251. ((this[offset + 1] << 16) |
  1252. (this[offset + 2] << 8) |
  1253. this[offset + 3])
  1254. }
  1255. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  1256. offset = offset | 0
  1257. byteLength = byteLength | 0
  1258. if (!noAssert) checkOffset(offset, byteLength, this.length)
  1259. var val = this[offset]
  1260. var mul = 1
  1261. var i = 0
  1262. while (++i < byteLength && (mul *= 0x100)) {
  1263. val += this[offset + i] * mul
  1264. }
  1265. mul *= 0x80
  1266. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  1267. return val
  1268. }
  1269. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  1270. offset = offset | 0
  1271. byteLength = byteLength | 0
  1272. if (!noAssert) checkOffset(offset, byteLength, this.length)
  1273. var i = byteLength
  1274. var mul = 1
  1275. var val = this[offset + --i]
  1276. while (i > 0 && (mul *= 0x100)) {
  1277. val += this[offset + --i] * mul
  1278. }
  1279. mul *= 0x80
  1280. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  1281. return val
  1282. }
  1283. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  1284. if (!noAssert) checkOffset(offset, 1, this.length)
  1285. if (!(this[offset] & 0x80)) return (this[offset])
  1286. return ((0xff - this[offset] + 1) * -1)
  1287. }
  1288. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  1289. if (!noAssert) checkOffset(offset, 2, this.length)
  1290. var val = this[offset] | (this[offset + 1] << 8)
  1291. return (val & 0x8000) ? val | 0xFFFF0000 : val
  1292. }
  1293. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  1294. if (!noAssert) checkOffset(offset, 2, this.length)
  1295. var val = this[offset + 1] | (this[offset] << 8)
  1296. return (val & 0x8000) ? val | 0xFFFF0000 : val
  1297. }
  1298. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  1299. if (!noAssert) checkOffset(offset, 4, this.length)
  1300. return (this[offset]) |
  1301. (this[offset + 1] << 8) |
  1302. (this[offset + 2] << 16) |
  1303. (this[offset + 3] << 24)
  1304. }
  1305. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  1306. if (!noAssert) checkOffset(offset, 4, this.length)
  1307. return (this[offset] << 24) |
  1308. (this[offset + 1] << 16) |
  1309. (this[offset + 2] << 8) |
  1310. (this[offset + 3])
  1311. }
  1312. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  1313. if (!noAssert) checkOffset(offset, 4, this.length)
  1314. return ieee754.read(this, offset, true, 23, 4)
  1315. }
  1316. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  1317. if (!noAssert) checkOffset(offset, 4, this.length)
  1318. return ieee754.read(this, offset, false, 23, 4)
  1319. }
  1320. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  1321. if (!noAssert) checkOffset(offset, 8, this.length)
  1322. return ieee754.read(this, offset, true, 52, 8)
  1323. }
  1324. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  1325. if (!noAssert) checkOffset(offset, 8, this.length)
  1326. return ieee754.read(this, offset, false, 52, 8)
  1327. }
  1328. function checkInt (buf, value, offset, ext, max, min) {
  1329. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  1330. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  1331. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  1332. }
  1333. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  1334. value = +value
  1335. offset = offset | 0
  1336. byteLength = byteLength | 0
  1337. if (!noAssert) {
  1338. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  1339. checkInt(this, value, offset, byteLength, maxBytes, 0)
  1340. }
  1341. var mul = 1
  1342. var i = 0
  1343. this[offset] = value & 0xFF
  1344. while (++i < byteLength && (mul *= 0x100)) {
  1345. this[offset + i] = (value / mul) & 0xFF
  1346. }
  1347. return offset + byteLength
  1348. }
  1349. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  1350. value = +value
  1351. offset = offset | 0
  1352. byteLength = byteLength | 0
  1353. if (!noAssert) {
  1354. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  1355. checkInt(this, value, offset, byteLength, maxBytes, 0)
  1356. }
  1357. var i = byteLength - 1
  1358. var mul = 1
  1359. this[offset + i] = value & 0xFF
  1360. while (--i >= 0 && (mul *= 0x100)) {
  1361. this[offset + i] = (value / mul) & 0xFF
  1362. }
  1363. return offset + byteLength
  1364. }
  1365. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  1366. value = +value
  1367. offset = offset | 0
  1368. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  1369. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  1370. this[offset] = (value & 0xff)
  1371. return offset + 1
  1372. }
  1373. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  1374. if (value < 0) value = 0xffff + value + 1
  1375. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
  1376. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  1377. (littleEndian ? i : 1 - i) * 8
  1378. }
  1379. }
  1380. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  1381. value = +value
  1382. offset = offset | 0
  1383. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  1384. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1385. this[offset] = (value & 0xff)
  1386. this[offset + 1] = (value >>> 8)
  1387. } else {
  1388. objectWriteUInt16(this, value, offset, true)
  1389. }
  1390. return offset + 2
  1391. }
  1392. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  1393. value = +value
  1394. offset = offset | 0
  1395. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  1396. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1397. this[offset] = (value >>> 8)
  1398. this[offset + 1] = (value & 0xff)
  1399. } else {
  1400. objectWriteUInt16(this, value, offset, false)
  1401. }
  1402. return offset + 2
  1403. }
  1404. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  1405. if (value < 0) value = 0xffffffff + value + 1
  1406. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
  1407. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
  1408. }
  1409. }
  1410. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  1411. value = +value
  1412. offset = offset | 0
  1413. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  1414. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1415. this[offset + 3] = (value >>> 24)
  1416. this[offset + 2] = (value >>> 16)
  1417. this[offset + 1] = (value >>> 8)
  1418. this[offset] = (value & 0xff)
  1419. } else {
  1420. objectWriteUInt32(this, value, offset, true)
  1421. }
  1422. return offset + 4
  1423. }
  1424. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  1425. value = +value
  1426. offset = offset | 0
  1427. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  1428. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1429. this[offset] = (value >>> 24)
  1430. this[offset + 1] = (value >>> 16)
  1431. this[offset + 2] = (value >>> 8)
  1432. this[offset + 3] = (value & 0xff)
  1433. } else {
  1434. objectWriteUInt32(this, value, offset, false)
  1435. }
  1436. return offset + 4
  1437. }
  1438. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  1439. value = +value
  1440. offset = offset | 0
  1441. if (!noAssert) {
  1442. var limit = Math.pow(2, 8 * byteLength - 1)
  1443. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  1444. }
  1445. var i = 0
  1446. var mul = 1
  1447. var sub = 0
  1448. this[offset] = value & 0xFF
  1449. while (++i < byteLength && (mul *= 0x100)) {
  1450. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  1451. sub = 1
  1452. }
  1453. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  1454. }
  1455. return offset + byteLength
  1456. }
  1457. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  1458. value = +value
  1459. offset = offset | 0
  1460. if (!noAssert) {
  1461. var limit = Math.pow(2, 8 * byteLength - 1)
  1462. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  1463. }
  1464. var i = byteLength - 1
  1465. var mul = 1
  1466. var sub = 0
  1467. this[offset + i] = value & 0xFF
  1468. while (--i >= 0 && (mul *= 0x100)) {
  1469. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  1470. sub = 1
  1471. }
  1472. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  1473. }
  1474. return offset + byteLength
  1475. }
  1476. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  1477. value = +value
  1478. offset = offset | 0
  1479. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  1480. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  1481. if (value < 0) value = 0xff + value + 1
  1482. this[offset] = (value & 0xff)
  1483. return offset + 1
  1484. }
  1485. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  1486. value = +value
  1487. offset = offset | 0
  1488. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  1489. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1490. this[offset] = (value & 0xff)
  1491. this[offset + 1] = (value >>> 8)
  1492. } else {
  1493. objectWriteUInt16(this, value, offset, true)
  1494. }
  1495. return offset + 2
  1496. }
  1497. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  1498. value = +value
  1499. offset = offset | 0
  1500. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  1501. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1502. this[offset] = (value >>> 8)
  1503. this[offset + 1] = (value & 0xff)
  1504. } else {
  1505. objectWriteUInt16(this, value, offset, false)
  1506. }
  1507. return offset + 2
  1508. }
  1509. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  1510. value = +value
  1511. offset = offset | 0
  1512. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  1513. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1514. this[offset] = (value & 0xff)
  1515. this[offset + 1] = (value >>> 8)
  1516. this[offset + 2] = (value >>> 16)
  1517. this[offset + 3] = (value >>> 24)
  1518. } else {
  1519. objectWriteUInt32(this, value, offset, true)
  1520. }
  1521. return offset + 4
  1522. }
  1523. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  1524. value = +value
  1525. offset = offset | 0
  1526. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  1527. if (value < 0) value = 0xffffffff + value + 1
  1528. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1529. this[offset] = (value >>> 24)
  1530. this[offset + 1] = (value >>> 16)
  1531. this[offset + 2] = (value >>> 8)
  1532. this[offset + 3] = (value & 0xff)
  1533. } else {
  1534. objectWriteUInt32(this, value, offset, false)
  1535. }
  1536. return offset + 4
  1537. }
  1538. function checkIEEE754 (buf, value, offset, ext, max, min) {
  1539. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  1540. if (offset < 0) throw new RangeError('Index out of range')
  1541. }
  1542. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  1543. if (!noAssert) {
  1544. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  1545. }
  1546. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  1547. return offset + 4
  1548. }
  1549. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  1550. return writeFloat(this, value, offset, true, noAssert)
  1551. }
  1552. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  1553. return writeFloat(this, value, offset, false, noAssert)
  1554. }
  1555. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  1556. if (!noAssert) {
  1557. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  1558. }
  1559. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  1560. return offset + 8
  1561. }
  1562. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  1563. return writeDouble(this, value, offset, true, noAssert)
  1564. }
  1565. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  1566. return writeDouble(this, value, offset, false, noAssert)
  1567. }
  1568. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  1569. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  1570. if (!start) start = 0
  1571. if (!end && end !== 0) end = this.length
  1572. if (targetStart >= target.length) targetStart = target.length
  1573. if (!targetStart) targetStart = 0
  1574. if (end > 0 && end < start) end = start
  1575. // Copy 0 bytes; we're done
  1576. if (end === start) return 0
  1577. if (target.length === 0 || this.length === 0) return 0
  1578. // Fatal error conditions
  1579. if (targetStart < 0) {
  1580. throw new RangeError('targetStart out of bounds')
  1581. }
  1582. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  1583. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  1584. // Are we oob?
  1585. if (end > this.length) end = this.length
  1586. if (target.length - targetStart < end - start) {
  1587. end = target.length - targetStart + start
  1588. }
  1589. var len = end - start
  1590. var i
  1591. if (this === target && start < targetStart && targetStart < end) {
  1592. // descending copy from end
  1593. for (i = len - 1; i >= 0; --i) {
  1594. target[i + targetStart] = this[i + start]
  1595. }
  1596. } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
  1597. // ascending copy from start
  1598. for (i = 0; i < len; ++i) {
  1599. target[i + targetStart] = this[i + start]
  1600. }
  1601. } else {
  1602. Uint8Array.prototype.set.call(
  1603. target,
  1604. this.subarray(start, start + len),
  1605. targetStart
  1606. )
  1607. }
  1608. return len
  1609. }
  1610. // Usage:
  1611. // buffer.fill(number[, offset[, end]])
  1612. // buffer.fill(buffer[, offset[, end]])
  1613. // buffer.fill(string[, offset[, end]][, encoding])
  1614. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  1615. // Handle string cases:
  1616. if (typeof val === 'string') {
  1617. if (typeof start === 'string') {
  1618. encoding = start
  1619. start = 0
  1620. end = this.length
  1621. } else if (typeof end === 'string') {
  1622. encoding = end
  1623. end = this.length
  1624. }
  1625. if (val.length === 1) {
  1626. var code = val.charCodeAt(0)
  1627. if (code < 256) {
  1628. val = code
  1629. }
  1630. }
  1631. if (encoding !== undefined && typeof encoding !== 'string') {
  1632. throw new TypeError('encoding must be a string')
  1633. }
  1634. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  1635. throw new TypeError('Unknown encoding: ' + encoding)
  1636. }
  1637. } else if (typeof val === 'number') {
  1638. val = val & 255
  1639. }
  1640. // Invalid ranges are not set to a default, so can range check early.
  1641. if (start < 0 || this.length < start || this.length < end) {
  1642. throw new RangeError('Out of range index')
  1643. }
  1644. if (end <= start) {
  1645. return this
  1646. }
  1647. start = start >>> 0
  1648. end = end === undefined ? this.length : end >>> 0
  1649. if (!val) val = 0
  1650. var i
  1651. if (typeof val === 'number') {
  1652. for (i = start; i < end; ++i) {
  1653. this[i] = val
  1654. }
  1655. } else {
  1656. var bytes = Buffer.isBuffer(val)
  1657. ? val
  1658. : utf8ToBytes(new Buffer(val, encoding).toString())
  1659. var len = bytes.length
  1660. for (i = 0; i < end - start; ++i) {
  1661. this[i + start] = bytes[i % len]
  1662. }
  1663. }
  1664. return this
  1665. }
  1666. // HELPER FUNCTIONS
  1667. // ================
  1668. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
  1669. function base64clean (str) {
  1670. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  1671. str = stringtrim(str).replace(INVALID_BASE64_RE, '')
  1672. // Node converts strings with length < 2 to ''
  1673. if (str.length < 2) return ''
  1674. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  1675. while (str.length % 4 !== 0) {
  1676. str = str + '='
  1677. }
  1678. return str
  1679. }
  1680. function stringtrim (str) {
  1681. if (str.trim) return str.trim()
  1682. return str.replace(/^\s+|\s+$/g, '')
  1683. }
  1684. function toHex (n) {
  1685. if (n < 16) return '0' + n.toString(16)
  1686. return n.toString(16)
  1687. }
  1688. function utf8ToBytes (string, units) {
  1689. units = units || Infinity
  1690. var codePoint
  1691. var length = string.length
  1692. var leadSurrogate = null
  1693. var bytes = []
  1694. for (var i = 0; i < length; ++i) {
  1695. codePoint = string.charCodeAt(i)
  1696. // is surrogate component
  1697. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  1698. // last char was a lead
  1699. if (!leadSurrogate) {
  1700. // no lead yet
  1701. if (codePoint > 0xDBFF) {
  1702. // unexpected trail
  1703. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  1704. continue
  1705. } else if (i + 1 === length) {
  1706. // unpaired lead
  1707. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  1708. continue
  1709. }
  1710. // valid lead
  1711. leadSurrogate = codePoint
  1712. continue
  1713. }
  1714. // 2 leads in a row
  1715. if (codePoint < 0xDC00) {
  1716. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  1717. leadSurrogate = codePoint
  1718. continue
  1719. }
  1720. // valid surrogate pair
  1721. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  1722. } else if (leadSurrogate) {
  1723. // valid bmp char, but last char was a lead
  1724. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  1725. }
  1726. leadSurrogate = null
  1727. // encode utf8
  1728. if (codePoint < 0x80) {
  1729. if ((units -= 1) < 0) break
  1730. bytes.push(codePoint)
  1731. } else if (codePoint < 0x800) {
  1732. if ((units -= 2) < 0) break
  1733. bytes.push(
  1734. codePoint >> 0x6 | 0xC0,
  1735. codePoint & 0x3F | 0x80
  1736. )
  1737. } else if (codePoint < 0x10000) {
  1738. if ((units -= 3) < 0) break
  1739. bytes.push(
  1740. codePoint >> 0xC | 0xE0,
  1741. codePoint >> 0x6 & 0x3F | 0x80,
  1742. codePoint & 0x3F | 0x80
  1743. )
  1744. } else if (codePoint < 0x110000) {
  1745. if ((units -= 4) < 0) break
  1746. bytes.push(
  1747. codePoint >> 0x12 | 0xF0,
  1748. codePoint >> 0xC & 0x3F | 0x80,
  1749. codePoint >> 0x6 & 0x3F | 0x80,
  1750. codePoint & 0x3F | 0x80
  1751. )
  1752. } else {
  1753. throw new Error('Invalid code point')
  1754. }
  1755. }
  1756. return bytes
  1757. }
  1758. function asciiToBytes (str) {
  1759. var byteArray = []
  1760. for (var i = 0; i < str.length; ++i) {
  1761. // Node's code seems to be doing this and not & 0x7F..
  1762. byteArray.push(str.charCodeAt(i) & 0xFF)
  1763. }
  1764. return byteArray
  1765. }
  1766. function utf16leToBytes (str, units) {
  1767. var c, hi, lo
  1768. var byteArray = []
  1769. for (var i = 0; i < str.length; ++i) {
  1770. if ((units -= 2) < 0) break
  1771. c = str.charCodeAt(i)
  1772. hi = c >> 8
  1773. lo = c % 256
  1774. byteArray.push(lo)
  1775. byteArray.push(hi)
  1776. }
  1777. return byteArray
  1778. }
  1779. function base64ToBytes (str) {
  1780. return base64.toByteArray(base64clean(str))
  1781. }
  1782. function blitBuffer (src, dst, offset, length) {
  1783. for (var i = 0; i < length; ++i) {
  1784. if ((i + offset >= dst.length) || (i >= src.length)) break
  1785. dst[i + offset] = src[i]
  1786. }
  1787. return i
  1788. }
  1789. function isnan (val) {
  1790. return val !== val // eslint-disable-line no-self-compare
  1791. }
  1792. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
  1793. /***/ }),
  1794. /* 3 */
  1795. /***/ (function(module, exports, __webpack_require__) {
  1796. "use strict";
  1797. // Copyright Joyent, Inc. and other Node contributors.
  1798. //
  1799. // Permission is hereby granted, free of charge, to any person obtaining a
  1800. // copy of this software and associated documentation files (the
  1801. // "Software"), to deal in the Software without restriction, including
  1802. // without limitation the rights to use, copy, modify, merge, publish,
  1803. // distribute, sublicense, and/or sell copies of the Software, and to permit
  1804. // persons to whom the Software is furnished to do so, subject to the
  1805. // following conditions:
  1806. //
  1807. // The above copyright notice and this permission notice shall be included
  1808. // in all copies or substantial portions of the Software.
  1809. //
  1810. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  1811. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  1812. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  1813. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  1814. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  1815. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  1816. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  1817. // a duplex stream is just a stream that is both readable and writable.
  1818. // Since JS doesn't have multiple prototypal inheritance, this class
  1819. // prototypally inherits from Readable, and then parasitically from
  1820. // Writable.
  1821. /*<replacement>*/
  1822. var pna = __webpack_require__(6);
  1823. /*</replacement>*/
  1824. /*<replacement>*/
  1825. var objectKeys = Object.keys || function (obj) {
  1826. var keys = [];
  1827. for (var key in obj) {
  1828. keys.push(key);
  1829. }return keys;
  1830. };
  1831. /*</replacement>*/
  1832. module.exports = Duplex;
  1833. /*<replacement>*/
  1834. var util = __webpack_require__(4);
  1835. util.inherits = __webpack_require__(5);
  1836. /*</replacement>*/
  1837. var Readable = __webpack_require__(15);
  1838. var Writable = __webpack_require__(18);
  1839. util.inherits(Duplex, Readable);
  1840. {
  1841. // avoid scope creep, the keys array can then be collected
  1842. var keys = objectKeys(Writable.prototype);
  1843. for (var v = 0; v < keys.length; v++) {
  1844. var method = keys[v];
  1845. if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
  1846. }
  1847. }
  1848. function Duplex(options) {
  1849. if (!(this instanceof Duplex)) return new Duplex(options);
  1850. Readable.call(this, options);
  1851. Writable.call(this, options);
  1852. if (options && options.readable === false) this.readable = false;
  1853. if (options && options.writable === false) this.writable = false;
  1854. this.allowHalfOpen = true;
  1855. if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
  1856. this.once('end', onend);
  1857. }
  1858. Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
  1859. // making it explicit this property is not enumerable
  1860. // because otherwise some prototype manipulation in
  1861. // userland will fail
  1862. enumerable: false,
  1863. get: function () {
  1864. return this._writableState.highWaterMark;
  1865. }
  1866. });
  1867. // the no-half-open enforcer
  1868. function onend() {
  1869. // if we allow half-open state, or if the writable side ended,
  1870. // then we're ok.
  1871. if (this.allowHalfOpen || this._writableState.ended) return;
  1872. // no more data can be written.
  1873. // But allow more writes to happen in this tick.
  1874. pna.nextTick(onEndNT, this);
  1875. }
  1876. function onEndNT(self) {
  1877. self.end();
  1878. }
  1879. Object.defineProperty(Duplex.prototype, 'destroyed', {
  1880. get: function () {
  1881. if (this._readableState === undefined || this._writableState === undefined) {
  1882. return false;
  1883. }
  1884. return this._readableState.destroyed && this._writableState.destroyed;
  1885. },
  1886. set: function (value) {
  1887. // we ignore the value if the stream
  1888. // has not been initialized yet
  1889. if (this._readableState === undefined || this._writableState === undefined) {
  1890. return;
  1891. }
  1892. // backward compatibility, the user is explicitly
  1893. // managing destroyed
  1894. this._readableState.destroyed = value;
  1895. this._writableState.destroyed = value;
  1896. }
  1897. });
  1898. Duplex.prototype._destroy = function (err, cb) {
  1899. this.push(null);
  1900. this.end();
  1901. pna.nextTick(cb, err);
  1902. };
  1903. /***/ }),
  1904. /* 4 */
  1905. /***/ (function(module, exports, __webpack_require__) {
  1906. /* WEBPACK VAR INJECTION */(function(Buffer) {// Copyright Joyent, Inc. and other Node contributors.
  1907. //
  1908. // Permission is hereby granted, free of charge, to any person obtaining a
  1909. // copy of this software and associated documentation files (the
  1910. // "Software"), to deal in the Software without restriction, including
  1911. // without limitation the rights to use, copy, modify, merge, publish,
  1912. // distribute, sublicense, and/or sell copies of the Software, and to permit
  1913. // persons to whom the Software is furnished to do so, subject to the
  1914. // following conditions:
  1915. //
  1916. // The above copyright notice and this permission notice shall be included
  1917. // in all copies or substantial portions of the Software.
  1918. //
  1919. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  1920. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  1921. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  1922. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  1923. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  1924. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  1925. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  1926. // NOTE: These type checking functions intentionally don't use `instanceof`
  1927. // because it is fragile and can be easily faked with `Object.create()`.
  1928. function isArray(arg) {
  1929. if (Array.isArray) {
  1930. return Array.isArray(arg);
  1931. }
  1932. return objectToString(arg) === '[object Array]';
  1933. }
  1934. exports.isArray = isArray;
  1935. function isBoolean(arg) {
  1936. return typeof arg === 'boolean';
  1937. }
  1938. exports.isBoolean = isBoolean;
  1939. function isNull(arg) {
  1940. return arg === null;
  1941. }
  1942. exports.isNull = isNull;
  1943. function isNullOrUndefined(arg) {
  1944. return arg == null;
  1945. }
  1946. exports.isNullOrUndefined = isNullOrUndefined;
  1947. function isNumber(arg) {
  1948. return typeof arg === 'number';
  1949. }
  1950. exports.isNumber = isNumber;
  1951. function isString(arg) {
  1952. return typeof arg === 'string';
  1953. }
  1954. exports.isString = isString;
  1955. function isSymbol(arg) {
  1956. return typeof arg === 'symbol';
  1957. }
  1958. exports.isSymbol = isSymbol;
  1959. function isUndefined(arg) {
  1960. return arg === void 0;
  1961. }
  1962. exports.isUndefined = isUndefined;
  1963. function isRegExp(re) {
  1964. return objectToString(re) === '[object RegExp]';
  1965. }
  1966. exports.isRegExp = isRegExp;
  1967. function isObject(arg) {
  1968. return typeof arg === 'object' && arg !== null;
  1969. }
  1970. exports.isObject = isObject;
  1971. function isDate(d) {
  1972. return objectToString(d) === '[object Date]';
  1973. }
  1974. exports.isDate = isDate;
  1975. function isError(e) {
  1976. return (objectToString(e) === '[object Error]' || e instanceof Error);
  1977. }
  1978. exports.isError = isError;
  1979. function isFunction(arg) {
  1980. return typeof arg === 'function';
  1981. }
  1982. exports.isFunction = isFunction;
  1983. function isPrimitive(arg) {
  1984. return arg === null ||
  1985. typeof arg === 'boolean' ||
  1986. typeof arg === 'number' ||
  1987. typeof arg === 'string' ||
  1988. typeof arg === 'symbol' || // ES6 symbol
  1989. typeof arg === 'undefined';
  1990. }
  1991. exports.isPrimitive = isPrimitive;
  1992. exports.isBuffer = Buffer.isBuffer;
  1993. function objectToString(o) {
  1994. return Object.prototype.toString.call(o);
  1995. }
  1996. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2).Buffer))
  1997. /***/ }),
  1998. /* 5 */
  1999. /***/ (function(module, exports) {
  2000. if (typeof Object.create === 'function') {
  2001. // implementation from standard node.js 'util' module
  2002. module.exports = function inherits(ctor, superCtor) {
  2003. ctor.super_ = superCtor
  2004. ctor.prototype = Object.create(superCtor.prototype, {
  2005. constructor: {
  2006. value: ctor,
  2007. enumerable: false,
  2008. writable: true,
  2009. configurable: true
  2010. }
  2011. });
  2012. };
  2013. } else {
  2014. // old school shim for old browsers
  2015. module.exports = function inherits(ctor, superCtor) {
  2016. ctor.super_ = superCtor
  2017. var TempCtor = function () {}
  2018. TempCtor.prototype = superCtor.prototype
  2019. ctor.prototype = new TempCtor()
  2020. ctor.prototype.constructor = ctor
  2021. }
  2022. }
  2023. /***/ }),
  2024. /* 6 */
  2025. /***/ (function(module, exports, __webpack_require__) {
  2026. "use strict";
  2027. /* WEBPACK VAR INJECTION */(function(process) {
  2028. if (!process.version ||
  2029. process.version.indexOf('v0.') === 0 ||
  2030. process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
  2031. module.exports = { nextTick: nextTick };
  2032. } else {
  2033. module.exports = process
  2034. }
  2035. function nextTick(fn, arg1, arg2, arg3) {
  2036. if (typeof fn !== 'function') {
  2037. throw new TypeError('"callback" argument must be a function');
  2038. }
  2039. var len = arguments.length;
  2040. var args, i;
  2041. switch (len) {
  2042. case 0:
  2043. case 1:
  2044. return process.nextTick(fn);
  2045. case 2:
  2046. return process.nextTick(function afterTickOne() {
  2047. fn.call(null, arg1);
  2048. });
  2049. case 3:
  2050. return process.nextTick(function afterTickTwo() {
  2051. fn.call(null, arg1, arg2);
  2052. });
  2053. case 4:
  2054. return process.nextTick(function afterTickThree() {
  2055. fn.call(null, arg1, arg2, arg3);
  2056. });
  2057. default:
  2058. args = new Array(len - 1);
  2059. i = 0;
  2060. while (i < args.length) {
  2061. args[i++] = arguments[i];
  2062. }
  2063. return process.nextTick(function afterTick() {
  2064. fn.apply(null, args);
  2065. });
  2066. }
  2067. }
  2068. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1)))
  2069. /***/ }),
  2070. /* 7 */
  2071. /***/ (function(module, exports, __webpack_require__) {
  2072. "use strict";
  2073. // Copyright Joyent, Inc. and other Node contributors.
  2074. //
  2075. // Permission is hereby granted, free of charge, to any person obtaining a
  2076. // copy of this software and associated documentation files (the
  2077. // "Software"), to deal in the Software without restriction, including
  2078. // without limitation the rights to use, copy, modify, merge, publish,
  2079. // distribute, sublicense, and/or sell copies of the Software, and to permit
  2080. // persons to whom the Software is furnished to do so, subject to the
  2081. // following conditions:
  2082. //
  2083. // The above copyright notice and this permission notice shall be included
  2084. // in all copies or substantial portions of the Software.
  2085. //
  2086. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  2087. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  2088. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  2089. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  2090. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  2091. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  2092. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  2093. var punycode = __webpack_require__(30);
  2094. var util = __webpack_require__(32);
  2095. exports.parse = urlParse;
  2096. exports.resolve = urlResolve;
  2097. exports.resolveObject = urlResolveObject;
  2098. exports.format = urlFormat;
  2099. exports.Url = Url;
  2100. function Url() {
  2101. this.protocol = null;
  2102. this.slashes = null;
  2103. this.auth = null;
  2104. this.host = null;
  2105. this.port = null;
  2106. this.hostname = null;
  2107. this.hash = null;
  2108. this.search = null;
  2109. this.query = null;
  2110. this.pathname = null;
  2111. this.path = null;
  2112. this.href = null;
  2113. }
  2114. // Reference: RFC 3986, RFC 1808, RFC 2396
  2115. // define these here so at least they only have to be
  2116. // compiled once on the first module load.
  2117. var protocolPattern = /^([a-z0-9.+-]+:)/i,
  2118. portPattern = /:[0-9]*$/,
  2119. // Special case for a simple path URL
  2120. simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,
  2121. // RFC 2396: characters reserved for delimiting URLs.
  2122. // We actually just auto-escape these.
  2123. delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
  2124. // RFC 2396: characters not allowed for various reasons.
  2125. unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims),
  2126. // Allowed by RFCs, but cause of XSS attacks. Always escape these.
  2127. autoEscape = ['\''].concat(unwise),
  2128. // Characters that are never ever allowed in a hostname.
  2129. // Note that any invalid chars are also handled, but these
  2130. // are the ones that are *expected* to be seen, so we fast-path
  2131. // them.
  2132. nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape),
  2133. hostEndingChars = ['/', '?', '#'],
  2134. hostnameMaxLen = 255,
  2135. hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,
  2136. hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,
  2137. // protocols that can allow "unsafe" and "unwise" chars.
  2138. unsafeProtocol = {
  2139. 'javascript': true,
  2140. 'javascript:': true
  2141. },
  2142. // protocols that never have a hostname.
  2143. hostlessProtocol = {
  2144. 'javascript': true,
  2145. 'javascript:': true
  2146. },
  2147. // protocols that always contain a // bit.
  2148. slashedProtocol = {
  2149. 'http': true,
  2150. 'https': true,
  2151. 'ftp': true,
  2152. 'gopher': true,
  2153. 'file': true,
  2154. 'http:': true,
  2155. 'https:': true,
  2156. 'ftp:': true,
  2157. 'gopher:': true,
  2158. 'file:': true
  2159. },
  2160. querystring = __webpack_require__(33);
  2161. function urlParse(url, parseQueryString, slashesDenoteHost) {
  2162. if (url && util.isObject(url) && url instanceof Url) return url;
  2163. var u = new Url;
  2164. u.parse(url, parseQueryString, slashesDenoteHost);
  2165. return u;
  2166. }
  2167. Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
  2168. if (!util.isString(url)) {
  2169. throw new TypeError("Parameter 'url' must be a string, not " + typeof url);
  2170. }
  2171. // Copy chrome, IE, opera backslash-handling behavior.
  2172. // Back slashes before the query string get converted to forward slashes
  2173. // See: https://code.google.com/p/chromium/issues/detail?id=25916
  2174. var queryIndex = url.indexOf('?'),
  2175. splitter =
  2176. (queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#',
  2177. uSplit = url.split(splitter),
  2178. slashRegex = /\\/g;
  2179. uSplit[0] = uSplit[0].replace(slashRegex, '/');
  2180. url = uSplit.join(splitter);
  2181. var rest = url;
  2182. // trim before proceeding.
  2183. // This is to support parse stuff like " http://foo.com \n"
  2184. rest = rest.trim();
  2185. if (!slashesDenoteHost && url.split('#').length === 1) {
  2186. // Try fast path regexp
  2187. var simplePath = simplePathPattern.exec(rest);
  2188. if (simplePath) {
  2189. this.path = rest;
  2190. this.href = rest;
  2191. this.pathname = simplePath[1];
  2192. if (simplePath[2]) {
  2193. this.search = simplePath[2];
  2194. if (parseQueryString) {
  2195. this.query = querystring.parse(this.search.substr(1));
  2196. } else {
  2197. this.query = this.search.substr(1);
  2198. }
  2199. } else if (parseQueryString) {
  2200. this.search = '';
  2201. this.query = {};
  2202. }
  2203. return this;
  2204. }
  2205. }
  2206. var proto = protocolPattern.exec(rest);
  2207. if (proto) {
  2208. proto = proto[0];
  2209. var lowerProto = proto.toLowerCase();
  2210. this.protocol = lowerProto;
  2211. rest = rest.substr(proto.length);
  2212. }
  2213. // figure out if it's got a host
  2214. // user@server is *always* interpreted as a hostname, and url
  2215. // resolution will treat //foo/bar as host=foo,path=bar because that's
  2216. // how the browser resolves relative URLs.
  2217. if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
  2218. var slashes = rest.substr(0, 2) === '//';
  2219. if (slashes && !(proto && hostlessProtocol[proto])) {
  2220. rest = rest.substr(2);
  2221. this.slashes = true;
  2222. }
  2223. }
  2224. if (!hostlessProtocol[proto] &&
  2225. (slashes || (proto && !slashedProtocol[proto]))) {
  2226. // there's a hostname.
  2227. // the first instance of /, ?, ;, or # ends the host.
  2228. //
  2229. // If there is an @ in the hostname, then non-host chars *are* allowed
  2230. // to the left of the last @ sign, unless some host-ending character
  2231. // comes *before* the @-sign.
  2232. // URLs are obnoxious.
  2233. //
  2234. // ex:
  2235. // http://a@b@c/ => user:a@b host:c
  2236. // http://a@b?@c => user:a host:c path:/?@c
  2237. // v0.12 TODO(isaacs): This is not quite how Chrome does things.
  2238. // Review our test case against browsers more comprehensively.
  2239. // find the first instance of any hostEndingChars
  2240. var hostEnd = -1;
  2241. for (var i = 0; i < hostEndingChars.length; i++) {
  2242. var hec = rest.indexOf(hostEndingChars[i]);
  2243. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
  2244. hostEnd = hec;
  2245. }
  2246. // at this point, either we have an explicit point where the
  2247. // auth portion cannot go past, or the last @ char is the decider.
  2248. var auth, atSign;
  2249. if (hostEnd === -1) {
  2250. // atSign can be anywhere.
  2251. atSign = rest.lastIndexOf('@');
  2252. } else {
  2253. // atSign must be in auth portion.
  2254. // http://a@b/c@d => host:b auth:a path:/c@d
  2255. atSign = rest.lastIndexOf('@', hostEnd);
  2256. }
  2257. // Now we have a portion which is definitely the auth.
  2258. // Pull that off.
  2259. if (atSign !== -1) {
  2260. auth = rest.slice(0, atSign);
  2261. rest = rest.slice(atSign + 1);
  2262. this.auth = decodeURIComponent(auth);
  2263. }
  2264. // the host is the remaining to the left of the first non-host char
  2265. hostEnd = -1;
  2266. for (var i = 0; i < nonHostChars.length; i++) {
  2267. var hec = rest.indexOf(nonHostChars[i]);
  2268. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
  2269. hostEnd = hec;
  2270. }
  2271. // if we still have not hit it, then the entire thing is a host.
  2272. if (hostEnd === -1)
  2273. hostEnd = rest.length;
  2274. this.host = rest.slice(0, hostEnd);
  2275. rest = rest.slice(hostEnd);
  2276. // pull out port.
  2277. this.parseHost();
  2278. // we've indicated that there is a hostname,
  2279. // so even if it's empty, it has to be present.
  2280. this.hostname = this.hostname || '';
  2281. // if hostname begins with [ and ends with ]
  2282. // assume that it's an IPv6 address.
  2283. var ipv6Hostname = this.hostname[0] === '[' &&
  2284. this.hostname[this.hostname.length - 1] === ']';
  2285. // validate a little.
  2286. if (!ipv6Hostname) {
  2287. var hostparts = this.hostname.split(/\./);
  2288. for (var i = 0, l = hostparts.length; i < l; i++) {
  2289. var part = hostparts[i];
  2290. if (!part) continue;
  2291. if (!part.match(hostnamePartPattern)) {
  2292. var newpart = '';
  2293. for (var j = 0, k = part.length; j < k; j++) {
  2294. if (part.charCodeAt(j) > 127) {
  2295. // we replace non-ASCII char with a temporary placeholder
  2296. // we need this to make sure size of hostname is not
  2297. // broken by replacing non-ASCII by nothing
  2298. newpart += 'x';
  2299. } else {
  2300. newpart += part[j];
  2301. }
  2302. }
  2303. // we test again with ASCII char only
  2304. if (!newpart.match(hostnamePartPattern)) {
  2305. var validParts = hostparts.slice(0, i);
  2306. var notHost = hostparts.slice(i + 1);
  2307. var bit = part.match(hostnamePartStart);
  2308. if (bit) {
  2309. validParts.push(bit[1]);
  2310. notHost.unshift(bit[2]);
  2311. }
  2312. if (notHost.length) {
  2313. rest = '/' + notHost.join('.') + rest;
  2314. }
  2315. this.hostname = validParts.join('.');
  2316. break;
  2317. }
  2318. }
  2319. }
  2320. }
  2321. if (this.hostname.length > hostnameMaxLen) {
  2322. this.hostname = '';
  2323. } else {
  2324. // hostnames are always lower case.
  2325. this.hostname = this.hostname.toLowerCase();
  2326. }
  2327. if (!ipv6Hostname) {
  2328. // IDNA Support: Returns a punycoded representation of "domain".
  2329. // It only converts parts of the domain name that
  2330. // have non-ASCII characters, i.e. it doesn't matter if
  2331. // you call it with a domain that already is ASCII-only.
  2332. this.hostname = punycode.toASCII(this.hostname);
  2333. }
  2334. var p = this.port ? ':' + this.port : '';
  2335. var h = this.hostname || '';
  2336. this.host = h + p;
  2337. this.href += this.host;
  2338. // strip [ and ] from the hostname
  2339. // the host field still retains them, though
  2340. if (ipv6Hostname) {
  2341. this.hostname = this.hostname.substr(1, this.hostname.length - 2);
  2342. if (rest[0] !== '/') {
  2343. rest = '/' + rest;
  2344. }
  2345. }
  2346. }
  2347. // now rest is set to the post-host stuff.
  2348. // chop off any delim chars.
  2349. if (!unsafeProtocol[lowerProto]) {
  2350. // First, make 100% sure that any "autoEscape" chars get
  2351. // escaped, even if encodeURIComponent doesn't think they
  2352. // need to be.
  2353. for (var i = 0, l = autoEscape.length; i < l; i++) {
  2354. var ae = autoEscape[i];
  2355. if (rest.indexOf(ae) === -1)
  2356. continue;
  2357. var esc = encodeURIComponent(ae);
  2358. if (esc === ae) {
  2359. esc = escape(ae);
  2360. }
  2361. rest = rest.split(ae).join(esc);
  2362. }
  2363. }
  2364. // chop off from the tail first.
  2365. var hash = rest.indexOf('#');
  2366. if (hash !== -1) {
  2367. // got a fragment string.
  2368. this.hash = rest.substr(hash);
  2369. rest = rest.slice(0, hash);
  2370. }
  2371. var qm = rest.indexOf('?');
  2372. if (qm !== -1) {
  2373. this.search = rest.substr(qm);
  2374. this.query = rest.substr(qm + 1);
  2375. if (parseQueryString) {
  2376. this.query = querystring.parse(this.query);
  2377. }
  2378. rest = rest.slice(0, qm);
  2379. } else if (parseQueryString) {
  2380. // no query string, but parseQueryString still requested
  2381. this.search = '';
  2382. this.query = {};
  2383. }
  2384. if (rest) this.pathname = rest;
  2385. if (slashedProtocol[lowerProto] &&
  2386. this.hostname && !this.pathname) {
  2387. this.pathname = '/';
  2388. }
  2389. //to support http.request
  2390. if (this.pathname || this.search) {
  2391. var p = this.pathname || '';
  2392. var s = this.search || '';
  2393. this.path = p + s;
  2394. }
  2395. // finally, reconstruct the href based on what has been validated.
  2396. this.href = this.format();
  2397. return this;
  2398. };
  2399. // format a parsed object into a url string
  2400. function urlFormat(obj) {
  2401. // ensure it's an object, and not a string url.
  2402. // If it's an obj, this is a no-op.
  2403. // this way, you can call url_format() on strings
  2404. // to clean up potentially wonky urls.
  2405. if (util.isString(obj)) obj = urlParse(obj);
  2406. if (!(obj instanceof Url)) return Url.prototype.format.call(obj);
  2407. return obj.format();
  2408. }
  2409. Url.prototype.format = function() {
  2410. var auth = this.auth || '';
  2411. if (auth) {
  2412. auth = encodeURIComponent(auth);
  2413. auth = auth.replace(/%3A/i, ':');
  2414. auth += '@';
  2415. }
  2416. var protocol = this.protocol || '',
  2417. pathname = this.pathname || '',
  2418. hash = this.hash || '',
  2419. host = false,
  2420. query = '';
  2421. if (this.host) {
  2422. host = auth + this.host;
  2423. } else if (this.hostname) {
  2424. host = auth + (this.hostname.indexOf(':') === -1 ?
  2425. this.hostname :
  2426. '[' + this.hostname + ']');
  2427. if (this.port) {
  2428. host += ':' + this.port;
  2429. }
  2430. }
  2431. if (this.query &&
  2432. util.isObject(this.query) &&
  2433. Object.keys(this.query).length) {
  2434. query = querystring.stringify(this.query);
  2435. }
  2436. var search = this.search || (query && ('?' + query)) || '';
  2437. if (protocol && protocol.substr(-1) !== ':') protocol += ':';
  2438. // only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
  2439. // unless they had them to begin with.
  2440. if (this.slashes ||
  2441. (!protocol || slashedProtocol[protocol]) && host !== false) {
  2442. host = '//' + (host || '');
  2443. if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname;
  2444. } else if (!host) {
  2445. host = '';
  2446. }
  2447. if (hash && hash.charAt(0) !== '#') hash = '#' + hash;
  2448. if (search && search.charAt(0) !== '?') search = '?' + search;
  2449. pathname = pathname.replace(/[?#]/g, function(match) {
  2450. return encodeURIComponent(match);
  2451. });
  2452. search = search.replace('#', '%23');
  2453. return protocol + host + pathname + search + hash;
  2454. };
  2455. function urlResolve(source, relative) {
  2456. return urlParse(source, false, true).resolve(relative);
  2457. }
  2458. Url.prototype.resolve = function(relative) {
  2459. return this.resolveObject(urlParse(relative, false, true)).format();
  2460. };
  2461. function urlResolveObject(source, relative) {
  2462. if (!source) return relative;
  2463. return urlParse(source, false, true).resolveObject(relative);
  2464. }
  2465. Url.prototype.resolveObject = function(relative) {
  2466. if (util.isString(relative)) {
  2467. var rel = new Url();
  2468. rel.parse(relative, false, true);
  2469. relative = rel;
  2470. }
  2471. var result = new Url();
  2472. var tkeys = Object.keys(this);
  2473. for (var tk = 0; tk < tkeys.length; tk++) {
  2474. var tkey = tkeys[tk];
  2475. result[tkey] = this[tkey];
  2476. }
  2477. // hash is always overridden, no matter what.
  2478. // even href="" will remove it.
  2479. result.hash = relative.hash;
  2480. // if the relative url is empty, then there's nothing left to do here.
  2481. if (relative.href === '') {
  2482. result.href = result.format();
  2483. return result;
  2484. }
  2485. // hrefs like //foo/bar always cut to the protocol.
  2486. if (relative.slashes && !relative.protocol) {
  2487. // take everything except the protocol from relative
  2488. var rkeys = Object.keys(relative);
  2489. for (var rk = 0; rk < rkeys.length; rk++) {
  2490. var rkey = rkeys[rk];
  2491. if (rkey !== 'protocol')
  2492. result[rkey] = relative[rkey];
  2493. }
  2494. //urlParse appends trailing / to urls like http://www.example.com
  2495. if (slashedProtocol[result.protocol] &&
  2496. result.hostname && !result.pathname) {
  2497. result.path = result.pathname = '/';
  2498. }
  2499. result.href = result.format();
  2500. return result;
  2501. }
  2502. if (relative.protocol && relative.protocol !== result.protocol) {
  2503. // if it's a known url protocol, then changing
  2504. // the protocol does weird things
  2505. // first, if it's not file:, then we MUST have a host,
  2506. // and if there was a path
  2507. // to begin with, then we MUST have a path.
  2508. // if it is file:, then the host is dropped,
  2509. // because that's known to be hostless.
  2510. // anything else is assumed to be absolute.
  2511. if (!slashedProtocol[relative.protocol]) {
  2512. var keys = Object.keys(relative);
  2513. for (var v = 0; v < keys.length; v++) {
  2514. var k = keys[v];
  2515. result[k] = relative[k];
  2516. }
  2517. result.href = result.format();
  2518. return result;
  2519. }
  2520. result.protocol = relative.protocol;
  2521. if (!relative.host && !hostlessProtocol[relative.protocol]) {
  2522. var relPath = (relative.pathname || '').split('/');
  2523. while (relPath.length && !(relative.host = relPath.shift()));
  2524. if (!relative.host) relative.host = '';
  2525. if (!relative.hostname) relative.hostname = '';
  2526. if (relPath[0] !== '') relPath.unshift('');
  2527. if (relPath.length < 2) relPath.unshift('');
  2528. result.pathname = relPath.join('/');
  2529. } else {
  2530. result.pathname = relative.pathname;
  2531. }
  2532. result.search = relative.search;
  2533. result.query = relative.query;
  2534. result.host = relative.host || '';
  2535. result.auth = relative.auth;
  2536. result.hostname = relative.hostname || relative.host;
  2537. result.port = relative.port;
  2538. // to support http.request
  2539. if (result.pathname || result.search) {
  2540. var p = result.pathname || '';
  2541. var s = result.search || '';
  2542. result.path = p + s;
  2543. }
  2544. result.slashes = result.slashes || relative.slashes;
  2545. result.href = result.format();
  2546. return result;
  2547. }
  2548. var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'),
  2549. isRelAbs = (
  2550. relative.host ||
  2551. relative.pathname && relative.pathname.charAt(0) === '/'
  2552. ),
  2553. mustEndAbs = (isRelAbs || isSourceAbs ||
  2554. (result.host && relative.pathname)),
  2555. removeAllDots = mustEndAbs,
  2556. srcPath = result.pathname && result.pathname.split('/') || [],
  2557. relPath = relative.pathname && relative.pathname.split('/') || [],
  2558. psychotic = result.protocol && !slashedProtocol[result.protocol];
  2559. // if the url is a non-slashed url, then relative
  2560. // links like ../.. should be able
  2561. // to crawl up to the hostname, as well. This is strange.
  2562. // result.protocol has already been set by now.
  2563. // Later on, put the first path part into the host field.
  2564. if (psychotic) {
  2565. result.hostname = '';
  2566. result.port = null;
  2567. if (result.host) {
  2568. if (srcPath[0] === '') srcPath[0] = result.host;
  2569. else srcPath.unshift(result.host);
  2570. }
  2571. result.host = '';
  2572. if (relative.protocol) {
  2573. relative.hostname = null;
  2574. relative.port = null;
  2575. if (relative.host) {
  2576. if (relPath[0] === '') relPath[0] = relative.host;
  2577. else relPath.unshift(relative.host);
  2578. }
  2579. relative.host = null;
  2580. }
  2581. mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');
  2582. }
  2583. if (isRelAbs) {
  2584. // it's absolute.
  2585. result.host = (relative.host || relative.host === '') ?
  2586. relative.host : result.host;
  2587. result.hostname = (relative.hostname || relative.hostname === '') ?
  2588. relative.hostname : result.hostname;
  2589. result.search = relative.search;
  2590. result.query = relative.query;
  2591. srcPath = relPath;
  2592. // fall through to the dot-handling below.
  2593. } else if (relPath.length) {
  2594. // it's relative
  2595. // throw away the existing file, and take the new path instead.
  2596. if (!srcPath) srcPath = [];
  2597. srcPath.pop();
  2598. srcPath = srcPath.concat(relPath);
  2599. result.search = relative.search;
  2600. result.query = relative.query;
  2601. } else if (!util.isNullOrUndefined(relative.search)) {
  2602. // just pull out the search.
  2603. // like href='?foo'.
  2604. // Put this after the other two cases because it simplifies the booleans
  2605. if (psychotic) {
  2606. result.hostname = result.host = srcPath.shift();
  2607. //occationaly the auth can get stuck only in host
  2608. //this especially happens in cases like
  2609. //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
  2610. var authInHost = result.host && result.host.indexOf('@') > 0 ?
  2611. result.host.split('@') : false;
  2612. if (authInHost) {
  2613. result.auth = authInHost.shift();
  2614. result.host = result.hostname = authInHost.shift();
  2615. }
  2616. }
  2617. result.search = relative.search;
  2618. result.query = relative.query;
  2619. //to support http.request
  2620. if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
  2621. result.path = (result.pathname ? result.pathname : '') +
  2622. (result.search ? result.search : '');
  2623. }
  2624. result.href = result.format();
  2625. return result;
  2626. }
  2627. if (!srcPath.length) {
  2628. // no path at all. easy.
  2629. // we've already handled the other stuff above.
  2630. result.pathname = null;
  2631. //to support http.request
  2632. if (result.search) {
  2633. result.path = '/' + result.search;
  2634. } else {
  2635. result.path = null;
  2636. }
  2637. result.href = result.format();
  2638. return result;
  2639. }
  2640. // if a url ENDs in . or .., then it must get a trailing slash.
  2641. // however, if it ends in anything else non-slashy,
  2642. // then it must NOT get a trailing slash.
  2643. var last = srcPath.slice(-1)[0];
  2644. var hasTrailingSlash = (
  2645. (result.host || relative.host || srcPath.length > 1) &&
  2646. (last === '.' || last === '..') || last === '');
  2647. // strip single dots, resolve double dots to parent dir
  2648. // if the path tries to go above the root, `up` ends up > 0
  2649. var up = 0;
  2650. for (var i = srcPath.length; i >= 0; i--) {
  2651. last = srcPath[i];
  2652. if (last === '.') {
  2653. srcPath.splice(i, 1);
  2654. } else if (last === '..') {
  2655. srcPath.splice(i, 1);
  2656. up++;
  2657. } else if (up) {
  2658. srcPath.splice(i, 1);
  2659. up--;
  2660. }
  2661. }
  2662. // if the path is allowed to go above the root, restore leading ..s
  2663. if (!mustEndAbs && !removeAllDots) {
  2664. for (; up--; up) {
  2665. srcPath.unshift('..');
  2666. }
  2667. }
  2668. if (mustEndAbs && srcPath[0] !== '' &&
  2669. (!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
  2670. srcPath.unshift('');
  2671. }
  2672. if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) {
  2673. srcPath.push('');
  2674. }
  2675. var isAbsolute = srcPath[0] === '' ||
  2676. (srcPath[0] && srcPath[0].charAt(0) === '/');
  2677. // put the host back
  2678. if (psychotic) {
  2679. result.hostname = result.host = isAbsolute ? '' :
  2680. srcPath.length ? srcPath.shift() : '';
  2681. //occationaly the auth can get stuck only in host
  2682. //this especially happens in cases like
  2683. //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
  2684. var authInHost = result.host && result.host.indexOf('@') > 0 ?
  2685. result.host.split('@') : false;
  2686. if (authInHost) {
  2687. result.auth = authInHost.shift();
  2688. result.host = result.hostname = authInHost.shift();
  2689. }
  2690. }
  2691. mustEndAbs = mustEndAbs || (result.host && srcPath.length);
  2692. if (mustEndAbs && !isAbsolute) {
  2693. srcPath.unshift('');
  2694. }
  2695. if (!srcPath.length) {
  2696. result.pathname = null;
  2697. result.path = null;
  2698. } else {
  2699. result.pathname = srcPath.join('/');
  2700. }
  2701. //to support request.http
  2702. if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
  2703. result.path = (result.pathname ? result.pathname : '') +
  2704. (result.search ? result.search : '');
  2705. }
  2706. result.auth = relative.auth || result.auth;
  2707. result.slashes = result.slashes || relative.slashes;
  2708. result.href = result.format();
  2709. return result;
  2710. };
  2711. Url.prototype.parseHost = function() {
  2712. var host = this.host;
  2713. var port = portPattern.exec(host);
  2714. if (port) {
  2715. port = port[0];
  2716. if (port !== ':') {
  2717. this.port = port.substr(1);
  2718. }
  2719. host = host.substr(0, host.length - port.length);
  2720. }
  2721. if (host) this.hostname = host;
  2722. };
  2723. /***/ }),
  2724. /* 8 */
  2725. /***/ (function(module, exports) {
  2726. // Copyright Joyent, Inc. and other Node contributors.
  2727. //
  2728. // Permission is hereby granted, free of charge, to any person obtaining a
  2729. // copy of this software and associated documentation files (the
  2730. // "Software"), to deal in the Software without restriction, including
  2731. // without limitation the rights to use, copy, modify, merge, publish,
  2732. // distribute, sublicense, and/or sell copies of the Software, and to permit
  2733. // persons to whom the Software is furnished to do so, subject to the
  2734. // following conditions:
  2735. //
  2736. // The above copyright notice and this permission notice shall be included
  2737. // in all copies or substantial portions of the Software.
  2738. //
  2739. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  2740. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  2741. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  2742. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  2743. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  2744. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  2745. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  2746. function EventEmitter() {
  2747. this._events = this._events || {};
  2748. this._maxListeners = this._maxListeners || undefined;
  2749. }
  2750. module.exports = EventEmitter;
  2751. // Backwards-compat with node 0.10.x
  2752. EventEmitter.EventEmitter = EventEmitter;
  2753. EventEmitter.prototype._events = undefined;
  2754. EventEmitter.prototype._maxListeners = undefined;
  2755. // By default EventEmitters will print a warning if more than 10 listeners are
  2756. // added to it. This is a useful default which helps finding memory leaks.
  2757. EventEmitter.defaultMaxListeners = 10;
  2758. // Obviously not all Emitters should be limited to 10. This function allows
  2759. // that to be increased. Set to zero for unlimited.
  2760. EventEmitter.prototype.setMaxListeners = function(n) {
  2761. if (!isNumber(n) || n < 0 || isNaN(n))
  2762. throw TypeError('n must be a positive number');
  2763. this._maxListeners = n;
  2764. return this;
  2765. };
  2766. EventEmitter.prototype.emit = function(type) {
  2767. var er, handler, len, args, i, listeners;
  2768. if (!this._events)
  2769. this._events = {};
  2770. // If there is no 'error' event listener then throw.
  2771. if (type === 'error') {
  2772. if (!this._events.error ||
  2773. (isObject(this._events.error) && !this._events.error.length)) {
  2774. er = arguments[1];
  2775. if (er instanceof Error) {
  2776. throw er; // Unhandled 'error' event
  2777. } else {
  2778. // At least give some kind of context to the user
  2779. var err = new Error('Uncaught, unspecified "error" event. (' + er + ')');
  2780. err.context = er;
  2781. throw err;
  2782. }
  2783. }
  2784. }
  2785. handler = this._events[type];
  2786. if (isUndefined(handler))
  2787. return false;
  2788. if (isFunction(handler)) {
  2789. switch (arguments.length) {
  2790. // fast cases
  2791. case 1:
  2792. handler.call(this);
  2793. break;
  2794. case 2:
  2795. handler.call(this, arguments[1]);
  2796. break;
  2797. case 3:
  2798. handler.call(this, arguments[1], arguments[2]);
  2799. break;
  2800. // slower
  2801. default:
  2802. args = Array.prototype.slice.call(arguments, 1);
  2803. handler.apply(this, args);
  2804. }
  2805. } else if (isObject(handler)) {
  2806. args = Array.prototype.slice.call(arguments, 1);
  2807. listeners = handler.slice();
  2808. len = listeners.length;
  2809. for (i = 0; i < len; i++)
  2810. listeners[i].apply(this, args);
  2811. }
  2812. return true;
  2813. };
  2814. EventEmitter.prototype.addListener = function(type, listener) {
  2815. var m;
  2816. if (!isFunction(listener))
  2817. throw TypeError('listener must be a function');
  2818. if (!this._events)
  2819. this._events = {};
  2820. // To avoid recursion in the case that type === "newListener"! Before
  2821. // adding it to the listeners, first emit "newListener".
  2822. if (this._events.newListener)
  2823. this.emit('newListener', type,
  2824. isFunction(listener.listener) ?
  2825. listener.listener : listener);
  2826. if (!this._events[type])
  2827. // Optimize the case of one listener. Don't need the extra array object.
  2828. this._events[type] = listener;
  2829. else if (isObject(this._events[type]))
  2830. // If we've already got an array, just append.
  2831. this._events[type].push(listener);
  2832. else
  2833. // Adding the second element, need to change to array.
  2834. this._events[type] = [this._events[type], listener];
  2835. // Check for listener leak
  2836. if (isObject(this._events[type]) && !this._events[type].warned) {
  2837. if (!isUndefined(this._maxListeners)) {
  2838. m = this._maxListeners;
  2839. } else {
  2840. m = EventEmitter.defaultMaxListeners;
  2841. }
  2842. if (m && m > 0 && this._events[type].length > m) {
  2843. this._events[type].warned = true;
  2844. console.error('(node) warning: possible EventEmitter memory ' +
  2845. 'leak detected. %d listeners added. ' +
  2846. 'Use emitter.setMaxListeners() to increase limit.',
  2847. this._events[type].length);
  2848. if (typeof console.trace === 'function') {
  2849. // not supported in IE 10
  2850. console.trace();
  2851. }
  2852. }
  2853. }
  2854. return this;
  2855. };
  2856. EventEmitter.prototype.on = EventEmitter.prototype.addListener;
  2857. EventEmitter.prototype.once = function(type, listener) {
  2858. if (!isFunction(listener))
  2859. throw TypeError('listener must be a function');
  2860. var fired = false;
  2861. function g() {
  2862. this.removeListener(type, g);
  2863. if (!fired) {
  2864. fired = true;
  2865. listener.apply(this, arguments);
  2866. }
  2867. }
  2868. g.listener = listener;
  2869. this.on(type, g);
  2870. return this;
  2871. };
  2872. // emits a 'removeListener' event iff the listener was removed
  2873. EventEmitter.prototype.removeListener = function(type, listener) {
  2874. var list, position, length, i;
  2875. if (!isFunction(listener))
  2876. throw TypeError('listener must be a function');
  2877. if (!this._events || !this._events[type])
  2878. return this;
  2879. list = this._events[type];
  2880. length = list.length;
  2881. position = -1;
  2882. if (list === listener ||
  2883. (isFunction(list.listener) && list.listener === listener)) {
  2884. delete this._events[type];
  2885. if (this._events.removeListener)
  2886. this.emit('removeListener', type, listener);
  2887. } else if (isObject(list)) {
  2888. for (i = length; i-- > 0;) {
  2889. if (list[i] === listener ||
  2890. (list[i].listener && list[i].listener === listener)) {
  2891. position = i;
  2892. break;
  2893. }
  2894. }
  2895. if (position < 0)
  2896. return this;
  2897. if (list.length === 1) {
  2898. list.length = 0;
  2899. delete this._events[type];
  2900. } else {
  2901. list.splice(position, 1);
  2902. }
  2903. if (this._events.removeListener)
  2904. this.emit('removeListener', type, listener);
  2905. }
  2906. return this;
  2907. };
  2908. EventEmitter.prototype.removeAllListeners = function(type) {
  2909. var key, listeners;
  2910. if (!this._events)
  2911. return this;
  2912. // not listening for removeListener, no need to emit
  2913. if (!this._events.removeListener) {
  2914. if (arguments.length === 0)
  2915. this._events = {};
  2916. else if (this._events[type])
  2917. delete this._events[type];
  2918. return this;
  2919. }
  2920. // emit removeListener for all listeners on all events
  2921. if (arguments.length === 0) {
  2922. for (key in this._events) {
  2923. if (key === 'removeListener') continue;
  2924. this.removeAllListeners(key);
  2925. }
  2926. this.removeAllListeners('removeListener');
  2927. this._events = {};
  2928. return this;
  2929. }
  2930. listeners = this._events[type];
  2931. if (isFunction(listeners)) {
  2932. this.removeListener(type, listeners);
  2933. } else if (listeners) {
  2934. // LIFO order
  2935. while (listeners.length)
  2936. this.removeListener(type, listeners[listeners.length - 1]);
  2937. }
  2938. delete this._events[type];
  2939. return this;
  2940. };
  2941. EventEmitter.prototype.listeners = function(type) {
  2942. var ret;
  2943. if (!this._events || !this._events[type])
  2944. ret = [];
  2945. else if (isFunction(this._events[type]))
  2946. ret = [this._events[type]];
  2947. else
  2948. ret = this._events[type].slice();
  2949. return ret;
  2950. };
  2951. EventEmitter.prototype.listenerCount = function(type) {
  2952. if (this._events) {
  2953. var evlistener = this._events[type];
  2954. if (isFunction(evlistener))
  2955. return 1;
  2956. else if (evlistener)
  2957. return evlistener.length;
  2958. }
  2959. return 0;
  2960. };
  2961. EventEmitter.listenerCount = function(emitter, type) {
  2962. return emitter.listenerCount(type);
  2963. };
  2964. function isFunction(arg) {
  2965. return typeof arg === 'function';
  2966. }
  2967. function isNumber(arg) {
  2968. return typeof arg === 'number';
  2969. }
  2970. function isObject(arg) {
  2971. return typeof arg === 'object' && arg !== null;
  2972. }
  2973. function isUndefined(arg) {
  2974. return arg === void 0;
  2975. }
  2976. /***/ }),
  2977. /* 9 */
  2978. /***/ (function(module, exports, __webpack_require__) {
  2979. /* eslint-disable node/no-deprecated-api */
  2980. var buffer = __webpack_require__(2)
  2981. var Buffer = buffer.Buffer
  2982. // alternative to using Object.keys for old browsers
  2983. function copyProps (src, dst) {
  2984. for (var key in src) {
  2985. dst[key] = src[key]
  2986. }
  2987. }
  2988. if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
  2989. module.exports = buffer
  2990. } else {
  2991. // Copy properties from require('buffer')
  2992. copyProps(buffer, exports)
  2993. exports.Buffer = SafeBuffer
  2994. }
  2995. function SafeBuffer (arg, encodingOrOffset, length) {
  2996. return Buffer(arg, encodingOrOffset, length)
  2997. }
  2998. // Copy static methods from Buffer
  2999. copyProps(Buffer, SafeBuffer)
  3000. SafeBuffer.from = function (arg, encodingOrOffset, length) {
  3001. if (typeof arg === 'number') {
  3002. throw new TypeError('Argument must not be a number')
  3003. }
  3004. return Buffer(arg, encodingOrOffset, length)
  3005. }
  3006. SafeBuffer.alloc = function (size, fill, encoding) {
  3007. if (typeof size !== 'number') {
  3008. throw new TypeError('Argument must be a number')
  3009. }
  3010. var buf = Buffer(size)
  3011. if (fill !== undefined) {
  3012. if (typeof encoding === 'string') {
  3013. buf.fill(fill, encoding)
  3014. } else {
  3015. buf.fill(fill)
  3016. }
  3017. } else {
  3018. buf.fill(0)
  3019. }
  3020. return buf
  3021. }
  3022. SafeBuffer.allocUnsafe = function (size) {
  3023. if (typeof size !== 'number') {
  3024. throw new TypeError('Argument must be a number')
  3025. }
  3026. return Buffer(size)
  3027. }
  3028. SafeBuffer.allocUnsafeSlow = function (size) {
  3029. if (typeof size !== 'number') {
  3030. throw new TypeError('Argument must be a number')
  3031. }
  3032. return buffer.SlowBuffer(size)
  3033. }
  3034. /***/ }),
  3035. /* 10 */
  3036. /***/ (function(module, exports, __webpack_require__) {
  3037. /* WEBPACK VAR INJECTION */(function(global) {var ClientRequest = __webpack_require__(37)
  3038. var response = __webpack_require__(13)
  3039. var extend = __webpack_require__(48)
  3040. var statusCodes = __webpack_require__(49)
  3041. var url = __webpack_require__(7)
  3042. var http = exports
  3043. http.request = function (opts, cb) {
  3044. if (typeof opts === 'string')
  3045. opts = url.parse(opts)
  3046. else
  3047. opts = extend(opts)
  3048. // Normally, the page is loaded from http or https, so not specifying a protocol
  3049. // will result in a (valid) protocol-relative url. However, this won't work if
  3050. // the protocol is something else, like 'file:'
  3051. var defaultProtocol = global.location.protocol.search(/^https?:$/) === -1 ? 'http:' : ''
  3052. var protocol = opts.protocol || defaultProtocol
  3053. var host = opts.hostname || opts.host
  3054. var port = opts.port
  3055. var path = opts.path || '/'
  3056. // Necessary for IPv6 addresses
  3057. if (host && host.indexOf(':') !== -1)
  3058. host = '[' + host + ']'
  3059. // This may be a relative url. The browser should always be able to interpret it correctly.
  3060. opts.url = (host ? (protocol + '//' + host) : '') + (port ? ':' + port : '') + path
  3061. opts.method = (opts.method || 'GET').toUpperCase()
  3062. opts.headers = opts.headers || {}
  3063. // Also valid opts.auth, opts.mode
  3064. var req = new ClientRequest(opts)
  3065. if (cb)
  3066. req.on('response', cb)
  3067. return req
  3068. }
  3069. http.get = function get (opts, cb) {
  3070. var req = http.request(opts, cb)
  3071. req.end()
  3072. return req
  3073. }
  3074. http.ClientRequest = ClientRequest
  3075. http.IncomingMessage = response.IncomingMessage
  3076. http.Agent = function () {}
  3077. http.Agent.defaultMaxSockets = 4
  3078. http.globalAgent = new http.Agent()
  3079. http.STATUS_CODES = statusCodes
  3080. http.METHODS = [
  3081. 'CHECKOUT',
  3082. 'CONNECT',
  3083. 'COPY',
  3084. 'DELETE',
  3085. 'GET',
  3086. 'HEAD',
  3087. 'LOCK',
  3088. 'M-SEARCH',
  3089. 'MERGE',
  3090. 'MKACTIVITY',
  3091. 'MKCOL',
  3092. 'MOVE',
  3093. 'NOTIFY',
  3094. 'OPTIONS',
  3095. 'PATCH',
  3096. 'POST',
  3097. 'PROPFIND',
  3098. 'PROPPATCH',
  3099. 'PURGE',
  3100. 'PUT',
  3101. 'REPORT',
  3102. 'SEARCH',
  3103. 'SUBSCRIBE',
  3104. 'TRACE',
  3105. 'UNLOCK',
  3106. 'UNSUBSCRIBE'
  3107. ]
  3108. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
  3109. /***/ }),
  3110. /* 11 */
  3111. /***/ (function(module, exports, __webpack_require__) {
  3112. /* WEBPACK VAR INJECTION */(function(global) {exports.fetch = isFunction(global.fetch) && isFunction(global.ReadableStream)
  3113. exports.writableStream = isFunction(global.WritableStream)
  3114. exports.abortController = isFunction(global.AbortController)
  3115. exports.blobConstructor = false
  3116. try {
  3117. new Blob([new ArrayBuffer(1)])
  3118. exports.blobConstructor = true
  3119. } catch (e) {}
  3120. // The xhr request to example.com may violate some restrictive CSP configurations,
  3121. // so if we're running in a browser that supports `fetch`, avoid calling getXHR()
  3122. // and assume support for certain features below.
  3123. var xhr
  3124. function getXHR () {
  3125. // Cache the xhr value
  3126. if (xhr !== undefined) return xhr
  3127. if (global.XMLHttpRequest) {
  3128. xhr = new global.XMLHttpRequest()
  3129. // If XDomainRequest is available (ie only, where xhr might not work
  3130. // cross domain), use the page location. Otherwise use example.com
  3131. // Note: this doesn't actually make an http request.
  3132. try {
  3133. xhr.open('GET', global.XDomainRequest ? '/' : 'https://example.com')
  3134. } catch(e) {
  3135. xhr = null
  3136. }
  3137. } else {
  3138. // Service workers don't have XHR
  3139. xhr = null
  3140. }
  3141. return xhr
  3142. }
  3143. function checkTypeSupport (type) {
  3144. var xhr = getXHR()
  3145. if (!xhr) return false
  3146. try {
  3147. xhr.responseType = type
  3148. return xhr.responseType === type
  3149. } catch (e) {}
  3150. return false
  3151. }
  3152. // For some strange reason, Safari 7.0 reports typeof global.ArrayBuffer === 'object'.
  3153. // Safari 7.1 appears to have fixed this bug.
  3154. var haveArrayBuffer = typeof global.ArrayBuffer !== 'undefined'
  3155. var haveSlice = haveArrayBuffer && isFunction(global.ArrayBuffer.prototype.slice)
  3156. // If fetch is supported, then arraybuffer will be supported too. Skip calling
  3157. // checkTypeSupport(), since that calls getXHR().
  3158. exports.arraybuffer = exports.fetch || (haveArrayBuffer && checkTypeSupport('arraybuffer'))
  3159. // These next two tests unavoidably show warnings in Chrome. Since fetch will always
  3160. // be used if it's available, just return false for these to avoid the warnings.
  3161. exports.msstream = !exports.fetch && haveSlice && checkTypeSupport('ms-stream')
  3162. exports.mozchunkedarraybuffer = !exports.fetch && haveArrayBuffer &&
  3163. checkTypeSupport('moz-chunked-arraybuffer')
  3164. // If fetch is supported, then overrideMimeType will be supported too. Skip calling
  3165. // getXHR().
  3166. exports.overrideMimeType = exports.fetch || (getXHR() ? isFunction(getXHR().overrideMimeType) : false)
  3167. exports.vbArray = isFunction(global.VBArray)
  3168. function isFunction (value) {
  3169. return typeof value === 'function'
  3170. }
  3171. xhr = null // Help gc
  3172. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
  3173. /***/ }),
  3174. /* 12 */
  3175. /***/ (function(module, exports) {
  3176. if (typeof Object.create === 'function') {
  3177. // implementation from standard node.js 'util' module
  3178. module.exports = function inherits(ctor, superCtor) {
  3179. ctor.super_ = superCtor
  3180. ctor.prototype = Object.create(superCtor.prototype, {
  3181. constructor: {
  3182. value: ctor,
  3183. enumerable: false,
  3184. writable: true,
  3185. configurable: true
  3186. }
  3187. });
  3188. };
  3189. } else {
  3190. // old school shim for old browsers
  3191. module.exports = function inherits(ctor, superCtor) {
  3192. ctor.super_ = superCtor
  3193. var TempCtor = function () {}
  3194. TempCtor.prototype = superCtor.prototype
  3195. ctor.prototype = new TempCtor()
  3196. ctor.prototype.constructor = ctor
  3197. }
  3198. }
  3199. /***/ }),
  3200. /* 13 */
  3201. /***/ (function(module, exports, __webpack_require__) {
  3202. /* WEBPACK VAR INJECTION */(function(process, Buffer, global) {var capability = __webpack_require__(11)
  3203. var inherits = __webpack_require__(12)
  3204. var stream = __webpack_require__(14)
  3205. var rStates = exports.readyStates = {
  3206. UNSENT: 0,
  3207. OPENED: 1,
  3208. HEADERS_RECEIVED: 2,
  3209. LOADING: 3,
  3210. DONE: 4
  3211. }
  3212. var IncomingMessage = exports.IncomingMessage = function (xhr, response, mode, fetchTimer) {
  3213. var self = this
  3214. stream.Readable.call(self)
  3215. self._mode = mode
  3216. self.headers = {}
  3217. self.rawHeaders = []
  3218. self.trailers = {}
  3219. self.rawTrailers = []
  3220. // Fake the 'close' event, but only once 'end' fires
  3221. self.on('end', function () {
  3222. // The nextTick is necessary to prevent the 'request' module from causing an infinite loop
  3223. process.nextTick(function () {
  3224. self.emit('close')
  3225. })
  3226. })
  3227. if (mode === 'fetch') {
  3228. self._fetchResponse = response
  3229. self.url = response.url
  3230. self.statusCode = response.status
  3231. self.statusMessage = response.statusText
  3232. response.headers.forEach(function (header, key){
  3233. self.headers[key.toLowerCase()] = header
  3234. self.rawHeaders.push(key, header)
  3235. })
  3236. if (capability.writableStream) {
  3237. var writable = new WritableStream({
  3238. write: function (chunk) {
  3239. return new Promise(function (resolve, reject) {
  3240. if (self._destroyed) {
  3241. reject()
  3242. } else if(self.push(new Buffer(chunk))) {
  3243. resolve()
  3244. } else {
  3245. self._resumeFetch = resolve
  3246. }
  3247. })
  3248. },
  3249. close: function () {
  3250. global.clearTimeout(fetchTimer)
  3251. if (!self._destroyed)
  3252. self.push(null)
  3253. },
  3254. abort: function (err) {
  3255. if (!self._destroyed)
  3256. self.emit('error', err)
  3257. }
  3258. })
  3259. try {
  3260. response.body.pipeTo(writable).catch(function (err) {
  3261. global.clearTimeout(fetchTimer)
  3262. if (!self._destroyed)
  3263. self.emit('error', err)
  3264. })
  3265. return
  3266. } catch (e) {} // pipeTo method isn't defined. Can't find a better way to feature test this
  3267. }
  3268. // fallback for when writableStream or pipeTo aren't available
  3269. var reader = response.body.getReader()
  3270. function read () {
  3271. reader.read().then(function (result) {
  3272. if (self._destroyed)
  3273. return
  3274. if (result.done) {
  3275. global.clearTimeout(fetchTimer)
  3276. self.push(null)
  3277. return
  3278. }
  3279. self.push(new Buffer(result.value))
  3280. read()
  3281. }).catch(function (err) {
  3282. global.clearTimeout(fetchTimer)
  3283. if (!self._destroyed)
  3284. self.emit('error', err)
  3285. })
  3286. }
  3287. read()
  3288. } else {
  3289. self._xhr = xhr
  3290. self._pos = 0
  3291. self.url = xhr.responseURL
  3292. self.statusCode = xhr.status
  3293. self.statusMessage = xhr.statusText
  3294. var headers = xhr.getAllResponseHeaders().split(/\r?\n/)
  3295. headers.forEach(function (header) {
  3296. var matches = header.match(/^([^:]+):\s*(.*)/)
  3297. if (matches) {
  3298. var key = matches[1].toLowerCase()
  3299. if (key === 'set-cookie') {
  3300. if (self.headers[key] === undefined) {
  3301. self.headers[key] = []
  3302. }
  3303. self.headers[key].push(matches[2])
  3304. } else if (self.headers[key] !== undefined) {
  3305. self.headers[key] += ', ' + matches[2]
  3306. } else {
  3307. self.headers[key] = matches[2]
  3308. }
  3309. self.rawHeaders.push(matches[1], matches[2])
  3310. }
  3311. })
  3312. self._charset = 'x-user-defined'
  3313. if (!capability.overrideMimeType) {
  3314. var mimeType = self.rawHeaders['mime-type']
  3315. if (mimeType) {
  3316. var charsetMatch = mimeType.match(/;\s*charset=([^;])(;|$)/)
  3317. if (charsetMatch) {
  3318. self._charset = charsetMatch[1].toLowerCase()
  3319. }
  3320. }
  3321. if (!self._charset)
  3322. self._charset = 'utf-8' // best guess
  3323. }
  3324. }
  3325. }
  3326. inherits(IncomingMessage, stream.Readable)
  3327. IncomingMessage.prototype._read = function () {
  3328. var self = this
  3329. var resolve = self._resumeFetch
  3330. if (resolve) {
  3331. self._resumeFetch = null
  3332. resolve()
  3333. }
  3334. }
  3335. IncomingMessage.prototype._onXHRProgress = function () {
  3336. var self = this
  3337. var xhr = self._xhr
  3338. var response = null
  3339. switch (self._mode) {
  3340. case 'text:vbarray': // For IE9
  3341. if (xhr.readyState !== rStates.DONE)
  3342. break
  3343. try {
  3344. // This fails in IE8
  3345. response = new global.VBArray(xhr.responseBody).toArray()
  3346. } catch (e) {}
  3347. if (response !== null) {
  3348. self.push(new Buffer(response))
  3349. break
  3350. }
  3351. // Falls through in IE8
  3352. case 'text':
  3353. try { // This will fail when readyState = 3 in IE9. Switch mode and wait for readyState = 4
  3354. response = xhr.responseText
  3355. } catch (e) {
  3356. self._mode = 'text:vbarray'
  3357. break
  3358. }
  3359. if (response.length > self._pos) {
  3360. var newData = response.substr(self._pos)
  3361. if (self._charset === 'x-user-defined') {
  3362. var buffer = new Buffer(newData.length)
  3363. for (var i = 0; i < newData.length; i++)
  3364. buffer[i] = newData.charCodeAt(i) & 0xff
  3365. self.push(buffer)
  3366. } else {
  3367. self.push(newData, self._charset)
  3368. }
  3369. self._pos = response.length
  3370. }
  3371. break
  3372. case 'arraybuffer':
  3373. if (xhr.readyState !== rStates.DONE || !xhr.response)
  3374. break
  3375. response = xhr.response
  3376. self.push(new Buffer(new Uint8Array(response)))
  3377. break
  3378. case 'moz-chunked-arraybuffer': // take whole
  3379. response = xhr.response
  3380. if (xhr.readyState !== rStates.LOADING || !response)
  3381. break
  3382. self.push(new Buffer(new Uint8Array(response)))
  3383. break
  3384. case 'ms-stream':
  3385. response = xhr.response
  3386. if (xhr.readyState !== rStates.LOADING)
  3387. break
  3388. var reader = new global.MSStreamReader()
  3389. reader.onprogress = function () {
  3390. if (reader.result.byteLength > self._pos) {
  3391. self.push(new Buffer(new Uint8Array(reader.result.slice(self._pos))))
  3392. self._pos = reader.result.byteLength
  3393. }
  3394. }
  3395. reader.onload = function () {
  3396. self.push(null)
  3397. }
  3398. // reader.onerror = ??? // TODO: this
  3399. reader.readAsArrayBuffer(response)
  3400. break
  3401. }
  3402. // The ms-stream case handles end separately in reader.onload()
  3403. if (self._xhr.readyState === rStates.DONE && self._mode !== 'ms-stream') {
  3404. self.push(null)
  3405. }
  3406. }
  3407. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1), __webpack_require__(2).Buffer, __webpack_require__(0)))
  3408. /***/ }),
  3409. /* 14 */
  3410. /***/ (function(module, exports, __webpack_require__) {
  3411. exports = module.exports = __webpack_require__(15);
  3412. exports.Stream = exports;
  3413. exports.Readable = exports;
  3414. exports.Writable = __webpack_require__(18);
  3415. exports.Duplex = __webpack_require__(3);
  3416. exports.Transform = __webpack_require__(20);
  3417. exports.PassThrough = __webpack_require__(46);
  3418. /***/ }),
  3419. /* 15 */
  3420. /***/ (function(module, exports, __webpack_require__) {
  3421. "use strict";
  3422. /* WEBPACK VAR INJECTION */(function(global, process) {// Copyright Joyent, Inc. and other Node contributors.
  3423. //
  3424. // Permission is hereby granted, free of charge, to any person obtaining a
  3425. // copy of this software and associated documentation files (the
  3426. // "Software"), to deal in the Software without restriction, including
  3427. // without limitation the rights to use, copy, modify, merge, publish,
  3428. // distribute, sublicense, and/or sell copies of the Software, and to permit
  3429. // persons to whom the Software is furnished to do so, subject to the
  3430. // following conditions:
  3431. //
  3432. // The above copyright notice and this permission notice shall be included
  3433. // in all copies or substantial portions of the Software.
  3434. //
  3435. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  3436. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  3437. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  3438. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  3439. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  3440. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  3441. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  3442. /*<replacement>*/
  3443. var pna = __webpack_require__(6);
  3444. /*</replacement>*/
  3445. module.exports = Readable;
  3446. /*<replacement>*/
  3447. var isArray = __webpack_require__(38);
  3448. /*</replacement>*/
  3449. /*<replacement>*/
  3450. var Duplex;
  3451. /*</replacement>*/
  3452. Readable.ReadableState = ReadableState;
  3453. /*<replacement>*/
  3454. var EE = __webpack_require__(8).EventEmitter;
  3455. var EElistenerCount = function (emitter, type) {
  3456. return emitter.listeners(type).length;
  3457. };
  3458. /*</replacement>*/
  3459. /*<replacement>*/
  3460. var Stream = __webpack_require__(16);
  3461. /*</replacement>*/
  3462. /*<replacement>*/
  3463. var Buffer = __webpack_require__(9).Buffer;
  3464. var OurUint8Array = global.Uint8Array || function () {};
  3465. function _uint8ArrayToBuffer(chunk) {
  3466. return Buffer.from(chunk);
  3467. }
  3468. function _isUint8Array(obj) {
  3469. return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
  3470. }
  3471. /*</replacement>*/
  3472. /*<replacement>*/
  3473. var util = __webpack_require__(4);
  3474. util.inherits = __webpack_require__(5);
  3475. /*</replacement>*/
  3476. /*<replacement>*/
  3477. var debugUtil = __webpack_require__(39);
  3478. var debug = void 0;
  3479. if (debugUtil && debugUtil.debuglog) {
  3480. debug = debugUtil.debuglog('stream');
  3481. } else {
  3482. debug = function () {};
  3483. }
  3484. /*</replacement>*/
  3485. var BufferList = __webpack_require__(40);
  3486. var destroyImpl = __webpack_require__(17);
  3487. var StringDecoder;
  3488. util.inherits(Readable, Stream);
  3489. var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
  3490. function prependListener(emitter, event, fn) {
  3491. // Sadly this is not cacheable as some libraries bundle their own
  3492. // event emitter implementation with them.
  3493. if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);
  3494. // This is a hack to make sure that our error handler is attached before any
  3495. // userland ones. NEVER DO THIS. This is here only because this code needs
  3496. // to continue to work with older versions of Node.js that do not include
  3497. // the prependListener() method. The goal is to eventually remove this hack.
  3498. if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
  3499. }
  3500. function ReadableState(options, stream) {
  3501. Duplex = Duplex || __webpack_require__(3);
  3502. options = options || {};
  3503. // Duplex streams are both readable and writable, but share
  3504. // the same options object.
  3505. // However, some cases require setting options to different
  3506. // values for the readable and the writable sides of the duplex stream.
  3507. // These options can be provided separately as readableXXX and writableXXX.
  3508. var isDuplex = stream instanceof Duplex;
  3509. // object stream flag. Used to make read(n) ignore n and to
  3510. // make all the buffer merging and length checks go away
  3511. this.objectMode = !!options.objectMode;
  3512. if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
  3513. // the point at which it stops calling _read() to fill the buffer
  3514. // Note: 0 is a valid value, means "don't call _read preemptively ever"
  3515. var hwm = options.highWaterMark;
  3516. var readableHwm = options.readableHighWaterMark;
  3517. var defaultHwm = this.objectMode ? 16 : 16 * 1024;
  3518. if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;
  3519. // cast to ints.
  3520. this.highWaterMark = Math.floor(this.highWaterMark);
  3521. // A linked list is used to store data chunks instead of an array because the
  3522. // linked list can remove elements from the beginning faster than
  3523. // array.shift()
  3524. this.buffer = new BufferList();
  3525. this.length = 0;
  3526. this.pipes = null;
  3527. this.pipesCount = 0;
  3528. this.flowing = null;
  3529. this.ended = false;
  3530. this.endEmitted = false;
  3531. this.reading = false;
  3532. // a flag to be able to tell if the event 'readable'/'data' is emitted
  3533. // immediately, or on a later tick. We set this to true at first, because
  3534. // any actions that shouldn't happen until "later" should generally also
  3535. // not happen before the first read call.
  3536. this.sync = true;
  3537. // whenever we return null, then we set a flag to say
  3538. // that we're awaiting a 'readable' event emission.
  3539. this.needReadable = false;
  3540. this.emittedReadable = false;
  3541. this.readableListening = false;
  3542. this.resumeScheduled = false;
  3543. // has it been destroyed
  3544. this.destroyed = false;
  3545. // Crypto is kind of old and crusty. Historically, its default string
  3546. // encoding is 'binary' so we have to make this configurable.
  3547. // Everything else in the universe uses 'utf8', though.
  3548. this.defaultEncoding = options.defaultEncoding || 'utf8';
  3549. // the number of writers that are awaiting a drain event in .pipe()s
  3550. this.awaitDrain = 0;
  3551. // if true, a maybeReadMore has been scheduled
  3552. this.readingMore = false;
  3553. this.decoder = null;
  3554. this.encoding = null;
  3555. if (options.encoding) {
  3556. if (!StringDecoder) StringDecoder = __webpack_require__(19).StringDecoder;
  3557. this.decoder = new StringDecoder(options.encoding);
  3558. this.encoding = options.encoding;
  3559. }
  3560. }
  3561. function Readable(options) {
  3562. Duplex = Duplex || __webpack_require__(3);
  3563. if (!(this instanceof Readable)) return new Readable(options);
  3564. this._readableState = new ReadableState(options, this);
  3565. // legacy
  3566. this.readable = true;
  3567. if (options) {
  3568. if (typeof options.read === 'function') this._read = options.read;
  3569. if (typeof options.destroy === 'function') this._destroy = options.destroy;
  3570. }
  3571. Stream.call(this);
  3572. }
  3573. Object.defineProperty(Readable.prototype, 'destroyed', {
  3574. get: function () {
  3575. if (this._readableState === undefined) {
  3576. return false;
  3577. }
  3578. return this._readableState.destroyed;
  3579. },
  3580. set: function (value) {
  3581. // we ignore the value if the stream
  3582. // has not been initialized yet
  3583. if (!this._readableState) {
  3584. return;
  3585. }
  3586. // backward compatibility, the user is explicitly
  3587. // managing destroyed
  3588. this._readableState.destroyed = value;
  3589. }
  3590. });
  3591. Readable.prototype.destroy = destroyImpl.destroy;
  3592. Readable.prototype._undestroy = destroyImpl.undestroy;
  3593. Readable.prototype._destroy = function (err, cb) {
  3594. this.push(null);
  3595. cb(err);
  3596. };
  3597. // Manually shove something into the read() buffer.
  3598. // This returns true if the highWaterMark has not been hit yet,
  3599. // similar to how Writable.write() returns true if you should
  3600. // write() some more.
  3601. Readable.prototype.push = function (chunk, encoding) {
  3602. var state = this._readableState;
  3603. var skipChunkCheck;
  3604. if (!state.objectMode) {
  3605. if (typeof chunk === 'string') {
  3606. encoding = encoding || state.defaultEncoding;
  3607. if (encoding !== state.encoding) {
  3608. chunk = Buffer.from(chunk, encoding);
  3609. encoding = '';
  3610. }
  3611. skipChunkCheck = true;
  3612. }
  3613. } else {
  3614. skipChunkCheck = true;
  3615. }
  3616. return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
  3617. };
  3618. // Unshift should *always* be something directly out of read()
  3619. Readable.prototype.unshift = function (chunk) {
  3620. return readableAddChunk(this, chunk, null, true, false);
  3621. };
  3622. function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
  3623. var state = stream._readableState;
  3624. if (chunk === null) {
  3625. state.reading = false;
  3626. onEofChunk(stream, state);
  3627. } else {
  3628. var er;
  3629. if (!skipChunkCheck) er = chunkInvalid(state, chunk);
  3630. if (er) {
  3631. stream.emit('error', er);
  3632. } else if (state.objectMode || chunk && chunk.length > 0) {
  3633. if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
  3634. chunk = _uint8ArrayToBuffer(chunk);
  3635. }
  3636. if (addToFront) {
  3637. if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);
  3638. } else if (state.ended) {
  3639. stream.emit('error', new Error('stream.push() after EOF'));
  3640. } else {
  3641. state.reading = false;
  3642. if (state.decoder && !encoding) {
  3643. chunk = state.decoder.write(chunk);
  3644. if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
  3645. } else {
  3646. addChunk(stream, state, chunk, false);
  3647. }
  3648. }
  3649. } else if (!addToFront) {
  3650. state.reading = false;
  3651. }
  3652. }
  3653. return needMoreData(state);
  3654. }
  3655. function addChunk(stream, state, chunk, addToFront) {
  3656. if (state.flowing && state.length === 0 && !state.sync) {
  3657. stream.emit('data', chunk);
  3658. stream.read(0);
  3659. } else {
  3660. // update the buffer info.
  3661. state.length += state.objectMode ? 1 : chunk.length;
  3662. if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
  3663. if (state.needReadable) emitReadable(stream);
  3664. }
  3665. maybeReadMore(stream, state);
  3666. }
  3667. function chunkInvalid(state, chunk) {
  3668. var er;
  3669. if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
  3670. er = new TypeError('Invalid non-string/buffer chunk');
  3671. }
  3672. return er;
  3673. }
  3674. // if it's past the high water mark, we can push in some more.
  3675. // Also, if we have no data yet, we can stand some
  3676. // more bytes. This is to work around cases where hwm=0,
  3677. // such as the repl. Also, if the push() triggered a
  3678. // readable event, and the user called read(largeNumber) such that
  3679. // needReadable was set, then we ought to push more, so that another
  3680. // 'readable' event will be triggered.
  3681. function needMoreData(state) {
  3682. return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
  3683. }
  3684. Readable.prototype.isPaused = function () {
  3685. return this._readableState.flowing === false;
  3686. };
  3687. // backwards compatibility.
  3688. Readable.prototype.setEncoding = function (enc) {
  3689. if (!StringDecoder) StringDecoder = __webpack_require__(19).StringDecoder;
  3690. this._readableState.decoder = new StringDecoder(enc);
  3691. this._readableState.encoding = enc;
  3692. return this;
  3693. };
  3694. // Don't raise the hwm > 8MB
  3695. var MAX_HWM = 0x800000;
  3696. function computeNewHighWaterMark(n) {
  3697. if (n >= MAX_HWM) {
  3698. n = MAX_HWM;
  3699. } else {
  3700. // Get the next highest power of 2 to prevent increasing hwm excessively in
  3701. // tiny amounts
  3702. n--;
  3703. n |= n >>> 1;
  3704. n |= n >>> 2;
  3705. n |= n >>> 4;
  3706. n |= n >>> 8;
  3707. n |= n >>> 16;
  3708. n++;
  3709. }
  3710. return n;
  3711. }
  3712. // This function is designed to be inlinable, so please take care when making
  3713. // changes to the function body.
  3714. function howMuchToRead(n, state) {
  3715. if (n <= 0 || state.length === 0 && state.ended) return 0;
  3716. if (state.objectMode) return 1;
  3717. if (n !== n) {
  3718. // Only flow one buffer at a time
  3719. if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
  3720. }
  3721. // If we're asking for more than the current hwm, then raise the hwm.
  3722. if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
  3723. if (n <= state.length) return n;
  3724. // Don't have enough
  3725. if (!state.ended) {
  3726. state.needReadable = true;
  3727. return 0;
  3728. }
  3729. return state.length;
  3730. }
  3731. // you can override either this method, or the async _read(n) below.
  3732. Readable.prototype.read = function (n) {
  3733. debug('read', n);
  3734. n = parseInt(n, 10);
  3735. var state = this._readableState;
  3736. var nOrig = n;
  3737. if (n !== 0) state.emittedReadable = false;
  3738. // if we're doing read(0) to trigger a readable event, but we
  3739. // already have a bunch of data in the buffer, then just trigger
  3740. // the 'readable' event and move on.
  3741. if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
  3742. debug('read: emitReadable', state.length, state.ended);
  3743. if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
  3744. return null;
  3745. }
  3746. n = howMuchToRead(n, state);
  3747. // if we've ended, and we're now clear, then finish it up.
  3748. if (n === 0 && state.ended) {
  3749. if (state.length === 0) endReadable(this);
  3750. return null;
  3751. }
  3752. // All the actual chunk generation logic needs to be
  3753. // *below* the call to _read. The reason is that in certain
  3754. // synthetic stream cases, such as passthrough streams, _read
  3755. // may be a completely synchronous operation which may change
  3756. // the state of the read buffer, providing enough data when
  3757. // before there was *not* enough.
  3758. //
  3759. // So, the steps are:
  3760. // 1. Figure out what the state of things will be after we do
  3761. // a read from the buffer.
  3762. //
  3763. // 2. If that resulting state will trigger a _read, then call _read.
  3764. // Note that this may be asynchronous, or synchronous. Yes, it is
  3765. // deeply ugly to write APIs this way, but that still doesn't mean
  3766. // that the Readable class should behave improperly, as streams are
  3767. // designed to be sync/async agnostic.
  3768. // Take note if the _read call is sync or async (ie, if the read call
  3769. // has returned yet), so that we know whether or not it's safe to emit
  3770. // 'readable' etc.
  3771. //
  3772. // 3. Actually pull the requested chunks out of the buffer and return.
  3773. // if we need a readable event, then we need to do some reading.
  3774. var doRead = state.needReadable;
  3775. debug('need readable', doRead);
  3776. // if we currently have less than the highWaterMark, then also read some
  3777. if (state.length === 0 || state.length - n < state.highWaterMark) {
  3778. doRead = true;
  3779. debug('length less than watermark', doRead);
  3780. }
  3781. // however, if we've ended, then there's no point, and if we're already
  3782. // reading, then it's unnecessary.
  3783. if (state.ended || state.reading) {
  3784. doRead = false;
  3785. debug('reading or ended', doRead);
  3786. } else if (doRead) {
  3787. debug('do read');
  3788. state.reading = true;
  3789. state.sync = true;
  3790. // if the length is currently zero, then we *need* a readable event.
  3791. if (state.length === 0) state.needReadable = true;
  3792. // call internal read method
  3793. this._read(state.highWaterMark);
  3794. state.sync = false;
  3795. // If _read pushed data synchronously, then `reading` will be false,
  3796. // and we need to re-evaluate how much data we can return to the user.
  3797. if (!state.reading) n = howMuchToRead(nOrig, state);
  3798. }
  3799. var ret;
  3800. if (n > 0) ret = fromList(n, state);else ret = null;
  3801. if (ret === null) {
  3802. state.needReadable = true;
  3803. n = 0;
  3804. } else {
  3805. state.length -= n;
  3806. }
  3807. if (state.length === 0) {
  3808. // If we have nothing in the buffer, then we want to know
  3809. // as soon as we *do* get something into the buffer.
  3810. if (!state.ended) state.needReadable = true;
  3811. // If we tried to read() past the EOF, then emit end on the next tick.
  3812. if (nOrig !== n && state.ended) endReadable(this);
  3813. }
  3814. if (ret !== null) this.emit('data', ret);
  3815. return ret;
  3816. };
  3817. function onEofChunk(stream, state) {
  3818. if (state.ended) return;
  3819. if (state.decoder) {
  3820. var chunk = state.decoder.end();
  3821. if (chunk && chunk.length) {
  3822. state.buffer.push(chunk);
  3823. state.length += state.objectMode ? 1 : chunk.length;
  3824. }
  3825. }
  3826. state.ended = true;
  3827. // emit 'readable' now to make sure it gets picked up.
  3828. emitReadable(stream);
  3829. }
  3830. // Don't emit readable right away in sync mode, because this can trigger
  3831. // another read() call => stack overflow. This way, it might trigger
  3832. // a nextTick recursion warning, but that's not so bad.
  3833. function emitReadable(stream) {
  3834. var state = stream._readableState;
  3835. state.needReadable = false;
  3836. if (!state.emittedReadable) {
  3837. debug('emitReadable', state.flowing);
  3838. state.emittedReadable = true;
  3839. if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);
  3840. }
  3841. }
  3842. function emitReadable_(stream) {
  3843. debug('emit readable');
  3844. stream.emit('readable');
  3845. flow(stream);
  3846. }
  3847. // at this point, the user has presumably seen the 'readable' event,
  3848. // and called read() to consume some data. that may have triggered
  3849. // in turn another _read(n) call, in which case reading = true if
  3850. // it's in progress.
  3851. // However, if we're not ended, or reading, and the length < hwm,
  3852. // then go ahead and try to read some more preemptively.
  3853. function maybeReadMore(stream, state) {
  3854. if (!state.readingMore) {
  3855. state.readingMore = true;
  3856. pna.nextTick(maybeReadMore_, stream, state);
  3857. }
  3858. }
  3859. function maybeReadMore_(stream, state) {
  3860. var len = state.length;
  3861. while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
  3862. debug('maybeReadMore read 0');
  3863. stream.read(0);
  3864. if (len === state.length)
  3865. // didn't get any data, stop spinning.
  3866. break;else len = state.length;
  3867. }
  3868. state.readingMore = false;
  3869. }
  3870. // abstract method. to be overridden in specific implementation classes.
  3871. // call cb(er, data) where data is <= n in length.
  3872. // for virtual (non-string, non-buffer) streams, "length" is somewhat
  3873. // arbitrary, and perhaps not very meaningful.
  3874. Readable.prototype._read = function (n) {
  3875. this.emit('error', new Error('_read() is not implemented'));
  3876. };
  3877. Readable.prototype.pipe = function (dest, pipeOpts) {
  3878. var src = this;
  3879. var state = this._readableState;
  3880. switch (state.pipesCount) {
  3881. case 0:
  3882. state.pipes = dest;
  3883. break;
  3884. case 1:
  3885. state.pipes = [state.pipes, dest];
  3886. break;
  3887. default:
  3888. state.pipes.push(dest);
  3889. break;
  3890. }
  3891. state.pipesCount += 1;
  3892. debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
  3893. var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
  3894. var endFn = doEnd ? onend : unpipe;
  3895. if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);
  3896. dest.on('unpipe', onunpipe);
  3897. function onunpipe(readable, unpipeInfo) {
  3898. debug('onunpipe');
  3899. if (readable === src) {
  3900. if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
  3901. unpipeInfo.hasUnpiped = true;
  3902. cleanup();
  3903. }
  3904. }
  3905. }
  3906. function onend() {
  3907. debug('onend');
  3908. dest.end();
  3909. }
  3910. // when the dest drains, it reduces the awaitDrain counter
  3911. // on the source. This would be more elegant with a .once()
  3912. // handler in flow(), but adding and removing repeatedly is
  3913. // too slow.
  3914. var ondrain = pipeOnDrain(src);
  3915. dest.on('drain', ondrain);
  3916. var cleanedUp = false;
  3917. function cleanup() {
  3918. debug('cleanup');
  3919. // cleanup event handlers once the pipe is broken
  3920. dest.removeListener('close', onclose);
  3921. dest.removeListener('finish', onfinish);
  3922. dest.removeListener('drain', ondrain);
  3923. dest.removeListener('error', onerror);
  3924. dest.removeListener('unpipe', onunpipe);
  3925. src.removeListener('end', onend);
  3926. src.removeListener('end', unpipe);
  3927. src.removeListener('data', ondata);
  3928. cleanedUp = true;
  3929. // if the reader is waiting for a drain event from this
  3930. // specific writer, then it would cause it to never start
  3931. // flowing again.
  3932. // So, if this is awaiting a drain, then we just call it now.
  3933. // If we don't know, then assume that we are waiting for one.
  3934. if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
  3935. }
  3936. // If the user pushes more data while we're writing to dest then we'll end up
  3937. // in ondata again. However, we only want to increase awaitDrain once because
  3938. // dest will only emit one 'drain' event for the multiple writes.
  3939. // => Introduce a guard on increasing awaitDrain.
  3940. var increasedAwaitDrain = false;
  3941. src.on('data', ondata);
  3942. function ondata(chunk) {
  3943. debug('ondata');
  3944. increasedAwaitDrain = false;
  3945. var ret = dest.write(chunk);
  3946. if (false === ret && !increasedAwaitDrain) {
  3947. // If the user unpiped during `dest.write()`, it is possible
  3948. // to get stuck in a permanently paused state if that write
  3949. // also returned false.
  3950. // => Check whether `dest` is still a piping destination.
  3951. if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
  3952. debug('false write response, pause', src._readableState.awaitDrain);
  3953. src._readableState.awaitDrain++;
  3954. increasedAwaitDrain = true;
  3955. }
  3956. src.pause();
  3957. }
  3958. }
  3959. // if the dest has an error, then stop piping into it.
  3960. // however, don't suppress the throwing behavior for this.
  3961. function onerror(er) {
  3962. debug('onerror', er);
  3963. unpipe();
  3964. dest.removeListener('error', onerror);
  3965. if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
  3966. }
  3967. // Make sure our error handler is attached before userland ones.
  3968. prependListener(dest, 'error', onerror);
  3969. // Both close and finish should trigger unpipe, but only once.
  3970. function onclose() {
  3971. dest.removeListener('finish', onfinish);
  3972. unpipe();
  3973. }
  3974. dest.once('close', onclose);
  3975. function onfinish() {
  3976. debug('onfinish');
  3977. dest.removeListener('close', onclose);
  3978. unpipe();
  3979. }
  3980. dest.once('finish', onfinish);
  3981. function unpipe() {
  3982. debug('unpipe');
  3983. src.unpipe(dest);
  3984. }
  3985. // tell the dest that it's being piped to
  3986. dest.emit('pipe', src);
  3987. // start the flow if it hasn't been started already.
  3988. if (!state.flowing) {
  3989. debug('pipe resume');
  3990. src.resume();
  3991. }
  3992. return dest;
  3993. };
  3994. function pipeOnDrain(src) {
  3995. return function () {
  3996. var state = src._readableState;
  3997. debug('pipeOnDrain', state.awaitDrain);
  3998. if (state.awaitDrain) state.awaitDrain--;
  3999. if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
  4000. state.flowing = true;
  4001. flow(src);
  4002. }
  4003. };
  4004. }
  4005. Readable.prototype.unpipe = function (dest) {
  4006. var state = this._readableState;
  4007. var unpipeInfo = { hasUnpiped: false };
  4008. // if we're not piping anywhere, then do nothing.
  4009. if (state.pipesCount === 0) return this;
  4010. // just one destination. most common case.
  4011. if (state.pipesCount === 1) {
  4012. // passed in one, but it's not the right one.
  4013. if (dest && dest !== state.pipes) return this;
  4014. if (!dest) dest = state.pipes;
  4015. // got a match.
  4016. state.pipes = null;
  4017. state.pipesCount = 0;
  4018. state.flowing = false;
  4019. if (dest) dest.emit('unpipe', this, unpipeInfo);
  4020. return this;
  4021. }
  4022. // slow case. multiple pipe destinations.
  4023. if (!dest) {
  4024. // remove all.
  4025. var dests = state.pipes;
  4026. var len = state.pipesCount;
  4027. state.pipes = null;
  4028. state.pipesCount = 0;
  4029. state.flowing = false;
  4030. for (var i = 0; i < len; i++) {
  4031. dests[i].emit('unpipe', this, unpipeInfo);
  4032. }return this;
  4033. }
  4034. // try to find the right one.
  4035. var index = indexOf(state.pipes, dest);
  4036. if (index === -1) return this;
  4037. state.pipes.splice(index, 1);
  4038. state.pipesCount -= 1;
  4039. if (state.pipesCount === 1) state.pipes = state.pipes[0];
  4040. dest.emit('unpipe', this, unpipeInfo);
  4041. return this;
  4042. };
  4043. // set up data events if they are asked for
  4044. // Ensure readable listeners eventually get something
  4045. Readable.prototype.on = function (ev, fn) {
  4046. var res = Stream.prototype.on.call(this, ev, fn);
  4047. if (ev === 'data') {
  4048. // Start flowing on next tick if stream isn't explicitly paused
  4049. if (this._readableState.flowing !== false) this.resume();
  4050. } else if (ev === 'readable') {
  4051. var state = this._readableState;
  4052. if (!state.endEmitted && !state.readableListening) {
  4053. state.readableListening = state.needReadable = true;
  4054. state.emittedReadable = false;
  4055. if (!state.reading) {
  4056. pna.nextTick(nReadingNextTick, this);
  4057. } else if (state.length) {
  4058. emitReadable(this);
  4059. }
  4060. }
  4061. }
  4062. return res;
  4063. };
  4064. Readable.prototype.addListener = Readable.prototype.on;
  4065. function nReadingNextTick(self) {
  4066. debug('readable nexttick read 0');
  4067. self.read(0);
  4068. }
  4069. // pause() and resume() are remnants of the legacy readable stream API
  4070. // If the user uses them, then switch into old mode.
  4071. Readable.prototype.resume = function () {
  4072. var state = this._readableState;
  4073. if (!state.flowing) {
  4074. debug('resume');
  4075. state.flowing = true;
  4076. resume(this, state);
  4077. }
  4078. return this;
  4079. };
  4080. function resume(stream, state) {
  4081. if (!state.resumeScheduled) {
  4082. state.resumeScheduled = true;
  4083. pna.nextTick(resume_, stream, state);
  4084. }
  4085. }
  4086. function resume_(stream, state) {
  4087. if (!state.reading) {
  4088. debug('resume read 0');
  4089. stream.read(0);
  4090. }
  4091. state.resumeScheduled = false;
  4092. state.awaitDrain = 0;
  4093. stream.emit('resume');
  4094. flow(stream);
  4095. if (state.flowing && !state.reading) stream.read(0);
  4096. }
  4097. Readable.prototype.pause = function () {
  4098. debug('call pause flowing=%j', this._readableState.flowing);
  4099. if (false !== this._readableState.flowing) {
  4100. debug('pause');
  4101. this._readableState.flowing = false;
  4102. this.emit('pause');
  4103. }
  4104. return this;
  4105. };
  4106. function flow(stream) {
  4107. var state = stream._readableState;
  4108. debug('flow', state.flowing);
  4109. while (state.flowing && stream.read() !== null) {}
  4110. }
  4111. // wrap an old-style stream as the async data source.
  4112. // This is *not* part of the readable stream interface.
  4113. // It is an ugly unfortunate mess of history.
  4114. Readable.prototype.wrap = function (stream) {
  4115. var _this = this;
  4116. var state = this._readableState;
  4117. var paused = false;
  4118. stream.on('end', function () {
  4119. debug('wrapped end');
  4120. if (state.decoder && !state.ended) {
  4121. var chunk = state.decoder.end();
  4122. if (chunk && chunk.length) _this.push(chunk);
  4123. }
  4124. _this.push(null);
  4125. });
  4126. stream.on('data', function (chunk) {
  4127. debug('wrapped data');
  4128. if (state.decoder) chunk = state.decoder.write(chunk);
  4129. // don't skip over falsy values in objectMode
  4130. if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
  4131. var ret = _this.push(chunk);
  4132. if (!ret) {
  4133. paused = true;
  4134. stream.pause();
  4135. }
  4136. });
  4137. // proxy all the other methods.
  4138. // important when wrapping filters and duplexes.
  4139. for (var i in stream) {
  4140. if (this[i] === undefined && typeof stream[i] === 'function') {
  4141. this[i] = function (method) {
  4142. return function () {
  4143. return stream[method].apply(stream, arguments);
  4144. };
  4145. }(i);
  4146. }
  4147. }
  4148. // proxy certain important events.
  4149. for (var n = 0; n < kProxyEvents.length; n++) {
  4150. stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
  4151. }
  4152. // when we try to consume some more bytes, simply unpause the
  4153. // underlying stream.
  4154. this._read = function (n) {
  4155. debug('wrapped _read', n);
  4156. if (paused) {
  4157. paused = false;
  4158. stream.resume();
  4159. }
  4160. };
  4161. return this;
  4162. };
  4163. Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
  4164. // making it explicit this property is not enumerable
  4165. // because otherwise some prototype manipulation in
  4166. // userland will fail
  4167. enumerable: false,
  4168. get: function () {
  4169. return this._readableState.highWaterMark;
  4170. }
  4171. });
  4172. // exposed for testing purposes only.
  4173. Readable._fromList = fromList;
  4174. // Pluck off n bytes from an array of buffers.
  4175. // Length is the combined lengths of all the buffers in the list.
  4176. // This function is designed to be inlinable, so please take care when making
  4177. // changes to the function body.
  4178. function fromList(n, state) {
  4179. // nothing buffered
  4180. if (state.length === 0) return null;
  4181. var ret;
  4182. if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
  4183. // read it all, truncate the list
  4184. if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);
  4185. state.buffer.clear();
  4186. } else {
  4187. // read part of list
  4188. ret = fromListPartial(n, state.buffer, state.decoder);
  4189. }
  4190. return ret;
  4191. }
  4192. // Extracts only enough buffered data to satisfy the amount requested.
  4193. // This function is designed to be inlinable, so please take care when making
  4194. // changes to the function body.
  4195. function fromListPartial(n, list, hasStrings) {
  4196. var ret;
  4197. if (n < list.head.data.length) {
  4198. // slice is the same for buffers and strings
  4199. ret = list.head.data.slice(0, n);
  4200. list.head.data = list.head.data.slice(n);
  4201. } else if (n === list.head.data.length) {
  4202. // first chunk is a perfect match
  4203. ret = list.shift();
  4204. } else {
  4205. // result spans more than one buffer
  4206. ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
  4207. }
  4208. return ret;
  4209. }
  4210. // Copies a specified amount of characters from the list of buffered data
  4211. // chunks.
  4212. // This function is designed to be inlinable, so please take care when making
  4213. // changes to the function body.
  4214. function copyFromBufferString(n, list) {
  4215. var p = list.head;
  4216. var c = 1;
  4217. var ret = p.data;
  4218. n -= ret.length;
  4219. while (p = p.next) {
  4220. var str = p.data;
  4221. var nb = n > str.length ? str.length : n;
  4222. if (nb === str.length) ret += str;else ret += str.slice(0, n);
  4223. n -= nb;
  4224. if (n === 0) {
  4225. if (nb === str.length) {
  4226. ++c;
  4227. if (p.next) list.head = p.next;else list.head = list.tail = null;
  4228. } else {
  4229. list.head = p;
  4230. p.data = str.slice(nb);
  4231. }
  4232. break;
  4233. }
  4234. ++c;
  4235. }
  4236. list.length -= c;
  4237. return ret;
  4238. }
  4239. // Copies a specified amount of bytes from the list of buffered data chunks.
  4240. // This function is designed to be inlinable, so please take care when making
  4241. // changes to the function body.
  4242. function copyFromBuffer(n, list) {
  4243. var ret = Buffer.allocUnsafe(n);
  4244. var p = list.head;
  4245. var c = 1;
  4246. p.data.copy(ret);
  4247. n -= p.data.length;
  4248. while (p = p.next) {
  4249. var buf = p.data;
  4250. var nb = n > buf.length ? buf.length : n;
  4251. buf.copy(ret, ret.length - n, 0, nb);
  4252. n -= nb;
  4253. if (n === 0) {
  4254. if (nb === buf.length) {
  4255. ++c;
  4256. if (p.next) list.head = p.next;else list.head = list.tail = null;
  4257. } else {
  4258. list.head = p;
  4259. p.data = buf.slice(nb);
  4260. }
  4261. break;
  4262. }
  4263. ++c;
  4264. }
  4265. list.length -= c;
  4266. return ret;
  4267. }
  4268. function endReadable(stream) {
  4269. var state = stream._readableState;
  4270. // If we get here before consuming all the bytes, then that is a
  4271. // bug in node. Should never happen.
  4272. if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
  4273. if (!state.endEmitted) {
  4274. state.ended = true;
  4275. pna.nextTick(endReadableNT, state, stream);
  4276. }
  4277. }
  4278. function endReadableNT(state, stream) {
  4279. // Check that we didn't get one last unshift.
  4280. if (!state.endEmitted && state.length === 0) {
  4281. state.endEmitted = true;
  4282. stream.readable = false;
  4283. stream.emit('end');
  4284. }
  4285. }
  4286. function indexOf(xs, x) {
  4287. for (var i = 0, l = xs.length; i < l; i++) {
  4288. if (xs[i] === x) return i;
  4289. }
  4290. return -1;
  4291. }
  4292. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0), __webpack_require__(1)))
  4293. /***/ }),
  4294. /* 16 */
  4295. /***/ (function(module, exports, __webpack_require__) {
  4296. module.exports = __webpack_require__(8).EventEmitter;
  4297. /***/ }),
  4298. /* 17 */
  4299. /***/ (function(module, exports, __webpack_require__) {
  4300. "use strict";
  4301. /*<replacement>*/
  4302. var pna = __webpack_require__(6);
  4303. /*</replacement>*/
  4304. // undocumented cb() API, needed for core, not for public API
  4305. function destroy(err, cb) {
  4306. var _this = this;
  4307. var readableDestroyed = this._readableState && this._readableState.destroyed;
  4308. var writableDestroyed = this._writableState && this._writableState.destroyed;
  4309. if (readableDestroyed || writableDestroyed) {
  4310. if (cb) {
  4311. cb(err);
  4312. } else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
  4313. pna.nextTick(emitErrorNT, this, err);
  4314. }
  4315. return this;
  4316. }
  4317. // we set destroyed to true before firing error callbacks in order
  4318. // to make it re-entrance safe in case destroy() is called within callbacks
  4319. if (this._readableState) {
  4320. this._readableState.destroyed = true;
  4321. }
  4322. // if this is a duplex stream mark the writable part as destroyed as well
  4323. if (this._writableState) {
  4324. this._writableState.destroyed = true;
  4325. }
  4326. this._destroy(err || null, function (err) {
  4327. if (!cb && err) {
  4328. pna.nextTick(emitErrorNT, _this, err);
  4329. if (_this._writableState) {
  4330. _this._writableState.errorEmitted = true;
  4331. }
  4332. } else if (cb) {
  4333. cb(err);
  4334. }
  4335. });
  4336. return this;
  4337. }
  4338. function undestroy() {
  4339. if (this._readableState) {
  4340. this._readableState.destroyed = false;
  4341. this._readableState.reading = false;
  4342. this._readableState.ended = false;
  4343. this._readableState.endEmitted = false;
  4344. }
  4345. if (this._writableState) {
  4346. this._writableState.destroyed = false;
  4347. this._writableState.ended = false;
  4348. this._writableState.ending = false;
  4349. this._writableState.finished = false;
  4350. this._writableState.errorEmitted = false;
  4351. }
  4352. }
  4353. function emitErrorNT(self, err) {
  4354. self.emit('error', err);
  4355. }
  4356. module.exports = {
  4357. destroy: destroy,
  4358. undestroy: undestroy
  4359. };
  4360. /***/ }),
  4361. /* 18 */
  4362. /***/ (function(module, exports, __webpack_require__) {
  4363. "use strict";
  4364. /* WEBPACK VAR INJECTION */(function(process, setImmediate, global) {// Copyright Joyent, Inc. and other Node contributors.
  4365. //
  4366. // Permission is hereby granted, free of charge, to any person obtaining a
  4367. // copy of this software and associated documentation files (the
  4368. // "Software"), to deal in the Software without restriction, including
  4369. // without limitation the rights to use, copy, modify, merge, publish,
  4370. // distribute, sublicense, and/or sell copies of the Software, and to permit
  4371. // persons to whom the Software is furnished to do so, subject to the
  4372. // following conditions:
  4373. //
  4374. // The above copyright notice and this permission notice shall be included
  4375. // in all copies or substantial portions of the Software.
  4376. //
  4377. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  4378. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  4379. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  4380. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  4381. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  4382. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  4383. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  4384. // A bit simpler than readable streams.
  4385. // Implement an async ._write(chunk, encoding, cb), and it'll handle all
  4386. // the drain event emission and buffering.
  4387. /*<replacement>*/
  4388. var pna = __webpack_require__(6);
  4389. /*</replacement>*/
  4390. module.exports = Writable;
  4391. /* <replacement> */
  4392. function WriteReq(chunk, encoding, cb) {
  4393. this.chunk = chunk;
  4394. this.encoding = encoding;
  4395. this.callback = cb;
  4396. this.next = null;
  4397. }
  4398. // It seems a linked list but it is not
  4399. // there will be only 2 of these for each stream
  4400. function CorkedRequest(state) {
  4401. var _this = this;
  4402. this.next = null;
  4403. this.entry = null;
  4404. this.finish = function () {
  4405. onCorkedFinish(_this, state);
  4406. };
  4407. }
  4408. /* </replacement> */
  4409. /*<replacement>*/
  4410. var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;
  4411. /*</replacement>*/
  4412. /*<replacement>*/
  4413. var Duplex;
  4414. /*</replacement>*/
  4415. Writable.WritableState = WritableState;
  4416. /*<replacement>*/
  4417. var util = __webpack_require__(4);
  4418. util.inherits = __webpack_require__(5);
  4419. /*</replacement>*/
  4420. /*<replacement>*/
  4421. var internalUtil = {
  4422. deprecate: __webpack_require__(44)
  4423. };
  4424. /*</replacement>*/
  4425. /*<replacement>*/
  4426. var Stream = __webpack_require__(16);
  4427. /*</replacement>*/
  4428. /*<replacement>*/
  4429. var Buffer = __webpack_require__(9).Buffer;
  4430. var OurUint8Array = global.Uint8Array || function () {};
  4431. function _uint8ArrayToBuffer(chunk) {
  4432. return Buffer.from(chunk);
  4433. }
  4434. function _isUint8Array(obj) {
  4435. return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
  4436. }
  4437. /*</replacement>*/
  4438. var destroyImpl = __webpack_require__(17);
  4439. util.inherits(Writable, Stream);
  4440. function nop() {}
  4441. function WritableState(options, stream) {
  4442. Duplex = Duplex || __webpack_require__(3);
  4443. options = options || {};
  4444. // Duplex streams are both readable and writable, but share
  4445. // the same options object.
  4446. // However, some cases require setting options to different
  4447. // values for the readable and the writable sides of the duplex stream.
  4448. // These options can be provided separately as readableXXX and writableXXX.
  4449. var isDuplex = stream instanceof Duplex;
  4450. // object stream flag to indicate whether or not this stream
  4451. // contains buffers or objects.
  4452. this.objectMode = !!options.objectMode;
  4453. if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
  4454. // the point at which write() starts returning false
  4455. // Note: 0 is a valid value, means that we always return false if
  4456. // the entire buffer is not flushed immediately on write()
  4457. var hwm = options.highWaterMark;
  4458. var writableHwm = options.writableHighWaterMark;
  4459. var defaultHwm = this.objectMode ? 16 : 16 * 1024;
  4460. if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;
  4461. // cast to ints.
  4462. this.highWaterMark = Math.floor(this.highWaterMark);
  4463. // if _final has been called
  4464. this.finalCalled = false;
  4465. // drain event flag.
  4466. this.needDrain = false;
  4467. // at the start of calling end()
  4468. this.ending = false;
  4469. // when end() has been called, and returned
  4470. this.ended = false;
  4471. // when 'finish' is emitted
  4472. this.finished = false;
  4473. // has it been destroyed
  4474. this.destroyed = false;
  4475. // should we decode strings into buffers before passing to _write?
  4476. // this is here so that some node-core streams can optimize string
  4477. // handling at a lower level.
  4478. var noDecode = options.decodeStrings === false;
  4479. this.decodeStrings = !noDecode;
  4480. // Crypto is kind of old and crusty. Historically, its default string
  4481. // encoding is 'binary' so we have to make this configurable.
  4482. // Everything else in the universe uses 'utf8', though.
  4483. this.defaultEncoding = options.defaultEncoding || 'utf8';
  4484. // not an actual buffer we keep track of, but a measurement
  4485. // of how much we're waiting to get pushed to some underlying
  4486. // socket or file.
  4487. this.length = 0;
  4488. // a flag to see when we're in the middle of a write.
  4489. this.writing = false;
  4490. // when true all writes will be buffered until .uncork() call
  4491. this.corked = 0;
  4492. // a flag to be able to tell if the onwrite cb is called immediately,
  4493. // or on a later tick. We set this to true at first, because any
  4494. // actions that shouldn't happen until "later" should generally also
  4495. // not happen before the first write call.
  4496. this.sync = true;
  4497. // a flag to know if we're processing previously buffered items, which
  4498. // may call the _write() callback in the same tick, so that we don't
  4499. // end up in an overlapped onwrite situation.
  4500. this.bufferProcessing = false;
  4501. // the callback that's passed to _write(chunk,cb)
  4502. this.onwrite = function (er) {
  4503. onwrite(stream, er);
  4504. };
  4505. // the callback that the user supplies to write(chunk,encoding,cb)
  4506. this.writecb = null;
  4507. // the amount that is being written when _write is called.
  4508. this.writelen = 0;
  4509. this.bufferedRequest = null;
  4510. this.lastBufferedRequest = null;
  4511. // number of pending user-supplied write callbacks
  4512. // this must be 0 before 'finish' can be emitted
  4513. this.pendingcb = 0;
  4514. // emit prefinish if the only thing we're waiting for is _write cbs
  4515. // This is relevant for synchronous Transform streams
  4516. this.prefinished = false;
  4517. // True if the error was already emitted and should not be thrown again
  4518. this.errorEmitted = false;
  4519. // count buffered requests
  4520. this.bufferedRequestCount = 0;
  4521. // allocate the first CorkedRequest, there is always
  4522. // one allocated and free to use, and we maintain at most two
  4523. this.corkedRequestsFree = new CorkedRequest(this);
  4524. }
  4525. WritableState.prototype.getBuffer = function getBuffer() {
  4526. var current = this.bufferedRequest;
  4527. var out = [];
  4528. while (current) {
  4529. out.push(current);
  4530. current = current.next;
  4531. }
  4532. return out;
  4533. };
  4534. (function () {
  4535. try {
  4536. Object.defineProperty(WritableState.prototype, 'buffer', {
  4537. get: internalUtil.deprecate(function () {
  4538. return this.getBuffer();
  4539. }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
  4540. });
  4541. } catch (_) {}
  4542. })();
  4543. // Test _writableState for inheritance to account for Duplex streams,
  4544. // whose prototype chain only points to Readable.
  4545. var realHasInstance;
  4546. if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
  4547. realHasInstance = Function.prototype[Symbol.hasInstance];
  4548. Object.defineProperty(Writable, Symbol.hasInstance, {
  4549. value: function (object) {
  4550. if (realHasInstance.call(this, object)) return true;
  4551. if (this !== Writable) return false;
  4552. return object && object._writableState instanceof WritableState;
  4553. }
  4554. });
  4555. } else {
  4556. realHasInstance = function (object) {
  4557. return object instanceof this;
  4558. };
  4559. }
  4560. function Writable(options) {
  4561. Duplex = Duplex || __webpack_require__(3);
  4562. // Writable ctor is applied to Duplexes, too.
  4563. // `realHasInstance` is necessary because using plain `instanceof`
  4564. // would return false, as no `_writableState` property is attached.
  4565. // Trying to use the custom `instanceof` for Writable here will also break the
  4566. // Node.js LazyTransform implementation, which has a non-trivial getter for
  4567. // `_writableState` that would lead to infinite recursion.
  4568. if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
  4569. return new Writable(options);
  4570. }
  4571. this._writableState = new WritableState(options, this);
  4572. // legacy.
  4573. this.writable = true;
  4574. if (options) {
  4575. if (typeof options.write === 'function') this._write = options.write;
  4576. if (typeof options.writev === 'function') this._writev = options.writev;
  4577. if (typeof options.destroy === 'function') this._destroy = options.destroy;
  4578. if (typeof options.final === 'function') this._final = options.final;
  4579. }
  4580. Stream.call(this);
  4581. }
  4582. // Otherwise people can pipe Writable streams, which is just wrong.
  4583. Writable.prototype.pipe = function () {
  4584. this.emit('error', new Error('Cannot pipe, not readable'));
  4585. };
  4586. function writeAfterEnd(stream, cb) {
  4587. var er = new Error('write after end');
  4588. // TODO: defer error events consistently everywhere, not just the cb
  4589. stream.emit('error', er);
  4590. pna.nextTick(cb, er);
  4591. }
  4592. // Checks that a user-supplied chunk is valid, especially for the particular
  4593. // mode the stream is in. Currently this means that `null` is never accepted
  4594. // and undefined/non-string values are only allowed in object mode.
  4595. function validChunk(stream, state, chunk, cb) {
  4596. var valid = true;
  4597. var er = false;
  4598. if (chunk === null) {
  4599. er = new TypeError('May not write null values to stream');
  4600. } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
  4601. er = new TypeError('Invalid non-string/buffer chunk');
  4602. }
  4603. if (er) {
  4604. stream.emit('error', er);
  4605. pna.nextTick(cb, er);
  4606. valid = false;
  4607. }
  4608. return valid;
  4609. }
  4610. Writable.prototype.write = function (chunk, encoding, cb) {
  4611. var state = this._writableState;
  4612. var ret = false;
  4613. var isBuf = !state.objectMode && _isUint8Array(chunk);
  4614. if (isBuf && !Buffer.isBuffer(chunk)) {
  4615. chunk = _uint8ArrayToBuffer(chunk);
  4616. }
  4617. if (typeof encoding === 'function') {
  4618. cb = encoding;
  4619. encoding = null;
  4620. }
  4621. if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
  4622. if (typeof cb !== 'function') cb = nop;
  4623. if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
  4624. state.pendingcb++;
  4625. ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
  4626. }
  4627. return ret;
  4628. };
  4629. Writable.prototype.cork = function () {
  4630. var state = this._writableState;
  4631. state.corked++;
  4632. };
  4633. Writable.prototype.uncork = function () {
  4634. var state = this._writableState;
  4635. if (state.corked) {
  4636. state.corked--;
  4637. if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
  4638. }
  4639. };
  4640. Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
  4641. // node::ParseEncoding() requires lower case.
  4642. if (typeof encoding === 'string') encoding = encoding.toLowerCase();
  4643. if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);
  4644. this._writableState.defaultEncoding = encoding;
  4645. return this;
  4646. };
  4647. function decodeChunk(state, chunk, encoding) {
  4648. if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
  4649. chunk = Buffer.from(chunk, encoding);
  4650. }
  4651. return chunk;
  4652. }
  4653. Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
  4654. // making it explicit this property is not enumerable
  4655. // because otherwise some prototype manipulation in
  4656. // userland will fail
  4657. enumerable: false,
  4658. get: function () {
  4659. return this._writableState.highWaterMark;
  4660. }
  4661. });
  4662. // if we're already writing something, then just put this
  4663. // in the queue, and wait our turn. Otherwise, call _write
  4664. // If we return false, then we need a drain event, so set that flag.
  4665. function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
  4666. if (!isBuf) {
  4667. var newChunk = decodeChunk(state, chunk, encoding);
  4668. if (chunk !== newChunk) {
  4669. isBuf = true;
  4670. encoding = 'buffer';
  4671. chunk = newChunk;
  4672. }
  4673. }
  4674. var len = state.objectMode ? 1 : chunk.length;
  4675. state.length += len;
  4676. var ret = state.length < state.highWaterMark;
  4677. // we must ensure that previous needDrain will not be reset to false.
  4678. if (!ret) state.needDrain = true;
  4679. if (state.writing || state.corked) {
  4680. var last = state.lastBufferedRequest;
  4681. state.lastBufferedRequest = {
  4682. chunk: chunk,
  4683. encoding: encoding,
  4684. isBuf: isBuf,
  4685. callback: cb,
  4686. next: null
  4687. };
  4688. if (last) {
  4689. last.next = state.lastBufferedRequest;
  4690. } else {
  4691. state.bufferedRequest = state.lastBufferedRequest;
  4692. }
  4693. state.bufferedRequestCount += 1;
  4694. } else {
  4695. doWrite(stream, state, false, len, chunk, encoding, cb);
  4696. }
  4697. return ret;
  4698. }
  4699. function doWrite(stream, state, writev, len, chunk, encoding, cb) {
  4700. state.writelen = len;
  4701. state.writecb = cb;
  4702. state.writing = true;
  4703. state.sync = true;
  4704. if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
  4705. state.sync = false;
  4706. }
  4707. function onwriteError(stream, state, sync, er, cb) {
  4708. --state.pendingcb;
  4709. if (sync) {
  4710. // defer the callback if we are being called synchronously
  4711. // to avoid piling up things on the stack
  4712. pna.nextTick(cb, er);
  4713. // this can emit finish, and it will always happen
  4714. // after error
  4715. pna.nextTick(finishMaybe, stream, state);
  4716. stream._writableState.errorEmitted = true;
  4717. stream.emit('error', er);
  4718. } else {
  4719. // the caller expect this to happen before if
  4720. // it is async
  4721. cb(er);
  4722. stream._writableState.errorEmitted = true;
  4723. stream.emit('error', er);
  4724. // this can emit finish, but finish must
  4725. // always follow error
  4726. finishMaybe(stream, state);
  4727. }
  4728. }
  4729. function onwriteStateUpdate(state) {
  4730. state.writing = false;
  4731. state.writecb = null;
  4732. state.length -= state.writelen;
  4733. state.writelen = 0;
  4734. }
  4735. function onwrite(stream, er) {
  4736. var state = stream._writableState;
  4737. var sync = state.sync;
  4738. var cb = state.writecb;
  4739. onwriteStateUpdate(state);
  4740. if (er) onwriteError(stream, state, sync, er, cb);else {
  4741. // Check if we're actually ready to finish, but don't emit yet
  4742. var finished = needFinish(state);
  4743. if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
  4744. clearBuffer(stream, state);
  4745. }
  4746. if (sync) {
  4747. /*<replacement>*/
  4748. asyncWrite(afterWrite, stream, state, finished, cb);
  4749. /*</replacement>*/
  4750. } else {
  4751. afterWrite(stream, state, finished, cb);
  4752. }
  4753. }
  4754. }
  4755. function afterWrite(stream, state, finished, cb) {
  4756. if (!finished) onwriteDrain(stream, state);
  4757. state.pendingcb--;
  4758. cb();
  4759. finishMaybe(stream, state);
  4760. }
  4761. // Must force callback to be called on nextTick, so that we don't
  4762. // emit 'drain' before the write() consumer gets the 'false' return
  4763. // value, and has a chance to attach a 'drain' listener.
  4764. function onwriteDrain(stream, state) {
  4765. if (state.length === 0 && state.needDrain) {
  4766. state.needDrain = false;
  4767. stream.emit('drain');
  4768. }
  4769. }
  4770. // if there's something in the buffer waiting, then process it
  4771. function clearBuffer(stream, state) {
  4772. state.bufferProcessing = true;
  4773. var entry = state.bufferedRequest;
  4774. if (stream._writev && entry && entry.next) {
  4775. // Fast case, write everything using _writev()
  4776. var l = state.bufferedRequestCount;
  4777. var buffer = new Array(l);
  4778. var holder = state.corkedRequestsFree;
  4779. holder.entry = entry;
  4780. var count = 0;
  4781. var allBuffers = true;
  4782. while (entry) {
  4783. buffer[count] = entry;
  4784. if (!entry.isBuf) allBuffers = false;
  4785. entry = entry.next;
  4786. count += 1;
  4787. }
  4788. buffer.allBuffers = allBuffers;
  4789. doWrite(stream, state, true, state.length, buffer, '', holder.finish);
  4790. // doWrite is almost always async, defer these to save a bit of time
  4791. // as the hot path ends with doWrite
  4792. state.pendingcb++;
  4793. state.lastBufferedRequest = null;
  4794. if (holder.next) {
  4795. state.corkedRequestsFree = holder.next;
  4796. holder.next = null;
  4797. } else {
  4798. state.corkedRequestsFree = new CorkedRequest(state);
  4799. }
  4800. state.bufferedRequestCount = 0;
  4801. } else {
  4802. // Slow case, write chunks one-by-one
  4803. while (entry) {
  4804. var chunk = entry.chunk;
  4805. var encoding = entry.encoding;
  4806. var cb = entry.callback;
  4807. var len = state.objectMode ? 1 : chunk.length;
  4808. doWrite(stream, state, false, len, chunk, encoding, cb);
  4809. entry = entry.next;
  4810. state.bufferedRequestCount--;
  4811. // if we didn't call the onwrite immediately, then
  4812. // it means that we need to wait until it does.
  4813. // also, that means that the chunk and cb are currently
  4814. // being processed, so move the buffer counter past them.
  4815. if (state.writing) {
  4816. break;
  4817. }
  4818. }
  4819. if (entry === null) state.lastBufferedRequest = null;
  4820. }
  4821. state.bufferedRequest = entry;
  4822. state.bufferProcessing = false;
  4823. }
  4824. Writable.prototype._write = function (chunk, encoding, cb) {
  4825. cb(new Error('_write() is not implemented'));
  4826. };
  4827. Writable.prototype._writev = null;
  4828. Writable.prototype.end = function (chunk, encoding, cb) {
  4829. var state = this._writableState;
  4830. if (typeof chunk === 'function') {
  4831. cb = chunk;
  4832. chunk = null;
  4833. encoding = null;
  4834. } else if (typeof encoding === 'function') {
  4835. cb = encoding;
  4836. encoding = null;
  4837. }
  4838. if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
  4839. // .end() fully uncorks
  4840. if (state.corked) {
  4841. state.corked = 1;
  4842. this.uncork();
  4843. }
  4844. // ignore unnecessary end() calls.
  4845. if (!state.ending && !state.finished) endWritable(this, state, cb);
  4846. };
  4847. function needFinish(state) {
  4848. return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
  4849. }
  4850. function callFinal(stream, state) {
  4851. stream._final(function (err) {
  4852. state.pendingcb--;
  4853. if (err) {
  4854. stream.emit('error', err);
  4855. }
  4856. state.prefinished = true;
  4857. stream.emit('prefinish');
  4858. finishMaybe(stream, state);
  4859. });
  4860. }
  4861. function prefinish(stream, state) {
  4862. if (!state.prefinished && !state.finalCalled) {
  4863. if (typeof stream._final === 'function') {
  4864. state.pendingcb++;
  4865. state.finalCalled = true;
  4866. pna.nextTick(callFinal, stream, state);
  4867. } else {
  4868. state.prefinished = true;
  4869. stream.emit('prefinish');
  4870. }
  4871. }
  4872. }
  4873. function finishMaybe(stream, state) {
  4874. var need = needFinish(state);
  4875. if (need) {
  4876. prefinish(stream, state);
  4877. if (state.pendingcb === 0) {
  4878. state.finished = true;
  4879. stream.emit('finish');
  4880. }
  4881. }
  4882. return need;
  4883. }
  4884. function endWritable(stream, state, cb) {
  4885. state.ending = true;
  4886. finishMaybe(stream, state);
  4887. if (cb) {
  4888. if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);
  4889. }
  4890. state.ended = true;
  4891. stream.writable = false;
  4892. }
  4893. function onCorkedFinish(corkReq, state, err) {
  4894. var entry = corkReq.entry;
  4895. corkReq.entry = null;
  4896. while (entry) {
  4897. var cb = entry.callback;
  4898. state.pendingcb--;
  4899. cb(err);
  4900. entry = entry.next;
  4901. }
  4902. if (state.corkedRequestsFree) {
  4903. state.corkedRequestsFree.next = corkReq;
  4904. } else {
  4905. state.corkedRequestsFree = corkReq;
  4906. }
  4907. }
  4908. Object.defineProperty(Writable.prototype, 'destroyed', {
  4909. get: function () {
  4910. if (this._writableState === undefined) {
  4911. return false;
  4912. }
  4913. return this._writableState.destroyed;
  4914. },
  4915. set: function (value) {
  4916. // we ignore the value if the stream
  4917. // has not been initialized yet
  4918. if (!this._writableState) {
  4919. return;
  4920. }
  4921. // backward compatibility, the user is explicitly
  4922. // managing destroyed
  4923. this._writableState.destroyed = value;
  4924. }
  4925. });
  4926. Writable.prototype.destroy = destroyImpl.destroy;
  4927. Writable.prototype._undestroy = destroyImpl.undestroy;
  4928. Writable.prototype._destroy = function (err, cb) {
  4929. this.end();
  4930. cb(err);
  4931. };
  4932. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1), __webpack_require__(42).setImmediate, __webpack_require__(0)))
  4933. /***/ }),
  4934. /* 19 */
  4935. /***/ (function(module, exports, __webpack_require__) {
  4936. "use strict";
  4937. // Copyright Joyent, Inc. and other Node contributors.
  4938. //
  4939. // Permission is hereby granted, free of charge, to any person obtaining a
  4940. // copy of this software and associated documentation files (the
  4941. // "Software"), to deal in the Software without restriction, including
  4942. // without limitation the rights to use, copy, modify, merge, publish,
  4943. // distribute, sublicense, and/or sell copies of the Software, and to permit
  4944. // persons to whom the Software is furnished to do so, subject to the
  4945. // following conditions:
  4946. //
  4947. // The above copyright notice and this permission notice shall be included
  4948. // in all copies or substantial portions of the Software.
  4949. //
  4950. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  4951. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  4952. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  4953. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  4954. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  4955. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  4956. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  4957. /*<replacement>*/
  4958. var Buffer = __webpack_require__(45).Buffer;
  4959. /*</replacement>*/
  4960. var isEncoding = Buffer.isEncoding || function (encoding) {
  4961. encoding = '' + encoding;
  4962. switch (encoding && encoding.toLowerCase()) {
  4963. case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':
  4964. return true;
  4965. default:
  4966. return false;
  4967. }
  4968. };
  4969. function _normalizeEncoding(enc) {
  4970. if (!enc) return 'utf8';
  4971. var retried;
  4972. while (true) {
  4973. switch (enc) {
  4974. case 'utf8':
  4975. case 'utf-8':
  4976. return 'utf8';
  4977. case 'ucs2':
  4978. case 'ucs-2':
  4979. case 'utf16le':
  4980. case 'utf-16le':
  4981. return 'utf16le';
  4982. case 'latin1':
  4983. case 'binary':
  4984. return 'latin1';
  4985. case 'base64':
  4986. case 'ascii':
  4987. case 'hex':
  4988. return enc;
  4989. default:
  4990. if (retried) return; // undefined
  4991. enc = ('' + enc).toLowerCase();
  4992. retried = true;
  4993. }
  4994. }
  4995. };
  4996. // Do not cache `Buffer.isEncoding` when checking encoding names as some
  4997. // modules monkey-patch it to support additional encodings
  4998. function normalizeEncoding(enc) {
  4999. var nenc = _normalizeEncoding(enc);
  5000. if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
  5001. return nenc || enc;
  5002. }
  5003. // StringDecoder provides an interface for efficiently splitting a series of
  5004. // buffers into a series of JS strings without breaking apart multi-byte
  5005. // characters.
  5006. exports.StringDecoder = StringDecoder;
  5007. function StringDecoder(encoding) {
  5008. this.encoding = normalizeEncoding(encoding);
  5009. var nb;
  5010. switch (this.encoding) {
  5011. case 'utf16le':
  5012. this.text = utf16Text;
  5013. this.end = utf16End;
  5014. nb = 4;
  5015. break;
  5016. case 'utf8':
  5017. this.fillLast = utf8FillLast;
  5018. nb = 4;
  5019. break;
  5020. case 'base64':
  5021. this.text = base64Text;
  5022. this.end = base64End;
  5023. nb = 3;
  5024. break;
  5025. default:
  5026. this.write = simpleWrite;
  5027. this.end = simpleEnd;
  5028. return;
  5029. }
  5030. this.lastNeed = 0;
  5031. this.lastTotal = 0;
  5032. this.lastChar = Buffer.allocUnsafe(nb);
  5033. }
  5034. StringDecoder.prototype.write = function (buf) {
  5035. if (buf.length === 0) return '';
  5036. var r;
  5037. var i;
  5038. if (this.lastNeed) {
  5039. r = this.fillLast(buf);
  5040. if (r === undefined) return '';
  5041. i = this.lastNeed;
  5042. this.lastNeed = 0;
  5043. } else {
  5044. i = 0;
  5045. }
  5046. if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
  5047. return r || '';
  5048. };
  5049. StringDecoder.prototype.end = utf8End;
  5050. // Returns only complete characters in a Buffer
  5051. StringDecoder.prototype.text = utf8Text;
  5052. // Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
  5053. StringDecoder.prototype.fillLast = function (buf) {
  5054. if (this.lastNeed <= buf.length) {
  5055. buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
  5056. return this.lastChar.toString(this.encoding, 0, this.lastTotal);
  5057. }
  5058. buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
  5059. this.lastNeed -= buf.length;
  5060. };
  5061. // Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
  5062. // continuation byte. If an invalid byte is detected, -2 is returned.
  5063. function utf8CheckByte(byte) {
  5064. if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;
  5065. return byte >> 6 === 0x02 ? -1 : -2;
  5066. }
  5067. // Checks at most 3 bytes at the end of a Buffer in order to detect an
  5068. // incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
  5069. // needed to complete the UTF-8 character (if applicable) are returned.
  5070. function utf8CheckIncomplete(self, buf, i) {
  5071. var j = buf.length - 1;
  5072. if (j < i) return 0;
  5073. var nb = utf8CheckByte(buf[j]);
  5074. if (nb >= 0) {
  5075. if (nb > 0) self.lastNeed = nb - 1;
  5076. return nb;
  5077. }
  5078. if (--j < i || nb === -2) return 0;
  5079. nb = utf8CheckByte(buf[j]);
  5080. if (nb >= 0) {
  5081. if (nb > 0) self.lastNeed = nb - 2;
  5082. return nb;
  5083. }
  5084. if (--j < i || nb === -2) return 0;
  5085. nb = utf8CheckByte(buf[j]);
  5086. if (nb >= 0) {
  5087. if (nb > 0) {
  5088. if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
  5089. }
  5090. return nb;
  5091. }
  5092. return 0;
  5093. }
  5094. // Validates as many continuation bytes for a multi-byte UTF-8 character as
  5095. // needed or are available. If we see a non-continuation byte where we expect
  5096. // one, we "replace" the validated continuation bytes we've seen so far with
  5097. // a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
  5098. // behavior. The continuation byte check is included three times in the case
  5099. // where all of the continuation bytes for a character exist in the same buffer.
  5100. // It is also done this way as a slight performance increase instead of using a
  5101. // loop.
  5102. function utf8CheckExtraBytes(self, buf, p) {
  5103. if ((buf[0] & 0xC0) !== 0x80) {
  5104. self.lastNeed = 0;
  5105. return '\ufffd';
  5106. }
  5107. if (self.lastNeed > 1 && buf.length > 1) {
  5108. if ((buf[1] & 0xC0) !== 0x80) {
  5109. self.lastNeed = 1;
  5110. return '\ufffd';
  5111. }
  5112. if (self.lastNeed > 2 && buf.length > 2) {
  5113. if ((buf[2] & 0xC0) !== 0x80) {
  5114. self.lastNeed = 2;
  5115. return '\ufffd';
  5116. }
  5117. }
  5118. }
  5119. }
  5120. // Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
  5121. function utf8FillLast(buf) {
  5122. var p = this.lastTotal - this.lastNeed;
  5123. var r = utf8CheckExtraBytes(this, buf, p);
  5124. if (r !== undefined) return r;
  5125. if (this.lastNeed <= buf.length) {
  5126. buf.copy(this.lastChar, p, 0, this.lastNeed);
  5127. return this.lastChar.toString(this.encoding, 0, this.lastTotal);
  5128. }
  5129. buf.copy(this.lastChar, p, 0, buf.length);
  5130. this.lastNeed -= buf.length;
  5131. }
  5132. // Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
  5133. // partial character, the character's bytes are buffered until the required
  5134. // number of bytes are available.
  5135. function utf8Text(buf, i) {
  5136. var total = utf8CheckIncomplete(this, buf, i);
  5137. if (!this.lastNeed) return buf.toString('utf8', i);
  5138. this.lastTotal = total;
  5139. var end = buf.length - (total - this.lastNeed);
  5140. buf.copy(this.lastChar, 0, end);
  5141. return buf.toString('utf8', i, end);
  5142. }
  5143. // For UTF-8, a replacement character is added when ending on a partial
  5144. // character.
  5145. function utf8End(buf) {
  5146. var r = buf && buf.length ? this.write(buf) : '';
  5147. if (this.lastNeed) return r + '\ufffd';
  5148. return r;
  5149. }
  5150. // UTF-16LE typically needs two bytes per character, but even if we have an even
  5151. // number of bytes available, we need to check if we end on a leading/high
  5152. // surrogate. In that case, we need to wait for the next two bytes in order to
  5153. // decode the last character properly.
  5154. function utf16Text(buf, i) {
  5155. if ((buf.length - i) % 2 === 0) {
  5156. var r = buf.toString('utf16le', i);
  5157. if (r) {
  5158. var c = r.charCodeAt(r.length - 1);
  5159. if (c >= 0xD800 && c <= 0xDBFF) {
  5160. this.lastNeed = 2;
  5161. this.lastTotal = 4;
  5162. this.lastChar[0] = buf[buf.length - 2];
  5163. this.lastChar[1] = buf[buf.length - 1];
  5164. return r.slice(0, -1);
  5165. }
  5166. }
  5167. return r;
  5168. }
  5169. this.lastNeed = 1;
  5170. this.lastTotal = 2;
  5171. this.lastChar[0] = buf[buf.length - 1];
  5172. return buf.toString('utf16le', i, buf.length - 1);
  5173. }
  5174. // For UTF-16LE we do not explicitly append special replacement characters if we
  5175. // end on a partial character, we simply let v8 handle that.
  5176. function utf16End(buf) {
  5177. var r = buf && buf.length ? this.write(buf) : '';
  5178. if (this.lastNeed) {
  5179. var end = this.lastTotal - this.lastNeed;
  5180. return r + this.lastChar.toString('utf16le', 0, end);
  5181. }
  5182. return r;
  5183. }
  5184. function base64Text(buf, i) {
  5185. var n = (buf.length - i) % 3;
  5186. if (n === 0) return buf.toString('base64', i);
  5187. this.lastNeed = 3 - n;
  5188. this.lastTotal = 3;
  5189. if (n === 1) {
  5190. this.lastChar[0] = buf[buf.length - 1];
  5191. } else {
  5192. this.lastChar[0] = buf[buf.length - 2];
  5193. this.lastChar[1] = buf[buf.length - 1];
  5194. }
  5195. return buf.toString('base64', i, buf.length - n);
  5196. }
  5197. function base64End(buf) {
  5198. var r = buf && buf.length ? this.write(buf) : '';
  5199. if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
  5200. return r;
  5201. }
  5202. // Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
  5203. function simpleWrite(buf) {
  5204. return buf.toString(this.encoding);
  5205. }
  5206. function simpleEnd(buf) {
  5207. return buf && buf.length ? this.write(buf) : '';
  5208. }
  5209. /***/ }),
  5210. /* 20 */
  5211. /***/ (function(module, exports, __webpack_require__) {
  5212. "use strict";
  5213. // Copyright Joyent, Inc. and other Node contributors.
  5214. //
  5215. // Permission is hereby granted, free of charge, to any person obtaining a
  5216. // copy of this software and associated documentation files (the
  5217. // "Software"), to deal in the Software without restriction, including
  5218. // without limitation the rights to use, copy, modify, merge, publish,
  5219. // distribute, sublicense, and/or sell copies of the Software, and to permit
  5220. // persons to whom the Software is furnished to do so, subject to the
  5221. // following conditions:
  5222. //
  5223. // The above copyright notice and this permission notice shall be included
  5224. // in all copies or substantial portions of the Software.
  5225. //
  5226. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  5227. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  5228. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  5229. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  5230. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  5231. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  5232. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  5233. // a transform stream is a readable/writable stream where you do
  5234. // something with the data. Sometimes it's called a "filter",
  5235. // but that's not a great name for it, since that implies a thing where
  5236. // some bits pass through, and others are simply ignored. (That would
  5237. // be a valid example of a transform, of course.)
  5238. //
  5239. // While the output is causally related to the input, it's not a
  5240. // necessarily symmetric or synchronous transformation. For example,
  5241. // a zlib stream might take multiple plain-text writes(), and then
  5242. // emit a single compressed chunk some time in the future.
  5243. //
  5244. // Here's how this works:
  5245. //
  5246. // The Transform stream has all the aspects of the readable and writable
  5247. // stream classes. When you write(chunk), that calls _write(chunk,cb)
  5248. // internally, and returns false if there's a lot of pending writes
  5249. // buffered up. When you call read(), that calls _read(n) until
  5250. // there's enough pending readable data buffered up.
  5251. //
  5252. // In a transform stream, the written data is placed in a buffer. When
  5253. // _read(n) is called, it transforms the queued up data, calling the
  5254. // buffered _write cb's as it consumes chunks. If consuming a single
  5255. // written chunk would result in multiple output chunks, then the first
  5256. // outputted bit calls the readcb, and subsequent chunks just go into
  5257. // the read buffer, and will cause it to emit 'readable' if necessary.
  5258. //
  5259. // This way, back-pressure is actually determined by the reading side,
  5260. // since _read has to be called to start processing a new chunk. However,
  5261. // a pathological inflate type of transform can cause excessive buffering
  5262. // here. For example, imagine a stream where every byte of input is
  5263. // interpreted as an integer from 0-255, and then results in that many
  5264. // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
  5265. // 1kb of data being output. In this case, you could write a very small
  5266. // amount of input, and end up with a very large amount of output. In
  5267. // such a pathological inflating mechanism, there'd be no way to tell
  5268. // the system to stop doing the transform. A single 4MB write could
  5269. // cause the system to run out of memory.
  5270. //
  5271. // However, even in such a pathological case, only a single written chunk
  5272. // would be consumed, and then the rest would wait (un-transformed) until
  5273. // the results of the previous transformed chunk were consumed.
  5274. module.exports = Transform;
  5275. var Duplex = __webpack_require__(3);
  5276. /*<replacement>*/
  5277. var util = __webpack_require__(4);
  5278. util.inherits = __webpack_require__(5);
  5279. /*</replacement>*/
  5280. util.inherits(Transform, Duplex);
  5281. function afterTransform(er, data) {
  5282. var ts = this._transformState;
  5283. ts.transforming = false;
  5284. var cb = ts.writecb;
  5285. if (!cb) {
  5286. return this.emit('error', new Error('write callback called multiple times'));
  5287. }
  5288. ts.writechunk = null;
  5289. ts.writecb = null;
  5290. if (data != null) // single equals check for both `null` and `undefined`
  5291. this.push(data);
  5292. cb(er);
  5293. var rs = this._readableState;
  5294. rs.reading = false;
  5295. if (rs.needReadable || rs.length < rs.highWaterMark) {
  5296. this._read(rs.highWaterMark);
  5297. }
  5298. }
  5299. function Transform(options) {
  5300. if (!(this instanceof Transform)) return new Transform(options);
  5301. Duplex.call(this, options);
  5302. this._transformState = {
  5303. afterTransform: afterTransform.bind(this),
  5304. needTransform: false,
  5305. transforming: false,
  5306. writecb: null,
  5307. writechunk: null,
  5308. writeencoding: null
  5309. };
  5310. // start out asking for a readable event once data is transformed.
  5311. this._readableState.needReadable = true;
  5312. // we have implemented the _read method, and done the other things
  5313. // that Readable wants before the first _read call, so unset the
  5314. // sync guard flag.
  5315. this._readableState.sync = false;
  5316. if (options) {
  5317. if (typeof options.transform === 'function') this._transform = options.transform;
  5318. if (typeof options.flush === 'function') this._flush = options.flush;
  5319. }
  5320. // When the writable side finishes, then flush out anything remaining.
  5321. this.on('prefinish', prefinish);
  5322. }
  5323. function prefinish() {
  5324. var _this = this;
  5325. if (typeof this._flush === 'function') {
  5326. this._flush(function (er, data) {
  5327. done(_this, er, data);
  5328. });
  5329. } else {
  5330. done(this, null, null);
  5331. }
  5332. }
  5333. Transform.prototype.push = function (chunk, encoding) {
  5334. this._transformState.needTransform = false;
  5335. return Duplex.prototype.push.call(this, chunk, encoding);
  5336. };
  5337. // This is the part where you do stuff!
  5338. // override this function in implementation classes.
  5339. // 'chunk' is an input chunk.
  5340. //
  5341. // Call `push(newChunk)` to pass along transformed output
  5342. // to the readable side. You may call 'push' zero or more times.
  5343. //
  5344. // Call `cb(err)` when you are done with this chunk. If you pass
  5345. // an error, then that'll put the hurt on the whole operation. If you
  5346. // never call cb(), then you'll never get another chunk.
  5347. Transform.prototype._transform = function (chunk, encoding, cb) {
  5348. throw new Error('_transform() is not implemented');
  5349. };
  5350. Transform.prototype._write = function (chunk, encoding, cb) {
  5351. var ts = this._transformState;
  5352. ts.writecb = cb;
  5353. ts.writechunk = chunk;
  5354. ts.writeencoding = encoding;
  5355. if (!ts.transforming) {
  5356. var rs = this._readableState;
  5357. if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
  5358. }
  5359. };
  5360. // Doesn't matter what the args are here.
  5361. // _transform does all the work.
  5362. // That we got here means that the readable side wants more data.
  5363. Transform.prototype._read = function (n) {
  5364. var ts = this._transformState;
  5365. if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
  5366. ts.transforming = true;
  5367. this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
  5368. } else {
  5369. // mark that we need a transform, so that any data that comes in
  5370. // will get processed, now that we've asked for it.
  5371. ts.needTransform = true;
  5372. }
  5373. };
  5374. Transform.prototype._destroy = function (err, cb) {
  5375. var _this2 = this;
  5376. Duplex.prototype._destroy.call(this, err, function (err2) {
  5377. cb(err2);
  5378. _this2.emit('close');
  5379. });
  5380. };
  5381. function done(stream, er, data) {
  5382. if (er) return stream.emit('error', er);
  5383. if (data != null) // single equals check for both `null` and `undefined`
  5384. stream.push(data);
  5385. // if there's nothing in the write buffer, then that means
  5386. // that nothing more will ever be provided
  5387. if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');
  5388. if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');
  5389. return stream.push(null);
  5390. }
  5391. /***/ }),
  5392. /* 21 */
  5393. /***/ (function(module, exports, __webpack_require__) {
  5394. var EventSource = __webpack_require__(22)
  5395. if (typeof window === 'object') {
  5396. window.EventSourcePolyfill = EventSource
  5397. if (!window.EventSource) window.EventSource = EventSource
  5398. module.exports = window.EventSource
  5399. } else {
  5400. module.exports = EventSource
  5401. }
  5402. /***/ }),
  5403. /* 22 */
  5404. /***/ (function(module, exports, __webpack_require__) {
  5405. /* WEBPACK VAR INJECTION */(function(process, Buffer) {var original = __webpack_require__(26)
  5406. var parse = __webpack_require__(7).parse
  5407. var events = __webpack_require__(8)
  5408. var https = __webpack_require__(36)
  5409. var http = __webpack_require__(10)
  5410. var util = __webpack_require__(50)
  5411. var httpsOptions = [
  5412. 'pfx', 'key', 'passphrase', 'cert', 'ca', 'ciphers',
  5413. 'rejectUnauthorized', 'secureProtocol', 'servername'
  5414. ]
  5415. var bom = [239, 187, 191]
  5416. var colon = 58
  5417. var space = 32
  5418. var lineFeed = 10
  5419. var carriageReturn = 13
  5420. function hasBom (buf) {
  5421. return bom.every(function (charCode, index) {
  5422. return buf[index] === charCode
  5423. })
  5424. }
  5425. /**
  5426. * Creates a new EventSource object
  5427. *
  5428. * @param {String} url the URL to which to connect
  5429. * @param {Object} [eventSourceInitDict] extra init params. See README for details.
  5430. * @api public
  5431. **/
  5432. function EventSource (url, eventSourceInitDict) {
  5433. var readyState = EventSource.CONNECTING
  5434. Object.defineProperty(this, 'readyState', {
  5435. get: function () {
  5436. return readyState
  5437. }
  5438. })
  5439. Object.defineProperty(this, 'url', {
  5440. get: function () {
  5441. return url
  5442. }
  5443. })
  5444. var self = this
  5445. self.reconnectInterval = 1000
  5446. function onConnectionClosed () {
  5447. if (readyState === EventSource.CLOSED) return
  5448. readyState = EventSource.CONNECTING
  5449. _emit('error', new Event('error'))
  5450. // The url may have been changed by a temporary
  5451. // redirect. If that's the case, revert it now.
  5452. if (reconnectUrl) {
  5453. url = reconnectUrl
  5454. reconnectUrl = null
  5455. }
  5456. setTimeout(function () {
  5457. if (readyState !== EventSource.CONNECTING) {
  5458. return
  5459. }
  5460. connect()
  5461. }, self.reconnectInterval)
  5462. }
  5463. var req
  5464. var lastEventId = ''
  5465. if (eventSourceInitDict && eventSourceInitDict.headers && eventSourceInitDict.headers['Last-Event-ID']) {
  5466. lastEventId = eventSourceInitDict.headers['Last-Event-ID']
  5467. delete eventSourceInitDict.headers['Last-Event-ID']
  5468. }
  5469. var discardTrailingNewline = false
  5470. var data = ''
  5471. var eventName = ''
  5472. var reconnectUrl = null
  5473. function connect () {
  5474. var options = parse(url)
  5475. var isSecure = options.protocol === 'https:'
  5476. options.headers = { 'Cache-Control': 'no-cache', 'Accept': 'text/event-stream' }
  5477. if (lastEventId) options.headers['Last-Event-ID'] = lastEventId
  5478. if (eventSourceInitDict && eventSourceInitDict.headers) {
  5479. for (var i in eventSourceInitDict.headers) {
  5480. var header = eventSourceInitDict.headers[i]
  5481. if (header) {
  5482. options.headers[i] = header
  5483. }
  5484. }
  5485. }
  5486. // Legacy: this should be specified as `eventSourceInitDict.https.rejectUnauthorized`,
  5487. // but for now exists as a backwards-compatibility layer
  5488. options.rejectUnauthorized = !(eventSourceInitDict && !eventSourceInitDict.rejectUnauthorized)
  5489. // If specify http proxy, make the request to sent to the proxy server,
  5490. // and include the original url in path and Host headers
  5491. var useProxy = eventSourceInitDict && eventSourceInitDict.proxy
  5492. if (useProxy) {
  5493. var proxy = parse(eventSourceInitDict.proxy)
  5494. isSecure = proxy.protocol === 'https:'
  5495. options.protocol = isSecure ? 'https:' : 'http:'
  5496. options.path = url
  5497. options.headers.Host = options.host
  5498. options.hostname = proxy.hostname
  5499. options.host = proxy.host
  5500. options.port = proxy.port
  5501. }
  5502. // If https options are specified, merge them into the request options
  5503. if (eventSourceInitDict && eventSourceInitDict.https) {
  5504. for (var optName in eventSourceInitDict.https) {
  5505. if (httpsOptions.indexOf(optName) === -1) {
  5506. continue
  5507. }
  5508. var option = eventSourceInitDict.https[optName]
  5509. if (option !== undefined) {
  5510. options[optName] = option
  5511. }
  5512. }
  5513. }
  5514. // Pass this on to the XHR
  5515. if (eventSourceInitDict && eventSourceInitDict.withCredentials !== undefined) {
  5516. options.withCredentials = eventSourceInitDict.withCredentials
  5517. }
  5518. req = (isSecure ? https : http).request(options, function (res) {
  5519. // Handle HTTP errors
  5520. if (res.statusCode === 500 || res.statusCode === 502 || res.statusCode === 503 || res.statusCode === 504) {
  5521. _emit('error', new Event('error', {status: res.statusCode}))
  5522. onConnectionClosed()
  5523. return
  5524. }
  5525. // Handle HTTP redirects
  5526. if (res.statusCode === 301 || res.statusCode === 302 || res.statusCode === 307) {
  5527. if (!res.headers.location) {
  5528. // Server sent redirect response without Location header.
  5529. _emit('error', new Event('error', {status: res.statusCode}))
  5530. return
  5531. }
  5532. if (res.statusCode === 307) reconnectUrl = url
  5533. url = res.headers.location
  5534. process.nextTick(connect)
  5535. return
  5536. }
  5537. if (res.statusCode !== 200) {
  5538. _emit('error', new Event('error', {status: res.statusCode}))
  5539. return self.close()
  5540. }
  5541. readyState = EventSource.OPEN
  5542. res.on('close', function () {
  5543. res.removeAllListeners('close')
  5544. res.removeAllListeners('end')
  5545. onConnectionClosed()
  5546. })
  5547. res.on('end', function () {
  5548. res.removeAllListeners('close')
  5549. res.removeAllListeners('end')
  5550. onConnectionClosed()
  5551. })
  5552. _emit('open', new Event('open'))
  5553. // text/event-stream parser adapted from webkit's
  5554. // Source/WebCore/page/EventSource.cpp
  5555. var isFirst = true
  5556. var buf
  5557. res.on('data', function (chunk) {
  5558. buf = buf ? Buffer.concat([buf, chunk]) : chunk
  5559. if (isFirst && hasBom(buf)) {
  5560. buf = buf.slice(bom.length)
  5561. }
  5562. isFirst = false
  5563. var pos = 0
  5564. var length = buf.length
  5565. while (pos < length) {
  5566. if (discardTrailingNewline) {
  5567. if (buf[pos] === lineFeed) {
  5568. ++pos
  5569. }
  5570. discardTrailingNewline = false
  5571. }
  5572. var lineLength = -1
  5573. var fieldLength = -1
  5574. var c
  5575. for (var i = pos; lineLength < 0 && i < length; ++i) {
  5576. c = buf[i]
  5577. if (c === colon) {
  5578. if (fieldLength < 0) {
  5579. fieldLength = i - pos
  5580. }
  5581. } else if (c === carriageReturn) {
  5582. discardTrailingNewline = true
  5583. lineLength = i - pos
  5584. } else if (c === lineFeed) {
  5585. lineLength = i - pos
  5586. }
  5587. }
  5588. if (lineLength < 0) {
  5589. break
  5590. }
  5591. parseEventStreamLine(buf, pos, fieldLength, lineLength)
  5592. pos += lineLength + 1
  5593. }
  5594. if (pos === length) {
  5595. buf = void 0
  5596. } else if (pos > 0) {
  5597. buf = buf.slice(pos)
  5598. }
  5599. })
  5600. })
  5601. req.on('error', onConnectionClosed)
  5602. if (req.setNoDelay) req.setNoDelay(true)
  5603. req.end()
  5604. }
  5605. connect()
  5606. function _emit () {
  5607. if (self.listeners(arguments[0]).length > 0) {
  5608. self.emit.apply(self, arguments)
  5609. }
  5610. }
  5611. this._close = function () {
  5612. if (readyState === EventSource.CLOSED) return
  5613. readyState = EventSource.CLOSED
  5614. if (req.abort) req.abort()
  5615. if (req.xhr && req.xhr.abort) req.xhr.abort()
  5616. }
  5617. function parseEventStreamLine (buf, pos, fieldLength, lineLength) {
  5618. if (lineLength === 0) {
  5619. if (data.length > 0) {
  5620. var type = eventName || 'message'
  5621. _emit(type, new MessageEvent(type, {
  5622. data: data.slice(0, -1), // remove trailing newline
  5623. lastEventId: lastEventId,
  5624. origin: original(url)
  5625. }))
  5626. data = ''
  5627. }
  5628. eventName = void 0
  5629. } else if (fieldLength > 0) {
  5630. var noValue = fieldLength < 0
  5631. var step = 0
  5632. var field = buf.slice(pos, pos + (noValue ? lineLength : fieldLength)).toString()
  5633. if (noValue) {
  5634. step = lineLength
  5635. } else if (buf[pos + fieldLength + 1] !== space) {
  5636. step = fieldLength + 1
  5637. } else {
  5638. step = fieldLength + 2
  5639. }
  5640. pos += step
  5641. var valueLength = lineLength - step
  5642. var value = buf.slice(pos, pos + valueLength).toString()
  5643. if (field === 'data') {
  5644. data += value + '\n'
  5645. } else if (field === 'event') {
  5646. eventName = value
  5647. } else if (field === 'id') {
  5648. lastEventId = value
  5649. } else if (field === 'retry') {
  5650. var retry = parseInt(value, 10)
  5651. if (!Number.isNaN(retry)) {
  5652. self.reconnectInterval = retry
  5653. }
  5654. }
  5655. }
  5656. }
  5657. }
  5658. module.exports = EventSource
  5659. util.inherits(EventSource, events.EventEmitter)
  5660. EventSource.prototype.constructor = EventSource; // make stacktraces readable
  5661. ['open', 'error', 'message'].forEach(function (method) {
  5662. Object.defineProperty(EventSource.prototype, 'on' + method, {
  5663. /**
  5664. * Returns the current listener
  5665. *
  5666. * @return {Mixed} the set function or undefined
  5667. * @api private
  5668. */
  5669. get: function get () {
  5670. var listener = this.listeners(method)[0]
  5671. return listener ? (listener._listener ? listener._listener : listener) : undefined
  5672. },
  5673. /**
  5674. * Start listening for events
  5675. *
  5676. * @param {Function} listener the listener
  5677. * @return {Mixed} the set function or undefined
  5678. * @api private
  5679. */
  5680. set: function set (listener) {
  5681. this.removeAllListeners(method)
  5682. this.addEventListener(method, listener)
  5683. }
  5684. })
  5685. })
  5686. /**
  5687. * Ready states
  5688. */
  5689. Object.defineProperty(EventSource, 'CONNECTING', {enumerable: true, value: 0})
  5690. Object.defineProperty(EventSource, 'OPEN', {enumerable: true, value: 1})
  5691. Object.defineProperty(EventSource, 'CLOSED', {enumerable: true, value: 2})
  5692. EventSource.prototype.CONNECTING = 0
  5693. EventSource.prototype.OPEN = 1
  5694. EventSource.prototype.CLOSED = 2
  5695. /**
  5696. * Closes the connection, if one is made, and sets the readyState attribute to 2 (closed)
  5697. *
  5698. * @see https://developer.mozilla.org/en-US/docs/Web/API/EventSource/close
  5699. * @api public
  5700. */
  5701. EventSource.prototype.close = function () {
  5702. this._close()
  5703. }
  5704. /**
  5705. * Emulates the W3C Browser based WebSocket interface using addEventListener.
  5706. *
  5707. * @param {String} type A string representing the event type to listen out for
  5708. * @param {Function} listener callback
  5709. * @see https://developer.mozilla.org/en/DOM/element.addEventListener
  5710. * @see http://dev.w3.org/html5/websockets/#the-websocket-interface
  5711. * @api public
  5712. */
  5713. EventSource.prototype.addEventListener = function addEventListener (type, listener) {
  5714. if (typeof listener === 'function') {
  5715. // store a reference so we can return the original function again
  5716. listener._listener = listener
  5717. this.on(type, listener)
  5718. }
  5719. }
  5720. /**
  5721. * Emulates the W3C Browser based WebSocket interface using removeEventListener.
  5722. *
  5723. * @param {String} type A string representing the event type to remove
  5724. * @param {Function} listener callback
  5725. * @see https://developer.mozilla.org/en/DOM/element.removeEventListener
  5726. * @see http://dev.w3.org/html5/websockets/#the-websocket-interface
  5727. * @api public
  5728. */
  5729. EventSource.prototype.removeEventListener = function removeEventListener (type, listener) {
  5730. if (typeof listener === 'function') {
  5731. listener._listener = undefined
  5732. this.removeListener(type, listener)
  5733. }
  5734. }
  5735. /**
  5736. * W3C Event
  5737. *
  5738. * @see http://www.w3.org/TR/DOM-Level-3-Events/#interface-Event
  5739. * @api private
  5740. */
  5741. function Event (type, optionalProperties) {
  5742. Object.defineProperty(this, 'type', { writable: false, value: type, enumerable: true })
  5743. if (optionalProperties) {
  5744. for (var f in optionalProperties) {
  5745. if (optionalProperties.hasOwnProperty(f)) {
  5746. Object.defineProperty(this, f, { writable: false, value: optionalProperties[f], enumerable: true })
  5747. }
  5748. }
  5749. }
  5750. }
  5751. /**
  5752. * W3C MessageEvent
  5753. *
  5754. * @see http://www.w3.org/TR/webmessaging/#event-definitions
  5755. * @api private
  5756. */
  5757. function MessageEvent (type, eventInitDict) {
  5758. Object.defineProperty(this, 'type', { writable: false, value: type, enumerable: true })
  5759. for (var f in eventInitDict) {
  5760. if (eventInitDict.hasOwnProperty(f)) {
  5761. Object.defineProperty(this, f, { writable: false, value: eventInitDict[f], enumerable: true })
  5762. }
  5763. }
  5764. }
  5765. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(1), __webpack_require__(2).Buffer))
  5766. /***/ }),
  5767. /* 23 */
  5768. /***/ (function(module, exports, __webpack_require__) {
  5769. "use strict";
  5770. exports.byteLength = byteLength
  5771. exports.toByteArray = toByteArray
  5772. exports.fromByteArray = fromByteArray
  5773. var lookup = []
  5774. var revLookup = []
  5775. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  5776. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  5777. for (var i = 0, len = code.length; i < len; ++i) {
  5778. lookup[i] = code[i]
  5779. revLookup[code.charCodeAt(i)] = i
  5780. }
  5781. // Support decoding URL-safe base64 strings, as Node.js does.
  5782. // See: https://en.wikipedia.org/wiki/Base64#URL_applications
  5783. revLookup['-'.charCodeAt(0)] = 62
  5784. revLookup['_'.charCodeAt(0)] = 63
  5785. function getLens (b64) {
  5786. var len = b64.length
  5787. if (len % 4 > 0) {
  5788. throw new Error('Invalid string. Length must be a multiple of 4')
  5789. }
  5790. // Trim off extra bytes after placeholder bytes are found
  5791. // See: https://github.com/beatgammit/base64-js/issues/42
  5792. var validLen = b64.indexOf('=')
  5793. if (validLen === -1) validLen = len
  5794. var placeHoldersLen = validLen === len
  5795. ? 0
  5796. : 4 - (validLen % 4)
  5797. return [validLen, placeHoldersLen]
  5798. }
  5799. // base64 is 4/3 + up to two characters of the original data
  5800. function byteLength (b64) {
  5801. var lens = getLens(b64)
  5802. var validLen = lens[0]
  5803. var placeHoldersLen = lens[1]
  5804. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  5805. }
  5806. function _byteLength (b64, validLen, placeHoldersLen) {
  5807. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  5808. }
  5809. function toByteArray (b64) {
  5810. var tmp
  5811. var lens = getLens(b64)
  5812. var validLen = lens[0]
  5813. var placeHoldersLen = lens[1]
  5814. var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
  5815. var curByte = 0
  5816. // if there are placeholders, only get up to the last complete 4 chars
  5817. var len = placeHoldersLen > 0
  5818. ? validLen - 4
  5819. : validLen
  5820. for (var i = 0; i < len; i += 4) {
  5821. tmp =
  5822. (revLookup[b64.charCodeAt(i)] << 18) |
  5823. (revLookup[b64.charCodeAt(i + 1)] << 12) |
  5824. (revLookup[b64.charCodeAt(i + 2)] << 6) |
  5825. revLookup[b64.charCodeAt(i + 3)]
  5826. arr[curByte++] = (tmp >> 16) & 0xFF
  5827. arr[curByte++] = (tmp >> 8) & 0xFF
  5828. arr[curByte++] = tmp & 0xFF
  5829. }
  5830. if (placeHoldersLen === 2) {
  5831. tmp =
  5832. (revLookup[b64.charCodeAt(i)] << 2) |
  5833. (revLookup[b64.charCodeAt(i + 1)] >> 4)
  5834. arr[curByte++] = tmp & 0xFF
  5835. }
  5836. if (placeHoldersLen === 1) {
  5837. tmp =
  5838. (revLookup[b64.charCodeAt(i)] << 10) |
  5839. (revLookup[b64.charCodeAt(i + 1)] << 4) |
  5840. (revLookup[b64.charCodeAt(i + 2)] >> 2)
  5841. arr[curByte++] = (tmp >> 8) & 0xFF
  5842. arr[curByte++] = tmp & 0xFF
  5843. }
  5844. return arr
  5845. }
  5846. function tripletToBase64 (num) {
  5847. return lookup[num >> 18 & 0x3F] +
  5848. lookup[num >> 12 & 0x3F] +
  5849. lookup[num >> 6 & 0x3F] +
  5850. lookup[num & 0x3F]
  5851. }
  5852. function encodeChunk (uint8, start, end) {
  5853. var tmp
  5854. var output = []
  5855. for (var i = start; i < end; i += 3) {
  5856. tmp =
  5857. ((uint8[i] << 16) & 0xFF0000) +
  5858. ((uint8[i + 1] << 8) & 0xFF00) +
  5859. (uint8[i + 2] & 0xFF)
  5860. output.push(tripletToBase64(tmp))
  5861. }
  5862. return output.join('')
  5863. }
  5864. function fromByteArray (uint8) {
  5865. var tmp
  5866. var len = uint8.length
  5867. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  5868. var parts = []
  5869. var maxChunkLength = 16383 // must be multiple of 3
  5870. // go through the array every three bytes, we'll deal with trailing stuff later
  5871. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  5872. parts.push(encodeChunk(
  5873. uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
  5874. ))
  5875. }
  5876. // pad the end with zeros, but make sure to not forget the extra bytes
  5877. if (extraBytes === 1) {
  5878. tmp = uint8[len - 1]
  5879. parts.push(
  5880. lookup[tmp >> 2] +
  5881. lookup[(tmp << 4) & 0x3F] +
  5882. '=='
  5883. )
  5884. } else if (extraBytes === 2) {
  5885. tmp = (uint8[len - 2] << 8) + uint8[len - 1]
  5886. parts.push(
  5887. lookup[tmp >> 10] +
  5888. lookup[(tmp >> 4) & 0x3F] +
  5889. lookup[(tmp << 2) & 0x3F] +
  5890. '='
  5891. )
  5892. }
  5893. return parts.join('')
  5894. }
  5895. /***/ }),
  5896. /* 24 */
  5897. /***/ (function(module, exports) {
  5898. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  5899. var e, m
  5900. var eLen = (nBytes * 8) - mLen - 1
  5901. var eMax = (1 << eLen) - 1
  5902. var eBias = eMax >> 1
  5903. var nBits = -7
  5904. var i = isLE ? (nBytes - 1) : 0
  5905. var d = isLE ? -1 : 1
  5906. var s = buffer[offset + i]
  5907. i += d
  5908. e = s & ((1 << (-nBits)) - 1)
  5909. s >>= (-nBits)
  5910. nBits += eLen
  5911. for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  5912. m = e & ((1 << (-nBits)) - 1)
  5913. e >>= (-nBits)
  5914. nBits += mLen
  5915. for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  5916. if (e === 0) {
  5917. e = 1 - eBias
  5918. } else if (e === eMax) {
  5919. return m ? NaN : ((s ? -1 : 1) * Infinity)
  5920. } else {
  5921. m = m + Math.pow(2, mLen)
  5922. e = e - eBias
  5923. }
  5924. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  5925. }
  5926. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  5927. var e, m, c
  5928. var eLen = (nBytes * 8) - mLen - 1
  5929. var eMax = (1 << eLen) - 1
  5930. var eBias = eMax >> 1
  5931. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  5932. var i = isLE ? 0 : (nBytes - 1)
  5933. var d = isLE ? 1 : -1
  5934. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  5935. value = Math.abs(value)
  5936. if (isNaN(value) || value === Infinity) {
  5937. m = isNaN(value) ? 1 : 0
  5938. e = eMax
  5939. } else {
  5940. e = Math.floor(Math.log(value) / Math.LN2)
  5941. if (value * (c = Math.pow(2, -e)) < 1) {
  5942. e--
  5943. c *= 2
  5944. }
  5945. if (e + eBias >= 1) {
  5946. value += rt / c
  5947. } else {
  5948. value += rt * Math.pow(2, 1 - eBias)
  5949. }
  5950. if (value * c >= 2) {
  5951. e++
  5952. c /= 2
  5953. }
  5954. if (e + eBias >= eMax) {
  5955. m = 0
  5956. e = eMax
  5957. } else if (e + eBias >= 1) {
  5958. m = ((value * c) - 1) * Math.pow(2, mLen)
  5959. e = e + eBias
  5960. } else {
  5961. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  5962. e = 0
  5963. }
  5964. }
  5965. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  5966. e = (e << mLen) | m
  5967. eLen += mLen
  5968. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  5969. buffer[offset + i - d] |= s * 128
  5970. }
  5971. /***/ }),
  5972. /* 25 */
  5973. /***/ (function(module, exports) {
  5974. var toString = {}.toString;
  5975. module.exports = Array.isArray || function (arr) {
  5976. return toString.call(arr) == '[object Array]';
  5977. };
  5978. /***/ }),
  5979. /* 26 */
  5980. /***/ (function(module, exports, __webpack_require__) {
  5981. "use strict";
  5982. var parse = __webpack_require__(27);
  5983. /**
  5984. * Transform an URL to a valid origin value.
  5985. *
  5986. * @param {String|Object} url URL to transform to it's origin.
  5987. * @returns {String} The origin.
  5988. * @api public
  5989. */
  5990. function origin(url) {
  5991. if ('string' === typeof url) url = parse(url);
  5992. //
  5993. // 6.2. ASCII Serialization of an Origin
  5994. // http://tools.ietf.org/html/rfc6454#section-6.2
  5995. //
  5996. if (!url.protocol || !url.hostname) return 'null';
  5997. //
  5998. // 4. Origin of a URI
  5999. // http://tools.ietf.org/html/rfc6454#section-4
  6000. //
  6001. // States that url.scheme, host should be converted to lower case. This also
  6002. // makes it easier to match origins as everything is just lower case.
  6003. //
  6004. return (url.protocol +'//'+ url.host).toLowerCase();
  6005. }
  6006. /**
  6007. * Check if the origins are the same.
  6008. *
  6009. * @param {String} a URL or origin of a.
  6010. * @param {String} b URL or origin of b.
  6011. * @returns {Boolean}
  6012. * @api public
  6013. */
  6014. origin.same = function same(a, b) {
  6015. return origin(a) === origin(b);
  6016. };
  6017. //
  6018. // Expose the origin
  6019. //
  6020. module.exports = origin;
  6021. /***/ }),
  6022. /* 27 */
  6023. /***/ (function(module, exports, __webpack_require__) {
  6024. "use strict";
  6025. /* WEBPACK VAR INJECTION */(function(global) {
  6026. var required = __webpack_require__(28)
  6027. , qs = __webpack_require__(29)
  6028. , protocolre = /^([a-z][a-z0-9.+-]*:)?(\/\/)?([\S\s]*)/i
  6029. , slashes = /^[A-Za-z][A-Za-z0-9+-.]*:\/\//;
  6030. /**
  6031. * These are the parse rules for the URL parser, it informs the parser
  6032. * about:
  6033. *
  6034. * 0. The char it Needs to parse, if it's a string it should be done using
  6035. * indexOf, RegExp using exec and NaN means set as current value.
  6036. * 1. The property we should set when parsing this value.
  6037. * 2. Indication if it's backwards or forward parsing, when set as number it's
  6038. * the value of extra chars that should be split off.
  6039. * 3. Inherit from location if non existing in the parser.
  6040. * 4. `toLowerCase` the resulting value.
  6041. */
  6042. var rules = [
  6043. ['#', 'hash'], // Extract from the back.
  6044. ['?', 'query'], // Extract from the back.
  6045. function sanitize(address) { // Sanitize what is left of the address
  6046. return address.replace('\\', '/');
  6047. },
  6048. ['/', 'pathname'], // Extract from the back.
  6049. ['@', 'auth', 1], // Extract from the front.
  6050. [NaN, 'host', undefined, 1, 1], // Set left over value.
  6051. [/:(\d+)$/, 'port', undefined, 1], // RegExp the back.
  6052. [NaN, 'hostname', undefined, 1, 1] // Set left over.
  6053. ];
  6054. /**
  6055. * These properties should not be copied or inherited from. This is only needed
  6056. * for all non blob URL's as a blob URL does not include a hash, only the
  6057. * origin.
  6058. *
  6059. * @type {Object}
  6060. * @private
  6061. */
  6062. var ignore = { hash: 1, query: 1 };
  6063. /**
  6064. * The location object differs when your code is loaded through a normal page,
  6065. * Worker or through a worker using a blob. And with the blobble begins the
  6066. * trouble as the location object will contain the URL of the blob, not the
  6067. * location of the page where our code is loaded in. The actual origin is
  6068. * encoded in the `pathname` so we can thankfully generate a good "default"
  6069. * location from it so we can generate proper relative URL's again.
  6070. *
  6071. * @param {Object|String} loc Optional default location object.
  6072. * @returns {Object} lolcation object.
  6073. * @public
  6074. */
  6075. function lolcation(loc) {
  6076. var location = global && global.location || {};
  6077. loc = loc || location;
  6078. var finaldestination = {}
  6079. , type = typeof loc
  6080. , key;
  6081. if ('blob:' === loc.protocol) {
  6082. finaldestination = new Url(unescape(loc.pathname), {});
  6083. } else if ('string' === type) {
  6084. finaldestination = new Url(loc, {});
  6085. for (key in ignore) delete finaldestination[key];
  6086. } else if ('object' === type) {
  6087. for (key in loc) {
  6088. if (key in ignore) continue;
  6089. finaldestination[key] = loc[key];
  6090. }
  6091. if (finaldestination.slashes === undefined) {
  6092. finaldestination.slashes = slashes.test(loc.href);
  6093. }
  6094. }
  6095. return finaldestination;
  6096. }
  6097. /**
  6098. * @typedef ProtocolExtract
  6099. * @type Object
  6100. * @property {String} protocol Protocol matched in the URL, in lowercase.
  6101. * @property {Boolean} slashes `true` if protocol is followed by "//", else `false`.
  6102. * @property {String} rest Rest of the URL that is not part of the protocol.
  6103. */
  6104. /**
  6105. * Extract protocol information from a URL with/without double slash ("//").
  6106. *
  6107. * @param {String} address URL we want to extract from.
  6108. * @return {ProtocolExtract} Extracted information.
  6109. * @private
  6110. */
  6111. function extractProtocol(address) {
  6112. var match = protocolre.exec(address);
  6113. return {
  6114. protocol: match[1] ? match[1].toLowerCase() : '',
  6115. slashes: !!match[2],
  6116. rest: match[3]
  6117. };
  6118. }
  6119. /**
  6120. * Resolve a relative URL pathname against a base URL pathname.
  6121. *
  6122. * @param {String} relative Pathname of the relative URL.
  6123. * @param {String} base Pathname of the base URL.
  6124. * @return {String} Resolved pathname.
  6125. * @private
  6126. */
  6127. function resolve(relative, base) {
  6128. var path = (base || '/').split('/').slice(0, -1).concat(relative.split('/'))
  6129. , i = path.length
  6130. , last = path[i - 1]
  6131. , unshift = false
  6132. , up = 0;
  6133. while (i--) {
  6134. if (path[i] === '.') {
  6135. path.splice(i, 1);
  6136. } else if (path[i] === '..') {
  6137. path.splice(i, 1);
  6138. up++;
  6139. } else if (up) {
  6140. if (i === 0) unshift = true;
  6141. path.splice(i, 1);
  6142. up--;
  6143. }
  6144. }
  6145. if (unshift) path.unshift('');
  6146. if (last === '.' || last === '..') path.push('');
  6147. return path.join('/');
  6148. }
  6149. /**
  6150. * The actual URL instance. Instead of returning an object we've opted-in to
  6151. * create an actual constructor as it's much more memory efficient and
  6152. * faster and it pleases my OCD.
  6153. *
  6154. * It is worth noting that we should not use `URL` as class name to prevent
  6155. * clashes with the global URL instance that got introduced in browsers.
  6156. *
  6157. * @constructor
  6158. * @param {String} address URL we want to parse.
  6159. * @param {Object|String} location Location defaults for relative paths.
  6160. * @param {Boolean|Function} parser Parser for the query string.
  6161. * @private
  6162. */
  6163. function Url(address, location, parser) {
  6164. if (!(this instanceof Url)) {
  6165. return new Url(address, location, parser);
  6166. }
  6167. var relative, extracted, parse, instruction, index, key
  6168. , instructions = rules.slice()
  6169. , type = typeof location
  6170. , url = this
  6171. , i = 0;
  6172. //
  6173. // The following if statements allows this module two have compatibility with
  6174. // 2 different API:
  6175. //
  6176. // 1. Node.js's `url.parse` api which accepts a URL, boolean as arguments
  6177. // where the boolean indicates that the query string should also be parsed.
  6178. //
  6179. // 2. The `URL` interface of the browser which accepts a URL, object as
  6180. // arguments. The supplied object will be used as default values / fall-back
  6181. // for relative paths.
  6182. //
  6183. if ('object' !== type && 'string' !== type) {
  6184. parser = location;
  6185. location = null;
  6186. }
  6187. if (parser && 'function' !== typeof parser) parser = qs.parse;
  6188. location = lolcation(location);
  6189. //
  6190. // Extract protocol information before running the instructions.
  6191. //
  6192. extracted = extractProtocol(address || '');
  6193. relative = !extracted.protocol && !extracted.slashes;
  6194. url.slashes = extracted.slashes || relative && location.slashes;
  6195. url.protocol = extracted.protocol || location.protocol || '';
  6196. address = extracted.rest;
  6197. //
  6198. // When the authority component is absent the URL starts with a path
  6199. // component.
  6200. //
  6201. if (!extracted.slashes) instructions[3] = [/(.*)/, 'pathname'];
  6202. for (; i < instructions.length; i++) {
  6203. instruction = instructions[i];
  6204. if (typeof instruction === 'function') {
  6205. address = instruction(address);
  6206. continue;
  6207. }
  6208. parse = instruction[0];
  6209. key = instruction[1];
  6210. if (parse !== parse) {
  6211. url[key] = address;
  6212. } else if ('string' === typeof parse) {
  6213. if (~(index = address.indexOf(parse))) {
  6214. if ('number' === typeof instruction[2]) {
  6215. url[key] = address.slice(0, index);
  6216. address = address.slice(index + instruction[2]);
  6217. } else {
  6218. url[key] = address.slice(index);
  6219. address = address.slice(0, index);
  6220. }
  6221. }
  6222. } else if ((index = parse.exec(address))) {
  6223. url[key] = index[1];
  6224. address = address.slice(0, index.index);
  6225. }
  6226. url[key] = url[key] || (
  6227. relative && instruction[3] ? location[key] || '' : ''
  6228. );
  6229. //
  6230. // Hostname, host and protocol should be lowercased so they can be used to
  6231. // create a proper `origin`.
  6232. //
  6233. if (instruction[4]) url[key] = url[key].toLowerCase();
  6234. }
  6235. //
  6236. // Also parse the supplied query string in to an object. If we're supplied
  6237. // with a custom parser as function use that instead of the default build-in
  6238. // parser.
  6239. //
  6240. if (parser) url.query = parser(url.query);
  6241. //
  6242. // If the URL is relative, resolve the pathname against the base URL.
  6243. //
  6244. if (
  6245. relative
  6246. && location.slashes
  6247. && url.pathname.charAt(0) !== '/'
  6248. && (url.pathname !== '' || location.pathname !== '')
  6249. ) {
  6250. url.pathname = resolve(url.pathname, location.pathname);
  6251. }
  6252. //
  6253. // We should not add port numbers if they are already the default port number
  6254. // for a given protocol. As the host also contains the port number we're going
  6255. // override it with the hostname which contains no port number.
  6256. //
  6257. if (!required(url.port, url.protocol)) {
  6258. url.host = url.hostname;
  6259. url.port = '';
  6260. }
  6261. //
  6262. // Parse down the `auth` for the username and password.
  6263. //
  6264. url.username = url.password = '';
  6265. if (url.auth) {
  6266. instruction = url.auth.split(':');
  6267. url.username = instruction[0] || '';
  6268. url.password = instruction[1] || '';
  6269. }
  6270. url.origin = url.protocol && url.host && url.protocol !== 'file:'
  6271. ? url.protocol +'//'+ url.host
  6272. : 'null';
  6273. //
  6274. // The href is just the compiled result.
  6275. //
  6276. url.href = url.toString();
  6277. }
  6278. /**
  6279. * This is convenience method for changing properties in the URL instance to
  6280. * insure that they all propagate correctly.
  6281. *
  6282. * @param {String} part Property we need to adjust.
  6283. * @param {Mixed} value The newly assigned value.
  6284. * @param {Boolean|Function} fn When setting the query, it will be the function
  6285. * used to parse the query.
  6286. * When setting the protocol, double slash will be
  6287. * removed from the final url if it is true.
  6288. * @returns {URL} URL instance for chaining.
  6289. * @public
  6290. */
  6291. function set(part, value, fn) {
  6292. var url = this;
  6293. switch (part) {
  6294. case 'query':
  6295. if ('string' === typeof value && value.length) {
  6296. value = (fn || qs.parse)(value);
  6297. }
  6298. url[part] = value;
  6299. break;
  6300. case 'port':
  6301. url[part] = value;
  6302. if (!required(value, url.protocol)) {
  6303. url.host = url.hostname;
  6304. url[part] = '';
  6305. } else if (value) {
  6306. url.host = url.hostname +':'+ value;
  6307. }
  6308. break;
  6309. case 'hostname':
  6310. url[part] = value;
  6311. if (url.port) value += ':'+ url.port;
  6312. url.host = value;
  6313. break;
  6314. case 'host':
  6315. url[part] = value;
  6316. if (/:\d+$/.test(value)) {
  6317. value = value.split(':');
  6318. url.port = value.pop();
  6319. url.hostname = value.join(':');
  6320. } else {
  6321. url.hostname = value;
  6322. url.port = '';
  6323. }
  6324. break;
  6325. case 'protocol':
  6326. url.protocol = value.toLowerCase();
  6327. url.slashes = !fn;
  6328. break;
  6329. case 'pathname':
  6330. case 'hash':
  6331. if (value) {
  6332. var char = part === 'pathname' ? '/' : '#';
  6333. url[part] = value.charAt(0) !== char ? char + value : value;
  6334. } else {
  6335. url[part] = value;
  6336. }
  6337. break;
  6338. default:
  6339. url[part] = value;
  6340. }
  6341. for (var i = 0; i < rules.length; i++) {
  6342. var ins = rules[i];
  6343. if (ins[4]) url[ins[1]] = url[ins[1]].toLowerCase();
  6344. }
  6345. url.origin = url.protocol && url.host && url.protocol !== 'file:'
  6346. ? url.protocol +'//'+ url.host
  6347. : 'null';
  6348. url.href = url.toString();
  6349. return url;
  6350. }
  6351. /**
  6352. * Transform the properties back in to a valid and full URL string.
  6353. *
  6354. * @param {Function} stringify Optional query stringify function.
  6355. * @returns {String} Compiled version of the URL.
  6356. * @public
  6357. */
  6358. function toString(stringify) {
  6359. if (!stringify || 'function' !== typeof stringify) stringify = qs.stringify;
  6360. var query
  6361. , url = this
  6362. , protocol = url.protocol;
  6363. if (protocol && protocol.charAt(protocol.length - 1) !== ':') protocol += ':';
  6364. var result = protocol + (url.slashes ? '//' : '');
  6365. if (url.username) {
  6366. result += url.username;
  6367. if (url.password) result += ':'+ url.password;
  6368. result += '@';
  6369. }
  6370. result += url.host + url.pathname;
  6371. query = 'object' === typeof url.query ? stringify(url.query) : url.query;
  6372. if (query) result += '?' !== query.charAt(0) ? '?'+ query : query;
  6373. if (url.hash) result += url.hash;
  6374. return result;
  6375. }
  6376. Url.prototype = { set: set, toString: toString };
  6377. //
  6378. // Expose the URL parser and some additional properties that might be useful for
  6379. // others or testing.
  6380. //
  6381. Url.extractProtocol = extractProtocol;
  6382. Url.location = lolcation;
  6383. Url.qs = qs;
  6384. module.exports = Url;
  6385. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
  6386. /***/ }),
  6387. /* 28 */
  6388. /***/ (function(module, exports, __webpack_require__) {
  6389. "use strict";
  6390. /**
  6391. * Check if we're required to add a port number.
  6392. *
  6393. * @see https://url.spec.whatwg.org/#default-port
  6394. * @param {Number|String} port Port number we need to check
  6395. * @param {String} protocol Protocol we need to check against.
  6396. * @returns {Boolean} Is it a default port for the given protocol
  6397. * @api private
  6398. */
  6399. module.exports = function required(port, protocol) {
  6400. protocol = protocol.split(':')[0];
  6401. port = +port;
  6402. if (!port) return false;
  6403. switch (protocol) {
  6404. case 'http':
  6405. case 'ws':
  6406. return port !== 80;
  6407. case 'https':
  6408. case 'wss':
  6409. return port !== 443;
  6410. case 'ftp':
  6411. return port !== 21;
  6412. case 'gopher':
  6413. return port !== 70;
  6414. case 'file':
  6415. return false;
  6416. }
  6417. return port !== 0;
  6418. };
  6419. /***/ }),
  6420. /* 29 */
  6421. /***/ (function(module, exports, __webpack_require__) {
  6422. "use strict";
  6423. var has = Object.prototype.hasOwnProperty;
  6424. /**
  6425. * Decode a URI encoded string.
  6426. *
  6427. * @param {String} input The URI encoded string.
  6428. * @returns {String} The decoded string.
  6429. * @api private
  6430. */
  6431. function decode(input) {
  6432. return decodeURIComponent(input.replace(/\+/g, ' '));
  6433. }
  6434. /**
  6435. * Simple query string parser.
  6436. *
  6437. * @param {String} query The query string that needs to be parsed.
  6438. * @returns {Object}
  6439. * @api public
  6440. */
  6441. function querystring(query) {
  6442. var parser = /([^=?&]+)=?([^&]*)/g
  6443. , result = {}
  6444. , part;
  6445. while (part = parser.exec(query)) {
  6446. var key = decode(part[1])
  6447. , value = decode(part[2]);
  6448. //
  6449. // Prevent overriding of existing properties. This ensures that build-in
  6450. // methods like `toString` or __proto__ are not overriden by malicious
  6451. // querystrings.
  6452. //
  6453. if (key in result) continue;
  6454. result[key] = value;
  6455. }
  6456. return result;
  6457. }
  6458. /**
  6459. * Transform a query string to an object.
  6460. *
  6461. * @param {Object} obj Object that should be transformed.
  6462. * @param {String} prefix Optional prefix.
  6463. * @returns {String}
  6464. * @api public
  6465. */
  6466. function querystringify(obj, prefix) {
  6467. prefix = prefix || '';
  6468. var pairs = [];
  6469. //
  6470. // Optionally prefix with a '?' if needed
  6471. //
  6472. if ('string' !== typeof prefix) prefix = '?';
  6473. for (var key in obj) {
  6474. if (has.call(obj, key)) {
  6475. pairs.push(encodeURIComponent(key) +'='+ encodeURIComponent(obj[key]));
  6476. }
  6477. }
  6478. return pairs.length ? prefix + pairs.join('&') : '';
  6479. }
  6480. //
  6481. // Expose the module.
  6482. //
  6483. exports.stringify = querystringify;
  6484. exports.parse = querystring;
  6485. /***/ }),
  6486. /* 30 */
  6487. /***/ (function(module, exports, __webpack_require__) {
  6488. /* WEBPACK VAR INJECTION */(function(module, global) {var __WEBPACK_AMD_DEFINE_RESULT__;/*! https://mths.be/punycode v1.4.1 by @mathias */
  6489. ;(function(root) {
  6490. /** Detect free variables */
  6491. var freeExports = typeof exports == 'object' && exports &&
  6492. !exports.nodeType && exports;
  6493. var freeModule = typeof module == 'object' && module &&
  6494. !module.nodeType && module;
  6495. var freeGlobal = typeof global == 'object' && global;
  6496. if (
  6497. freeGlobal.global === freeGlobal ||
  6498. freeGlobal.window === freeGlobal ||
  6499. freeGlobal.self === freeGlobal
  6500. ) {
  6501. root = freeGlobal;
  6502. }
  6503. /**
  6504. * The `punycode` object.
  6505. * @name punycode
  6506. * @type Object
  6507. */
  6508. var punycode,
  6509. /** Highest positive signed 32-bit float value */
  6510. maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1
  6511. /** Bootstring parameters */
  6512. base = 36,
  6513. tMin = 1,
  6514. tMax = 26,
  6515. skew = 38,
  6516. damp = 700,
  6517. initialBias = 72,
  6518. initialN = 128, // 0x80
  6519. delimiter = '-', // '\x2D'
  6520. /** Regular expressions */
  6521. regexPunycode = /^xn--/,
  6522. regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars
  6523. regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators
  6524. /** Error messages */
  6525. errors = {
  6526. 'overflow': 'Overflow: input needs wider integers to process',
  6527. 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
  6528. 'invalid-input': 'Invalid input'
  6529. },
  6530. /** Convenience shortcuts */
  6531. baseMinusTMin = base - tMin,
  6532. floor = Math.floor,
  6533. stringFromCharCode = String.fromCharCode,
  6534. /** Temporary variable */
  6535. key;
  6536. /*--------------------------------------------------------------------------*/
  6537. /**
  6538. * A generic error utility function.
  6539. * @private
  6540. * @param {String} type The error type.
  6541. * @returns {Error} Throws a `RangeError` with the applicable error message.
  6542. */
  6543. function error(type) {
  6544. throw new RangeError(errors[type]);
  6545. }
  6546. /**
  6547. * A generic `Array#map` utility function.
  6548. * @private
  6549. * @param {Array} array The array to iterate over.
  6550. * @param {Function} callback The function that gets called for every array
  6551. * item.
  6552. * @returns {Array} A new array of values returned by the callback function.
  6553. */
  6554. function map(array, fn) {
  6555. var length = array.length;
  6556. var result = [];
  6557. while (length--) {
  6558. result[length] = fn(array[length]);
  6559. }
  6560. return result;
  6561. }
  6562. /**
  6563. * A simple `Array#map`-like wrapper to work with domain name strings or email
  6564. * addresses.
  6565. * @private
  6566. * @param {String} domain The domain name or email address.
  6567. * @param {Function} callback The function that gets called for every
  6568. * character.
  6569. * @returns {Array} A new string of characters returned by the callback
  6570. * function.
  6571. */
  6572. function mapDomain(string, fn) {
  6573. var parts = string.split('@');
  6574. var result = '';
  6575. if (parts.length > 1) {
  6576. // In email addresses, only the domain name should be punycoded. Leave
  6577. // the local part (i.e. everything up to `@`) intact.
  6578. result = parts[0] + '@';
  6579. string = parts[1];
  6580. }
  6581. // Avoid `split(regex)` for IE8 compatibility. See #17.
  6582. string = string.replace(regexSeparators, '\x2E');
  6583. var labels = string.split('.');
  6584. var encoded = map(labels, fn).join('.');
  6585. return result + encoded;
  6586. }
  6587. /**
  6588. * Creates an array containing the numeric code points of each Unicode
  6589. * character in the string. While JavaScript uses UCS-2 internally,
  6590. * this function will convert a pair of surrogate halves (each of which
  6591. * UCS-2 exposes as separate characters) into a single code point,
  6592. * matching UTF-16.
  6593. * @see `punycode.ucs2.encode`
  6594. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  6595. * @memberOf punycode.ucs2
  6596. * @name decode
  6597. * @param {String} string The Unicode input string (UCS-2).
  6598. * @returns {Array} The new array of code points.
  6599. */
  6600. function ucs2decode(string) {
  6601. var output = [],
  6602. counter = 0,
  6603. length = string.length,
  6604. value,
  6605. extra;
  6606. while (counter < length) {
  6607. value = string.charCodeAt(counter++);
  6608. if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
  6609. // high surrogate, and there is a next character
  6610. extra = string.charCodeAt(counter++);
  6611. if ((extra & 0xFC00) == 0xDC00) { // low surrogate
  6612. output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
  6613. } else {
  6614. // unmatched surrogate; only append this code unit, in case the next
  6615. // code unit is the high surrogate of a surrogate pair
  6616. output.push(value);
  6617. counter--;
  6618. }
  6619. } else {
  6620. output.push(value);
  6621. }
  6622. }
  6623. return output;
  6624. }
  6625. /**
  6626. * Creates a string based on an array of numeric code points.
  6627. * @see `punycode.ucs2.decode`
  6628. * @memberOf punycode.ucs2
  6629. * @name encode
  6630. * @param {Array} codePoints The array of numeric code points.
  6631. * @returns {String} The new Unicode string (UCS-2).
  6632. */
  6633. function ucs2encode(array) {
  6634. return map(array, function(value) {
  6635. var output = '';
  6636. if (value > 0xFFFF) {
  6637. value -= 0x10000;
  6638. output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
  6639. value = 0xDC00 | value & 0x3FF;
  6640. }
  6641. output += stringFromCharCode(value);
  6642. return output;
  6643. }).join('');
  6644. }
  6645. /**
  6646. * Converts a basic code point into a digit/integer.
  6647. * @see `digitToBasic()`
  6648. * @private
  6649. * @param {Number} codePoint The basic numeric code point value.
  6650. * @returns {Number} The numeric value of a basic code point (for use in
  6651. * representing integers) in the range `0` to `base - 1`, or `base` if
  6652. * the code point does not represent a value.
  6653. */
  6654. function basicToDigit(codePoint) {
  6655. if (codePoint - 48 < 10) {
  6656. return codePoint - 22;
  6657. }
  6658. if (codePoint - 65 < 26) {
  6659. return codePoint - 65;
  6660. }
  6661. if (codePoint - 97 < 26) {
  6662. return codePoint - 97;
  6663. }
  6664. return base;
  6665. }
  6666. /**
  6667. * Converts a digit/integer into a basic code point.
  6668. * @see `basicToDigit()`
  6669. * @private
  6670. * @param {Number} digit The numeric value of a basic code point.
  6671. * @returns {Number} The basic code point whose value (when used for
  6672. * representing integers) is `digit`, which needs to be in the range
  6673. * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
  6674. * used; else, the lowercase form is used. The behavior is undefined
  6675. * if `flag` is non-zero and `digit` has no uppercase form.
  6676. */
  6677. function digitToBasic(digit, flag) {
  6678. // 0..25 map to ASCII a..z or A..Z
  6679. // 26..35 map to ASCII 0..9
  6680. return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
  6681. }
  6682. /**
  6683. * Bias adaptation function as per section 3.4 of RFC 3492.
  6684. * https://tools.ietf.org/html/rfc3492#section-3.4
  6685. * @private
  6686. */
  6687. function adapt(delta, numPoints, firstTime) {
  6688. var k = 0;
  6689. delta = firstTime ? floor(delta / damp) : delta >> 1;
  6690. delta += floor(delta / numPoints);
  6691. for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {
  6692. delta = floor(delta / baseMinusTMin);
  6693. }
  6694. return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
  6695. }
  6696. /**
  6697. * Converts a Punycode string of ASCII-only symbols to a string of Unicode
  6698. * symbols.
  6699. * @memberOf punycode
  6700. * @param {String} input The Punycode string of ASCII-only symbols.
  6701. * @returns {String} The resulting string of Unicode symbols.
  6702. */
  6703. function decode(input) {
  6704. // Don't use UCS-2
  6705. var output = [],
  6706. inputLength = input.length,
  6707. out,
  6708. i = 0,
  6709. n = initialN,
  6710. bias = initialBias,
  6711. basic,
  6712. j,
  6713. index,
  6714. oldi,
  6715. w,
  6716. k,
  6717. digit,
  6718. t,
  6719. /** Cached calculation results */
  6720. baseMinusT;
  6721. // Handle the basic code points: let `basic` be the number of input code
  6722. // points before the last delimiter, or `0` if there is none, then copy
  6723. // the first basic code points to the output.
  6724. basic = input.lastIndexOf(delimiter);
  6725. if (basic < 0) {
  6726. basic = 0;
  6727. }
  6728. for (j = 0; j < basic; ++j) {
  6729. // if it's not a basic code point
  6730. if (input.charCodeAt(j) >= 0x80) {
  6731. error('not-basic');
  6732. }
  6733. output.push(input.charCodeAt(j));
  6734. }
  6735. // Main decoding loop: start just after the last delimiter if any basic code
  6736. // points were copied; start at the beginning otherwise.
  6737. for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {
  6738. // `index` is the index of the next character to be consumed.
  6739. // Decode a generalized variable-length integer into `delta`,
  6740. // which gets added to `i`. The overflow checking is easier
  6741. // if we increase `i` as we go, then subtract off its starting
  6742. // value at the end to obtain `delta`.
  6743. for (oldi = i, w = 1, k = base; /* no condition */; k += base) {
  6744. if (index >= inputLength) {
  6745. error('invalid-input');
  6746. }
  6747. digit = basicToDigit(input.charCodeAt(index++));
  6748. if (digit >= base || digit > floor((maxInt - i) / w)) {
  6749. error('overflow');
  6750. }
  6751. i += digit * w;
  6752. t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
  6753. if (digit < t) {
  6754. break;
  6755. }
  6756. baseMinusT = base - t;
  6757. if (w > floor(maxInt / baseMinusT)) {
  6758. error('overflow');
  6759. }
  6760. w *= baseMinusT;
  6761. }
  6762. out = output.length + 1;
  6763. bias = adapt(i - oldi, out, oldi == 0);
  6764. // `i` was supposed to wrap around from `out` to `0`,
  6765. // incrementing `n` each time, so we'll fix that now:
  6766. if (floor(i / out) > maxInt - n) {
  6767. error('overflow');
  6768. }
  6769. n += floor(i / out);
  6770. i %= out;
  6771. // Insert `n` at position `i` of the output
  6772. output.splice(i++, 0, n);
  6773. }
  6774. return ucs2encode(output);
  6775. }
  6776. /**
  6777. * Converts a string of Unicode symbols (e.g. a domain name label) to a
  6778. * Punycode string of ASCII-only symbols.
  6779. * @memberOf punycode
  6780. * @param {String} input The string of Unicode symbols.
  6781. * @returns {String} The resulting Punycode string of ASCII-only symbols.
  6782. */
  6783. function encode(input) {
  6784. var n,
  6785. delta,
  6786. handledCPCount,
  6787. basicLength,
  6788. bias,
  6789. j,
  6790. m,
  6791. q,
  6792. k,
  6793. t,
  6794. currentValue,
  6795. output = [],
  6796. /** `inputLength` will hold the number of code points in `input`. */
  6797. inputLength,
  6798. /** Cached calculation results */
  6799. handledCPCountPlusOne,
  6800. baseMinusT,
  6801. qMinusT;
  6802. // Convert the input in UCS-2 to Unicode
  6803. input = ucs2decode(input);
  6804. // Cache the length
  6805. inputLength = input.length;
  6806. // Initialize the state
  6807. n = initialN;
  6808. delta = 0;
  6809. bias = initialBias;
  6810. // Handle the basic code points
  6811. for (j = 0; j < inputLength; ++j) {
  6812. currentValue = input[j];
  6813. if (currentValue < 0x80) {
  6814. output.push(stringFromCharCode(currentValue));
  6815. }
  6816. }
  6817. handledCPCount = basicLength = output.length;
  6818. // `handledCPCount` is the number of code points that have been handled;
  6819. // `basicLength` is the number of basic code points.
  6820. // Finish the basic string - if it is not empty - with a delimiter
  6821. if (basicLength) {
  6822. output.push(delimiter);
  6823. }
  6824. // Main encoding loop:
  6825. while (handledCPCount < inputLength) {
  6826. // All non-basic code points < n have been handled already. Find the next
  6827. // larger one:
  6828. for (m = maxInt, j = 0; j < inputLength; ++j) {
  6829. currentValue = input[j];
  6830. if (currentValue >= n && currentValue < m) {
  6831. m = currentValue;
  6832. }
  6833. }
  6834. // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
  6835. // but guard against overflow
  6836. handledCPCountPlusOne = handledCPCount + 1;
  6837. if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
  6838. error('overflow');
  6839. }
  6840. delta += (m - n) * handledCPCountPlusOne;
  6841. n = m;
  6842. for (j = 0; j < inputLength; ++j) {
  6843. currentValue = input[j];
  6844. if (currentValue < n && ++delta > maxInt) {
  6845. error('overflow');
  6846. }
  6847. if (currentValue == n) {
  6848. // Represent delta as a generalized variable-length integer
  6849. for (q = delta, k = base; /* no condition */; k += base) {
  6850. t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
  6851. if (q < t) {
  6852. break;
  6853. }
  6854. qMinusT = q - t;
  6855. baseMinusT = base - t;
  6856. output.push(
  6857. stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
  6858. );
  6859. q = floor(qMinusT / baseMinusT);
  6860. }
  6861. output.push(stringFromCharCode(digitToBasic(q, 0)));
  6862. bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
  6863. delta = 0;
  6864. ++handledCPCount;
  6865. }
  6866. }
  6867. ++delta;
  6868. ++n;
  6869. }
  6870. return output.join('');
  6871. }
  6872. /**
  6873. * Converts a Punycode string representing a domain name or an email address
  6874. * to Unicode. Only the Punycoded parts of the input will be converted, i.e.
  6875. * it doesn't matter if you call it on a string that has already been
  6876. * converted to Unicode.
  6877. * @memberOf punycode
  6878. * @param {String} input The Punycoded domain name or email address to
  6879. * convert to Unicode.
  6880. * @returns {String} The Unicode representation of the given Punycode
  6881. * string.
  6882. */
  6883. function toUnicode(input) {
  6884. return mapDomain(input, function(string) {
  6885. return regexPunycode.test(string)
  6886. ? decode(string.slice(4).toLowerCase())
  6887. : string;
  6888. });
  6889. }
  6890. /**
  6891. * Converts a Unicode string representing a domain name or an email address to
  6892. * Punycode. Only the non-ASCII parts of the domain name will be converted,
  6893. * i.e. it doesn't matter if you call it with a domain that's already in
  6894. * ASCII.
  6895. * @memberOf punycode
  6896. * @param {String} input The domain name or email address to convert, as a
  6897. * Unicode string.
  6898. * @returns {String} The Punycode representation of the given domain name or
  6899. * email address.
  6900. */
  6901. function toASCII(input) {
  6902. return mapDomain(input, function(string) {
  6903. return regexNonASCII.test(string)
  6904. ? 'xn--' + encode(string)
  6905. : string;
  6906. });
  6907. }
  6908. /*--------------------------------------------------------------------------*/
  6909. /** Define the public API */
  6910. punycode = {
  6911. /**
  6912. * A string representing the current Punycode.js version number.
  6913. * @memberOf punycode
  6914. * @type String
  6915. */
  6916. 'version': '1.4.1',
  6917. /**
  6918. * An object of methods to convert from JavaScript's internal character
  6919. * representation (UCS-2) to Unicode code points, and back.
  6920. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  6921. * @memberOf punycode
  6922. * @type Object
  6923. */
  6924. 'ucs2': {
  6925. 'decode': ucs2decode,
  6926. 'encode': ucs2encode
  6927. },
  6928. 'decode': decode,
  6929. 'encode': encode,
  6930. 'toASCII': toASCII,
  6931. 'toUnicode': toUnicode
  6932. };
  6933. /** Expose `punycode` */
  6934. // Some AMD build optimizers, like r.js, check for specific condition patterns
  6935. // like the following:
  6936. if (
  6937. true
  6938. ) {
  6939. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  6940. return punycode;
  6941. }).call(exports, __webpack_require__, exports, module),
  6942. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  6943. } else if (freeExports && freeModule) {
  6944. if (module.exports == freeExports) {
  6945. // in Node.js, io.js, or RingoJS v0.8.0+
  6946. freeModule.exports = punycode;
  6947. } else {
  6948. // in Narwhal or RingoJS v0.7.0-
  6949. for (key in punycode) {
  6950. punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
  6951. }
  6952. }
  6953. } else {
  6954. // in Rhino or a web browser
  6955. root.punycode = punycode;
  6956. }
  6957. }(this));
  6958. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(31)(module), __webpack_require__(0)))
  6959. /***/ }),
  6960. /* 31 */
  6961. /***/ (function(module, exports) {
  6962. module.exports = function(module) {
  6963. if(!module.webpackPolyfill) {
  6964. module.deprecate = function() {};
  6965. module.paths = [];
  6966. // module.parent = undefined by default
  6967. if(!module.children) module.children = [];
  6968. Object.defineProperty(module, "loaded", {
  6969. enumerable: true,
  6970. get: function() {
  6971. return module.l;
  6972. }
  6973. });
  6974. Object.defineProperty(module, "id", {
  6975. enumerable: true,
  6976. get: function() {
  6977. return module.i;
  6978. }
  6979. });
  6980. module.webpackPolyfill = 1;
  6981. }
  6982. return module;
  6983. };
  6984. /***/ }),
  6985. /* 32 */
  6986. /***/ (function(module, exports, __webpack_require__) {
  6987. "use strict";
  6988. module.exports = {
  6989. isString: function(arg) {
  6990. return typeof(arg) === 'string';
  6991. },
  6992. isObject: function(arg) {
  6993. return typeof(arg) === 'object' && arg !== null;
  6994. },
  6995. isNull: function(arg) {
  6996. return arg === null;
  6997. },
  6998. isNullOrUndefined: function(arg) {
  6999. return arg == null;
  7000. }
  7001. };
  7002. /***/ }),
  7003. /* 33 */
  7004. /***/ (function(module, exports, __webpack_require__) {
  7005. "use strict";
  7006. exports.decode = exports.parse = __webpack_require__(34);
  7007. exports.encode = exports.stringify = __webpack_require__(35);
  7008. /***/ }),
  7009. /* 34 */
  7010. /***/ (function(module, exports, __webpack_require__) {
  7011. "use strict";
  7012. // Copyright Joyent, Inc. and other Node contributors.
  7013. //
  7014. // Permission is hereby granted, free of charge, to any person obtaining a
  7015. // copy of this software and associated documentation files (the
  7016. // "Software"), to deal in the Software without restriction, including
  7017. // without limitation the rights to use, copy, modify, merge, publish,
  7018. // distribute, sublicense, and/or sell copies of the Software, and to permit
  7019. // persons to whom the Software is furnished to do so, subject to the
  7020. // following conditions:
  7021. //
  7022. // The above copyright notice and this permission notice shall be included
  7023. // in all copies or substantial portions of the Software.
  7024. //
  7025. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  7026. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  7027. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  7028. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  7029. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  7030. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  7031. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  7032. // If obj.hasOwnProperty has been overridden, then calling
  7033. // obj.hasOwnProperty(prop) will break.
  7034. // See: https://github.com/joyent/node/issues/1707
  7035. function hasOwnProperty(obj, prop) {
  7036. return Object.prototype.hasOwnProperty.call(obj, prop);
  7037. }
  7038. module.exports = function(qs, sep, eq, options) {
  7039. sep = sep || '&';
  7040. eq = eq || '=';
  7041. var obj = {};
  7042. if (typeof qs !== 'string' || qs.length === 0) {
  7043. return obj;
  7044. }
  7045. var regexp = /\+/g;
  7046. qs = qs.split(sep);
  7047. var maxKeys = 1000;
  7048. if (options && typeof options.maxKeys === 'number') {
  7049. maxKeys = options.maxKeys;
  7050. }
  7051. var len = qs.length;
  7052. // maxKeys <= 0 means that we should not limit keys count
  7053. if (maxKeys > 0 && len > maxKeys) {
  7054. len = maxKeys;
  7055. }
  7056. for (var i = 0; i < len; ++i) {
  7057. var x = qs[i].replace(regexp, '%20'),
  7058. idx = x.indexOf(eq),
  7059. kstr, vstr, k, v;
  7060. if (idx >= 0) {
  7061. kstr = x.substr(0, idx);
  7062. vstr = x.substr(idx + 1);
  7063. } else {
  7064. kstr = x;
  7065. vstr = '';
  7066. }
  7067. k = decodeURIComponent(kstr);
  7068. v = decodeURIComponent(vstr);
  7069. if (!hasOwnProperty(obj, k)) {
  7070. obj[k] = v;
  7071. } else if (isArray(obj[k])) {
  7072. obj[k].push(v);
  7073. } else {
  7074. obj[k] = [obj[k], v];
  7075. }
  7076. }
  7077. return obj;
  7078. };
  7079. var isArray = Array.isArray || function (xs) {
  7080. return Object.prototype.toString.call(xs) === '[object Array]';
  7081. };
  7082. /***/ }),
  7083. /* 35 */
  7084. /***/ (function(module, exports, __webpack_require__) {
  7085. "use strict";
  7086. // Copyright Joyent, Inc. and other Node contributors.
  7087. //
  7088. // Permission is hereby granted, free of charge, to any person obtaining a
  7089. // copy of this software and associated documentation files (the
  7090. // "Software"), to deal in the Software without restriction, including
  7091. // without limitation the rights to use, copy, modify, merge, publish,
  7092. // distribute, sublicense, and/or sell copies of the Software, and to permit
  7093. // persons to whom the Software is furnished to do so, subject to the
  7094. // following conditions:
  7095. //
  7096. // The above copyright notice and this permission notice shall be included
  7097. // in all copies or substantial portions of the Software.
  7098. //
  7099. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  7100. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  7101. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  7102. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  7103. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  7104. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  7105. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  7106. var stringifyPrimitive = function(v) {
  7107. switch (typeof v) {
  7108. case 'string':
  7109. return v;
  7110. case 'boolean':
  7111. return v ? 'true' : 'false';
  7112. case 'number':
  7113. return isFinite(v) ? v : '';
  7114. default:
  7115. return '';
  7116. }
  7117. };
  7118. module.exports = function(obj, sep, eq, name) {
  7119. sep = sep || '&';
  7120. eq = eq || '=';
  7121. if (obj === null) {
  7122. obj = undefined;
  7123. }
  7124. if (typeof obj === 'object') {
  7125. return map(objectKeys(obj), function(k) {
  7126. var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
  7127. if (isArray(obj[k])) {
  7128. return map(obj[k], function(v) {
  7129. return ks + encodeURIComponent(stringifyPrimitive(v));
  7130. }).join(sep);
  7131. } else {
  7132. return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
  7133. }
  7134. }).join(sep);
  7135. }
  7136. if (!name) return '';
  7137. return encodeURIComponent(stringifyPrimitive(name)) + eq +
  7138. encodeURIComponent(stringifyPrimitive(obj));
  7139. };
  7140. var isArray = Array.isArray || function (xs) {
  7141. return Object.prototype.toString.call(xs) === '[object Array]';
  7142. };
  7143. function map (xs, f) {
  7144. if (xs.map) return xs.map(f);
  7145. var res = [];
  7146. for (var i = 0; i < xs.length; i++) {
  7147. res.push(f(xs[i], i));
  7148. }
  7149. return res;
  7150. }
  7151. var objectKeys = Object.keys || function (obj) {
  7152. var res = [];
  7153. for (var key in obj) {
  7154. if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key);
  7155. }
  7156. return res;
  7157. };
  7158. /***/ }),
  7159. /* 36 */
  7160. /***/ (function(module, exports, __webpack_require__) {
  7161. var http = __webpack_require__(10)
  7162. var url = __webpack_require__(7)
  7163. var https = module.exports
  7164. for (var key in http) {
  7165. if (http.hasOwnProperty(key)) https[key] = http[key]
  7166. }
  7167. https.request = function (params, cb) {
  7168. params = validateParams(params)
  7169. return http.request.call(this, params, cb)
  7170. }
  7171. https.get = function (params, cb) {
  7172. params = validateParams(params)
  7173. return http.get.call(this, params, cb)
  7174. }
  7175. function validateParams (params) {
  7176. if (typeof params === 'string') {
  7177. params = url.parse(params)
  7178. }
  7179. if (!params.protocol) {
  7180. params.protocol = 'https:'
  7181. }
  7182. if (params.protocol !== 'https:') {
  7183. throw new Error('Protocol "' + params.protocol + '" not supported. Expected "https:"')
  7184. }
  7185. return params
  7186. }
  7187. /***/ }),
  7188. /* 37 */
  7189. /***/ (function(module, exports, __webpack_require__) {
  7190. /* WEBPACK VAR INJECTION */(function(Buffer, global, process) {var capability = __webpack_require__(11)
  7191. var inherits = __webpack_require__(12)
  7192. var response = __webpack_require__(13)
  7193. var stream = __webpack_require__(14)
  7194. var toArrayBuffer = __webpack_require__(47)
  7195. var IncomingMessage = response.IncomingMessage
  7196. var rStates = response.readyStates
  7197. function decideMode (preferBinary, useFetch) {
  7198. if (capability.fetch && useFetch) {
  7199. return 'fetch'
  7200. } else if (capability.mozchunkedarraybuffer) {
  7201. return 'moz-chunked-arraybuffer'
  7202. } else if (capability.msstream) {
  7203. return 'ms-stream'
  7204. } else if (capability.arraybuffer && preferBinary) {
  7205. return 'arraybuffer'
  7206. } else if (capability.vbArray && preferBinary) {
  7207. return 'text:vbarray'
  7208. } else {
  7209. return 'text'
  7210. }
  7211. }
  7212. var ClientRequest = module.exports = function (opts) {
  7213. var self = this
  7214. stream.Writable.call(self)
  7215. self._opts = opts
  7216. self._body = []
  7217. self._headers = {}
  7218. if (opts.auth)
  7219. self.setHeader('Authorization', 'Basic ' + new Buffer(opts.auth).toString('base64'))
  7220. Object.keys(opts.headers).forEach(function (name) {
  7221. self.setHeader(name, opts.headers[name])
  7222. })
  7223. var preferBinary
  7224. var useFetch = true
  7225. if (opts.mode === 'disable-fetch' || ('requestTimeout' in opts && !capability.abortController)) {
  7226. // If the use of XHR should be preferred. Not typically needed.
  7227. useFetch = false
  7228. preferBinary = true
  7229. } else if (opts.mode === 'prefer-streaming') {
  7230. // If streaming is a high priority but binary compatibility and
  7231. // the accuracy of the 'content-type' header aren't
  7232. preferBinary = false
  7233. } else if (opts.mode === 'allow-wrong-content-type') {
  7234. // If streaming is more important than preserving the 'content-type' header
  7235. preferBinary = !capability.overrideMimeType
  7236. } else if (!opts.mode || opts.mode === 'default' || opts.mode === 'prefer-fast') {
  7237. // Use binary if text streaming may corrupt data or the content-type header, or for speed
  7238. preferBinary = true
  7239. } else {
  7240. throw new Error('Invalid value for opts.mode')
  7241. }
  7242. self._mode = decideMode(preferBinary, useFetch)
  7243. self._fetchTimer = null
  7244. self.on('finish', function () {
  7245. self._onFinish()
  7246. })
  7247. }
  7248. inherits(ClientRequest, stream.Writable)
  7249. ClientRequest.prototype.setHeader = function (name, value) {
  7250. var self = this
  7251. var lowerName = name.toLowerCase()
  7252. // This check is not necessary, but it prevents warnings from browsers about setting unsafe
  7253. // headers. To be honest I'm not entirely sure hiding these warnings is a good thing, but
  7254. // http-browserify did it, so I will too.
  7255. if (unsafeHeaders.indexOf(lowerName) !== -1)
  7256. return
  7257. self._headers[lowerName] = {
  7258. name: name,
  7259. value: value
  7260. }
  7261. }
  7262. ClientRequest.prototype.getHeader = function (name) {
  7263. var header = this._headers[name.toLowerCase()]
  7264. if (header)
  7265. return header.value
  7266. return null
  7267. }
  7268. ClientRequest.prototype.removeHeader = function (name) {
  7269. var self = this
  7270. delete self._headers[name.toLowerCase()]
  7271. }
  7272. ClientRequest.prototype._onFinish = function () {
  7273. var self = this
  7274. if (self._destroyed)
  7275. return
  7276. var opts = self._opts
  7277. var headersObj = self._headers
  7278. var body = null
  7279. if (opts.method !== 'GET' && opts.method !== 'HEAD') {
  7280. if (capability.arraybuffer) {
  7281. body = toArrayBuffer(Buffer.concat(self._body))
  7282. } else if (capability.blobConstructor) {
  7283. body = new global.Blob(self._body.map(function (buffer) {
  7284. return toArrayBuffer(buffer)
  7285. }), {
  7286. type: (headersObj['content-type'] || {}).value || ''
  7287. })
  7288. } else {
  7289. // get utf8 string
  7290. body = Buffer.concat(self._body).toString()
  7291. }
  7292. }
  7293. // create flattened list of headers
  7294. var headersList = []
  7295. Object.keys(headersObj).forEach(function (keyName) {
  7296. var name = headersObj[keyName].name
  7297. var value = headersObj[keyName].value
  7298. if (Array.isArray(value)) {
  7299. value.forEach(function (v) {
  7300. headersList.push([name, v])
  7301. })
  7302. } else {
  7303. headersList.push([name, value])
  7304. }
  7305. })
  7306. if (self._mode === 'fetch') {
  7307. var signal = null
  7308. var fetchTimer = null
  7309. if (capability.abortController) {
  7310. var controller = new AbortController()
  7311. signal = controller.signal
  7312. self._fetchAbortController = controller
  7313. if ('requestTimeout' in opts && opts.requestTimeout !== 0) {
  7314. self._fetchTimer = global.setTimeout(function () {
  7315. self.emit('requestTimeout')
  7316. if (self._fetchAbortController)
  7317. self._fetchAbortController.abort()
  7318. }, opts.requestTimeout)
  7319. }
  7320. }
  7321. global.fetch(self._opts.url, {
  7322. method: self._opts.method,
  7323. headers: headersList,
  7324. body: body || undefined,
  7325. mode: 'cors',
  7326. credentials: opts.withCredentials ? 'include' : 'same-origin',
  7327. signal: signal
  7328. }).then(function (response) {
  7329. self._fetchResponse = response
  7330. self._connect()
  7331. }, function (reason) {
  7332. global.clearTimeout(self._fetchTimer)
  7333. if (!self._destroyed)
  7334. self.emit('error', reason)
  7335. })
  7336. } else {
  7337. var xhr = self._xhr = new global.XMLHttpRequest()
  7338. try {
  7339. xhr.open(self._opts.method, self._opts.url, true)
  7340. } catch (err) {
  7341. process.nextTick(function () {
  7342. self.emit('error', err)
  7343. })
  7344. return
  7345. }
  7346. // Can't set responseType on really old browsers
  7347. if ('responseType' in xhr)
  7348. xhr.responseType = self._mode.split(':')[0]
  7349. if ('withCredentials' in xhr)
  7350. xhr.withCredentials = !!opts.withCredentials
  7351. if (self._mode === 'text' && 'overrideMimeType' in xhr)
  7352. xhr.overrideMimeType('text/plain; charset=x-user-defined')
  7353. if ('requestTimeout' in opts) {
  7354. xhr.timeout = opts.requestTimeout
  7355. xhr.ontimeout = function () {
  7356. self.emit('requestTimeout')
  7357. }
  7358. }
  7359. headersList.forEach(function (header) {
  7360. xhr.setRequestHeader(header[0], header[1])
  7361. })
  7362. self._response = null
  7363. xhr.onreadystatechange = function () {
  7364. switch (xhr.readyState) {
  7365. case rStates.LOADING:
  7366. case rStates.DONE:
  7367. self._onXHRProgress()
  7368. break
  7369. }
  7370. }
  7371. // Necessary for streaming in Firefox, since xhr.response is ONLY defined
  7372. // in onprogress, not in onreadystatechange with xhr.readyState = 3
  7373. if (self._mode === 'moz-chunked-arraybuffer') {
  7374. xhr.onprogress = function () {
  7375. self._onXHRProgress()
  7376. }
  7377. }
  7378. xhr.onerror = function () {
  7379. if (self._destroyed)
  7380. return
  7381. self.emit('error', new Error('XHR error'))
  7382. }
  7383. try {
  7384. xhr.send(body)
  7385. } catch (err) {
  7386. process.nextTick(function () {
  7387. self.emit('error', err)
  7388. })
  7389. return
  7390. }
  7391. }
  7392. }
  7393. /**
  7394. * Checks if xhr.status is readable and non-zero, indicating no error.
  7395. * Even though the spec says it should be available in readyState 3,
  7396. * accessing it throws an exception in IE8
  7397. */
  7398. function statusValid (xhr) {
  7399. try {
  7400. var status = xhr.status
  7401. return (status !== null && status !== 0)
  7402. } catch (e) {
  7403. return false
  7404. }
  7405. }
  7406. ClientRequest.prototype._onXHRProgress = function () {
  7407. var self = this
  7408. if (!statusValid(self._xhr) || self._destroyed)
  7409. return
  7410. if (!self._response)
  7411. self._connect()
  7412. self._response._onXHRProgress()
  7413. }
  7414. ClientRequest.prototype._connect = function () {
  7415. var self = this
  7416. if (self._destroyed)
  7417. return
  7418. self._response = new IncomingMessage(self._xhr, self._fetchResponse, self._mode, self._fetchTimer)
  7419. self._response.on('error', function(err) {
  7420. self.emit('error', err)
  7421. })
  7422. self.emit('response', self._response)
  7423. }
  7424. ClientRequest.prototype._write = function (chunk, encoding, cb) {
  7425. var self = this
  7426. self._body.push(chunk)
  7427. cb()
  7428. }
  7429. ClientRequest.prototype.abort = ClientRequest.prototype.destroy = function () {
  7430. var self = this
  7431. self._destroyed = true
  7432. global.clearTimeout(self._fetchTimer)
  7433. if (self._response)
  7434. self._response._destroyed = true
  7435. if (self._xhr)
  7436. self._xhr.abort()
  7437. else if (self._fetchAbortController)
  7438. self._fetchAbortController.abort()
  7439. }
  7440. ClientRequest.prototype.end = function (data, encoding, cb) {
  7441. var self = this
  7442. if (typeof data === 'function') {
  7443. cb = data
  7444. data = undefined
  7445. }
  7446. stream.Writable.prototype.end.call(self, data, encoding, cb)
  7447. }
  7448. ClientRequest.prototype.flushHeaders = function () {}
  7449. ClientRequest.prototype.setTimeout = function () {}
  7450. ClientRequest.prototype.setNoDelay = function () {}
  7451. ClientRequest.prototype.setSocketKeepAlive = function () {}
  7452. // Taken from http://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader%28%29-method
  7453. var unsafeHeaders = [
  7454. 'accept-charset',
  7455. 'accept-encoding',
  7456. 'access-control-request-headers',
  7457. 'access-control-request-method',
  7458. 'connection',
  7459. 'content-length',
  7460. 'cookie',
  7461. 'cookie2',
  7462. 'date',
  7463. 'dnt',
  7464. 'expect',
  7465. 'host',
  7466. 'keep-alive',
  7467. 'origin',
  7468. 'referer',
  7469. 'te',
  7470. 'trailer',
  7471. 'transfer-encoding',
  7472. 'upgrade',
  7473. 'via'
  7474. ]
  7475. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2).Buffer, __webpack_require__(0), __webpack_require__(1)))
  7476. /***/ }),
  7477. /* 38 */
  7478. /***/ (function(module, exports) {
  7479. var toString = {}.toString;
  7480. module.exports = Array.isArray || function (arr) {
  7481. return toString.call(arr) == '[object Array]';
  7482. };
  7483. /***/ }),
  7484. /* 39 */
  7485. /***/ (function(module, exports) {
  7486. /* (ignored) */
  7487. /***/ }),
  7488. /* 40 */
  7489. /***/ (function(module, exports, __webpack_require__) {
  7490. "use strict";
  7491. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7492. var Buffer = __webpack_require__(9).Buffer;
  7493. var util = __webpack_require__(41);
  7494. function copyBuffer(src, target, offset) {
  7495. src.copy(target, offset);
  7496. }
  7497. module.exports = function () {
  7498. function BufferList() {
  7499. _classCallCheck(this, BufferList);
  7500. this.head = null;
  7501. this.tail = null;
  7502. this.length = 0;
  7503. }
  7504. BufferList.prototype.push = function push(v) {
  7505. var entry = { data: v, next: null };
  7506. if (this.length > 0) this.tail.next = entry;else this.head = entry;
  7507. this.tail = entry;
  7508. ++this.length;
  7509. };
  7510. BufferList.prototype.unshift = function unshift(v) {
  7511. var entry = { data: v, next: this.head };
  7512. if (this.length === 0) this.tail = entry;
  7513. this.head = entry;
  7514. ++this.length;
  7515. };
  7516. BufferList.prototype.shift = function shift() {
  7517. if (this.length === 0) return;
  7518. var ret = this.head.data;
  7519. if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
  7520. --this.length;
  7521. return ret;
  7522. };
  7523. BufferList.prototype.clear = function clear() {
  7524. this.head = this.tail = null;
  7525. this.length = 0;
  7526. };
  7527. BufferList.prototype.join = function join(s) {
  7528. if (this.length === 0) return '';
  7529. var p = this.head;
  7530. var ret = '' + p.data;
  7531. while (p = p.next) {
  7532. ret += s + p.data;
  7533. }return ret;
  7534. };
  7535. BufferList.prototype.concat = function concat(n) {
  7536. if (this.length === 0) return Buffer.alloc(0);
  7537. if (this.length === 1) return this.head.data;
  7538. var ret = Buffer.allocUnsafe(n >>> 0);
  7539. var p = this.head;
  7540. var i = 0;
  7541. while (p) {
  7542. copyBuffer(p.data, ret, i);
  7543. i += p.data.length;
  7544. p = p.next;
  7545. }
  7546. return ret;
  7547. };
  7548. return BufferList;
  7549. }();
  7550. if (util && util.inspect && util.inspect.custom) {
  7551. module.exports.prototype[util.inspect.custom] = function () {
  7552. var obj = util.inspect({ length: this.length });
  7553. return this.constructor.name + ' ' + obj;
  7554. };
  7555. }
  7556. /***/ }),
  7557. /* 41 */
  7558. /***/ (function(module, exports) {
  7559. /* (ignored) */
  7560. /***/ }),
  7561. /* 42 */
  7562. /***/ (function(module, exports, __webpack_require__) {
  7563. /* WEBPACK VAR INJECTION */(function(global) {var scope = (typeof global !== "undefined" && global) ||
  7564. (typeof self !== "undefined" && self) ||
  7565. window;
  7566. var apply = Function.prototype.apply;
  7567. // DOM APIs, for completeness
  7568. exports.setTimeout = function() {
  7569. return new Timeout(apply.call(setTimeout, scope, arguments), clearTimeout);
  7570. };
  7571. exports.setInterval = function() {
  7572. return new Timeout(apply.call(setInterval, scope, arguments), clearInterval);
  7573. };
  7574. exports.clearTimeout =
  7575. exports.clearInterval = function(timeout) {
  7576. if (timeout) {
  7577. timeout.close();
  7578. }
  7579. };
  7580. function Timeout(id, clearFn) {
  7581. this._id = id;
  7582. this._clearFn = clearFn;
  7583. }
  7584. Timeout.prototype.unref = Timeout.prototype.ref = function() {};
  7585. Timeout.prototype.close = function() {
  7586. this._clearFn.call(scope, this._id);
  7587. };
  7588. // Does not start the time, just sets up the members needed.
  7589. exports.enroll = function(item, msecs) {
  7590. clearTimeout(item._idleTimeoutId);
  7591. item._idleTimeout = msecs;
  7592. };
  7593. exports.unenroll = function(item) {
  7594. clearTimeout(item._idleTimeoutId);
  7595. item._idleTimeout = -1;
  7596. };
  7597. exports._unrefActive = exports.active = function(item) {
  7598. clearTimeout(item._idleTimeoutId);
  7599. var msecs = item._idleTimeout;
  7600. if (msecs >= 0) {
  7601. item._idleTimeoutId = setTimeout(function onTimeout() {
  7602. if (item._onTimeout)
  7603. item._onTimeout();
  7604. }, msecs);
  7605. }
  7606. };
  7607. // setimmediate attaches itself to the global object
  7608. __webpack_require__(43);
  7609. // On some exotic environments, it's not clear which object `setimmediate` was
  7610. // able to install onto. Search each possibility in the same order as the
  7611. // `setimmediate` library.
  7612. exports.setImmediate = (typeof self !== "undefined" && self.setImmediate) ||
  7613. (typeof global !== "undefined" && global.setImmediate) ||
  7614. (this && this.setImmediate);
  7615. exports.clearImmediate = (typeof self !== "undefined" && self.clearImmediate) ||
  7616. (typeof global !== "undefined" && global.clearImmediate) ||
  7617. (this && this.clearImmediate);
  7618. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
  7619. /***/ }),
  7620. /* 43 */
  7621. /***/ (function(module, exports, __webpack_require__) {
  7622. /* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) {
  7623. "use strict";
  7624. if (global.setImmediate) {
  7625. return;
  7626. }
  7627. var nextHandle = 1; // Spec says greater than zero
  7628. var tasksByHandle = {};
  7629. var currentlyRunningATask = false;
  7630. var doc = global.document;
  7631. var registerImmediate;
  7632. function setImmediate(callback) {
  7633. // Callback can either be a function or a string
  7634. if (typeof callback !== "function") {
  7635. callback = new Function("" + callback);
  7636. }
  7637. // Copy function arguments
  7638. var args = new Array(arguments.length - 1);
  7639. for (var i = 0; i < args.length; i++) {
  7640. args[i] = arguments[i + 1];
  7641. }
  7642. // Store and register the task
  7643. var task = { callback: callback, args: args };
  7644. tasksByHandle[nextHandle] = task;
  7645. registerImmediate(nextHandle);
  7646. return nextHandle++;
  7647. }
  7648. function clearImmediate(handle) {
  7649. delete tasksByHandle[handle];
  7650. }
  7651. function run(task) {
  7652. var callback = task.callback;
  7653. var args = task.args;
  7654. switch (args.length) {
  7655. case 0:
  7656. callback();
  7657. break;
  7658. case 1:
  7659. callback(args[0]);
  7660. break;
  7661. case 2:
  7662. callback(args[0], args[1]);
  7663. break;
  7664. case 3:
  7665. callback(args[0], args[1], args[2]);
  7666. break;
  7667. default:
  7668. callback.apply(undefined, args);
  7669. break;
  7670. }
  7671. }
  7672. function runIfPresent(handle) {
  7673. // From the spec: "Wait until any invocations of this algorithm started before this one have completed."
  7674. // So if we're currently running a task, we'll need to delay this invocation.
  7675. if (currentlyRunningATask) {
  7676. // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
  7677. // "too much recursion" error.
  7678. setTimeout(runIfPresent, 0, handle);
  7679. } else {
  7680. var task = tasksByHandle[handle];
  7681. if (task) {
  7682. currentlyRunningATask = true;
  7683. try {
  7684. run(task);
  7685. } finally {
  7686. clearImmediate(handle);
  7687. currentlyRunningATask = false;
  7688. }
  7689. }
  7690. }
  7691. }
  7692. function installNextTickImplementation() {
  7693. registerImmediate = function(handle) {
  7694. process.nextTick(function () { runIfPresent(handle); });
  7695. };
  7696. }
  7697. function canUsePostMessage() {
  7698. // The test against `importScripts` prevents this implementation from being installed inside a web worker,
  7699. // where `global.postMessage` means something completely different and can't be used for this purpose.
  7700. if (global.postMessage && !global.importScripts) {
  7701. var postMessageIsAsynchronous = true;
  7702. var oldOnMessage = global.onmessage;
  7703. global.onmessage = function() {
  7704. postMessageIsAsynchronous = false;
  7705. };
  7706. global.postMessage("", "*");
  7707. global.onmessage = oldOnMessage;
  7708. return postMessageIsAsynchronous;
  7709. }
  7710. }
  7711. function installPostMessageImplementation() {
  7712. // Installs an event handler on `global` for the `message` event: see
  7713. // * https://developer.mozilla.org/en/DOM/window.postMessage
  7714. // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
  7715. var messagePrefix = "setImmediate$" + Math.random() + "$";
  7716. var onGlobalMessage = function(event) {
  7717. if (event.source === global &&
  7718. typeof event.data === "string" &&
  7719. event.data.indexOf(messagePrefix) === 0) {
  7720. runIfPresent(+event.data.slice(messagePrefix.length));
  7721. }
  7722. };
  7723. if (global.addEventListener) {
  7724. global.addEventListener("message", onGlobalMessage, false);
  7725. } else {
  7726. global.attachEvent("onmessage", onGlobalMessage);
  7727. }
  7728. registerImmediate = function(handle) {
  7729. global.postMessage(messagePrefix + handle, "*");
  7730. };
  7731. }
  7732. function installMessageChannelImplementation() {
  7733. var channel = new MessageChannel();
  7734. channel.port1.onmessage = function(event) {
  7735. var handle = event.data;
  7736. runIfPresent(handle);
  7737. };
  7738. registerImmediate = function(handle) {
  7739. channel.port2.postMessage(handle);
  7740. };
  7741. }
  7742. function installReadyStateChangeImplementation() {
  7743. var html = doc.documentElement;
  7744. registerImmediate = function(handle) {
  7745. // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
  7746. // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
  7747. var script = doc.createElement("script");
  7748. script.onreadystatechange = function () {
  7749. runIfPresent(handle);
  7750. script.onreadystatechange = null;
  7751. html.removeChild(script);
  7752. script = null;
  7753. };
  7754. html.appendChild(script);
  7755. };
  7756. }
  7757. function installSetTimeoutImplementation() {
  7758. registerImmediate = function(handle) {
  7759. setTimeout(runIfPresent, 0, handle);
  7760. };
  7761. }
  7762. // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
  7763. var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
  7764. attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
  7765. // Don't get fooled by e.g. browserify environments.
  7766. if ({}.toString.call(global.process) === "[object process]") {
  7767. // For Node.js before 0.9
  7768. installNextTickImplementation();
  7769. } else if (canUsePostMessage()) {
  7770. // For non-IE10 modern browsers
  7771. installPostMessageImplementation();
  7772. } else if (global.MessageChannel) {
  7773. // For web workers, where supported
  7774. installMessageChannelImplementation();
  7775. } else if (doc && "onreadystatechange" in doc.createElement("script")) {
  7776. // For IE 6–8
  7777. installReadyStateChangeImplementation();
  7778. } else {
  7779. // For older browsers
  7780. installSetTimeoutImplementation();
  7781. }
  7782. attachTo.setImmediate = setImmediate;
  7783. attachTo.clearImmediate = clearImmediate;
  7784. }(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self));
  7785. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0), __webpack_require__(1)))
  7786. /***/ }),
  7787. /* 44 */
  7788. /***/ (function(module, exports, __webpack_require__) {
  7789. /* WEBPACK VAR INJECTION */(function(global) {
  7790. /**
  7791. * Module exports.
  7792. */
  7793. module.exports = deprecate;
  7794. /**
  7795. * Mark that a method should not be used.
  7796. * Returns a modified function which warns once by default.
  7797. *
  7798. * If `localStorage.noDeprecation = true` is set, then it is a no-op.
  7799. *
  7800. * If `localStorage.throwDeprecation = true` is set, then deprecated functions
  7801. * will throw an Error when invoked.
  7802. *
  7803. * If `localStorage.traceDeprecation = true` is set, then deprecated functions
  7804. * will invoke `console.trace()` instead of `console.error()`.
  7805. *
  7806. * @param {Function} fn - the function to deprecate
  7807. * @param {String} msg - the string to print to the console when `fn` is invoked
  7808. * @returns {Function} a new "deprecated" version of `fn`
  7809. * @api public
  7810. */
  7811. function deprecate (fn, msg) {
  7812. if (config('noDeprecation')) {
  7813. return fn;
  7814. }
  7815. var warned = false;
  7816. function deprecated() {
  7817. if (!warned) {
  7818. if (config('throwDeprecation')) {
  7819. throw new Error(msg);
  7820. } else if (config('traceDeprecation')) {
  7821. console.trace(msg);
  7822. } else {
  7823. console.warn(msg);
  7824. }
  7825. warned = true;
  7826. }
  7827. return fn.apply(this, arguments);
  7828. }
  7829. return deprecated;
  7830. }
  7831. /**
  7832. * Checks `localStorage` for boolean values for the given `name`.
  7833. *
  7834. * @param {String} name
  7835. * @returns {Boolean}
  7836. * @api private
  7837. */
  7838. function config (name) {
  7839. // accessing global.localStorage can trigger a DOMException in sandboxed iframes
  7840. try {
  7841. if (!global.localStorage) return false;
  7842. } catch (_) {
  7843. return false;
  7844. }
  7845. var val = global.localStorage[name];
  7846. if (null == val) return false;
  7847. return String(val).toLowerCase() === 'true';
  7848. }
  7849. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
  7850. /***/ }),
  7851. /* 45 */
  7852. /***/ (function(module, exports, __webpack_require__) {
  7853. /* eslint-disable node/no-deprecated-api */
  7854. var buffer = __webpack_require__(2)
  7855. var Buffer = buffer.Buffer
  7856. // alternative to using Object.keys for old browsers
  7857. function copyProps (src, dst) {
  7858. for (var key in src) {
  7859. dst[key] = src[key]
  7860. }
  7861. }
  7862. if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
  7863. module.exports = buffer
  7864. } else {
  7865. // Copy properties from require('buffer')
  7866. copyProps(buffer, exports)
  7867. exports.Buffer = SafeBuffer
  7868. }
  7869. function SafeBuffer (arg, encodingOrOffset, length) {
  7870. return Buffer(arg, encodingOrOffset, length)
  7871. }
  7872. // Copy static methods from Buffer
  7873. copyProps(Buffer, SafeBuffer)
  7874. SafeBuffer.from = function (arg, encodingOrOffset, length) {
  7875. if (typeof arg === 'number') {
  7876. throw new TypeError('Argument must not be a number')
  7877. }
  7878. return Buffer(arg, encodingOrOffset, length)
  7879. }
  7880. SafeBuffer.alloc = function (size, fill, encoding) {
  7881. if (typeof size !== 'number') {
  7882. throw new TypeError('Argument must be a number')
  7883. }
  7884. var buf = Buffer(size)
  7885. if (fill !== undefined) {
  7886. if (typeof encoding === 'string') {
  7887. buf.fill(fill, encoding)
  7888. } else {
  7889. buf.fill(fill)
  7890. }
  7891. } else {
  7892. buf.fill(0)
  7893. }
  7894. return buf
  7895. }
  7896. SafeBuffer.allocUnsafe = function (size) {
  7897. if (typeof size !== 'number') {
  7898. throw new TypeError('Argument must be a number')
  7899. }
  7900. return Buffer(size)
  7901. }
  7902. SafeBuffer.allocUnsafeSlow = function (size) {
  7903. if (typeof size !== 'number') {
  7904. throw new TypeError('Argument must be a number')
  7905. }
  7906. return buffer.SlowBuffer(size)
  7907. }
  7908. /***/ }),
  7909. /* 46 */
  7910. /***/ (function(module, exports, __webpack_require__) {
  7911. "use strict";
  7912. // Copyright Joyent, Inc. and other Node contributors.
  7913. //
  7914. // Permission is hereby granted, free of charge, to any person obtaining a
  7915. // copy of this software and associated documentation files (the
  7916. // "Software"), to deal in the Software without restriction, including
  7917. // without limitation the rights to use, copy, modify, merge, publish,
  7918. // distribute, sublicense, and/or sell copies of the Software, and to permit
  7919. // persons to whom the Software is furnished to do so, subject to the
  7920. // following conditions:
  7921. //
  7922. // The above copyright notice and this permission notice shall be included
  7923. // in all copies or substantial portions of the Software.
  7924. //
  7925. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  7926. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  7927. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  7928. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  7929. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  7930. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  7931. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  7932. // a passthrough stream.
  7933. // basically just the most minimal sort of Transform stream.
  7934. // Every written chunk gets output as-is.
  7935. module.exports = PassThrough;
  7936. var Transform = __webpack_require__(20);
  7937. /*<replacement>*/
  7938. var util = __webpack_require__(4);
  7939. util.inherits = __webpack_require__(5);
  7940. /*</replacement>*/
  7941. util.inherits(PassThrough, Transform);
  7942. function PassThrough(options) {
  7943. if (!(this instanceof PassThrough)) return new PassThrough(options);
  7944. Transform.call(this, options);
  7945. }
  7946. PassThrough.prototype._transform = function (chunk, encoding, cb) {
  7947. cb(null, chunk);
  7948. };
  7949. /***/ }),
  7950. /* 47 */
  7951. /***/ (function(module, exports, __webpack_require__) {
  7952. var Buffer = __webpack_require__(2).Buffer
  7953. module.exports = function (buf) {
  7954. // If the buffer is backed by a Uint8Array, a faster version will work
  7955. if (buf instanceof Uint8Array) {
  7956. // If the buffer isn't a subarray, return the underlying ArrayBuffer
  7957. if (buf.byteOffset === 0 && buf.byteLength === buf.buffer.byteLength) {
  7958. return buf.buffer
  7959. } else if (typeof buf.buffer.slice === 'function') {
  7960. // Otherwise we need to get a proper copy
  7961. return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength)
  7962. }
  7963. }
  7964. if (Buffer.isBuffer(buf)) {
  7965. // This is the slow version that will work with any Buffer
  7966. // implementation (even in old browsers)
  7967. var arrayCopy = new Uint8Array(buf.length)
  7968. var len = buf.length
  7969. for (var i = 0; i < len; i++) {
  7970. arrayCopy[i] = buf[i]
  7971. }
  7972. return arrayCopy.buffer
  7973. } else {
  7974. throw new Error('Argument must be a Buffer')
  7975. }
  7976. }
  7977. /***/ }),
  7978. /* 48 */
  7979. /***/ (function(module, exports) {
  7980. module.exports = extend
  7981. var hasOwnProperty = Object.prototype.hasOwnProperty;
  7982. function extend() {
  7983. var target = {}
  7984. for (var i = 0; i < arguments.length; i++) {
  7985. var source = arguments[i]
  7986. for (var key in source) {
  7987. if (hasOwnProperty.call(source, key)) {
  7988. target[key] = source[key]
  7989. }
  7990. }
  7991. }
  7992. return target
  7993. }
  7994. /***/ }),
  7995. /* 49 */
  7996. /***/ (function(module, exports) {
  7997. module.exports = {
  7998. "100": "Continue",
  7999. "101": "Switching Protocols",
  8000. "102": "Processing",
  8001. "200": "OK",
  8002. "201": "Created",
  8003. "202": "Accepted",
  8004. "203": "Non-Authoritative Information",
  8005. "204": "No Content",
  8006. "205": "Reset Content",
  8007. "206": "Partial Content",
  8008. "207": "Multi-Status",
  8009. "208": "Already Reported",
  8010. "226": "IM Used",
  8011. "300": "Multiple Choices",
  8012. "301": "Moved Permanently",
  8013. "302": "Found",
  8014. "303": "See Other",
  8015. "304": "Not Modified",
  8016. "305": "Use Proxy",
  8017. "307": "Temporary Redirect",
  8018. "308": "Permanent Redirect",
  8019. "400": "Bad Request",
  8020. "401": "Unauthorized",
  8021. "402": "Payment Required",
  8022. "403": "Forbidden",
  8023. "404": "Not Found",
  8024. "405": "Method Not Allowed",
  8025. "406": "Not Acceptable",
  8026. "407": "Proxy Authentication Required",
  8027. "408": "Request Timeout",
  8028. "409": "Conflict",
  8029. "410": "Gone",
  8030. "411": "Length Required",
  8031. "412": "Precondition Failed",
  8032. "413": "Payload Too Large",
  8033. "414": "URI Too Long",
  8034. "415": "Unsupported Media Type",
  8035. "416": "Range Not Satisfiable",
  8036. "417": "Expectation Failed",
  8037. "418": "I'm a teapot",
  8038. "421": "Misdirected Request",
  8039. "422": "Unprocessable Entity",
  8040. "423": "Locked",
  8041. "424": "Failed Dependency",
  8042. "425": "Unordered Collection",
  8043. "426": "Upgrade Required",
  8044. "428": "Precondition Required",
  8045. "429": "Too Many Requests",
  8046. "431": "Request Header Fields Too Large",
  8047. "451": "Unavailable For Legal Reasons",
  8048. "500": "Internal Server Error",
  8049. "501": "Not Implemented",
  8050. "502": "Bad Gateway",
  8051. "503": "Service Unavailable",
  8052. "504": "Gateway Timeout",
  8053. "505": "HTTP Version Not Supported",
  8054. "506": "Variant Also Negotiates",
  8055. "507": "Insufficient Storage",
  8056. "508": "Loop Detected",
  8057. "509": "Bandwidth Limit Exceeded",
  8058. "510": "Not Extended",
  8059. "511": "Network Authentication Required"
  8060. }
  8061. /***/ }),
  8062. /* 50 */
  8063. /***/ (function(module, exports, __webpack_require__) {
  8064. /* WEBPACK VAR INJECTION */(function(global, process) {// Copyright Joyent, Inc. and other Node contributors.
  8065. //
  8066. // Permission is hereby granted, free of charge, to any person obtaining a
  8067. // copy of this software and associated documentation files (the
  8068. // "Software"), to deal in the Software without restriction, including
  8069. // without limitation the rights to use, copy, modify, merge, publish,
  8070. // distribute, sublicense, and/or sell copies of the Software, and to permit
  8071. // persons to whom the Software is furnished to do so, subject to the
  8072. // following conditions:
  8073. //
  8074. // The above copyright notice and this permission notice shall be included
  8075. // in all copies or substantial portions of the Software.
  8076. //
  8077. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  8078. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  8079. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  8080. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  8081. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  8082. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  8083. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  8084. var formatRegExp = /%[sdj%]/g;
  8085. exports.format = function(f) {
  8086. if (!isString(f)) {
  8087. var objects = [];
  8088. for (var i = 0; i < arguments.length; i++) {
  8089. objects.push(inspect(arguments[i]));
  8090. }
  8091. return objects.join(' ');
  8092. }
  8093. var i = 1;
  8094. var args = arguments;
  8095. var len = args.length;
  8096. var str = String(f).replace(formatRegExp, function(x) {
  8097. if (x === '%%') return '%';
  8098. if (i >= len) return x;
  8099. switch (x) {
  8100. case '%s': return String(args[i++]);
  8101. case '%d': return Number(args[i++]);
  8102. case '%j':
  8103. try {
  8104. return JSON.stringify(args[i++]);
  8105. } catch (_) {
  8106. return '[Circular]';
  8107. }
  8108. default:
  8109. return x;
  8110. }
  8111. });
  8112. for (var x = args[i]; i < len; x = args[++i]) {
  8113. if (isNull(x) || !isObject(x)) {
  8114. str += ' ' + x;
  8115. } else {
  8116. str += ' ' + inspect(x);
  8117. }
  8118. }
  8119. return str;
  8120. };
  8121. // Mark that a method should not be used.
  8122. // Returns a modified function which warns once by default.
  8123. // If --no-deprecation is set, then it is a no-op.
  8124. exports.deprecate = function(fn, msg) {
  8125. // Allow for deprecating things in the process of starting up.
  8126. if (isUndefined(global.process)) {
  8127. return function() {
  8128. return exports.deprecate(fn, msg).apply(this, arguments);
  8129. };
  8130. }
  8131. if (process.noDeprecation === true) {
  8132. return fn;
  8133. }
  8134. var warned = false;
  8135. function deprecated() {
  8136. if (!warned) {
  8137. if (process.throwDeprecation) {
  8138. throw new Error(msg);
  8139. } else if (process.traceDeprecation) {
  8140. console.trace(msg);
  8141. } else {
  8142. console.error(msg);
  8143. }
  8144. warned = true;
  8145. }
  8146. return fn.apply(this, arguments);
  8147. }
  8148. return deprecated;
  8149. };
  8150. var debugs = {};
  8151. var debugEnviron;
  8152. exports.debuglog = function(set) {
  8153. if (isUndefined(debugEnviron))
  8154. debugEnviron = process.env.NODE_DEBUG || '';
  8155. set = set.toUpperCase();
  8156. if (!debugs[set]) {
  8157. if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
  8158. var pid = process.pid;
  8159. debugs[set] = function() {
  8160. var msg = exports.format.apply(exports, arguments);
  8161. console.error('%s %d: %s', set, pid, msg);
  8162. };
  8163. } else {
  8164. debugs[set] = function() {};
  8165. }
  8166. }
  8167. return debugs[set];
  8168. };
  8169. /**
  8170. * Echos the value of a value. Trys to print the value out
  8171. * in the best way possible given the different types.
  8172. *
  8173. * @param {Object} obj The object to print out.
  8174. * @param {Object} opts Optional options object that alters the output.
  8175. */
  8176. /* legacy: obj, showHidden, depth, colors*/
  8177. function inspect(obj, opts) {
  8178. // default options
  8179. var ctx = {
  8180. seen: [],
  8181. stylize: stylizeNoColor
  8182. };
  8183. // legacy...
  8184. if (arguments.length >= 3) ctx.depth = arguments[2];
  8185. if (arguments.length >= 4) ctx.colors = arguments[3];
  8186. if (isBoolean(opts)) {
  8187. // legacy...
  8188. ctx.showHidden = opts;
  8189. } else if (opts) {
  8190. // got an "options" object
  8191. exports._extend(ctx, opts);
  8192. }
  8193. // set default options
  8194. if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
  8195. if (isUndefined(ctx.depth)) ctx.depth = 2;
  8196. if (isUndefined(ctx.colors)) ctx.colors = false;
  8197. if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
  8198. if (ctx.colors) ctx.stylize = stylizeWithColor;
  8199. return formatValue(ctx, obj, ctx.depth);
  8200. }
  8201. exports.inspect = inspect;
  8202. // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
  8203. inspect.colors = {
  8204. 'bold' : [1, 22],
  8205. 'italic' : [3, 23],
  8206. 'underline' : [4, 24],
  8207. 'inverse' : [7, 27],
  8208. 'white' : [37, 39],
  8209. 'grey' : [90, 39],
  8210. 'black' : [30, 39],
  8211. 'blue' : [34, 39],
  8212. 'cyan' : [36, 39],
  8213. 'green' : [32, 39],
  8214. 'magenta' : [35, 39],
  8215. 'red' : [31, 39],
  8216. 'yellow' : [33, 39]
  8217. };
  8218. // Don't use 'blue' not visible on cmd.exe
  8219. inspect.styles = {
  8220. 'special': 'cyan',
  8221. 'number': 'yellow',
  8222. 'boolean': 'yellow',
  8223. 'undefined': 'grey',
  8224. 'null': 'bold',
  8225. 'string': 'green',
  8226. 'date': 'magenta',
  8227. // "name": intentionally not styling
  8228. 'regexp': 'red'
  8229. };
  8230. function stylizeWithColor(str, styleType) {
  8231. var style = inspect.styles[styleType];
  8232. if (style) {
  8233. return '\u001b[' + inspect.colors[style][0] + 'm' + str +
  8234. '\u001b[' + inspect.colors[style][1] + 'm';
  8235. } else {
  8236. return str;
  8237. }
  8238. }
  8239. function stylizeNoColor(str, styleType) {
  8240. return str;
  8241. }
  8242. function arrayToHash(array) {
  8243. var hash = {};
  8244. array.forEach(function(val, idx) {
  8245. hash[val] = true;
  8246. });
  8247. return hash;
  8248. }
  8249. function formatValue(ctx, value, recurseTimes) {
  8250. // Provide a hook for user-specified inspect functions.
  8251. // Check that value is an object with an inspect function on it
  8252. if (ctx.customInspect &&
  8253. value &&
  8254. isFunction(value.inspect) &&
  8255. // Filter out the util module, it's inspect function is special
  8256. value.inspect !== exports.inspect &&
  8257. // Also filter out any prototype objects using the circular check.
  8258. !(value.constructor && value.constructor.prototype === value)) {
  8259. var ret = value.inspect(recurseTimes, ctx);
  8260. if (!isString(ret)) {
  8261. ret = formatValue(ctx, ret, recurseTimes);
  8262. }
  8263. return ret;
  8264. }
  8265. // Primitive types cannot have properties
  8266. var primitive = formatPrimitive(ctx, value);
  8267. if (primitive) {
  8268. return primitive;
  8269. }
  8270. // Look up the keys of the object.
  8271. var keys = Object.keys(value);
  8272. var visibleKeys = arrayToHash(keys);
  8273. if (ctx.showHidden) {
  8274. keys = Object.getOwnPropertyNames(value);
  8275. }
  8276. // IE doesn't make error fields non-enumerable
  8277. // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
  8278. if (isError(value)
  8279. && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
  8280. return formatError(value);
  8281. }
  8282. // Some type of object without properties can be shortcutted.
  8283. if (keys.length === 0) {
  8284. if (isFunction(value)) {
  8285. var name = value.name ? ': ' + value.name : '';
  8286. return ctx.stylize('[Function' + name + ']', 'special');
  8287. }
  8288. if (isRegExp(value)) {
  8289. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  8290. }
  8291. if (isDate(value)) {
  8292. return ctx.stylize(Date.prototype.toString.call(value), 'date');
  8293. }
  8294. if (isError(value)) {
  8295. return formatError(value);
  8296. }
  8297. }
  8298. var base = '', array = false, braces = ['{', '}'];
  8299. // Make Array say that they are Array
  8300. if (isArray(value)) {
  8301. array = true;
  8302. braces = ['[', ']'];
  8303. }
  8304. // Make functions say that they are functions
  8305. if (isFunction(value)) {
  8306. var n = value.name ? ': ' + value.name : '';
  8307. base = ' [Function' + n + ']';
  8308. }
  8309. // Make RegExps say that they are RegExps
  8310. if (isRegExp(value)) {
  8311. base = ' ' + RegExp.prototype.toString.call(value);
  8312. }
  8313. // Make dates with properties first say the date
  8314. if (isDate(value)) {
  8315. base = ' ' + Date.prototype.toUTCString.call(value);
  8316. }
  8317. // Make error with message first say the error
  8318. if (isError(value)) {
  8319. base = ' ' + formatError(value);
  8320. }
  8321. if (keys.length === 0 && (!array || value.length == 0)) {
  8322. return braces[0] + base + braces[1];
  8323. }
  8324. if (recurseTimes < 0) {
  8325. if (isRegExp(value)) {
  8326. return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
  8327. } else {
  8328. return ctx.stylize('[Object]', 'special');
  8329. }
  8330. }
  8331. ctx.seen.push(value);
  8332. var output;
  8333. if (array) {
  8334. output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
  8335. } else {
  8336. output = keys.map(function(key) {
  8337. return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
  8338. });
  8339. }
  8340. ctx.seen.pop();
  8341. return reduceToSingleString(output, base, braces);
  8342. }
  8343. function formatPrimitive(ctx, value) {
  8344. if (isUndefined(value))
  8345. return ctx.stylize('undefined', 'undefined');
  8346. if (isString(value)) {
  8347. var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
  8348. .replace(/'/g, "\\'")
  8349. .replace(/\\"/g, '"') + '\'';
  8350. return ctx.stylize(simple, 'string');
  8351. }
  8352. if (isNumber(value))
  8353. return ctx.stylize('' + value, 'number');
  8354. if (isBoolean(value))
  8355. return ctx.stylize('' + value, 'boolean');
  8356. // For some reason typeof null is "object", so special case here.
  8357. if (isNull(value))
  8358. return ctx.stylize('null', 'null');
  8359. }
  8360. function formatError(value) {
  8361. return '[' + Error.prototype.toString.call(value) + ']';
  8362. }
  8363. function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
  8364. var output = [];
  8365. for (var i = 0, l = value.length; i < l; ++i) {
  8366. if (hasOwnProperty(value, String(i))) {
  8367. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  8368. String(i), true));
  8369. } else {
  8370. output.push('');
  8371. }
  8372. }
  8373. keys.forEach(function(key) {
  8374. if (!key.match(/^\d+$/)) {
  8375. output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
  8376. key, true));
  8377. }
  8378. });
  8379. return output;
  8380. }
  8381. function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
  8382. var name, str, desc;
  8383. desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
  8384. if (desc.get) {
  8385. if (desc.set) {
  8386. str = ctx.stylize('[Getter/Setter]', 'special');
  8387. } else {
  8388. str = ctx.stylize('[Getter]', 'special');
  8389. }
  8390. } else {
  8391. if (desc.set) {
  8392. str = ctx.stylize('[Setter]', 'special');
  8393. }
  8394. }
  8395. if (!hasOwnProperty(visibleKeys, key)) {
  8396. name = '[' + key + ']';
  8397. }
  8398. if (!str) {
  8399. if (ctx.seen.indexOf(desc.value) < 0) {
  8400. if (isNull(recurseTimes)) {
  8401. str = formatValue(ctx, desc.value, null);
  8402. } else {
  8403. str = formatValue(ctx, desc.value, recurseTimes - 1);
  8404. }
  8405. if (str.indexOf('\n') > -1) {
  8406. if (array) {
  8407. str = str.split('\n').map(function(line) {
  8408. return ' ' + line;
  8409. }).join('\n').substr(2);
  8410. } else {
  8411. str = '\n' + str.split('\n').map(function(line) {
  8412. return ' ' + line;
  8413. }).join('\n');
  8414. }
  8415. }
  8416. } else {
  8417. str = ctx.stylize('[Circular]', 'special');
  8418. }
  8419. }
  8420. if (isUndefined(name)) {
  8421. if (array && key.match(/^\d+$/)) {
  8422. return str;
  8423. }
  8424. name = JSON.stringify('' + key);
  8425. if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
  8426. name = name.substr(1, name.length - 2);
  8427. name = ctx.stylize(name, 'name');
  8428. } else {
  8429. name = name.replace(/'/g, "\\'")
  8430. .replace(/\\"/g, '"')
  8431. .replace(/(^"|"$)/g, "'");
  8432. name = ctx.stylize(name, 'string');
  8433. }
  8434. }
  8435. return name + ': ' + str;
  8436. }
  8437. function reduceToSingleString(output, base, braces) {
  8438. var numLinesEst = 0;
  8439. var length = output.reduce(function(prev, cur) {
  8440. numLinesEst++;
  8441. if (cur.indexOf('\n') >= 0) numLinesEst++;
  8442. return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
  8443. }, 0);
  8444. if (length > 60) {
  8445. return braces[0] +
  8446. (base === '' ? '' : base + '\n ') +
  8447. ' ' +
  8448. output.join(',\n ') +
  8449. ' ' +
  8450. braces[1];
  8451. }
  8452. return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
  8453. }
  8454. // NOTE: These type checking functions intentionally don't use `instanceof`
  8455. // because it is fragile and can be easily faked with `Object.create()`.
  8456. function isArray(ar) {
  8457. return Array.isArray(ar);
  8458. }
  8459. exports.isArray = isArray;
  8460. function isBoolean(arg) {
  8461. return typeof arg === 'boolean';
  8462. }
  8463. exports.isBoolean = isBoolean;
  8464. function isNull(arg) {
  8465. return arg === null;
  8466. }
  8467. exports.isNull = isNull;
  8468. function isNullOrUndefined(arg) {
  8469. return arg == null;
  8470. }
  8471. exports.isNullOrUndefined = isNullOrUndefined;
  8472. function isNumber(arg) {
  8473. return typeof arg === 'number';
  8474. }
  8475. exports.isNumber = isNumber;
  8476. function isString(arg) {
  8477. return typeof arg === 'string';
  8478. }
  8479. exports.isString = isString;
  8480. function isSymbol(arg) {
  8481. return typeof arg === 'symbol';
  8482. }
  8483. exports.isSymbol = isSymbol;
  8484. function isUndefined(arg) {
  8485. return arg === void 0;
  8486. }
  8487. exports.isUndefined = isUndefined;
  8488. function isRegExp(re) {
  8489. return isObject(re) && objectToString(re) === '[object RegExp]';
  8490. }
  8491. exports.isRegExp = isRegExp;
  8492. function isObject(arg) {
  8493. return typeof arg === 'object' && arg !== null;
  8494. }
  8495. exports.isObject = isObject;
  8496. function isDate(d) {
  8497. return isObject(d) && objectToString(d) === '[object Date]';
  8498. }
  8499. exports.isDate = isDate;
  8500. function isError(e) {
  8501. return isObject(e) &&
  8502. (objectToString(e) === '[object Error]' || e instanceof Error);
  8503. }
  8504. exports.isError = isError;
  8505. function isFunction(arg) {
  8506. return typeof arg === 'function';
  8507. }
  8508. exports.isFunction = isFunction;
  8509. function isPrimitive(arg) {
  8510. return arg === null ||
  8511. typeof arg === 'boolean' ||
  8512. typeof arg === 'number' ||
  8513. typeof arg === 'string' ||
  8514. typeof arg === 'symbol' || // ES6 symbol
  8515. typeof arg === 'undefined';
  8516. }
  8517. exports.isPrimitive = isPrimitive;
  8518. exports.isBuffer = __webpack_require__(51);
  8519. function objectToString(o) {
  8520. return Object.prototype.toString.call(o);
  8521. }
  8522. function pad(n) {
  8523. return n < 10 ? '0' + n.toString(10) : n.toString(10);
  8524. }
  8525. var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
  8526. 'Oct', 'Nov', 'Dec'];
  8527. // 26 Feb 16:19:34
  8528. function timestamp() {
  8529. var d = new Date();
  8530. var time = [pad(d.getHours()),
  8531. pad(d.getMinutes()),
  8532. pad(d.getSeconds())].join(':');
  8533. return [d.getDate(), months[d.getMonth()], time].join(' ');
  8534. }
  8535. // log is just a thin wrapper to console.log that prepends a timestamp
  8536. exports.log = function() {
  8537. console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
  8538. };
  8539. /**
  8540. * Inherit the prototype methods from one constructor into another.
  8541. *
  8542. * The Function.prototype.inherits from lang.js rewritten as a standalone
  8543. * function (not on Function.prototype). NOTE: If this file is to be loaded
  8544. * during bootstrapping this function needs to be rewritten using some native
  8545. * functions as prototype setup using normal JavaScript does not work as
  8546. * expected during bootstrapping (see mirror.js in r114903).
  8547. *
  8548. * @param {function} ctor Constructor function which needs to inherit the
  8549. * prototype.
  8550. * @param {function} superCtor Constructor function to inherit prototype from.
  8551. */
  8552. exports.inherits = __webpack_require__(52);
  8553. exports._extend = function(origin, add) {
  8554. // Don't do anything if add isn't an object
  8555. if (!add || !isObject(add)) return origin;
  8556. var keys = Object.keys(add);
  8557. var i = keys.length;
  8558. while (i--) {
  8559. origin[keys[i]] = add[keys[i]];
  8560. }
  8561. return origin;
  8562. };
  8563. function hasOwnProperty(obj, prop) {
  8564. return Object.prototype.hasOwnProperty.call(obj, prop);
  8565. }
  8566. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0), __webpack_require__(1)))
  8567. /***/ }),
  8568. /* 51 */
  8569. /***/ (function(module, exports) {
  8570. module.exports = function isBuffer(arg) {
  8571. return arg && typeof arg === 'object'
  8572. && typeof arg.copy === 'function'
  8573. && typeof arg.fill === 'function'
  8574. && typeof arg.readUInt8 === 'function';
  8575. }
  8576. /***/ }),
  8577. /* 52 */
  8578. /***/ (function(module, exports) {
  8579. if (typeof Object.create === 'function') {
  8580. // implementation from standard node.js 'util' module
  8581. module.exports = function inherits(ctor, superCtor) {
  8582. ctor.super_ = superCtor
  8583. ctor.prototype = Object.create(superCtor.prototype, {
  8584. constructor: {
  8585. value: ctor,
  8586. enumerable: false,
  8587. writable: true,
  8588. configurable: true
  8589. }
  8590. });
  8591. };
  8592. } else {
  8593. // old school shim for old browsers
  8594. module.exports = function inherits(ctor, superCtor) {
  8595. ctor.super_ = superCtor
  8596. var TempCtor = function () {}
  8597. TempCtor.prototype = superCtor.prototype
  8598. ctor.prototype = new TempCtor()
  8599. ctor.prototype.constructor = ctor
  8600. }
  8601. }
  8602. /***/ })
  8603. /******/ ]);