eventsource-polyfill.js 273 KB

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