xml-js.js 235 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310
  1. (function(e, a) { for(var i in a) e[i] = a[i]; }(window, /******/ (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, __webpack_require__) {
  69. "use strict";
  70. // Copyright Joyent, Inc. and other Node contributors.
  71. //
  72. // Permission is hereby granted, free of charge, to any person obtaining a
  73. // copy of this software and associated documentation files (the
  74. // "Software"), to deal in the Software without restriction, including
  75. // without limitation the rights to use, copy, modify, merge, publish,
  76. // distribute, sublicense, and/or sell copies of the Software, and to permit
  77. // persons to whom the Software is furnished to do so, subject to the
  78. // following conditions:
  79. //
  80. // The above copyright notice and this permission notice shall be included
  81. // in all copies or substantial portions of the Software.
  82. //
  83. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  84. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  85. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  86. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  87. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  88. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  89. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  90. // a duplex stream is just a stream that is both readable and writable.
  91. // Since JS doesn't have multiple prototypal inheritance, this class
  92. // prototypally inherits from Readable, and then parasitically from
  93. // Writable.
  94. /*<replacement>*/
  95. var processNextTick = __webpack_require__(6);
  96. /*</replacement>*/
  97. /*<replacement>*/
  98. var objectKeys = Object.keys || function (obj) {
  99. var keys = [];
  100. for (var key in obj) {
  101. keys.push(key);
  102. }return keys;
  103. };
  104. /*</replacement>*/
  105. module.exports = Duplex;
  106. /*<replacement>*/
  107. var util = __webpack_require__(3);
  108. util.inherits = __webpack_require__(1);
  109. /*</replacement>*/
  110. var Readable = __webpack_require__(16);
  111. var Writable = __webpack_require__(10);
  112. util.inherits(Duplex, Readable);
  113. var keys = objectKeys(Writable.prototype);
  114. for (var v = 0; v < keys.length; v++) {
  115. var method = keys[v];
  116. if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
  117. }
  118. function Duplex(options) {
  119. if (!(this instanceof Duplex)) return new Duplex(options);
  120. Readable.call(this, options);
  121. Writable.call(this, options);
  122. if (options && options.readable === false) this.readable = false;
  123. if (options && options.writable === false) this.writable = false;
  124. this.allowHalfOpen = true;
  125. if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
  126. this.once('end', onend);
  127. }
  128. // the no-half-open enforcer
  129. function onend() {
  130. // if we allow half-open state, or if the writable side ended,
  131. // then we're ok.
  132. if (this.allowHalfOpen || this._writableState.ended) return;
  133. // no more data can be written.
  134. // But allow more writes to happen in this tick.
  135. processNextTick(onEndNT, this);
  136. }
  137. function onEndNT(self) {
  138. self.end();
  139. }
  140. Object.defineProperty(Duplex.prototype, 'destroyed', {
  141. get: function () {
  142. if (this._readableState === undefined || this._writableState === undefined) {
  143. return false;
  144. }
  145. return this._readableState.destroyed && this._writableState.destroyed;
  146. },
  147. set: function (value) {
  148. // we ignore the value if the stream
  149. // has not been initialized yet
  150. if (this._readableState === undefined || this._writableState === undefined) {
  151. return;
  152. }
  153. // backward compatibility, the user is explicitly
  154. // managing destroyed
  155. this._readableState.destroyed = value;
  156. this._writableState.destroyed = value;
  157. }
  158. });
  159. Duplex.prototype._destroy = function (err, cb) {
  160. this.push(null);
  161. this.end();
  162. processNextTick(cb, err);
  163. };
  164. function forEach(xs, f) {
  165. for (var i = 0, l = xs.length; i < l; i++) {
  166. f(xs[i], i);
  167. }
  168. }
  169. /***/ }),
  170. /* 1 */
  171. /***/ (function(module, exports) {
  172. if (typeof Object.create === 'function') {
  173. // implementation from standard node.js 'util' module
  174. module.exports = function inherits(ctor, superCtor) {
  175. ctor.super_ = superCtor
  176. ctor.prototype = Object.create(superCtor.prototype, {
  177. constructor: {
  178. value: ctor,
  179. enumerable: false,
  180. writable: true,
  181. configurable: true
  182. }
  183. });
  184. };
  185. } else {
  186. // old school shim for old browsers
  187. module.exports = function inherits(ctor, superCtor) {
  188. ctor.super_ = superCtor
  189. var TempCtor = function () {}
  190. TempCtor.prototype = superCtor.prototype
  191. ctor.prototype = new TempCtor()
  192. ctor.prototype.constructor = ctor
  193. }
  194. }
  195. /***/ }),
  196. /* 2 */
  197. /***/ (function(module, exports) {
  198. var g;
  199. // This works in non-strict mode
  200. g = (function() {
  201. return this;
  202. })();
  203. try {
  204. // This works if eval is allowed (see CSP)
  205. g = g || Function("return this")() || (1,eval)("this");
  206. } catch(e) {
  207. // This works if the window reference is available
  208. if(typeof window === "object")
  209. g = window;
  210. }
  211. // g can still be undefined, but nothing to do about it...
  212. // We return undefined, instead of nothing here, so it's
  213. // easier to handle this case. if(!global) { ...}
  214. module.exports = g;
  215. /***/ }),
  216. /* 3 */
  217. /***/ (function(module, exports, __webpack_require__) {
  218. /* WEBPACK VAR INJECTION */(function(Buffer) {// Copyright Joyent, Inc. and other Node contributors.
  219. //
  220. // Permission is hereby granted, free of charge, to any person obtaining a
  221. // copy of this software and associated documentation files (the
  222. // "Software"), to deal in the Software without restriction, including
  223. // without limitation the rights to use, copy, modify, merge, publish,
  224. // distribute, sublicense, and/or sell copies of the Software, and to permit
  225. // persons to whom the Software is furnished to do so, subject to the
  226. // following conditions:
  227. //
  228. // The above copyright notice and this permission notice shall be included
  229. // in all copies or substantial portions of the Software.
  230. //
  231. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  232. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  233. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  234. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  235. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  236. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  237. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  238. // NOTE: These type checking functions intentionally don't use `instanceof`
  239. // because it is fragile and can be easily faked with `Object.create()`.
  240. function isArray(arg) {
  241. if (Array.isArray) {
  242. return Array.isArray(arg);
  243. }
  244. return objectToString(arg) === '[object Array]';
  245. }
  246. exports.isArray = isArray;
  247. function isBoolean(arg) {
  248. return typeof arg === 'boolean';
  249. }
  250. exports.isBoolean = isBoolean;
  251. function isNull(arg) {
  252. return arg === null;
  253. }
  254. exports.isNull = isNull;
  255. function isNullOrUndefined(arg) {
  256. return arg == null;
  257. }
  258. exports.isNullOrUndefined = isNullOrUndefined;
  259. function isNumber(arg) {
  260. return typeof arg === 'number';
  261. }
  262. exports.isNumber = isNumber;
  263. function isString(arg) {
  264. return typeof arg === 'string';
  265. }
  266. exports.isString = isString;
  267. function isSymbol(arg) {
  268. return typeof arg === 'symbol';
  269. }
  270. exports.isSymbol = isSymbol;
  271. function isUndefined(arg) {
  272. return arg === void 0;
  273. }
  274. exports.isUndefined = isUndefined;
  275. function isRegExp(re) {
  276. return objectToString(re) === '[object RegExp]';
  277. }
  278. exports.isRegExp = isRegExp;
  279. function isObject(arg) {
  280. return typeof arg === 'object' && arg !== null;
  281. }
  282. exports.isObject = isObject;
  283. function isDate(d) {
  284. return objectToString(d) === '[object Date]';
  285. }
  286. exports.isDate = isDate;
  287. function isError(e) {
  288. return (objectToString(e) === '[object Error]' || e instanceof Error);
  289. }
  290. exports.isError = isError;
  291. function isFunction(arg) {
  292. return typeof arg === 'function';
  293. }
  294. exports.isFunction = isFunction;
  295. function isPrimitive(arg) {
  296. return arg === null ||
  297. typeof arg === 'boolean' ||
  298. typeof arg === 'number' ||
  299. typeof arg === 'string' ||
  300. typeof arg === 'symbol' || // ES6 symbol
  301. typeof arg === 'undefined';
  302. }
  303. exports.isPrimitive = isPrimitive;
  304. exports.isBuffer = Buffer.isBuffer;
  305. function objectToString(o) {
  306. return Object.prototype.toString.call(o);
  307. }
  308. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4).Buffer))
  309. /***/ }),
  310. /* 4 */
  311. /***/ (function(module, exports, __webpack_require__) {
  312. "use strict";
  313. /* WEBPACK VAR INJECTION */(function(global) {/*!
  314. * The buffer module from node.js, for the browser.
  315. *
  316. * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
  317. * @license MIT
  318. */
  319. /* eslint-disable no-proto */
  320. var base64 = __webpack_require__(23)
  321. var ieee754 = __webpack_require__(24)
  322. var isArray = __webpack_require__(15)
  323. exports.Buffer = Buffer
  324. exports.SlowBuffer = SlowBuffer
  325. exports.INSPECT_MAX_BYTES = 50
  326. /**
  327. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  328. * === true Use Uint8Array implementation (fastest)
  329. * === false Use Object implementation (most compatible, even IE6)
  330. *
  331. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  332. * Opera 11.6+, iOS 4.2+.
  333. *
  334. * Due to various browser bugs, sometimes the Object implementation will be used even
  335. * when the browser supports typed arrays.
  336. *
  337. * Note:
  338. *
  339. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  340. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  341. *
  342. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  343. *
  344. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  345. * incorrect length in some situations.
  346. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  347. * get the Object implementation, which is slower but behaves correctly.
  348. */
  349. Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
  350. ? global.TYPED_ARRAY_SUPPORT
  351. : typedArraySupport()
  352. /*
  353. * Export kMaxLength after typed array support is determined.
  354. */
  355. exports.kMaxLength = kMaxLength()
  356. function typedArraySupport () {
  357. try {
  358. var arr = new Uint8Array(1)
  359. arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
  360. return arr.foo() === 42 && // typed array instances can be augmented
  361. typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
  362. arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
  363. } catch (e) {
  364. return false
  365. }
  366. }
  367. function kMaxLength () {
  368. return Buffer.TYPED_ARRAY_SUPPORT
  369. ? 0x7fffffff
  370. : 0x3fffffff
  371. }
  372. function createBuffer (that, length) {
  373. if (kMaxLength() < length) {
  374. throw new RangeError('Invalid typed array length')
  375. }
  376. if (Buffer.TYPED_ARRAY_SUPPORT) {
  377. // Return an augmented `Uint8Array` instance, for best performance
  378. that = new Uint8Array(length)
  379. that.__proto__ = Buffer.prototype
  380. } else {
  381. // Fallback: Return an object instance of the Buffer class
  382. if (that === null) {
  383. that = new Buffer(length)
  384. }
  385. that.length = length
  386. }
  387. return that
  388. }
  389. /**
  390. * The Buffer constructor returns instances of `Uint8Array` that have their
  391. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  392. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  393. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  394. * returns a single octet.
  395. *
  396. * The `Uint8Array` prototype remains unmodified.
  397. */
  398. function Buffer (arg, encodingOrOffset, length) {
  399. if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
  400. return new Buffer(arg, encodingOrOffset, length)
  401. }
  402. // Common case.
  403. if (typeof arg === 'number') {
  404. if (typeof encodingOrOffset === 'string') {
  405. throw new Error(
  406. 'If encoding is specified then the first argument must be a string'
  407. )
  408. }
  409. return allocUnsafe(this, arg)
  410. }
  411. return from(this, arg, encodingOrOffset, length)
  412. }
  413. Buffer.poolSize = 8192 // not used by this implementation
  414. // TODO: Legacy, not needed anymore. Remove in next major version.
  415. Buffer._augment = function (arr) {
  416. arr.__proto__ = Buffer.prototype
  417. return arr
  418. }
  419. function from (that, value, encodingOrOffset, length) {
  420. if (typeof value === 'number') {
  421. throw new TypeError('"value" argument must not be a number')
  422. }
  423. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  424. return fromArrayBuffer(that, value, encodingOrOffset, length)
  425. }
  426. if (typeof value === 'string') {
  427. return fromString(that, value, encodingOrOffset)
  428. }
  429. return fromObject(that, value)
  430. }
  431. /**
  432. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  433. * if value is a number.
  434. * Buffer.from(str[, encoding])
  435. * Buffer.from(array)
  436. * Buffer.from(buffer)
  437. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  438. **/
  439. Buffer.from = function (value, encodingOrOffset, length) {
  440. return from(null, value, encodingOrOffset, length)
  441. }
  442. if (Buffer.TYPED_ARRAY_SUPPORT) {
  443. Buffer.prototype.__proto__ = Uint8Array.prototype
  444. Buffer.__proto__ = Uint8Array
  445. if (typeof Symbol !== 'undefined' && Symbol.species &&
  446. Buffer[Symbol.species] === Buffer) {
  447. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  448. Object.defineProperty(Buffer, Symbol.species, {
  449. value: null,
  450. configurable: true
  451. })
  452. }
  453. }
  454. function assertSize (size) {
  455. if (typeof size !== 'number') {
  456. throw new TypeError('"size" argument must be a number')
  457. } else if (size < 0) {
  458. throw new RangeError('"size" argument must not be negative')
  459. }
  460. }
  461. function alloc (that, size, fill, encoding) {
  462. assertSize(size)
  463. if (size <= 0) {
  464. return createBuffer(that, size)
  465. }
  466. if (fill !== undefined) {
  467. // Only pay attention to encoding if it's a string. This
  468. // prevents accidentally sending in a number that would
  469. // be interpretted as a start offset.
  470. return typeof encoding === 'string'
  471. ? createBuffer(that, size).fill(fill, encoding)
  472. : createBuffer(that, size).fill(fill)
  473. }
  474. return createBuffer(that, size)
  475. }
  476. /**
  477. * Creates a new filled Buffer instance.
  478. * alloc(size[, fill[, encoding]])
  479. **/
  480. Buffer.alloc = function (size, fill, encoding) {
  481. return alloc(null, size, fill, encoding)
  482. }
  483. function allocUnsafe (that, size) {
  484. assertSize(size)
  485. that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
  486. if (!Buffer.TYPED_ARRAY_SUPPORT) {
  487. for (var i = 0; i < size; ++i) {
  488. that[i] = 0
  489. }
  490. }
  491. return that
  492. }
  493. /**
  494. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  495. * */
  496. Buffer.allocUnsafe = function (size) {
  497. return allocUnsafe(null, size)
  498. }
  499. /**
  500. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  501. */
  502. Buffer.allocUnsafeSlow = function (size) {
  503. return allocUnsafe(null, size)
  504. }
  505. function fromString (that, string, encoding) {
  506. if (typeof encoding !== 'string' || encoding === '') {
  507. encoding = 'utf8'
  508. }
  509. if (!Buffer.isEncoding(encoding)) {
  510. throw new TypeError('"encoding" must be a valid string encoding')
  511. }
  512. var length = byteLength(string, encoding) | 0
  513. that = createBuffer(that, length)
  514. var actual = that.write(string, encoding)
  515. if (actual !== length) {
  516. // Writing a hex string, for example, that contains invalid characters will
  517. // cause everything after the first invalid character to be ignored. (e.g.
  518. // 'abxxcd' will be treated as 'ab')
  519. that = that.slice(0, actual)
  520. }
  521. return that
  522. }
  523. function fromArrayLike (that, array) {
  524. var length = array.length < 0 ? 0 : checked(array.length) | 0
  525. that = createBuffer(that, length)
  526. for (var i = 0; i < length; i += 1) {
  527. that[i] = array[i] & 255
  528. }
  529. return that
  530. }
  531. function fromArrayBuffer (that, array, byteOffset, length) {
  532. array.byteLength // this throws if `array` is not a valid ArrayBuffer
  533. if (byteOffset < 0 || array.byteLength < byteOffset) {
  534. throw new RangeError('\'offset\' is out of bounds')
  535. }
  536. if (array.byteLength < byteOffset + (length || 0)) {
  537. throw new RangeError('\'length\' is out of bounds')
  538. }
  539. if (byteOffset === undefined && length === undefined) {
  540. array = new Uint8Array(array)
  541. } else if (length === undefined) {
  542. array = new Uint8Array(array, byteOffset)
  543. } else {
  544. array = new Uint8Array(array, byteOffset, length)
  545. }
  546. if (Buffer.TYPED_ARRAY_SUPPORT) {
  547. // Return an augmented `Uint8Array` instance, for best performance
  548. that = array
  549. that.__proto__ = Buffer.prototype
  550. } else {
  551. // Fallback: Return an object instance of the Buffer class
  552. that = fromArrayLike(that, array)
  553. }
  554. return that
  555. }
  556. function fromObject (that, obj) {
  557. if (Buffer.isBuffer(obj)) {
  558. var len = checked(obj.length) | 0
  559. that = createBuffer(that, len)
  560. if (that.length === 0) {
  561. return that
  562. }
  563. obj.copy(that, 0, 0, len)
  564. return that
  565. }
  566. if (obj) {
  567. if ((typeof ArrayBuffer !== 'undefined' &&
  568. obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
  569. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  570. return createBuffer(that, 0)
  571. }
  572. return fromArrayLike(that, obj)
  573. }
  574. if (obj.type === 'Buffer' && isArray(obj.data)) {
  575. return fromArrayLike(that, obj.data)
  576. }
  577. }
  578. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
  579. }
  580. function checked (length) {
  581. // Note: cannot use `length < kMaxLength()` here because that fails when
  582. // length is NaN (which is otherwise coerced to zero.)
  583. if (length >= kMaxLength()) {
  584. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  585. 'size: 0x' + kMaxLength().toString(16) + ' bytes')
  586. }
  587. return length | 0
  588. }
  589. function SlowBuffer (length) {
  590. if (+length != length) { // eslint-disable-line eqeqeq
  591. length = 0
  592. }
  593. return Buffer.alloc(+length)
  594. }
  595. Buffer.isBuffer = function isBuffer (b) {
  596. return !!(b != null && b._isBuffer)
  597. }
  598. Buffer.compare = function compare (a, b) {
  599. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  600. throw new TypeError('Arguments must be Buffers')
  601. }
  602. if (a === b) return 0
  603. var x = a.length
  604. var y = b.length
  605. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  606. if (a[i] !== b[i]) {
  607. x = a[i]
  608. y = b[i]
  609. break
  610. }
  611. }
  612. if (x < y) return -1
  613. if (y < x) return 1
  614. return 0
  615. }
  616. Buffer.isEncoding = function isEncoding (encoding) {
  617. switch (String(encoding).toLowerCase()) {
  618. case 'hex':
  619. case 'utf8':
  620. case 'utf-8':
  621. case 'ascii':
  622. case 'latin1':
  623. case 'binary':
  624. case 'base64':
  625. case 'ucs2':
  626. case 'ucs-2':
  627. case 'utf16le':
  628. case 'utf-16le':
  629. return true
  630. default:
  631. return false
  632. }
  633. }
  634. Buffer.concat = function concat (list, length) {
  635. if (!isArray(list)) {
  636. throw new TypeError('"list" argument must be an Array of Buffers')
  637. }
  638. if (list.length === 0) {
  639. return Buffer.alloc(0)
  640. }
  641. var i
  642. if (length === undefined) {
  643. length = 0
  644. for (i = 0; i < list.length; ++i) {
  645. length += list[i].length
  646. }
  647. }
  648. var buffer = Buffer.allocUnsafe(length)
  649. var pos = 0
  650. for (i = 0; i < list.length; ++i) {
  651. var buf = list[i]
  652. if (!Buffer.isBuffer(buf)) {
  653. throw new TypeError('"list" argument must be an Array of Buffers')
  654. }
  655. buf.copy(buffer, pos)
  656. pos += buf.length
  657. }
  658. return buffer
  659. }
  660. function byteLength (string, encoding) {
  661. if (Buffer.isBuffer(string)) {
  662. return string.length
  663. }
  664. if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
  665. (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
  666. return string.byteLength
  667. }
  668. if (typeof string !== 'string') {
  669. string = '' + string
  670. }
  671. var len = string.length
  672. if (len === 0) return 0
  673. // Use a for loop to avoid recursion
  674. var loweredCase = false
  675. for (;;) {
  676. switch (encoding) {
  677. case 'ascii':
  678. case 'latin1':
  679. case 'binary':
  680. return len
  681. case 'utf8':
  682. case 'utf-8':
  683. case undefined:
  684. return utf8ToBytes(string).length
  685. case 'ucs2':
  686. case 'ucs-2':
  687. case 'utf16le':
  688. case 'utf-16le':
  689. return len * 2
  690. case 'hex':
  691. return len >>> 1
  692. case 'base64':
  693. return base64ToBytes(string).length
  694. default:
  695. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  696. encoding = ('' + encoding).toLowerCase()
  697. loweredCase = true
  698. }
  699. }
  700. }
  701. Buffer.byteLength = byteLength
  702. function slowToString (encoding, start, end) {
  703. var loweredCase = false
  704. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  705. // property of a typed array.
  706. // This behaves neither like String nor Uint8Array in that we set start/end
  707. // to their upper/lower bounds if the value passed is out of range.
  708. // undefined is handled specially as per ECMA-262 6th Edition,
  709. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  710. if (start === undefined || start < 0) {
  711. start = 0
  712. }
  713. // Return early if start > this.length. Done here to prevent potential uint32
  714. // coercion fail below.
  715. if (start > this.length) {
  716. return ''
  717. }
  718. if (end === undefined || end > this.length) {
  719. end = this.length
  720. }
  721. if (end <= 0) {
  722. return ''
  723. }
  724. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  725. end >>>= 0
  726. start >>>= 0
  727. if (end <= start) {
  728. return ''
  729. }
  730. if (!encoding) encoding = 'utf8'
  731. while (true) {
  732. switch (encoding) {
  733. case 'hex':
  734. return hexSlice(this, start, end)
  735. case 'utf8':
  736. case 'utf-8':
  737. return utf8Slice(this, start, end)
  738. case 'ascii':
  739. return asciiSlice(this, start, end)
  740. case 'latin1':
  741. case 'binary':
  742. return latin1Slice(this, start, end)
  743. case 'base64':
  744. return base64Slice(this, start, end)
  745. case 'ucs2':
  746. case 'ucs-2':
  747. case 'utf16le':
  748. case 'utf-16le':
  749. return utf16leSlice(this, start, end)
  750. default:
  751. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  752. encoding = (encoding + '').toLowerCase()
  753. loweredCase = true
  754. }
  755. }
  756. }
  757. // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
  758. // Buffer instances.
  759. Buffer.prototype._isBuffer = true
  760. function swap (b, n, m) {
  761. var i = b[n]
  762. b[n] = b[m]
  763. b[m] = i
  764. }
  765. Buffer.prototype.swap16 = function swap16 () {
  766. var len = this.length
  767. if (len % 2 !== 0) {
  768. throw new RangeError('Buffer size must be a multiple of 16-bits')
  769. }
  770. for (var i = 0; i < len; i += 2) {
  771. swap(this, i, i + 1)
  772. }
  773. return this
  774. }
  775. Buffer.prototype.swap32 = function swap32 () {
  776. var len = this.length
  777. if (len % 4 !== 0) {
  778. throw new RangeError('Buffer size must be a multiple of 32-bits')
  779. }
  780. for (var i = 0; i < len; i += 4) {
  781. swap(this, i, i + 3)
  782. swap(this, i + 1, i + 2)
  783. }
  784. return this
  785. }
  786. Buffer.prototype.swap64 = function swap64 () {
  787. var len = this.length
  788. if (len % 8 !== 0) {
  789. throw new RangeError('Buffer size must be a multiple of 64-bits')
  790. }
  791. for (var i = 0; i < len; i += 8) {
  792. swap(this, i, i + 7)
  793. swap(this, i + 1, i + 6)
  794. swap(this, i + 2, i + 5)
  795. swap(this, i + 3, i + 4)
  796. }
  797. return this
  798. }
  799. Buffer.prototype.toString = function toString () {
  800. var length = this.length | 0
  801. if (length === 0) return ''
  802. if (arguments.length === 0) return utf8Slice(this, 0, length)
  803. return slowToString.apply(this, arguments)
  804. }
  805. Buffer.prototype.equals = function equals (b) {
  806. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  807. if (this === b) return true
  808. return Buffer.compare(this, b) === 0
  809. }
  810. Buffer.prototype.inspect = function inspect () {
  811. var str = ''
  812. var max = exports.INSPECT_MAX_BYTES
  813. if (this.length > 0) {
  814. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
  815. if (this.length > max) str += ' ... '
  816. }
  817. return '<Buffer ' + str + '>'
  818. }
  819. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  820. if (!Buffer.isBuffer(target)) {
  821. throw new TypeError('Argument must be a Buffer')
  822. }
  823. if (start === undefined) {
  824. start = 0
  825. }
  826. if (end === undefined) {
  827. end = target ? target.length : 0
  828. }
  829. if (thisStart === undefined) {
  830. thisStart = 0
  831. }
  832. if (thisEnd === undefined) {
  833. thisEnd = this.length
  834. }
  835. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  836. throw new RangeError('out of range index')
  837. }
  838. if (thisStart >= thisEnd && start >= end) {
  839. return 0
  840. }
  841. if (thisStart >= thisEnd) {
  842. return -1
  843. }
  844. if (start >= end) {
  845. return 1
  846. }
  847. start >>>= 0
  848. end >>>= 0
  849. thisStart >>>= 0
  850. thisEnd >>>= 0
  851. if (this === target) return 0
  852. var x = thisEnd - thisStart
  853. var y = end - start
  854. var len = Math.min(x, y)
  855. var thisCopy = this.slice(thisStart, thisEnd)
  856. var targetCopy = target.slice(start, end)
  857. for (var i = 0; i < len; ++i) {
  858. if (thisCopy[i] !== targetCopy[i]) {
  859. x = thisCopy[i]
  860. y = targetCopy[i]
  861. break
  862. }
  863. }
  864. if (x < y) return -1
  865. if (y < x) return 1
  866. return 0
  867. }
  868. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  869. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  870. //
  871. // Arguments:
  872. // - buffer - a Buffer to search
  873. // - val - a string, Buffer, or number
  874. // - byteOffset - an index into `buffer`; will be clamped to an int32
  875. // - encoding - an optional encoding, relevant is val is a string
  876. // - dir - true for indexOf, false for lastIndexOf
  877. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  878. // Empty buffer means no match
  879. if (buffer.length === 0) return -1
  880. // Normalize byteOffset
  881. if (typeof byteOffset === 'string') {
  882. encoding = byteOffset
  883. byteOffset = 0
  884. } else if (byteOffset > 0x7fffffff) {
  885. byteOffset = 0x7fffffff
  886. } else if (byteOffset < -0x80000000) {
  887. byteOffset = -0x80000000
  888. }
  889. byteOffset = +byteOffset // Coerce to Number.
  890. if (isNaN(byteOffset)) {
  891. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  892. byteOffset = dir ? 0 : (buffer.length - 1)
  893. }
  894. // Normalize byteOffset: negative offsets start from the end of the buffer
  895. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  896. if (byteOffset >= buffer.length) {
  897. if (dir) return -1
  898. else byteOffset = buffer.length - 1
  899. } else if (byteOffset < 0) {
  900. if (dir) byteOffset = 0
  901. else return -1
  902. }
  903. // Normalize val
  904. if (typeof val === 'string') {
  905. val = Buffer.from(val, encoding)
  906. }
  907. // Finally, search either indexOf (if dir is true) or lastIndexOf
  908. if (Buffer.isBuffer(val)) {
  909. // Special case: looking for empty string/buffer always fails
  910. if (val.length === 0) {
  911. return -1
  912. }
  913. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  914. } else if (typeof val === 'number') {
  915. val = val & 0xFF // Search for a byte value [0-255]
  916. if (Buffer.TYPED_ARRAY_SUPPORT &&
  917. typeof Uint8Array.prototype.indexOf === 'function') {
  918. if (dir) {
  919. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  920. } else {
  921. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  922. }
  923. }
  924. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  925. }
  926. throw new TypeError('val must be string, number or Buffer')
  927. }
  928. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  929. var indexSize = 1
  930. var arrLength = arr.length
  931. var valLength = val.length
  932. if (encoding !== undefined) {
  933. encoding = String(encoding).toLowerCase()
  934. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  935. encoding === 'utf16le' || encoding === 'utf-16le') {
  936. if (arr.length < 2 || val.length < 2) {
  937. return -1
  938. }
  939. indexSize = 2
  940. arrLength /= 2
  941. valLength /= 2
  942. byteOffset /= 2
  943. }
  944. }
  945. function read (buf, i) {
  946. if (indexSize === 1) {
  947. return buf[i]
  948. } else {
  949. return buf.readUInt16BE(i * indexSize)
  950. }
  951. }
  952. var i
  953. if (dir) {
  954. var foundIndex = -1
  955. for (i = byteOffset; i < arrLength; i++) {
  956. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  957. if (foundIndex === -1) foundIndex = i
  958. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  959. } else {
  960. if (foundIndex !== -1) i -= i - foundIndex
  961. foundIndex = -1
  962. }
  963. }
  964. } else {
  965. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  966. for (i = byteOffset; i >= 0; i--) {
  967. var found = true
  968. for (var j = 0; j < valLength; j++) {
  969. if (read(arr, i + j) !== read(val, j)) {
  970. found = false
  971. break
  972. }
  973. }
  974. if (found) return i
  975. }
  976. }
  977. return -1
  978. }
  979. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  980. return this.indexOf(val, byteOffset, encoding) !== -1
  981. }
  982. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  983. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  984. }
  985. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  986. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  987. }
  988. function hexWrite (buf, string, offset, length) {
  989. offset = Number(offset) || 0
  990. var remaining = buf.length - offset
  991. if (!length) {
  992. length = remaining
  993. } else {
  994. length = Number(length)
  995. if (length > remaining) {
  996. length = remaining
  997. }
  998. }
  999. // must be an even number of digits
  1000. var strLen = string.length
  1001. if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
  1002. if (length > strLen / 2) {
  1003. length = strLen / 2
  1004. }
  1005. for (var i = 0; i < length; ++i) {
  1006. var parsed = parseInt(string.substr(i * 2, 2), 16)
  1007. if (isNaN(parsed)) return i
  1008. buf[offset + i] = parsed
  1009. }
  1010. return i
  1011. }
  1012. function utf8Write (buf, string, offset, length) {
  1013. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  1014. }
  1015. function asciiWrite (buf, string, offset, length) {
  1016. return blitBuffer(asciiToBytes(string), buf, offset, length)
  1017. }
  1018. function latin1Write (buf, string, offset, length) {
  1019. return asciiWrite(buf, string, offset, length)
  1020. }
  1021. function base64Write (buf, string, offset, length) {
  1022. return blitBuffer(base64ToBytes(string), buf, offset, length)
  1023. }
  1024. function ucs2Write (buf, string, offset, length) {
  1025. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  1026. }
  1027. Buffer.prototype.write = function write (string, offset, length, encoding) {
  1028. // Buffer#write(string)
  1029. if (offset === undefined) {
  1030. encoding = 'utf8'
  1031. length = this.length
  1032. offset = 0
  1033. // Buffer#write(string, encoding)
  1034. } else if (length === undefined && typeof offset === 'string') {
  1035. encoding = offset
  1036. length = this.length
  1037. offset = 0
  1038. // Buffer#write(string, offset[, length][, encoding])
  1039. } else if (isFinite(offset)) {
  1040. offset = offset | 0
  1041. if (isFinite(length)) {
  1042. length = length | 0
  1043. if (encoding === undefined) encoding = 'utf8'
  1044. } else {
  1045. encoding = length
  1046. length = undefined
  1047. }
  1048. // legacy write(string, encoding, offset, length) - remove in v0.13
  1049. } else {
  1050. throw new Error(
  1051. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  1052. )
  1053. }
  1054. var remaining = this.length - offset
  1055. if (length === undefined || length > remaining) length = remaining
  1056. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  1057. throw new RangeError('Attempt to write outside buffer bounds')
  1058. }
  1059. if (!encoding) encoding = 'utf8'
  1060. var loweredCase = false
  1061. for (;;) {
  1062. switch (encoding) {
  1063. case 'hex':
  1064. return hexWrite(this, string, offset, length)
  1065. case 'utf8':
  1066. case 'utf-8':
  1067. return utf8Write(this, string, offset, length)
  1068. case 'ascii':
  1069. return asciiWrite(this, string, offset, length)
  1070. case 'latin1':
  1071. case 'binary':
  1072. return latin1Write(this, string, offset, length)
  1073. case 'base64':
  1074. // Warning: maxLength not taken into account in base64Write
  1075. return base64Write(this, string, offset, length)
  1076. case 'ucs2':
  1077. case 'ucs-2':
  1078. case 'utf16le':
  1079. case 'utf-16le':
  1080. return ucs2Write(this, string, offset, length)
  1081. default:
  1082. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  1083. encoding = ('' + encoding).toLowerCase()
  1084. loweredCase = true
  1085. }
  1086. }
  1087. }
  1088. Buffer.prototype.toJSON = function toJSON () {
  1089. return {
  1090. type: 'Buffer',
  1091. data: Array.prototype.slice.call(this._arr || this, 0)
  1092. }
  1093. }
  1094. function base64Slice (buf, start, end) {
  1095. if (start === 0 && end === buf.length) {
  1096. return base64.fromByteArray(buf)
  1097. } else {
  1098. return base64.fromByteArray(buf.slice(start, end))
  1099. }
  1100. }
  1101. function utf8Slice (buf, start, end) {
  1102. end = Math.min(buf.length, end)
  1103. var res = []
  1104. var i = start
  1105. while (i < end) {
  1106. var firstByte = buf[i]
  1107. var codePoint = null
  1108. var bytesPerSequence = (firstByte > 0xEF) ? 4
  1109. : (firstByte > 0xDF) ? 3
  1110. : (firstByte > 0xBF) ? 2
  1111. : 1
  1112. if (i + bytesPerSequence <= end) {
  1113. var secondByte, thirdByte, fourthByte, tempCodePoint
  1114. switch (bytesPerSequence) {
  1115. case 1:
  1116. if (firstByte < 0x80) {
  1117. codePoint = firstByte
  1118. }
  1119. break
  1120. case 2:
  1121. secondByte = buf[i + 1]
  1122. if ((secondByte & 0xC0) === 0x80) {
  1123. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  1124. if (tempCodePoint > 0x7F) {
  1125. codePoint = tempCodePoint
  1126. }
  1127. }
  1128. break
  1129. case 3:
  1130. secondByte = buf[i + 1]
  1131. thirdByte = buf[i + 2]
  1132. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  1133. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  1134. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  1135. codePoint = tempCodePoint
  1136. }
  1137. }
  1138. break
  1139. case 4:
  1140. secondByte = buf[i + 1]
  1141. thirdByte = buf[i + 2]
  1142. fourthByte = buf[i + 3]
  1143. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  1144. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  1145. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  1146. codePoint = tempCodePoint
  1147. }
  1148. }
  1149. }
  1150. }
  1151. if (codePoint === null) {
  1152. // we did not generate a valid codePoint so insert a
  1153. // replacement char (U+FFFD) and advance only 1 byte
  1154. codePoint = 0xFFFD
  1155. bytesPerSequence = 1
  1156. } else if (codePoint > 0xFFFF) {
  1157. // encode to utf16 (surrogate pair dance)
  1158. codePoint -= 0x10000
  1159. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  1160. codePoint = 0xDC00 | codePoint & 0x3FF
  1161. }
  1162. res.push(codePoint)
  1163. i += bytesPerSequence
  1164. }
  1165. return decodeCodePointsArray(res)
  1166. }
  1167. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  1168. // the lowest limit is Chrome, with 0x10000 args.
  1169. // We go 1 magnitude less, for safety
  1170. var MAX_ARGUMENTS_LENGTH = 0x1000
  1171. function decodeCodePointsArray (codePoints) {
  1172. var len = codePoints.length
  1173. if (len <= MAX_ARGUMENTS_LENGTH) {
  1174. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  1175. }
  1176. // Decode in chunks to avoid "call stack size exceeded".
  1177. var res = ''
  1178. var i = 0
  1179. while (i < len) {
  1180. res += String.fromCharCode.apply(
  1181. String,
  1182. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  1183. )
  1184. }
  1185. return res
  1186. }
  1187. function asciiSlice (buf, start, end) {
  1188. var ret = ''
  1189. end = Math.min(buf.length, end)
  1190. for (var i = start; i < end; ++i) {
  1191. ret += String.fromCharCode(buf[i] & 0x7F)
  1192. }
  1193. return ret
  1194. }
  1195. function latin1Slice (buf, start, end) {
  1196. var ret = ''
  1197. end = Math.min(buf.length, end)
  1198. for (var i = start; i < end; ++i) {
  1199. ret += String.fromCharCode(buf[i])
  1200. }
  1201. return ret
  1202. }
  1203. function hexSlice (buf, start, end) {
  1204. var len = buf.length
  1205. if (!start || start < 0) start = 0
  1206. if (!end || end < 0 || end > len) end = len
  1207. var out = ''
  1208. for (var i = start; i < end; ++i) {
  1209. out += toHex(buf[i])
  1210. }
  1211. return out
  1212. }
  1213. function utf16leSlice (buf, start, end) {
  1214. var bytes = buf.slice(start, end)
  1215. var res = ''
  1216. for (var i = 0; i < bytes.length; i += 2) {
  1217. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
  1218. }
  1219. return res
  1220. }
  1221. Buffer.prototype.slice = function slice (start, end) {
  1222. var len = this.length
  1223. start = ~~start
  1224. end = end === undefined ? len : ~~end
  1225. if (start < 0) {
  1226. start += len
  1227. if (start < 0) start = 0
  1228. } else if (start > len) {
  1229. start = len
  1230. }
  1231. if (end < 0) {
  1232. end += len
  1233. if (end < 0) end = 0
  1234. } else if (end > len) {
  1235. end = len
  1236. }
  1237. if (end < start) end = start
  1238. var newBuf
  1239. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1240. newBuf = this.subarray(start, end)
  1241. newBuf.__proto__ = Buffer.prototype
  1242. } else {
  1243. var sliceLen = end - start
  1244. newBuf = new Buffer(sliceLen, undefined)
  1245. for (var i = 0; i < sliceLen; ++i) {
  1246. newBuf[i] = this[i + start]
  1247. }
  1248. }
  1249. return newBuf
  1250. }
  1251. /*
  1252. * Need to make sure that buffer isn't trying to write out of bounds.
  1253. */
  1254. function checkOffset (offset, ext, length) {
  1255. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  1256. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  1257. }
  1258. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  1259. offset = offset | 0
  1260. byteLength = byteLength | 0
  1261. if (!noAssert) checkOffset(offset, byteLength, this.length)
  1262. var val = this[offset]
  1263. var mul = 1
  1264. var i = 0
  1265. while (++i < byteLength && (mul *= 0x100)) {
  1266. val += this[offset + i] * mul
  1267. }
  1268. return val
  1269. }
  1270. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  1271. offset = offset | 0
  1272. byteLength = byteLength | 0
  1273. if (!noAssert) {
  1274. checkOffset(offset, byteLength, this.length)
  1275. }
  1276. var val = this[offset + --byteLength]
  1277. var mul = 1
  1278. while (byteLength > 0 && (mul *= 0x100)) {
  1279. val += this[offset + --byteLength] * mul
  1280. }
  1281. return val
  1282. }
  1283. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  1284. if (!noAssert) checkOffset(offset, 1, this.length)
  1285. return this[offset]
  1286. }
  1287. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  1288. if (!noAssert) checkOffset(offset, 2, this.length)
  1289. return this[offset] | (this[offset + 1] << 8)
  1290. }
  1291. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  1292. if (!noAssert) checkOffset(offset, 2, this.length)
  1293. return (this[offset] << 8) | this[offset + 1]
  1294. }
  1295. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  1296. if (!noAssert) checkOffset(offset, 4, this.length)
  1297. return ((this[offset]) |
  1298. (this[offset + 1] << 8) |
  1299. (this[offset + 2] << 16)) +
  1300. (this[offset + 3] * 0x1000000)
  1301. }
  1302. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  1303. if (!noAssert) checkOffset(offset, 4, this.length)
  1304. return (this[offset] * 0x1000000) +
  1305. ((this[offset + 1] << 16) |
  1306. (this[offset + 2] << 8) |
  1307. this[offset + 3])
  1308. }
  1309. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  1310. offset = offset | 0
  1311. byteLength = byteLength | 0
  1312. if (!noAssert) checkOffset(offset, byteLength, this.length)
  1313. var val = this[offset]
  1314. var mul = 1
  1315. var i = 0
  1316. while (++i < byteLength && (mul *= 0x100)) {
  1317. val += this[offset + i] * mul
  1318. }
  1319. mul *= 0x80
  1320. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  1321. return val
  1322. }
  1323. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  1324. offset = offset | 0
  1325. byteLength = byteLength | 0
  1326. if (!noAssert) checkOffset(offset, byteLength, this.length)
  1327. var i = byteLength
  1328. var mul = 1
  1329. var val = this[offset + --i]
  1330. while (i > 0 && (mul *= 0x100)) {
  1331. val += this[offset + --i] * mul
  1332. }
  1333. mul *= 0x80
  1334. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  1335. return val
  1336. }
  1337. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  1338. if (!noAssert) checkOffset(offset, 1, this.length)
  1339. if (!(this[offset] & 0x80)) return (this[offset])
  1340. return ((0xff - this[offset] + 1) * -1)
  1341. }
  1342. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  1343. if (!noAssert) checkOffset(offset, 2, this.length)
  1344. var val = this[offset] | (this[offset + 1] << 8)
  1345. return (val & 0x8000) ? val | 0xFFFF0000 : val
  1346. }
  1347. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  1348. if (!noAssert) checkOffset(offset, 2, this.length)
  1349. var val = this[offset + 1] | (this[offset] << 8)
  1350. return (val & 0x8000) ? val | 0xFFFF0000 : val
  1351. }
  1352. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  1353. if (!noAssert) checkOffset(offset, 4, this.length)
  1354. return (this[offset]) |
  1355. (this[offset + 1] << 8) |
  1356. (this[offset + 2] << 16) |
  1357. (this[offset + 3] << 24)
  1358. }
  1359. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  1360. if (!noAssert) checkOffset(offset, 4, this.length)
  1361. return (this[offset] << 24) |
  1362. (this[offset + 1] << 16) |
  1363. (this[offset + 2] << 8) |
  1364. (this[offset + 3])
  1365. }
  1366. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  1367. if (!noAssert) checkOffset(offset, 4, this.length)
  1368. return ieee754.read(this, offset, true, 23, 4)
  1369. }
  1370. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  1371. if (!noAssert) checkOffset(offset, 4, this.length)
  1372. return ieee754.read(this, offset, false, 23, 4)
  1373. }
  1374. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  1375. if (!noAssert) checkOffset(offset, 8, this.length)
  1376. return ieee754.read(this, offset, true, 52, 8)
  1377. }
  1378. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  1379. if (!noAssert) checkOffset(offset, 8, this.length)
  1380. return ieee754.read(this, offset, false, 52, 8)
  1381. }
  1382. function checkInt (buf, value, offset, ext, max, min) {
  1383. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  1384. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  1385. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  1386. }
  1387. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  1388. value = +value
  1389. offset = offset | 0
  1390. byteLength = byteLength | 0
  1391. if (!noAssert) {
  1392. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  1393. checkInt(this, value, offset, byteLength, maxBytes, 0)
  1394. }
  1395. var mul = 1
  1396. var i = 0
  1397. this[offset] = value & 0xFF
  1398. while (++i < byteLength && (mul *= 0x100)) {
  1399. this[offset + i] = (value / mul) & 0xFF
  1400. }
  1401. return offset + byteLength
  1402. }
  1403. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  1404. value = +value
  1405. offset = offset | 0
  1406. byteLength = byteLength | 0
  1407. if (!noAssert) {
  1408. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  1409. checkInt(this, value, offset, byteLength, maxBytes, 0)
  1410. }
  1411. var i = byteLength - 1
  1412. var mul = 1
  1413. this[offset + i] = value & 0xFF
  1414. while (--i >= 0 && (mul *= 0x100)) {
  1415. this[offset + i] = (value / mul) & 0xFF
  1416. }
  1417. return offset + byteLength
  1418. }
  1419. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  1420. value = +value
  1421. offset = offset | 0
  1422. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  1423. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  1424. this[offset] = (value & 0xff)
  1425. return offset + 1
  1426. }
  1427. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  1428. if (value < 0) value = 0xffff + value + 1
  1429. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
  1430. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  1431. (littleEndian ? i : 1 - i) * 8
  1432. }
  1433. }
  1434. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  1435. value = +value
  1436. offset = offset | 0
  1437. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  1438. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1439. this[offset] = (value & 0xff)
  1440. this[offset + 1] = (value >>> 8)
  1441. } else {
  1442. objectWriteUInt16(this, value, offset, true)
  1443. }
  1444. return offset + 2
  1445. }
  1446. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  1447. value = +value
  1448. offset = offset | 0
  1449. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  1450. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1451. this[offset] = (value >>> 8)
  1452. this[offset + 1] = (value & 0xff)
  1453. } else {
  1454. objectWriteUInt16(this, value, offset, false)
  1455. }
  1456. return offset + 2
  1457. }
  1458. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  1459. if (value < 0) value = 0xffffffff + value + 1
  1460. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
  1461. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
  1462. }
  1463. }
  1464. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  1465. value = +value
  1466. offset = offset | 0
  1467. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  1468. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1469. this[offset + 3] = (value >>> 24)
  1470. this[offset + 2] = (value >>> 16)
  1471. this[offset + 1] = (value >>> 8)
  1472. this[offset] = (value & 0xff)
  1473. } else {
  1474. objectWriteUInt32(this, value, offset, true)
  1475. }
  1476. return offset + 4
  1477. }
  1478. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  1479. value = +value
  1480. offset = offset | 0
  1481. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  1482. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1483. this[offset] = (value >>> 24)
  1484. this[offset + 1] = (value >>> 16)
  1485. this[offset + 2] = (value >>> 8)
  1486. this[offset + 3] = (value & 0xff)
  1487. } else {
  1488. objectWriteUInt32(this, value, offset, false)
  1489. }
  1490. return offset + 4
  1491. }
  1492. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  1493. value = +value
  1494. offset = offset | 0
  1495. if (!noAssert) {
  1496. var limit = Math.pow(2, 8 * byteLength - 1)
  1497. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  1498. }
  1499. var i = 0
  1500. var mul = 1
  1501. var sub = 0
  1502. this[offset] = value & 0xFF
  1503. while (++i < byteLength && (mul *= 0x100)) {
  1504. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  1505. sub = 1
  1506. }
  1507. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  1508. }
  1509. return offset + byteLength
  1510. }
  1511. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  1512. value = +value
  1513. offset = offset | 0
  1514. if (!noAssert) {
  1515. var limit = Math.pow(2, 8 * byteLength - 1)
  1516. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  1517. }
  1518. var i = byteLength - 1
  1519. var mul = 1
  1520. var sub = 0
  1521. this[offset + i] = value & 0xFF
  1522. while (--i >= 0 && (mul *= 0x100)) {
  1523. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  1524. sub = 1
  1525. }
  1526. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  1527. }
  1528. return offset + byteLength
  1529. }
  1530. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  1531. value = +value
  1532. offset = offset | 0
  1533. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  1534. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  1535. if (value < 0) value = 0xff + value + 1
  1536. this[offset] = (value & 0xff)
  1537. return offset + 1
  1538. }
  1539. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  1540. value = +value
  1541. offset = offset | 0
  1542. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  1543. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1544. this[offset] = (value & 0xff)
  1545. this[offset + 1] = (value >>> 8)
  1546. } else {
  1547. objectWriteUInt16(this, value, offset, true)
  1548. }
  1549. return offset + 2
  1550. }
  1551. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  1552. value = +value
  1553. offset = offset | 0
  1554. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  1555. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1556. this[offset] = (value >>> 8)
  1557. this[offset + 1] = (value & 0xff)
  1558. } else {
  1559. objectWriteUInt16(this, value, offset, false)
  1560. }
  1561. return offset + 2
  1562. }
  1563. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  1564. value = +value
  1565. offset = offset | 0
  1566. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  1567. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1568. this[offset] = (value & 0xff)
  1569. this[offset + 1] = (value >>> 8)
  1570. this[offset + 2] = (value >>> 16)
  1571. this[offset + 3] = (value >>> 24)
  1572. } else {
  1573. objectWriteUInt32(this, value, offset, true)
  1574. }
  1575. return offset + 4
  1576. }
  1577. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  1578. value = +value
  1579. offset = offset | 0
  1580. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  1581. if (value < 0) value = 0xffffffff + value + 1
  1582. if (Buffer.TYPED_ARRAY_SUPPORT) {
  1583. this[offset] = (value >>> 24)
  1584. this[offset + 1] = (value >>> 16)
  1585. this[offset + 2] = (value >>> 8)
  1586. this[offset + 3] = (value & 0xff)
  1587. } else {
  1588. objectWriteUInt32(this, value, offset, false)
  1589. }
  1590. return offset + 4
  1591. }
  1592. function checkIEEE754 (buf, value, offset, ext, max, min) {
  1593. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  1594. if (offset < 0) throw new RangeError('Index out of range')
  1595. }
  1596. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  1597. if (!noAssert) {
  1598. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  1599. }
  1600. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  1601. return offset + 4
  1602. }
  1603. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  1604. return writeFloat(this, value, offset, true, noAssert)
  1605. }
  1606. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  1607. return writeFloat(this, value, offset, false, noAssert)
  1608. }
  1609. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  1610. if (!noAssert) {
  1611. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  1612. }
  1613. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  1614. return offset + 8
  1615. }
  1616. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  1617. return writeDouble(this, value, offset, true, noAssert)
  1618. }
  1619. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  1620. return writeDouble(this, value, offset, false, noAssert)
  1621. }
  1622. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  1623. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  1624. if (!start) start = 0
  1625. if (!end && end !== 0) end = this.length
  1626. if (targetStart >= target.length) targetStart = target.length
  1627. if (!targetStart) targetStart = 0
  1628. if (end > 0 && end < start) end = start
  1629. // Copy 0 bytes; we're done
  1630. if (end === start) return 0
  1631. if (target.length === 0 || this.length === 0) return 0
  1632. // Fatal error conditions
  1633. if (targetStart < 0) {
  1634. throw new RangeError('targetStart out of bounds')
  1635. }
  1636. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  1637. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  1638. // Are we oob?
  1639. if (end > this.length) end = this.length
  1640. if (target.length - targetStart < end - start) {
  1641. end = target.length - targetStart + start
  1642. }
  1643. var len = end - start
  1644. var i
  1645. if (this === target && start < targetStart && targetStart < end) {
  1646. // descending copy from end
  1647. for (i = len - 1; i >= 0; --i) {
  1648. target[i + targetStart] = this[i + start]
  1649. }
  1650. } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
  1651. // ascending copy from start
  1652. for (i = 0; i < len; ++i) {
  1653. target[i + targetStart] = this[i + start]
  1654. }
  1655. } else {
  1656. Uint8Array.prototype.set.call(
  1657. target,
  1658. this.subarray(start, start + len),
  1659. targetStart
  1660. )
  1661. }
  1662. return len
  1663. }
  1664. // Usage:
  1665. // buffer.fill(number[, offset[, end]])
  1666. // buffer.fill(buffer[, offset[, end]])
  1667. // buffer.fill(string[, offset[, end]][, encoding])
  1668. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  1669. // Handle string cases:
  1670. if (typeof val === 'string') {
  1671. if (typeof start === 'string') {
  1672. encoding = start
  1673. start = 0
  1674. end = this.length
  1675. } else if (typeof end === 'string') {
  1676. encoding = end
  1677. end = this.length
  1678. }
  1679. if (val.length === 1) {
  1680. var code = val.charCodeAt(0)
  1681. if (code < 256) {
  1682. val = code
  1683. }
  1684. }
  1685. if (encoding !== undefined && typeof encoding !== 'string') {
  1686. throw new TypeError('encoding must be a string')
  1687. }
  1688. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  1689. throw new TypeError('Unknown encoding: ' + encoding)
  1690. }
  1691. } else if (typeof val === 'number') {
  1692. val = val & 255
  1693. }
  1694. // Invalid ranges are not set to a default, so can range check early.
  1695. if (start < 0 || this.length < start || this.length < end) {
  1696. throw new RangeError('Out of range index')
  1697. }
  1698. if (end <= start) {
  1699. return this
  1700. }
  1701. start = start >>> 0
  1702. end = end === undefined ? this.length : end >>> 0
  1703. if (!val) val = 0
  1704. var i
  1705. if (typeof val === 'number') {
  1706. for (i = start; i < end; ++i) {
  1707. this[i] = val
  1708. }
  1709. } else {
  1710. var bytes = Buffer.isBuffer(val)
  1711. ? val
  1712. : utf8ToBytes(new Buffer(val, encoding).toString())
  1713. var len = bytes.length
  1714. for (i = 0; i < end - start; ++i) {
  1715. this[i + start] = bytes[i % len]
  1716. }
  1717. }
  1718. return this
  1719. }
  1720. // HELPER FUNCTIONS
  1721. // ================
  1722. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
  1723. function base64clean (str) {
  1724. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  1725. str = stringtrim(str).replace(INVALID_BASE64_RE, '')
  1726. // Node converts strings with length < 2 to ''
  1727. if (str.length < 2) return ''
  1728. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  1729. while (str.length % 4 !== 0) {
  1730. str = str + '='
  1731. }
  1732. return str
  1733. }
  1734. function stringtrim (str) {
  1735. if (str.trim) return str.trim()
  1736. return str.replace(/^\s+|\s+$/g, '')
  1737. }
  1738. function toHex (n) {
  1739. if (n < 16) return '0' + n.toString(16)
  1740. return n.toString(16)
  1741. }
  1742. function utf8ToBytes (string, units) {
  1743. units = units || Infinity
  1744. var codePoint
  1745. var length = string.length
  1746. var leadSurrogate = null
  1747. var bytes = []
  1748. for (var i = 0; i < length; ++i) {
  1749. codePoint = string.charCodeAt(i)
  1750. // is surrogate component
  1751. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  1752. // last char was a lead
  1753. if (!leadSurrogate) {
  1754. // no lead yet
  1755. if (codePoint > 0xDBFF) {
  1756. // unexpected trail
  1757. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  1758. continue
  1759. } else if (i + 1 === length) {
  1760. // unpaired lead
  1761. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  1762. continue
  1763. }
  1764. // valid lead
  1765. leadSurrogate = codePoint
  1766. continue
  1767. }
  1768. // 2 leads in a row
  1769. if (codePoint < 0xDC00) {
  1770. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  1771. leadSurrogate = codePoint
  1772. continue
  1773. }
  1774. // valid surrogate pair
  1775. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  1776. } else if (leadSurrogate) {
  1777. // valid bmp char, but last char was a lead
  1778. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  1779. }
  1780. leadSurrogate = null
  1781. // encode utf8
  1782. if (codePoint < 0x80) {
  1783. if ((units -= 1) < 0) break
  1784. bytes.push(codePoint)
  1785. } else if (codePoint < 0x800) {
  1786. if ((units -= 2) < 0) break
  1787. bytes.push(
  1788. codePoint >> 0x6 | 0xC0,
  1789. codePoint & 0x3F | 0x80
  1790. )
  1791. } else if (codePoint < 0x10000) {
  1792. if ((units -= 3) < 0) break
  1793. bytes.push(
  1794. codePoint >> 0xC | 0xE0,
  1795. codePoint >> 0x6 & 0x3F | 0x80,
  1796. codePoint & 0x3F | 0x80
  1797. )
  1798. } else if (codePoint < 0x110000) {
  1799. if ((units -= 4) < 0) break
  1800. bytes.push(
  1801. codePoint >> 0x12 | 0xF0,
  1802. codePoint >> 0xC & 0x3F | 0x80,
  1803. codePoint >> 0x6 & 0x3F | 0x80,
  1804. codePoint & 0x3F | 0x80
  1805. )
  1806. } else {
  1807. throw new Error('Invalid code point')
  1808. }
  1809. }
  1810. return bytes
  1811. }
  1812. function asciiToBytes (str) {
  1813. var byteArray = []
  1814. for (var i = 0; i < str.length; ++i) {
  1815. // Node's code seems to be doing this and not & 0x7F..
  1816. byteArray.push(str.charCodeAt(i) & 0xFF)
  1817. }
  1818. return byteArray
  1819. }
  1820. function utf16leToBytes (str, units) {
  1821. var c, hi, lo
  1822. var byteArray = []
  1823. for (var i = 0; i < str.length; ++i) {
  1824. if ((units -= 2) < 0) break
  1825. c = str.charCodeAt(i)
  1826. hi = c >> 8
  1827. lo = c % 256
  1828. byteArray.push(lo)
  1829. byteArray.push(hi)
  1830. }
  1831. return byteArray
  1832. }
  1833. function base64ToBytes (str) {
  1834. return base64.toByteArray(base64clean(str))
  1835. }
  1836. function blitBuffer (src, dst, offset, length) {
  1837. for (var i = 0; i < length; ++i) {
  1838. if ((i + offset >= dst.length) || (i >= src.length)) break
  1839. dst[i + offset] = src[i]
  1840. }
  1841. return i
  1842. }
  1843. function isnan (val) {
  1844. return val !== val // eslint-disable-line no-self-compare
  1845. }
  1846. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)))
  1847. /***/ }),
  1848. /* 5 */
  1849. /***/ (function(module, exports) {
  1850. // shim for using process in browser
  1851. var process = module.exports = {};
  1852. // cached from whatever global is present so that test runners that stub it
  1853. // don't break things. But we need to wrap it in a try catch in case it is
  1854. // wrapped in strict mode code which doesn't define any globals. It's inside a
  1855. // function because try/catches deoptimize in certain engines.
  1856. var cachedSetTimeout;
  1857. var cachedClearTimeout;
  1858. function defaultSetTimout() {
  1859. throw new Error('setTimeout has not been defined');
  1860. }
  1861. function defaultClearTimeout () {
  1862. throw new Error('clearTimeout has not been defined');
  1863. }
  1864. (function () {
  1865. try {
  1866. if (typeof setTimeout === 'function') {
  1867. cachedSetTimeout = setTimeout;
  1868. } else {
  1869. cachedSetTimeout = defaultSetTimout;
  1870. }
  1871. } catch (e) {
  1872. cachedSetTimeout = defaultSetTimout;
  1873. }
  1874. try {
  1875. if (typeof clearTimeout === 'function') {
  1876. cachedClearTimeout = clearTimeout;
  1877. } else {
  1878. cachedClearTimeout = defaultClearTimeout;
  1879. }
  1880. } catch (e) {
  1881. cachedClearTimeout = defaultClearTimeout;
  1882. }
  1883. } ())
  1884. function runTimeout(fun) {
  1885. if (cachedSetTimeout === setTimeout) {
  1886. //normal enviroments in sane situations
  1887. return setTimeout(fun, 0);
  1888. }
  1889. // if setTimeout wasn't available but was latter defined
  1890. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  1891. cachedSetTimeout = setTimeout;
  1892. return setTimeout(fun, 0);
  1893. }
  1894. try {
  1895. // when when somebody has screwed with setTimeout but no I.E. maddness
  1896. return cachedSetTimeout(fun, 0);
  1897. } catch(e){
  1898. try {
  1899. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  1900. return cachedSetTimeout.call(null, fun, 0);
  1901. } catch(e){
  1902. // 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
  1903. return cachedSetTimeout.call(this, fun, 0);
  1904. }
  1905. }
  1906. }
  1907. function runClearTimeout(marker) {
  1908. if (cachedClearTimeout === clearTimeout) {
  1909. //normal enviroments in sane situations
  1910. return clearTimeout(marker);
  1911. }
  1912. // if clearTimeout wasn't available but was latter defined
  1913. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  1914. cachedClearTimeout = clearTimeout;
  1915. return clearTimeout(marker);
  1916. }
  1917. try {
  1918. // when when somebody has screwed with setTimeout but no I.E. maddness
  1919. return cachedClearTimeout(marker);
  1920. } catch (e){
  1921. try {
  1922. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  1923. return cachedClearTimeout.call(null, marker);
  1924. } catch (e){
  1925. // 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.
  1926. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  1927. return cachedClearTimeout.call(this, marker);
  1928. }
  1929. }
  1930. }
  1931. var queue = [];
  1932. var draining = false;
  1933. var currentQueue;
  1934. var queueIndex = -1;
  1935. function cleanUpNextTick() {
  1936. if (!draining || !currentQueue) {
  1937. return;
  1938. }
  1939. draining = false;
  1940. if (currentQueue.length) {
  1941. queue = currentQueue.concat(queue);
  1942. } else {
  1943. queueIndex = -1;
  1944. }
  1945. if (queue.length) {
  1946. drainQueue();
  1947. }
  1948. }
  1949. function drainQueue() {
  1950. if (draining) {
  1951. return;
  1952. }
  1953. var timeout = runTimeout(cleanUpNextTick);
  1954. draining = true;
  1955. var len = queue.length;
  1956. while(len) {
  1957. currentQueue = queue;
  1958. queue = [];
  1959. while (++queueIndex < len) {
  1960. if (currentQueue) {
  1961. currentQueue[queueIndex].run();
  1962. }
  1963. }
  1964. queueIndex = -1;
  1965. len = queue.length;
  1966. }
  1967. currentQueue = null;
  1968. draining = false;
  1969. runClearTimeout(timeout);
  1970. }
  1971. process.nextTick = function (fun) {
  1972. var args = new Array(arguments.length - 1);
  1973. if (arguments.length > 1) {
  1974. for (var i = 1; i < arguments.length; i++) {
  1975. args[i - 1] = arguments[i];
  1976. }
  1977. }
  1978. queue.push(new Item(fun, args));
  1979. if (queue.length === 1 && !draining) {
  1980. runTimeout(drainQueue);
  1981. }
  1982. };
  1983. // v8 likes predictible objects
  1984. function Item(fun, array) {
  1985. this.fun = fun;
  1986. this.array = array;
  1987. }
  1988. Item.prototype.run = function () {
  1989. this.fun.apply(null, this.array);
  1990. };
  1991. process.title = 'browser';
  1992. process.browser = true;
  1993. process.env = {};
  1994. process.argv = [];
  1995. process.version = ''; // empty string to avoid regexp issues
  1996. process.versions = {};
  1997. function noop() {}
  1998. process.on = noop;
  1999. process.addListener = noop;
  2000. process.once = noop;
  2001. process.off = noop;
  2002. process.removeListener = noop;
  2003. process.removeAllListeners = noop;
  2004. process.emit = noop;
  2005. process.prependListener = noop;
  2006. process.prependOnceListener = noop;
  2007. process.listeners = function (name) { return [] }
  2008. process.binding = function (name) {
  2009. throw new Error('process.binding is not supported');
  2010. };
  2011. process.cwd = function () { return '/' };
  2012. process.chdir = function (dir) {
  2013. throw new Error('process.chdir is not supported');
  2014. };
  2015. process.umask = function() { return 0; };
  2016. /***/ }),
  2017. /* 6 */
  2018. /***/ (function(module, exports, __webpack_require__) {
  2019. "use strict";
  2020. /* WEBPACK VAR INJECTION */(function(process) {
  2021. if (!process.version ||
  2022. process.version.indexOf('v0.') === 0 ||
  2023. process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
  2024. module.exports = nextTick;
  2025. } else {
  2026. module.exports = process.nextTick;
  2027. }
  2028. function nextTick(fn, arg1, arg2, arg3) {
  2029. if (typeof fn !== 'function') {
  2030. throw new TypeError('"callback" argument must be a function');
  2031. }
  2032. var len = arguments.length;
  2033. var args, i;
  2034. switch (len) {
  2035. case 0:
  2036. case 1:
  2037. return process.nextTick(fn);
  2038. case 2:
  2039. return process.nextTick(function afterTickOne() {
  2040. fn.call(null, arg1);
  2041. });
  2042. case 3:
  2043. return process.nextTick(function afterTickTwo() {
  2044. fn.call(null, arg1, arg2);
  2045. });
  2046. case 4:
  2047. return process.nextTick(function afterTickThree() {
  2048. fn.call(null, arg1, arg2, arg3);
  2049. });
  2050. default:
  2051. args = new Array(len - 1);
  2052. i = 0;
  2053. while (i < args.length) {
  2054. args[i++] = arguments[i];
  2055. }
  2056. return process.nextTick(function afterTick() {
  2057. fn.apply(null, args);
  2058. });
  2059. }
  2060. }
  2061. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5)))
  2062. /***/ }),
  2063. /* 7 */
  2064. /***/ (function(module, exports, __webpack_require__) {
  2065. /* eslint-disable node/no-deprecated-api */
  2066. var buffer = __webpack_require__(4)
  2067. var Buffer = buffer.Buffer
  2068. // alternative to using Object.keys for old browsers
  2069. function copyProps (src, dst) {
  2070. for (var key in src) {
  2071. dst[key] = src[key]
  2072. }
  2073. }
  2074. if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
  2075. module.exports = buffer
  2076. } else {
  2077. // Copy properties from require('buffer')
  2078. copyProps(buffer, exports)
  2079. exports.Buffer = SafeBuffer
  2080. }
  2081. function SafeBuffer (arg, encodingOrOffset, length) {
  2082. return Buffer(arg, encodingOrOffset, length)
  2083. }
  2084. // Copy static methods from Buffer
  2085. copyProps(Buffer, SafeBuffer)
  2086. SafeBuffer.from = function (arg, encodingOrOffset, length) {
  2087. if (typeof arg === 'number') {
  2088. throw new TypeError('Argument must not be a number')
  2089. }
  2090. return Buffer(arg, encodingOrOffset, length)
  2091. }
  2092. SafeBuffer.alloc = function (size, fill, encoding) {
  2093. if (typeof size !== 'number') {
  2094. throw new TypeError('Argument must be a number')
  2095. }
  2096. var buf = Buffer(size)
  2097. if (fill !== undefined) {
  2098. if (typeof encoding === 'string') {
  2099. buf.fill(fill, encoding)
  2100. } else {
  2101. buf.fill(fill)
  2102. }
  2103. } else {
  2104. buf.fill(0)
  2105. }
  2106. return buf
  2107. }
  2108. SafeBuffer.allocUnsafe = function (size) {
  2109. if (typeof size !== 'number') {
  2110. throw new TypeError('Argument must be a number')
  2111. }
  2112. return Buffer(size)
  2113. }
  2114. SafeBuffer.allocUnsafeSlow = function (size) {
  2115. if (typeof size !== 'number') {
  2116. throw new TypeError('Argument must be a number')
  2117. }
  2118. return buffer.SlowBuffer(size)
  2119. }
  2120. /***/ }),
  2121. /* 8 */
  2122. /***/ (function(module, exports) {
  2123. // Copyright Joyent, Inc. and other Node contributors.
  2124. //
  2125. // Permission is hereby granted, free of charge, to any person obtaining a
  2126. // copy of this software and associated documentation files (the
  2127. // "Software"), to deal in the Software without restriction, including
  2128. // without limitation the rights to use, copy, modify, merge, publish,
  2129. // distribute, sublicense, and/or sell copies of the Software, and to permit
  2130. // persons to whom the Software is furnished to do so, subject to the
  2131. // following conditions:
  2132. //
  2133. // The above copyright notice and this permission notice shall be included
  2134. // in all copies or substantial portions of the Software.
  2135. //
  2136. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  2137. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  2138. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  2139. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  2140. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  2141. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  2142. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  2143. function EventEmitter() {
  2144. this._events = this._events || {};
  2145. this._maxListeners = this._maxListeners || undefined;
  2146. }
  2147. module.exports = EventEmitter;
  2148. // Backwards-compat with node 0.10.x
  2149. EventEmitter.EventEmitter = EventEmitter;
  2150. EventEmitter.prototype._events = undefined;
  2151. EventEmitter.prototype._maxListeners = undefined;
  2152. // By default EventEmitters will print a warning if more than 10 listeners are
  2153. // added to it. This is a useful default which helps finding memory leaks.
  2154. EventEmitter.defaultMaxListeners = 10;
  2155. // Obviously not all Emitters should be limited to 10. This function allows
  2156. // that to be increased. Set to zero for unlimited.
  2157. EventEmitter.prototype.setMaxListeners = function(n) {
  2158. if (!isNumber(n) || n < 0 || isNaN(n))
  2159. throw TypeError('n must be a positive number');
  2160. this._maxListeners = n;
  2161. return this;
  2162. };
  2163. EventEmitter.prototype.emit = function(type) {
  2164. var er, handler, len, args, i, listeners;
  2165. if (!this._events)
  2166. this._events = {};
  2167. // If there is no 'error' event listener then throw.
  2168. if (type === 'error') {
  2169. if (!this._events.error ||
  2170. (isObject(this._events.error) && !this._events.error.length)) {
  2171. er = arguments[1];
  2172. if (er instanceof Error) {
  2173. throw er; // Unhandled 'error' event
  2174. } else {
  2175. // At least give some kind of context to the user
  2176. var err = new Error('Uncaught, unspecified "error" event. (' + er + ')');
  2177. err.context = er;
  2178. throw err;
  2179. }
  2180. }
  2181. }
  2182. handler = this._events[type];
  2183. if (isUndefined(handler))
  2184. return false;
  2185. if (isFunction(handler)) {
  2186. switch (arguments.length) {
  2187. // fast cases
  2188. case 1:
  2189. handler.call(this);
  2190. break;
  2191. case 2:
  2192. handler.call(this, arguments[1]);
  2193. break;
  2194. case 3:
  2195. handler.call(this, arguments[1], arguments[2]);
  2196. break;
  2197. // slower
  2198. default:
  2199. args = Array.prototype.slice.call(arguments, 1);
  2200. handler.apply(this, args);
  2201. }
  2202. } else if (isObject(handler)) {
  2203. args = Array.prototype.slice.call(arguments, 1);
  2204. listeners = handler.slice();
  2205. len = listeners.length;
  2206. for (i = 0; i < len; i++)
  2207. listeners[i].apply(this, args);
  2208. }
  2209. return true;
  2210. };
  2211. EventEmitter.prototype.addListener = function(type, listener) {
  2212. var m;
  2213. if (!isFunction(listener))
  2214. throw TypeError('listener must be a function');
  2215. if (!this._events)
  2216. this._events = {};
  2217. // To avoid recursion in the case that type === "newListener"! Before
  2218. // adding it to the listeners, first emit "newListener".
  2219. if (this._events.newListener)
  2220. this.emit('newListener', type,
  2221. isFunction(listener.listener) ?
  2222. listener.listener : listener);
  2223. if (!this._events[type])
  2224. // Optimize the case of one listener. Don't need the extra array object.
  2225. this._events[type] = listener;
  2226. else if (isObject(this._events[type]))
  2227. // If we've already got an array, just append.
  2228. this._events[type].push(listener);
  2229. else
  2230. // Adding the second element, need to change to array.
  2231. this._events[type] = [this._events[type], listener];
  2232. // Check for listener leak
  2233. if (isObject(this._events[type]) && !this._events[type].warned) {
  2234. if (!isUndefined(this._maxListeners)) {
  2235. m = this._maxListeners;
  2236. } else {
  2237. m = EventEmitter.defaultMaxListeners;
  2238. }
  2239. if (m && m > 0 && this._events[type].length > m) {
  2240. this._events[type].warned = true;
  2241. console.error('(node) warning: possible EventEmitter memory ' +
  2242. 'leak detected. %d listeners added. ' +
  2243. 'Use emitter.setMaxListeners() to increase limit.',
  2244. this._events[type].length);
  2245. if (typeof console.trace === 'function') {
  2246. // not supported in IE 10
  2247. console.trace();
  2248. }
  2249. }
  2250. }
  2251. return this;
  2252. };
  2253. EventEmitter.prototype.on = EventEmitter.prototype.addListener;
  2254. EventEmitter.prototype.once = function(type, listener) {
  2255. if (!isFunction(listener))
  2256. throw TypeError('listener must be a function');
  2257. var fired = false;
  2258. function g() {
  2259. this.removeListener(type, g);
  2260. if (!fired) {
  2261. fired = true;
  2262. listener.apply(this, arguments);
  2263. }
  2264. }
  2265. g.listener = listener;
  2266. this.on(type, g);
  2267. return this;
  2268. };
  2269. // emits a 'removeListener' event iff the listener was removed
  2270. EventEmitter.prototype.removeListener = function(type, listener) {
  2271. var list, position, length, i;
  2272. if (!isFunction(listener))
  2273. throw TypeError('listener must be a function');
  2274. if (!this._events || !this._events[type])
  2275. return this;
  2276. list = this._events[type];
  2277. length = list.length;
  2278. position = -1;
  2279. if (list === listener ||
  2280. (isFunction(list.listener) && list.listener === listener)) {
  2281. delete this._events[type];
  2282. if (this._events.removeListener)
  2283. this.emit('removeListener', type, listener);
  2284. } else if (isObject(list)) {
  2285. for (i = length; i-- > 0;) {
  2286. if (list[i] === listener ||
  2287. (list[i].listener && list[i].listener === listener)) {
  2288. position = i;
  2289. break;
  2290. }
  2291. }
  2292. if (position < 0)
  2293. return this;
  2294. if (list.length === 1) {
  2295. list.length = 0;
  2296. delete this._events[type];
  2297. } else {
  2298. list.splice(position, 1);
  2299. }
  2300. if (this._events.removeListener)
  2301. this.emit('removeListener', type, listener);
  2302. }
  2303. return this;
  2304. };
  2305. EventEmitter.prototype.removeAllListeners = function(type) {
  2306. var key, listeners;
  2307. if (!this._events)
  2308. return this;
  2309. // not listening for removeListener, no need to emit
  2310. if (!this._events.removeListener) {
  2311. if (arguments.length === 0)
  2312. this._events = {};
  2313. else if (this._events[type])
  2314. delete this._events[type];
  2315. return this;
  2316. }
  2317. // emit removeListener for all listeners on all events
  2318. if (arguments.length === 0) {
  2319. for (key in this._events) {
  2320. if (key === 'removeListener') continue;
  2321. this.removeAllListeners(key);
  2322. }
  2323. this.removeAllListeners('removeListener');
  2324. this._events = {};
  2325. return this;
  2326. }
  2327. listeners = this._events[type];
  2328. if (isFunction(listeners)) {
  2329. this.removeListener(type, listeners);
  2330. } else if (listeners) {
  2331. // LIFO order
  2332. while (listeners.length)
  2333. this.removeListener(type, listeners[listeners.length - 1]);
  2334. }
  2335. delete this._events[type];
  2336. return this;
  2337. };
  2338. EventEmitter.prototype.listeners = function(type) {
  2339. var ret;
  2340. if (!this._events || !this._events[type])
  2341. ret = [];
  2342. else if (isFunction(this._events[type]))
  2343. ret = [this._events[type]];
  2344. else
  2345. ret = this._events[type].slice();
  2346. return ret;
  2347. };
  2348. EventEmitter.prototype.listenerCount = function(type) {
  2349. if (this._events) {
  2350. var evlistener = this._events[type];
  2351. if (isFunction(evlistener))
  2352. return 1;
  2353. else if (evlistener)
  2354. return evlistener.length;
  2355. }
  2356. return 0;
  2357. };
  2358. EventEmitter.listenerCount = function(emitter, type) {
  2359. return emitter.listenerCount(type);
  2360. };
  2361. function isFunction(arg) {
  2362. return typeof arg === 'function';
  2363. }
  2364. function isNumber(arg) {
  2365. return typeof arg === 'number';
  2366. }
  2367. function isObject(arg) {
  2368. return typeof arg === 'object' && arg !== null;
  2369. }
  2370. function isUndefined(arg) {
  2371. return arg === void 0;
  2372. }
  2373. /***/ }),
  2374. /* 9 */
  2375. /***/ (function(module, exports, __webpack_require__) {
  2376. exports = module.exports = __webpack_require__(16);
  2377. exports.Stream = exports;
  2378. exports.Readable = exports;
  2379. exports.Writable = __webpack_require__(10);
  2380. exports.Duplex = __webpack_require__(0);
  2381. exports.Transform = __webpack_require__(19);
  2382. exports.PassThrough = __webpack_require__(31);
  2383. /***/ }),
  2384. /* 10 */
  2385. /***/ (function(module, exports, __webpack_require__) {
  2386. "use strict";
  2387. /* WEBPACK VAR INJECTION */(function(process, setImmediate, global) {// Copyright Joyent, Inc. and other Node contributors.
  2388. //
  2389. // Permission is hereby granted, free of charge, to any person obtaining a
  2390. // copy of this software and associated documentation files (the
  2391. // "Software"), to deal in the Software without restriction, including
  2392. // without limitation the rights to use, copy, modify, merge, publish,
  2393. // distribute, sublicense, and/or sell copies of the Software, and to permit
  2394. // persons to whom the Software is furnished to do so, subject to the
  2395. // following conditions:
  2396. //
  2397. // The above copyright notice and this permission notice shall be included
  2398. // in all copies or substantial portions of the Software.
  2399. //
  2400. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  2401. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  2402. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  2403. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  2404. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  2405. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  2406. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  2407. // A bit simpler than readable streams.
  2408. // Implement an async ._write(chunk, encoding, cb), and it'll handle all
  2409. // the drain event emission and buffering.
  2410. /*<replacement>*/
  2411. var processNextTick = __webpack_require__(6);
  2412. /*</replacement>*/
  2413. module.exports = Writable;
  2414. /* <replacement> */
  2415. function WriteReq(chunk, encoding, cb) {
  2416. this.chunk = chunk;
  2417. this.encoding = encoding;
  2418. this.callback = cb;
  2419. this.next = null;
  2420. }
  2421. // It seems a linked list but it is not
  2422. // there will be only 2 of these for each stream
  2423. function CorkedRequest(state) {
  2424. var _this = this;
  2425. this.next = null;
  2426. this.entry = null;
  2427. this.finish = function () {
  2428. onCorkedFinish(_this, state);
  2429. };
  2430. }
  2431. /* </replacement> */
  2432. /*<replacement>*/
  2433. var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : processNextTick;
  2434. /*</replacement>*/
  2435. /*<replacement>*/
  2436. var Duplex;
  2437. /*</replacement>*/
  2438. Writable.WritableState = WritableState;
  2439. /*<replacement>*/
  2440. var util = __webpack_require__(3);
  2441. util.inherits = __webpack_require__(1);
  2442. /*</replacement>*/
  2443. /*<replacement>*/
  2444. var internalUtil = {
  2445. deprecate: __webpack_require__(30)
  2446. };
  2447. /*</replacement>*/
  2448. /*<replacement>*/
  2449. var Stream = __webpack_require__(17);
  2450. /*</replacement>*/
  2451. /*<replacement>*/
  2452. var Buffer = __webpack_require__(7).Buffer;
  2453. var OurUint8Array = global.Uint8Array || function () {};
  2454. function _uint8ArrayToBuffer(chunk) {
  2455. return Buffer.from(chunk);
  2456. }
  2457. function _isUint8Array(obj) {
  2458. return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
  2459. }
  2460. /*</replacement>*/
  2461. var destroyImpl = __webpack_require__(18);
  2462. util.inherits(Writable, Stream);
  2463. function nop() {}
  2464. function WritableState(options, stream) {
  2465. Duplex = Duplex || __webpack_require__(0);
  2466. options = options || {};
  2467. // object stream flag to indicate whether or not this stream
  2468. // contains buffers or objects.
  2469. this.objectMode = !!options.objectMode;
  2470. if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
  2471. // the point at which write() starts returning false
  2472. // Note: 0 is a valid value, means that we always return false if
  2473. // the entire buffer is not flushed immediately on write()
  2474. var hwm = options.highWaterMark;
  2475. var defaultHwm = this.objectMode ? 16 : 16 * 1024;
  2476. this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
  2477. // cast to ints.
  2478. this.highWaterMark = Math.floor(this.highWaterMark);
  2479. // if _final has been called
  2480. this.finalCalled = false;
  2481. // drain event flag.
  2482. this.needDrain = false;
  2483. // at the start of calling end()
  2484. this.ending = false;
  2485. // when end() has been called, and returned
  2486. this.ended = false;
  2487. // when 'finish' is emitted
  2488. this.finished = false;
  2489. // has it been destroyed
  2490. this.destroyed = false;
  2491. // should we decode strings into buffers before passing to _write?
  2492. // this is here so that some node-core streams can optimize string
  2493. // handling at a lower level.
  2494. var noDecode = options.decodeStrings === false;
  2495. this.decodeStrings = !noDecode;
  2496. // Crypto is kind of old and crusty. Historically, its default string
  2497. // encoding is 'binary' so we have to make this configurable.
  2498. // Everything else in the universe uses 'utf8', though.
  2499. this.defaultEncoding = options.defaultEncoding || 'utf8';
  2500. // not an actual buffer we keep track of, but a measurement
  2501. // of how much we're waiting to get pushed to some underlying
  2502. // socket or file.
  2503. this.length = 0;
  2504. // a flag to see when we're in the middle of a write.
  2505. this.writing = false;
  2506. // when true all writes will be buffered until .uncork() call
  2507. this.corked = 0;
  2508. // a flag to be able to tell if the onwrite cb is called immediately,
  2509. // or on a later tick. We set this to true at first, because any
  2510. // actions that shouldn't happen until "later" should generally also
  2511. // not happen before the first write call.
  2512. this.sync = true;
  2513. // a flag to know if we're processing previously buffered items, which
  2514. // may call the _write() callback in the same tick, so that we don't
  2515. // end up in an overlapped onwrite situation.
  2516. this.bufferProcessing = false;
  2517. // the callback that's passed to _write(chunk,cb)
  2518. this.onwrite = function (er) {
  2519. onwrite(stream, er);
  2520. };
  2521. // the callback that the user supplies to write(chunk,encoding,cb)
  2522. this.writecb = null;
  2523. // the amount that is being written when _write is called.
  2524. this.writelen = 0;
  2525. this.bufferedRequest = null;
  2526. this.lastBufferedRequest = null;
  2527. // number of pending user-supplied write callbacks
  2528. // this must be 0 before 'finish' can be emitted
  2529. this.pendingcb = 0;
  2530. // emit prefinish if the only thing we're waiting for is _write cbs
  2531. // This is relevant for synchronous Transform streams
  2532. this.prefinished = false;
  2533. // True if the error was already emitted and should not be thrown again
  2534. this.errorEmitted = false;
  2535. // count buffered requests
  2536. this.bufferedRequestCount = 0;
  2537. // allocate the first CorkedRequest, there is always
  2538. // one allocated and free to use, and we maintain at most two
  2539. this.corkedRequestsFree = new CorkedRequest(this);
  2540. }
  2541. WritableState.prototype.getBuffer = function getBuffer() {
  2542. var current = this.bufferedRequest;
  2543. var out = [];
  2544. while (current) {
  2545. out.push(current);
  2546. current = current.next;
  2547. }
  2548. return out;
  2549. };
  2550. (function () {
  2551. try {
  2552. Object.defineProperty(WritableState.prototype, 'buffer', {
  2553. get: internalUtil.deprecate(function () {
  2554. return this.getBuffer();
  2555. }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
  2556. });
  2557. } catch (_) {}
  2558. })();
  2559. // Test _writableState for inheritance to account for Duplex streams,
  2560. // whose prototype chain only points to Readable.
  2561. var realHasInstance;
  2562. if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
  2563. realHasInstance = Function.prototype[Symbol.hasInstance];
  2564. Object.defineProperty(Writable, Symbol.hasInstance, {
  2565. value: function (object) {
  2566. if (realHasInstance.call(this, object)) return true;
  2567. return object && object._writableState instanceof WritableState;
  2568. }
  2569. });
  2570. } else {
  2571. realHasInstance = function (object) {
  2572. return object instanceof this;
  2573. };
  2574. }
  2575. function Writable(options) {
  2576. Duplex = Duplex || __webpack_require__(0);
  2577. // Writable ctor is applied to Duplexes, too.
  2578. // `realHasInstance` is necessary because using plain `instanceof`
  2579. // would return false, as no `_writableState` property is attached.
  2580. // Trying to use the custom `instanceof` for Writable here will also break the
  2581. // Node.js LazyTransform implementation, which has a non-trivial getter for
  2582. // `_writableState` that would lead to infinite recursion.
  2583. if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
  2584. return new Writable(options);
  2585. }
  2586. this._writableState = new WritableState(options, this);
  2587. // legacy.
  2588. this.writable = true;
  2589. if (options) {
  2590. if (typeof options.write === 'function') this._write = options.write;
  2591. if (typeof options.writev === 'function') this._writev = options.writev;
  2592. if (typeof options.destroy === 'function') this._destroy = options.destroy;
  2593. if (typeof options.final === 'function') this._final = options.final;
  2594. }
  2595. Stream.call(this);
  2596. }
  2597. // Otherwise people can pipe Writable streams, which is just wrong.
  2598. Writable.prototype.pipe = function () {
  2599. this.emit('error', new Error('Cannot pipe, not readable'));
  2600. };
  2601. function writeAfterEnd(stream, cb) {
  2602. var er = new Error('write after end');
  2603. // TODO: defer error events consistently everywhere, not just the cb
  2604. stream.emit('error', er);
  2605. processNextTick(cb, er);
  2606. }
  2607. // Checks that a user-supplied chunk is valid, especially for the particular
  2608. // mode the stream is in. Currently this means that `null` is never accepted
  2609. // and undefined/non-string values are only allowed in object mode.
  2610. function validChunk(stream, state, chunk, cb) {
  2611. var valid = true;
  2612. var er = false;
  2613. if (chunk === null) {
  2614. er = new TypeError('May not write null values to stream');
  2615. } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
  2616. er = new TypeError('Invalid non-string/buffer chunk');
  2617. }
  2618. if (er) {
  2619. stream.emit('error', er);
  2620. processNextTick(cb, er);
  2621. valid = false;
  2622. }
  2623. return valid;
  2624. }
  2625. Writable.prototype.write = function (chunk, encoding, cb) {
  2626. var state = this._writableState;
  2627. var ret = false;
  2628. var isBuf = _isUint8Array(chunk) && !state.objectMode;
  2629. if (isBuf && !Buffer.isBuffer(chunk)) {
  2630. chunk = _uint8ArrayToBuffer(chunk);
  2631. }
  2632. if (typeof encoding === 'function') {
  2633. cb = encoding;
  2634. encoding = null;
  2635. }
  2636. if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
  2637. if (typeof cb !== 'function') cb = nop;
  2638. if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
  2639. state.pendingcb++;
  2640. ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
  2641. }
  2642. return ret;
  2643. };
  2644. Writable.prototype.cork = function () {
  2645. var state = this._writableState;
  2646. state.corked++;
  2647. };
  2648. Writable.prototype.uncork = function () {
  2649. var state = this._writableState;
  2650. if (state.corked) {
  2651. state.corked--;
  2652. if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
  2653. }
  2654. };
  2655. Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
  2656. // node::ParseEncoding() requires lower case.
  2657. if (typeof encoding === 'string') encoding = encoding.toLowerCase();
  2658. 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);
  2659. this._writableState.defaultEncoding = encoding;
  2660. return this;
  2661. };
  2662. function decodeChunk(state, chunk, encoding) {
  2663. if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
  2664. chunk = Buffer.from(chunk, encoding);
  2665. }
  2666. return chunk;
  2667. }
  2668. // if we're already writing something, then just put this
  2669. // in the queue, and wait our turn. Otherwise, call _write
  2670. // If we return false, then we need a drain event, so set that flag.
  2671. function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
  2672. if (!isBuf) {
  2673. var newChunk = decodeChunk(state, chunk, encoding);
  2674. if (chunk !== newChunk) {
  2675. isBuf = true;
  2676. encoding = 'buffer';
  2677. chunk = newChunk;
  2678. }
  2679. }
  2680. var len = state.objectMode ? 1 : chunk.length;
  2681. state.length += len;
  2682. var ret = state.length < state.highWaterMark;
  2683. // we must ensure that previous needDrain will not be reset to false.
  2684. if (!ret) state.needDrain = true;
  2685. if (state.writing || state.corked) {
  2686. var last = state.lastBufferedRequest;
  2687. state.lastBufferedRequest = {
  2688. chunk: chunk,
  2689. encoding: encoding,
  2690. isBuf: isBuf,
  2691. callback: cb,
  2692. next: null
  2693. };
  2694. if (last) {
  2695. last.next = state.lastBufferedRequest;
  2696. } else {
  2697. state.bufferedRequest = state.lastBufferedRequest;
  2698. }
  2699. state.bufferedRequestCount += 1;
  2700. } else {
  2701. doWrite(stream, state, false, len, chunk, encoding, cb);
  2702. }
  2703. return ret;
  2704. }
  2705. function doWrite(stream, state, writev, len, chunk, encoding, cb) {
  2706. state.writelen = len;
  2707. state.writecb = cb;
  2708. state.writing = true;
  2709. state.sync = true;
  2710. if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
  2711. state.sync = false;
  2712. }
  2713. function onwriteError(stream, state, sync, er, cb) {
  2714. --state.pendingcb;
  2715. if (sync) {
  2716. // defer the callback if we are being called synchronously
  2717. // to avoid piling up things on the stack
  2718. processNextTick(cb, er);
  2719. // this can emit finish, and it will always happen
  2720. // after error
  2721. processNextTick(finishMaybe, stream, state);
  2722. stream._writableState.errorEmitted = true;
  2723. stream.emit('error', er);
  2724. } else {
  2725. // the caller expect this to happen before if
  2726. // it is async
  2727. cb(er);
  2728. stream._writableState.errorEmitted = true;
  2729. stream.emit('error', er);
  2730. // this can emit finish, but finish must
  2731. // always follow error
  2732. finishMaybe(stream, state);
  2733. }
  2734. }
  2735. function onwriteStateUpdate(state) {
  2736. state.writing = false;
  2737. state.writecb = null;
  2738. state.length -= state.writelen;
  2739. state.writelen = 0;
  2740. }
  2741. function onwrite(stream, er) {
  2742. var state = stream._writableState;
  2743. var sync = state.sync;
  2744. var cb = state.writecb;
  2745. onwriteStateUpdate(state);
  2746. if (er) onwriteError(stream, state, sync, er, cb);else {
  2747. // Check if we're actually ready to finish, but don't emit yet
  2748. var finished = needFinish(state);
  2749. if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
  2750. clearBuffer(stream, state);
  2751. }
  2752. if (sync) {
  2753. /*<replacement>*/
  2754. asyncWrite(afterWrite, stream, state, finished, cb);
  2755. /*</replacement>*/
  2756. } else {
  2757. afterWrite(stream, state, finished, cb);
  2758. }
  2759. }
  2760. }
  2761. function afterWrite(stream, state, finished, cb) {
  2762. if (!finished) onwriteDrain(stream, state);
  2763. state.pendingcb--;
  2764. cb();
  2765. finishMaybe(stream, state);
  2766. }
  2767. // Must force callback to be called on nextTick, so that we don't
  2768. // emit 'drain' before the write() consumer gets the 'false' return
  2769. // value, and has a chance to attach a 'drain' listener.
  2770. function onwriteDrain(stream, state) {
  2771. if (state.length === 0 && state.needDrain) {
  2772. state.needDrain = false;
  2773. stream.emit('drain');
  2774. }
  2775. }
  2776. // if there's something in the buffer waiting, then process it
  2777. function clearBuffer(stream, state) {
  2778. state.bufferProcessing = true;
  2779. var entry = state.bufferedRequest;
  2780. if (stream._writev && entry && entry.next) {
  2781. // Fast case, write everything using _writev()
  2782. var l = state.bufferedRequestCount;
  2783. var buffer = new Array(l);
  2784. var holder = state.corkedRequestsFree;
  2785. holder.entry = entry;
  2786. var count = 0;
  2787. var allBuffers = true;
  2788. while (entry) {
  2789. buffer[count] = entry;
  2790. if (!entry.isBuf) allBuffers = false;
  2791. entry = entry.next;
  2792. count += 1;
  2793. }
  2794. buffer.allBuffers = allBuffers;
  2795. doWrite(stream, state, true, state.length, buffer, '', holder.finish);
  2796. // doWrite is almost always async, defer these to save a bit of time
  2797. // as the hot path ends with doWrite
  2798. state.pendingcb++;
  2799. state.lastBufferedRequest = null;
  2800. if (holder.next) {
  2801. state.corkedRequestsFree = holder.next;
  2802. holder.next = null;
  2803. } else {
  2804. state.corkedRequestsFree = new CorkedRequest(state);
  2805. }
  2806. } else {
  2807. // Slow case, write chunks one-by-one
  2808. while (entry) {
  2809. var chunk = entry.chunk;
  2810. var encoding = entry.encoding;
  2811. var cb = entry.callback;
  2812. var len = state.objectMode ? 1 : chunk.length;
  2813. doWrite(stream, state, false, len, chunk, encoding, cb);
  2814. entry = entry.next;
  2815. // if we didn't call the onwrite immediately, then
  2816. // it means that we need to wait until it does.
  2817. // also, that means that the chunk and cb are currently
  2818. // being processed, so move the buffer counter past them.
  2819. if (state.writing) {
  2820. break;
  2821. }
  2822. }
  2823. if (entry === null) state.lastBufferedRequest = null;
  2824. }
  2825. state.bufferedRequestCount = 0;
  2826. state.bufferedRequest = entry;
  2827. state.bufferProcessing = false;
  2828. }
  2829. Writable.prototype._write = function (chunk, encoding, cb) {
  2830. cb(new Error('_write() is not implemented'));
  2831. };
  2832. Writable.prototype._writev = null;
  2833. Writable.prototype.end = function (chunk, encoding, cb) {
  2834. var state = this._writableState;
  2835. if (typeof chunk === 'function') {
  2836. cb = chunk;
  2837. chunk = null;
  2838. encoding = null;
  2839. } else if (typeof encoding === 'function') {
  2840. cb = encoding;
  2841. encoding = null;
  2842. }
  2843. if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
  2844. // .end() fully uncorks
  2845. if (state.corked) {
  2846. state.corked = 1;
  2847. this.uncork();
  2848. }
  2849. // ignore unnecessary end() calls.
  2850. if (!state.ending && !state.finished) endWritable(this, state, cb);
  2851. };
  2852. function needFinish(state) {
  2853. return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
  2854. }
  2855. function callFinal(stream, state) {
  2856. stream._final(function (err) {
  2857. state.pendingcb--;
  2858. if (err) {
  2859. stream.emit('error', err);
  2860. }
  2861. state.prefinished = true;
  2862. stream.emit('prefinish');
  2863. finishMaybe(stream, state);
  2864. });
  2865. }
  2866. function prefinish(stream, state) {
  2867. if (!state.prefinished && !state.finalCalled) {
  2868. if (typeof stream._final === 'function') {
  2869. state.pendingcb++;
  2870. state.finalCalled = true;
  2871. processNextTick(callFinal, stream, state);
  2872. } else {
  2873. state.prefinished = true;
  2874. stream.emit('prefinish');
  2875. }
  2876. }
  2877. }
  2878. function finishMaybe(stream, state) {
  2879. var need = needFinish(state);
  2880. if (need) {
  2881. prefinish(stream, state);
  2882. if (state.pendingcb === 0) {
  2883. state.finished = true;
  2884. stream.emit('finish');
  2885. }
  2886. }
  2887. return need;
  2888. }
  2889. function endWritable(stream, state, cb) {
  2890. state.ending = true;
  2891. finishMaybe(stream, state);
  2892. if (cb) {
  2893. if (state.finished) processNextTick(cb);else stream.once('finish', cb);
  2894. }
  2895. state.ended = true;
  2896. stream.writable = false;
  2897. }
  2898. function onCorkedFinish(corkReq, state, err) {
  2899. var entry = corkReq.entry;
  2900. corkReq.entry = null;
  2901. while (entry) {
  2902. var cb = entry.callback;
  2903. state.pendingcb--;
  2904. cb(err);
  2905. entry = entry.next;
  2906. }
  2907. if (state.corkedRequestsFree) {
  2908. state.corkedRequestsFree.next = corkReq;
  2909. } else {
  2910. state.corkedRequestsFree = corkReq;
  2911. }
  2912. }
  2913. Object.defineProperty(Writable.prototype, 'destroyed', {
  2914. get: function () {
  2915. if (this._writableState === undefined) {
  2916. return false;
  2917. }
  2918. return this._writableState.destroyed;
  2919. },
  2920. set: function (value) {
  2921. // we ignore the value if the stream
  2922. // has not been initialized yet
  2923. if (!this._writableState) {
  2924. return;
  2925. }
  2926. // backward compatibility, the user is explicitly
  2927. // managing destroyed
  2928. this._writableState.destroyed = value;
  2929. }
  2930. });
  2931. Writable.prototype.destroy = destroyImpl.destroy;
  2932. Writable.prototype._undestroy = destroyImpl.undestroy;
  2933. Writable.prototype._destroy = function (err, cb) {
  2934. this.end();
  2935. cb(err);
  2936. };
  2937. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5), __webpack_require__(28).setImmediate, __webpack_require__(2)))
  2938. /***/ }),
  2939. /* 11 */
  2940. /***/ (function(module, exports, __webpack_require__) {
  2941. "use strict";
  2942. var Buffer = __webpack_require__(7).Buffer;
  2943. var isEncoding = Buffer.isEncoding || function (encoding) {
  2944. encoding = '' + encoding;
  2945. switch (encoding && encoding.toLowerCase()) {
  2946. 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':
  2947. return true;
  2948. default:
  2949. return false;
  2950. }
  2951. };
  2952. function _normalizeEncoding(enc) {
  2953. if (!enc) return 'utf8';
  2954. var retried;
  2955. while (true) {
  2956. switch (enc) {
  2957. case 'utf8':
  2958. case 'utf-8':
  2959. return 'utf8';
  2960. case 'ucs2':
  2961. case 'ucs-2':
  2962. case 'utf16le':
  2963. case 'utf-16le':
  2964. return 'utf16le';
  2965. case 'latin1':
  2966. case 'binary':
  2967. return 'latin1';
  2968. case 'base64':
  2969. case 'ascii':
  2970. case 'hex':
  2971. return enc;
  2972. default:
  2973. if (retried) return; // undefined
  2974. enc = ('' + enc).toLowerCase();
  2975. retried = true;
  2976. }
  2977. }
  2978. };
  2979. // Do not cache `Buffer.isEncoding` when checking encoding names as some
  2980. // modules monkey-patch it to support additional encodings
  2981. function normalizeEncoding(enc) {
  2982. var nenc = _normalizeEncoding(enc);
  2983. if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
  2984. return nenc || enc;
  2985. }
  2986. // StringDecoder provides an interface for efficiently splitting a series of
  2987. // buffers into a series of JS strings without breaking apart multi-byte
  2988. // characters.
  2989. exports.StringDecoder = StringDecoder;
  2990. function StringDecoder(encoding) {
  2991. this.encoding = normalizeEncoding(encoding);
  2992. var nb;
  2993. switch (this.encoding) {
  2994. case 'utf16le':
  2995. this.text = utf16Text;
  2996. this.end = utf16End;
  2997. nb = 4;
  2998. break;
  2999. case 'utf8':
  3000. this.fillLast = utf8FillLast;
  3001. nb = 4;
  3002. break;
  3003. case 'base64':
  3004. this.text = base64Text;
  3005. this.end = base64End;
  3006. nb = 3;
  3007. break;
  3008. default:
  3009. this.write = simpleWrite;
  3010. this.end = simpleEnd;
  3011. return;
  3012. }
  3013. this.lastNeed = 0;
  3014. this.lastTotal = 0;
  3015. this.lastChar = Buffer.allocUnsafe(nb);
  3016. }
  3017. StringDecoder.prototype.write = function (buf) {
  3018. if (buf.length === 0) return '';
  3019. var r;
  3020. var i;
  3021. if (this.lastNeed) {
  3022. r = this.fillLast(buf);
  3023. if (r === undefined) return '';
  3024. i = this.lastNeed;
  3025. this.lastNeed = 0;
  3026. } else {
  3027. i = 0;
  3028. }
  3029. if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
  3030. return r || '';
  3031. };
  3032. StringDecoder.prototype.end = utf8End;
  3033. // Returns only complete characters in a Buffer
  3034. StringDecoder.prototype.text = utf8Text;
  3035. // Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
  3036. StringDecoder.prototype.fillLast = function (buf) {
  3037. if (this.lastNeed <= buf.length) {
  3038. buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
  3039. return this.lastChar.toString(this.encoding, 0, this.lastTotal);
  3040. }
  3041. buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
  3042. this.lastNeed -= buf.length;
  3043. };
  3044. // Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
  3045. // continuation byte.
  3046. function utf8CheckByte(byte) {
  3047. 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;
  3048. return -1;
  3049. }
  3050. // Checks at most 3 bytes at the end of a Buffer in order to detect an
  3051. // incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
  3052. // needed to complete the UTF-8 character (if applicable) are returned.
  3053. function utf8CheckIncomplete(self, buf, i) {
  3054. var j = buf.length - 1;
  3055. if (j < i) return 0;
  3056. var nb = utf8CheckByte(buf[j]);
  3057. if (nb >= 0) {
  3058. if (nb > 0) self.lastNeed = nb - 1;
  3059. return nb;
  3060. }
  3061. if (--j < i) return 0;
  3062. nb = utf8CheckByte(buf[j]);
  3063. if (nb >= 0) {
  3064. if (nb > 0) self.lastNeed = nb - 2;
  3065. return nb;
  3066. }
  3067. if (--j < i) return 0;
  3068. nb = utf8CheckByte(buf[j]);
  3069. if (nb >= 0) {
  3070. if (nb > 0) {
  3071. if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
  3072. }
  3073. return nb;
  3074. }
  3075. return 0;
  3076. }
  3077. // Validates as many continuation bytes for a multi-byte UTF-8 character as
  3078. // needed or are available. If we see a non-continuation byte where we expect
  3079. // one, we "replace" the validated continuation bytes we've seen so far with
  3080. // UTF-8 replacement characters ('\ufffd'), to match v8's UTF-8 decoding
  3081. // behavior. The continuation byte check is included three times in the case
  3082. // where all of the continuation bytes for a character exist in the same buffer.
  3083. // It is also done this way as a slight performance increase instead of using a
  3084. // loop.
  3085. function utf8CheckExtraBytes(self, buf, p) {
  3086. if ((buf[0] & 0xC0) !== 0x80) {
  3087. self.lastNeed = 0;
  3088. return '\ufffd'.repeat(p);
  3089. }
  3090. if (self.lastNeed > 1 && buf.length > 1) {
  3091. if ((buf[1] & 0xC0) !== 0x80) {
  3092. self.lastNeed = 1;
  3093. return '\ufffd'.repeat(p + 1);
  3094. }
  3095. if (self.lastNeed > 2 && buf.length > 2) {
  3096. if ((buf[2] & 0xC0) !== 0x80) {
  3097. self.lastNeed = 2;
  3098. return '\ufffd'.repeat(p + 2);
  3099. }
  3100. }
  3101. }
  3102. }
  3103. // Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
  3104. function utf8FillLast(buf) {
  3105. var p = this.lastTotal - this.lastNeed;
  3106. var r = utf8CheckExtraBytes(this, buf, p);
  3107. if (r !== undefined) return r;
  3108. if (this.lastNeed <= buf.length) {
  3109. buf.copy(this.lastChar, p, 0, this.lastNeed);
  3110. return this.lastChar.toString(this.encoding, 0, this.lastTotal);
  3111. }
  3112. buf.copy(this.lastChar, p, 0, buf.length);
  3113. this.lastNeed -= buf.length;
  3114. }
  3115. // Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
  3116. // partial character, the character's bytes are buffered until the required
  3117. // number of bytes are available.
  3118. function utf8Text(buf, i) {
  3119. var total = utf8CheckIncomplete(this, buf, i);
  3120. if (!this.lastNeed) return buf.toString('utf8', i);
  3121. this.lastTotal = total;
  3122. var end = buf.length - (total - this.lastNeed);
  3123. buf.copy(this.lastChar, 0, end);
  3124. return buf.toString('utf8', i, end);
  3125. }
  3126. // For UTF-8, a replacement character for each buffered byte of a (partial)
  3127. // character needs to be added to the output.
  3128. function utf8End(buf) {
  3129. var r = buf && buf.length ? this.write(buf) : '';
  3130. if (this.lastNeed) return r + '\ufffd'.repeat(this.lastTotal - this.lastNeed);
  3131. return r;
  3132. }
  3133. // UTF-16LE typically needs two bytes per character, but even if we have an even
  3134. // number of bytes available, we need to check if we end on a leading/high
  3135. // surrogate. In that case, we need to wait for the next two bytes in order to
  3136. // decode the last character properly.
  3137. function utf16Text(buf, i) {
  3138. if ((buf.length - i) % 2 === 0) {
  3139. var r = buf.toString('utf16le', i);
  3140. if (r) {
  3141. var c = r.charCodeAt(r.length - 1);
  3142. if (c >= 0xD800 && c <= 0xDBFF) {
  3143. this.lastNeed = 2;
  3144. this.lastTotal = 4;
  3145. this.lastChar[0] = buf[buf.length - 2];
  3146. this.lastChar[1] = buf[buf.length - 1];
  3147. return r.slice(0, -1);
  3148. }
  3149. }
  3150. return r;
  3151. }
  3152. this.lastNeed = 1;
  3153. this.lastTotal = 2;
  3154. this.lastChar[0] = buf[buf.length - 1];
  3155. return buf.toString('utf16le', i, buf.length - 1);
  3156. }
  3157. // For UTF-16LE we do not explicitly append special replacement characters if we
  3158. // end on a partial character, we simply let v8 handle that.
  3159. function utf16End(buf) {
  3160. var r = buf && buf.length ? this.write(buf) : '';
  3161. if (this.lastNeed) {
  3162. var end = this.lastTotal - this.lastNeed;
  3163. return r + this.lastChar.toString('utf16le', 0, end);
  3164. }
  3165. return r;
  3166. }
  3167. function base64Text(buf, i) {
  3168. var n = (buf.length - i) % 3;
  3169. if (n === 0) return buf.toString('base64', i);
  3170. this.lastNeed = 3 - n;
  3171. this.lastTotal = 3;
  3172. if (n === 1) {
  3173. this.lastChar[0] = buf[buf.length - 1];
  3174. } else {
  3175. this.lastChar[0] = buf[buf.length - 2];
  3176. this.lastChar[1] = buf[buf.length - 1];
  3177. }
  3178. return buf.toString('base64', i, buf.length - n);
  3179. }
  3180. function base64End(buf) {
  3181. var r = buf && buf.length ? this.write(buf) : '';
  3182. if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
  3183. return r;
  3184. }
  3185. // Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
  3186. function simpleWrite(buf) {
  3187. return buf.toString(this.encoding);
  3188. }
  3189. function simpleEnd(buf) {
  3190. return buf && buf.length ? this.write(buf) : '';
  3191. }
  3192. /***/ }),
  3193. /* 12 */
  3194. /***/ (function(module, exports, __webpack_require__) {
  3195. var isArray = __webpack_require__(13).isArray;
  3196. module.exports = {
  3197. copyOptions: function (options) {
  3198. var key, copy = {};
  3199. for (key in options) {
  3200. if (options.hasOwnProperty(key)) {
  3201. copy[key] = options[key];
  3202. }
  3203. }
  3204. return copy;
  3205. },
  3206. ensureFlagExists: function (item, options) {
  3207. if (!(item in options) || typeof options[item] !== 'boolean') {
  3208. options[item] = false;
  3209. }
  3210. },
  3211. ensureSpacesExists: function (options) {
  3212. if (!('spaces' in options) || (typeof options.spaces !== 'number' && typeof options.spaces !== 'string')) {
  3213. options.spaces = 0;
  3214. }
  3215. },
  3216. ensureAlwaysArrayExists: function (options) {
  3217. if (!('alwaysArray' in options) || (typeof options.alwaysArray !== 'boolean' && !isArray(options.alwaysArray))) {
  3218. options.alwaysArray = false;
  3219. }
  3220. },
  3221. ensureKeyExists: function (key, options) {
  3222. if (!(key + 'Key' in options) || typeof options[key + 'Key'] !== 'string') {
  3223. options[key + 'Key'] = options.compact ? '_' + key : key;
  3224. }
  3225. },
  3226. checkFnExists: function (key, options) {
  3227. return key + 'Fn' in options;
  3228. }
  3229. };
  3230. /***/ }),
  3231. /* 13 */
  3232. /***/ (function(module, exports) {
  3233. module.exports = {
  3234. isArray: function(value) {
  3235. if (Array.isArray) {
  3236. return Array.isArray(value);
  3237. }
  3238. // fallback for older browsers like IE 8
  3239. return Object.prototype.toString.call( value ) === '[object Array]';
  3240. }
  3241. };
  3242. /***/ }),
  3243. /* 14 */
  3244. /***/ (function(module, exports, __webpack_require__) {
  3245. var sax = __webpack_require__(22);
  3246. var expat /*= require('node-expat');*/ = { on: function () { }, parse: function () { } };
  3247. var helper = __webpack_require__(12);
  3248. var isArray = __webpack_require__(13).isArray;
  3249. var options;
  3250. var pureJsParser = true;
  3251. var currentElement;
  3252. function validateOptions(userOptions) {
  3253. options = helper.copyOptions(userOptions);
  3254. helper.ensureFlagExists('ignoreDeclaration', options);
  3255. helper.ensureFlagExists('ignoreInstruction', options);
  3256. helper.ensureFlagExists('ignoreAttributes', options);
  3257. helper.ensureFlagExists('ignoreText', options);
  3258. helper.ensureFlagExists('ignoreComment', options);
  3259. helper.ensureFlagExists('ignoreCdata', options);
  3260. helper.ensureFlagExists('ignoreDoctype', options);
  3261. helper.ensureFlagExists('compact', options);
  3262. helper.ensureFlagExists('alwaysChildren', options);
  3263. helper.ensureFlagExists('addParent', options);
  3264. helper.ensureFlagExists('trim', options);
  3265. helper.ensureFlagExists('nativeType', options);
  3266. helper.ensureFlagExists('sanitize', options);
  3267. helper.ensureFlagExists('instructionHasAttributes', options);
  3268. helper.ensureFlagExists('captureSpacesBetweenElements', options);
  3269. helper.ensureAlwaysArrayExists(options);
  3270. helper.ensureKeyExists('declaration', options);
  3271. helper.ensureKeyExists('instruction', options);
  3272. helper.ensureKeyExists('attributes', options);
  3273. helper.ensureKeyExists('text', options);
  3274. helper.ensureKeyExists('comment', options);
  3275. helper.ensureKeyExists('cdata', options);
  3276. helper.ensureKeyExists('doctype', options);
  3277. helper.ensureKeyExists('type', options);
  3278. helper.ensureKeyExists('name', options);
  3279. helper.ensureKeyExists('elements', options);
  3280. helper.ensureKeyExists('parent', options);
  3281. helper.checkFnExists('doctype', options);
  3282. helper.checkFnExists('instruction', options);
  3283. helper.checkFnExists('cdata', options);
  3284. helper.checkFnExists('comment', options);
  3285. helper.checkFnExists('text', options);
  3286. helper.checkFnExists('instructionName', options);
  3287. helper.checkFnExists('elementName', options);
  3288. helper.checkFnExists('attributeName', options);
  3289. helper.checkFnExists('attributeValue', options);
  3290. helper.checkFnExists('attributes', options);
  3291. return options;
  3292. }
  3293. function nativeType(value) {
  3294. var nValue = Number(value);
  3295. if (!isNaN(nValue)) {
  3296. return nValue;
  3297. }
  3298. var bValue = value.toLowerCase();
  3299. if (bValue === 'true') {
  3300. return true;
  3301. } else if (bValue === 'false') {
  3302. return false;
  3303. }
  3304. return value;
  3305. }
  3306. function addField(type, value) {
  3307. var key;
  3308. if (options.compact) {
  3309. if (
  3310. !currentElement[options[type + 'Key']] &&
  3311. (isArray(options.alwaysArray) ? options.alwaysArray.indexOf(options[type + 'Key']) !== -1 : options.alwaysArray)
  3312. ) {
  3313. currentElement[options[type + 'Key']] = [];
  3314. }
  3315. if (currentElement[options[type + 'Key']] && !isArray(currentElement[options[type + 'Key']])) {
  3316. currentElement[options[type + 'Key']] = [currentElement[options[type + 'Key']]];
  3317. }
  3318. if (type + 'Fn' in options && typeof value === 'string') {
  3319. value = options[type + 'Fn'](value, currentElement);
  3320. }
  3321. if (type === 'instruction' && ('instructionFn' in options || 'instructionNameFn' in options)) {
  3322. for (key in value) {
  3323. if (value.hasOwnProperty(key)) {
  3324. if ('instructionFn' in options) {
  3325. value[key] = options.instructionFn(value[key], key, currentElement);
  3326. } else {
  3327. var temp = value[key];
  3328. delete value[key];
  3329. value[options.instructionNameFn(key, temp, currentElement)] = temp;
  3330. }
  3331. }
  3332. }
  3333. }
  3334. if (isArray(currentElement[options[type + 'Key']])) {
  3335. currentElement[options[type + 'Key']].push(value);
  3336. } else {
  3337. currentElement[options[type + 'Key']] = value;
  3338. }
  3339. } else {
  3340. if (!currentElement[options.elementsKey]) {
  3341. currentElement[options.elementsKey] = [];
  3342. }
  3343. var element = {};
  3344. element[options.typeKey] = type;
  3345. if (type === 'instruction') {
  3346. for (key in value) {
  3347. if (value.hasOwnProperty(key)) {
  3348. break;
  3349. }
  3350. }
  3351. element[options.nameKey] = 'instructionNameFn' in options ? options.instructionNameFn(key, value, currentElement) : key;
  3352. if (options.instructionHasAttributes) {
  3353. element[options.attributesKey] = value[key][options.attributesKey];
  3354. if ('instructionFn' in options) {
  3355. element[options.attributesKey] = options.instructionFn(element[options.attributesKey], key, currentElement);
  3356. }
  3357. } else {
  3358. if ('instructionFn' in options) {
  3359. value[key] = options.instructionFn(value[key], key, currentElement);
  3360. }
  3361. element[options.instructionKey] = value[key];
  3362. }
  3363. } else {
  3364. if (type + 'Fn' in options) {
  3365. value = options[type + 'Fn'](value, currentElement);
  3366. }
  3367. element[options[type + 'Key']] = value;
  3368. }
  3369. if (options.addParent) {
  3370. element[options.parentKey] = currentElement;
  3371. }
  3372. currentElement[options.elementsKey].push(element);
  3373. }
  3374. }
  3375. function manipulateAttributes(attributes) {
  3376. if ('attributesFn' in options && attributes) {
  3377. attributes = options.attributesFn(attributes, currentElement);
  3378. }
  3379. if ((options.trim || 'attributeValueFn' in options || 'attributeNameFn' in options) && attributes) {
  3380. var key;
  3381. for (key in attributes) {
  3382. if (attributes.hasOwnProperty(key)) {
  3383. if (options.trim) attributes[key] = attributes[key].trim();
  3384. if ('attributeValueFn' in options) attributes[key] = options.attributeValueFn(attributes[key], key, currentElement);
  3385. if ('attributeNameFn' in options) {
  3386. var temp = attributes[key];
  3387. delete attributes[key];
  3388. attributes[options.attributeNameFn(key, attributes[key], currentElement)] = temp;
  3389. }
  3390. }
  3391. }
  3392. }
  3393. return attributes;
  3394. }
  3395. function onInstruction(instruction) {
  3396. var attributes = {};
  3397. if (instruction.body && (instruction.name.toLowerCase() === 'xml' || options.instructionHasAttributes)) {
  3398. var attrsRegExp = /([\w:-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|(\w+))\s*/g;
  3399. var match;
  3400. while ((match = attrsRegExp.exec(instruction.body)) !== null) {
  3401. attributes[match[1]] = match[2] || match[3] || match[4];
  3402. }
  3403. attributes = manipulateAttributes(attributes);
  3404. }
  3405. if (instruction.name.toLowerCase() === 'xml') {
  3406. if (options.ignoreDeclaration) {
  3407. return;
  3408. }
  3409. currentElement[options.declarationKey] = {};
  3410. if (Object.keys(attributes).length) {
  3411. currentElement[options.declarationKey][options.attributesKey] = attributes;
  3412. }
  3413. if (options.addParent) {
  3414. currentElement[options.declarationKey][options.parentKey] = currentElement;
  3415. }
  3416. } else {
  3417. if (options.ignoreInstruction) {
  3418. return;
  3419. }
  3420. if (options.trim) {
  3421. instruction.body = instruction.body.trim();
  3422. }
  3423. var value = {};
  3424. if (options.instructionHasAttributes && Object.keys(attributes).length) {
  3425. value[instruction.name] = {};
  3426. value[instruction.name][options.attributesKey] = attributes;
  3427. } else {
  3428. value[instruction.name] = instruction.body;
  3429. }
  3430. addField('instruction', value);
  3431. }
  3432. }
  3433. function onStartElement(name, attributes) {
  3434. var element;
  3435. if (typeof name === 'object') {
  3436. attributes = name.attributes;
  3437. name = name.name;
  3438. }
  3439. attributes = manipulateAttributes(attributes);
  3440. if ('elementNameFn' in options) {
  3441. name = options.elementNameFn(name, currentElement);
  3442. }
  3443. if (options.compact) {
  3444. element = {};
  3445. if (!options.ignoreAttributes && attributes && Object.keys(attributes).length) {
  3446. element[options.attributesKey] = {};
  3447. var key;
  3448. for (key in attributes) {
  3449. if (attributes.hasOwnProperty(key)) {
  3450. element[options.attributesKey][key] = attributes[key];
  3451. }
  3452. }
  3453. }
  3454. if (
  3455. !(name in currentElement) &&
  3456. (isArray(options.alwaysArray) ? options.alwaysArray.indexOf(name) !== -1 : options.alwaysArray)
  3457. ) {
  3458. currentElement[name] = [];
  3459. }
  3460. if (currentElement[name] && !isArray(currentElement[name])) {
  3461. currentElement[name] = [currentElement[name]];
  3462. }
  3463. if (isArray(currentElement[name])) {
  3464. currentElement[name].push(element);
  3465. } else {
  3466. currentElement[name] = element;
  3467. }
  3468. } else {
  3469. if (!currentElement[options.elementsKey]) {
  3470. currentElement[options.elementsKey] = [];
  3471. }
  3472. element = {};
  3473. element[options.typeKey] = 'element';
  3474. element[options.nameKey] = name;
  3475. if (!options.ignoreAttributes && attributes && Object.keys(attributes).length) {
  3476. element[options.attributesKey] = attributes;
  3477. }
  3478. if (options.alwaysChildren) {
  3479. element[options.elementsKey] = [];
  3480. }
  3481. currentElement[options.elementsKey].push(element);
  3482. }
  3483. element[options.parentKey] = currentElement; // will be deleted in onEndElement() if !options.addParent
  3484. currentElement = element;
  3485. }
  3486. function onText(text) {
  3487. if (options.ignoreText) {
  3488. return;
  3489. }
  3490. if (!text.trim() && !options.captureSpacesBetweenElements) {
  3491. return;
  3492. }
  3493. if (options.trim) {
  3494. text = text.trim();
  3495. }
  3496. if (options.nativeType) {
  3497. text = nativeType(text);
  3498. }
  3499. if (options.sanitize) {
  3500. text = text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
  3501. }
  3502. addField('text', text);
  3503. }
  3504. function onComment(comment) {
  3505. if (options.ignoreComment) {
  3506. return;
  3507. }
  3508. if (options.trim) {
  3509. comment = comment.trim();
  3510. }
  3511. addField('comment', comment);
  3512. }
  3513. function onEndElement(name) {
  3514. var parentElement = currentElement[options.parentKey];
  3515. if (!options.addParent) {
  3516. delete currentElement[options.parentKey];
  3517. }
  3518. currentElement = parentElement;
  3519. }
  3520. function onCdata(cdata) {
  3521. if (options.ignoreCdata) {
  3522. return;
  3523. }
  3524. if (options.trim) {
  3525. cdata = cdata.trim();
  3526. }
  3527. addField('cdata', cdata);
  3528. }
  3529. function onDoctype(doctype) {
  3530. if (options.ignoreDoctype) {
  3531. return;
  3532. }
  3533. doctype = doctype.replace(/^ /, '');
  3534. if (options.trim) {
  3535. doctype = doctype.trim();
  3536. }
  3537. addField('doctype', doctype);
  3538. }
  3539. function onError(error) {
  3540. error.note = error; //console.error(error);
  3541. }
  3542. module.exports = function (xml, userOptions) {
  3543. var parser = pureJsParser ? sax.parser(true, {}) : parser = new expat.Parser('UTF-8');
  3544. var result = {};
  3545. currentElement = result;
  3546. options = validateOptions(userOptions);
  3547. if (pureJsParser) {
  3548. parser.opt = {strictEntities: true};
  3549. parser.onopentag = onStartElement;
  3550. parser.ontext = onText;
  3551. parser.oncomment = onComment;
  3552. parser.onclosetag = onEndElement;
  3553. parser.onerror = onError;
  3554. parser.oncdata = onCdata;
  3555. parser.ondoctype = onDoctype;
  3556. parser.onprocessinginstruction = onInstruction;
  3557. } else {
  3558. parser.on('startElement', onStartElement);
  3559. parser.on('text', onText);
  3560. parser.on('comment', onComment);
  3561. parser.on('endElement', onEndElement);
  3562. parser.on('error', onError);
  3563. //parser.on('startCdata', onStartCdata);
  3564. //parser.on('endCdata', onEndCdata);
  3565. //parser.on('entityDecl', onEntityDecl);
  3566. }
  3567. if (pureJsParser) {
  3568. parser.write(xml).close();
  3569. } else {
  3570. if (!parser.parse(xml)) {
  3571. throw new Error('XML parsing error: ' + parser.getError());
  3572. }
  3573. }
  3574. if (result[options.elementsKey]) {
  3575. var temp = result[options.elementsKey];
  3576. delete result[options.elementsKey];
  3577. result[options.elementsKey] = temp;
  3578. delete result.text;
  3579. }
  3580. return result;
  3581. };
  3582. /***/ }),
  3583. /* 15 */
  3584. /***/ (function(module, exports) {
  3585. var toString = {}.toString;
  3586. module.exports = Array.isArray || function (arr) {
  3587. return toString.call(arr) == '[object Array]';
  3588. };
  3589. /***/ }),
  3590. /* 16 */
  3591. /***/ (function(module, exports, __webpack_require__) {
  3592. "use strict";
  3593. /* WEBPACK VAR INJECTION */(function(global, process) {// Copyright Joyent, Inc. and other Node contributors.
  3594. //
  3595. // Permission is hereby granted, free of charge, to any person obtaining a
  3596. // copy of this software and associated documentation files (the
  3597. // "Software"), to deal in the Software without restriction, including
  3598. // without limitation the rights to use, copy, modify, merge, publish,
  3599. // distribute, sublicense, and/or sell copies of the Software, and to permit
  3600. // persons to whom the Software is furnished to do so, subject to the
  3601. // following conditions:
  3602. //
  3603. // The above copyright notice and this permission notice shall be included
  3604. // in all copies or substantial portions of the Software.
  3605. //
  3606. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  3607. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  3608. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  3609. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  3610. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  3611. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  3612. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  3613. /*<replacement>*/
  3614. var processNextTick = __webpack_require__(6);
  3615. /*</replacement>*/
  3616. module.exports = Readable;
  3617. /*<replacement>*/
  3618. var isArray = __webpack_require__(15);
  3619. /*</replacement>*/
  3620. /*<replacement>*/
  3621. var Duplex;
  3622. /*</replacement>*/
  3623. Readable.ReadableState = ReadableState;
  3624. /*<replacement>*/
  3625. var EE = __webpack_require__(8).EventEmitter;
  3626. var EElistenerCount = function (emitter, type) {
  3627. return emitter.listeners(type).length;
  3628. };
  3629. /*</replacement>*/
  3630. /*<replacement>*/
  3631. var Stream = __webpack_require__(17);
  3632. /*</replacement>*/
  3633. // TODO(bmeurer): Change this back to const once hole checks are
  3634. // properly optimized away early in Ignition+TurboFan.
  3635. /*<replacement>*/
  3636. var Buffer = __webpack_require__(7).Buffer;
  3637. var OurUint8Array = global.Uint8Array || function () {};
  3638. function _uint8ArrayToBuffer(chunk) {
  3639. return Buffer.from(chunk);
  3640. }
  3641. function _isUint8Array(obj) {
  3642. return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
  3643. }
  3644. /*</replacement>*/
  3645. /*<replacement>*/
  3646. var util = __webpack_require__(3);
  3647. util.inherits = __webpack_require__(1);
  3648. /*</replacement>*/
  3649. /*<replacement>*/
  3650. var debugUtil = __webpack_require__(26);
  3651. var debug = void 0;
  3652. if (debugUtil && debugUtil.debuglog) {
  3653. debug = debugUtil.debuglog('stream');
  3654. } else {
  3655. debug = function () {};
  3656. }
  3657. /*</replacement>*/
  3658. var BufferList = __webpack_require__(27);
  3659. var destroyImpl = __webpack_require__(18);
  3660. var StringDecoder;
  3661. util.inherits(Readable, Stream);
  3662. var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
  3663. function prependListener(emitter, event, fn) {
  3664. // Sadly this is not cacheable as some libraries bundle their own
  3665. // event emitter implementation with them.
  3666. if (typeof emitter.prependListener === 'function') {
  3667. return emitter.prependListener(event, fn);
  3668. } else {
  3669. // This is a hack to make sure that our error handler is attached before any
  3670. // userland ones. NEVER DO THIS. This is here only because this code needs
  3671. // to continue to work with older versions of Node.js that do not include
  3672. // the prependListener() method. The goal is to eventually remove this hack.
  3673. 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]];
  3674. }
  3675. }
  3676. function ReadableState(options, stream) {
  3677. Duplex = Duplex || __webpack_require__(0);
  3678. options = options || {};
  3679. // object stream flag. Used to make read(n) ignore n and to
  3680. // make all the buffer merging and length checks go away
  3681. this.objectMode = !!options.objectMode;
  3682. if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
  3683. // the point at which it stops calling _read() to fill the buffer
  3684. // Note: 0 is a valid value, means "don't call _read preemptively ever"
  3685. var hwm = options.highWaterMark;
  3686. var defaultHwm = this.objectMode ? 16 : 16 * 1024;
  3687. this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
  3688. // cast to ints.
  3689. this.highWaterMark = Math.floor(this.highWaterMark);
  3690. // A linked list is used to store data chunks instead of an array because the
  3691. // linked list can remove elements from the beginning faster than
  3692. // array.shift()
  3693. this.buffer = new BufferList();
  3694. this.length = 0;
  3695. this.pipes = null;
  3696. this.pipesCount = 0;
  3697. this.flowing = null;
  3698. this.ended = false;
  3699. this.endEmitted = false;
  3700. this.reading = false;
  3701. // a flag to be able to tell if the event 'readable'/'data' is emitted
  3702. // immediately, or on a later tick. We set this to true at first, because
  3703. // any actions that shouldn't happen until "later" should generally also
  3704. // not happen before the first read call.
  3705. this.sync = true;
  3706. // whenever we return null, then we set a flag to say
  3707. // that we're awaiting a 'readable' event emission.
  3708. this.needReadable = false;
  3709. this.emittedReadable = false;
  3710. this.readableListening = false;
  3711. this.resumeScheduled = false;
  3712. // has it been destroyed
  3713. this.destroyed = false;
  3714. // Crypto is kind of old and crusty. Historically, its default string
  3715. // encoding is 'binary' so we have to make this configurable.
  3716. // Everything else in the universe uses 'utf8', though.
  3717. this.defaultEncoding = options.defaultEncoding || 'utf8';
  3718. // the number of writers that are awaiting a drain event in .pipe()s
  3719. this.awaitDrain = 0;
  3720. // if true, a maybeReadMore has been scheduled
  3721. this.readingMore = false;
  3722. this.decoder = null;
  3723. this.encoding = null;
  3724. if (options.encoding) {
  3725. if (!StringDecoder) StringDecoder = __webpack_require__(11).StringDecoder;
  3726. this.decoder = new StringDecoder(options.encoding);
  3727. this.encoding = options.encoding;
  3728. }
  3729. }
  3730. function Readable(options) {
  3731. Duplex = Duplex || __webpack_require__(0);
  3732. if (!(this instanceof Readable)) return new Readable(options);
  3733. this._readableState = new ReadableState(options, this);
  3734. // legacy
  3735. this.readable = true;
  3736. if (options) {
  3737. if (typeof options.read === 'function') this._read = options.read;
  3738. if (typeof options.destroy === 'function') this._destroy = options.destroy;
  3739. }
  3740. Stream.call(this);
  3741. }
  3742. Object.defineProperty(Readable.prototype, 'destroyed', {
  3743. get: function () {
  3744. if (this._readableState === undefined) {
  3745. return false;
  3746. }
  3747. return this._readableState.destroyed;
  3748. },
  3749. set: function (value) {
  3750. // we ignore the value if the stream
  3751. // has not been initialized yet
  3752. if (!this._readableState) {
  3753. return;
  3754. }
  3755. // backward compatibility, the user is explicitly
  3756. // managing destroyed
  3757. this._readableState.destroyed = value;
  3758. }
  3759. });
  3760. Readable.prototype.destroy = destroyImpl.destroy;
  3761. Readable.prototype._undestroy = destroyImpl.undestroy;
  3762. Readable.prototype._destroy = function (err, cb) {
  3763. this.push(null);
  3764. cb(err);
  3765. };
  3766. // Manually shove something into the read() buffer.
  3767. // This returns true if the highWaterMark has not been hit yet,
  3768. // similar to how Writable.write() returns true if you should
  3769. // write() some more.
  3770. Readable.prototype.push = function (chunk, encoding) {
  3771. var state = this._readableState;
  3772. var skipChunkCheck;
  3773. if (!state.objectMode) {
  3774. if (typeof chunk === 'string') {
  3775. encoding = encoding || state.defaultEncoding;
  3776. if (encoding !== state.encoding) {
  3777. chunk = Buffer.from(chunk, encoding);
  3778. encoding = '';
  3779. }
  3780. skipChunkCheck = true;
  3781. }
  3782. } else {
  3783. skipChunkCheck = true;
  3784. }
  3785. return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
  3786. };
  3787. // Unshift should *always* be something directly out of read()
  3788. Readable.prototype.unshift = function (chunk) {
  3789. return readableAddChunk(this, chunk, null, true, false);
  3790. };
  3791. function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
  3792. var state = stream._readableState;
  3793. if (chunk === null) {
  3794. state.reading = false;
  3795. onEofChunk(stream, state);
  3796. } else {
  3797. var er;
  3798. if (!skipChunkCheck) er = chunkInvalid(state, chunk);
  3799. if (er) {
  3800. stream.emit('error', er);
  3801. } else if (state.objectMode || chunk && chunk.length > 0) {
  3802. if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
  3803. chunk = _uint8ArrayToBuffer(chunk);
  3804. }
  3805. if (addToFront) {
  3806. if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);
  3807. } else if (state.ended) {
  3808. stream.emit('error', new Error('stream.push() after EOF'));
  3809. } else {
  3810. state.reading = false;
  3811. if (state.decoder && !encoding) {
  3812. chunk = state.decoder.write(chunk);
  3813. if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
  3814. } else {
  3815. addChunk(stream, state, chunk, false);
  3816. }
  3817. }
  3818. } else if (!addToFront) {
  3819. state.reading = false;
  3820. }
  3821. }
  3822. return needMoreData(state);
  3823. }
  3824. function addChunk(stream, state, chunk, addToFront) {
  3825. if (state.flowing && state.length === 0 && !state.sync) {
  3826. stream.emit('data', chunk);
  3827. stream.read(0);
  3828. } else {
  3829. // update the buffer info.
  3830. state.length += state.objectMode ? 1 : chunk.length;
  3831. if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
  3832. if (state.needReadable) emitReadable(stream);
  3833. }
  3834. maybeReadMore(stream, state);
  3835. }
  3836. function chunkInvalid(state, chunk) {
  3837. var er;
  3838. if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
  3839. er = new TypeError('Invalid non-string/buffer chunk');
  3840. }
  3841. return er;
  3842. }
  3843. // if it's past the high water mark, we can push in some more.
  3844. // Also, if we have no data yet, we can stand some
  3845. // more bytes. This is to work around cases where hwm=0,
  3846. // such as the repl. Also, if the push() triggered a
  3847. // readable event, and the user called read(largeNumber) such that
  3848. // needReadable was set, then we ought to push more, so that another
  3849. // 'readable' event will be triggered.
  3850. function needMoreData(state) {
  3851. return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
  3852. }
  3853. Readable.prototype.isPaused = function () {
  3854. return this._readableState.flowing === false;
  3855. };
  3856. // backwards compatibility.
  3857. Readable.prototype.setEncoding = function (enc) {
  3858. if (!StringDecoder) StringDecoder = __webpack_require__(11).StringDecoder;
  3859. this._readableState.decoder = new StringDecoder(enc);
  3860. this._readableState.encoding = enc;
  3861. return this;
  3862. };
  3863. // Don't raise the hwm > 8MB
  3864. var MAX_HWM = 0x800000;
  3865. function computeNewHighWaterMark(n) {
  3866. if (n >= MAX_HWM) {
  3867. n = MAX_HWM;
  3868. } else {
  3869. // Get the next highest power of 2 to prevent increasing hwm excessively in
  3870. // tiny amounts
  3871. n--;
  3872. n |= n >>> 1;
  3873. n |= n >>> 2;
  3874. n |= n >>> 4;
  3875. n |= n >>> 8;
  3876. n |= n >>> 16;
  3877. n++;
  3878. }
  3879. return n;
  3880. }
  3881. // This function is designed to be inlinable, so please take care when making
  3882. // changes to the function body.
  3883. function howMuchToRead(n, state) {
  3884. if (n <= 0 || state.length === 0 && state.ended) return 0;
  3885. if (state.objectMode) return 1;
  3886. if (n !== n) {
  3887. // Only flow one buffer at a time
  3888. if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
  3889. }
  3890. // If we're asking for more than the current hwm, then raise the hwm.
  3891. if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
  3892. if (n <= state.length) return n;
  3893. // Don't have enough
  3894. if (!state.ended) {
  3895. state.needReadable = true;
  3896. return 0;
  3897. }
  3898. return state.length;
  3899. }
  3900. // you can override either this method, or the async _read(n) below.
  3901. Readable.prototype.read = function (n) {
  3902. debug('read', n);
  3903. n = parseInt(n, 10);
  3904. var state = this._readableState;
  3905. var nOrig = n;
  3906. if (n !== 0) state.emittedReadable = false;
  3907. // if we're doing read(0) to trigger a readable event, but we
  3908. // already have a bunch of data in the buffer, then just trigger
  3909. // the 'readable' event and move on.
  3910. if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
  3911. debug('read: emitReadable', state.length, state.ended);
  3912. if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
  3913. return null;
  3914. }
  3915. n = howMuchToRead(n, state);
  3916. // if we've ended, and we're now clear, then finish it up.
  3917. if (n === 0 && state.ended) {
  3918. if (state.length === 0) endReadable(this);
  3919. return null;
  3920. }
  3921. // All the actual chunk generation logic needs to be
  3922. // *below* the call to _read. The reason is that in certain
  3923. // synthetic stream cases, such as passthrough streams, _read
  3924. // may be a completely synchronous operation which may change
  3925. // the state of the read buffer, providing enough data when
  3926. // before there was *not* enough.
  3927. //
  3928. // So, the steps are:
  3929. // 1. Figure out what the state of things will be after we do
  3930. // a read from the buffer.
  3931. //
  3932. // 2. If that resulting state will trigger a _read, then call _read.
  3933. // Note that this may be asynchronous, or synchronous. Yes, it is
  3934. // deeply ugly to write APIs this way, but that still doesn't mean
  3935. // that the Readable class should behave improperly, as streams are
  3936. // designed to be sync/async agnostic.
  3937. // Take note if the _read call is sync or async (ie, if the read call
  3938. // has returned yet), so that we know whether or not it's safe to emit
  3939. // 'readable' etc.
  3940. //
  3941. // 3. Actually pull the requested chunks out of the buffer and return.
  3942. // if we need a readable event, then we need to do some reading.
  3943. var doRead = state.needReadable;
  3944. debug('need readable', doRead);
  3945. // if we currently have less than the highWaterMark, then also read some
  3946. if (state.length === 0 || state.length - n < state.highWaterMark) {
  3947. doRead = true;
  3948. debug('length less than watermark', doRead);
  3949. }
  3950. // however, if we've ended, then there's no point, and if we're already
  3951. // reading, then it's unnecessary.
  3952. if (state.ended || state.reading) {
  3953. doRead = false;
  3954. debug('reading or ended', doRead);
  3955. } else if (doRead) {
  3956. debug('do read');
  3957. state.reading = true;
  3958. state.sync = true;
  3959. // if the length is currently zero, then we *need* a readable event.
  3960. if (state.length === 0) state.needReadable = true;
  3961. // call internal read method
  3962. this._read(state.highWaterMark);
  3963. state.sync = false;
  3964. // If _read pushed data synchronously, then `reading` will be false,
  3965. // and we need to re-evaluate how much data we can return to the user.
  3966. if (!state.reading) n = howMuchToRead(nOrig, state);
  3967. }
  3968. var ret;
  3969. if (n > 0) ret = fromList(n, state);else ret = null;
  3970. if (ret === null) {
  3971. state.needReadable = true;
  3972. n = 0;
  3973. } else {
  3974. state.length -= n;
  3975. }
  3976. if (state.length === 0) {
  3977. // If we have nothing in the buffer, then we want to know
  3978. // as soon as we *do* get something into the buffer.
  3979. if (!state.ended) state.needReadable = true;
  3980. // If we tried to read() past the EOF, then emit end on the next tick.
  3981. if (nOrig !== n && state.ended) endReadable(this);
  3982. }
  3983. if (ret !== null) this.emit('data', ret);
  3984. return ret;
  3985. };
  3986. function onEofChunk(stream, state) {
  3987. if (state.ended) return;
  3988. if (state.decoder) {
  3989. var chunk = state.decoder.end();
  3990. if (chunk && chunk.length) {
  3991. state.buffer.push(chunk);
  3992. state.length += state.objectMode ? 1 : chunk.length;
  3993. }
  3994. }
  3995. state.ended = true;
  3996. // emit 'readable' now to make sure it gets picked up.
  3997. emitReadable(stream);
  3998. }
  3999. // Don't emit readable right away in sync mode, because this can trigger
  4000. // another read() call => stack overflow. This way, it might trigger
  4001. // a nextTick recursion warning, but that's not so bad.
  4002. function emitReadable(stream) {
  4003. var state = stream._readableState;
  4004. state.needReadable = false;
  4005. if (!state.emittedReadable) {
  4006. debug('emitReadable', state.flowing);
  4007. state.emittedReadable = true;
  4008. if (state.sync) processNextTick(emitReadable_, stream);else emitReadable_(stream);
  4009. }
  4010. }
  4011. function emitReadable_(stream) {
  4012. debug('emit readable');
  4013. stream.emit('readable');
  4014. flow(stream);
  4015. }
  4016. // at this point, the user has presumably seen the 'readable' event,
  4017. // and called read() to consume some data. that may have triggered
  4018. // in turn another _read(n) call, in which case reading = true if
  4019. // it's in progress.
  4020. // However, if we're not ended, or reading, and the length < hwm,
  4021. // then go ahead and try to read some more preemptively.
  4022. function maybeReadMore(stream, state) {
  4023. if (!state.readingMore) {
  4024. state.readingMore = true;
  4025. processNextTick(maybeReadMore_, stream, state);
  4026. }
  4027. }
  4028. function maybeReadMore_(stream, state) {
  4029. var len = state.length;
  4030. while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
  4031. debug('maybeReadMore read 0');
  4032. stream.read(0);
  4033. if (len === state.length)
  4034. // didn't get any data, stop spinning.
  4035. break;else len = state.length;
  4036. }
  4037. state.readingMore = false;
  4038. }
  4039. // abstract method. to be overridden in specific implementation classes.
  4040. // call cb(er, data) where data is <= n in length.
  4041. // for virtual (non-string, non-buffer) streams, "length" is somewhat
  4042. // arbitrary, and perhaps not very meaningful.
  4043. Readable.prototype._read = function (n) {
  4044. this.emit('error', new Error('_read() is not implemented'));
  4045. };
  4046. Readable.prototype.pipe = function (dest, pipeOpts) {
  4047. var src = this;
  4048. var state = this._readableState;
  4049. switch (state.pipesCount) {
  4050. case 0:
  4051. state.pipes = dest;
  4052. break;
  4053. case 1:
  4054. state.pipes = [state.pipes, dest];
  4055. break;
  4056. default:
  4057. state.pipes.push(dest);
  4058. break;
  4059. }
  4060. state.pipesCount += 1;
  4061. debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
  4062. var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
  4063. var endFn = doEnd ? onend : unpipe;
  4064. if (state.endEmitted) processNextTick(endFn);else src.once('end', endFn);
  4065. dest.on('unpipe', onunpipe);
  4066. function onunpipe(readable, unpipeInfo) {
  4067. debug('onunpipe');
  4068. if (readable === src) {
  4069. if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
  4070. unpipeInfo.hasUnpiped = true;
  4071. cleanup();
  4072. }
  4073. }
  4074. }
  4075. function onend() {
  4076. debug('onend');
  4077. dest.end();
  4078. }
  4079. // when the dest drains, it reduces the awaitDrain counter
  4080. // on the source. This would be more elegant with a .once()
  4081. // handler in flow(), but adding and removing repeatedly is
  4082. // too slow.
  4083. var ondrain = pipeOnDrain(src);
  4084. dest.on('drain', ondrain);
  4085. var cleanedUp = false;
  4086. function cleanup() {
  4087. debug('cleanup');
  4088. // cleanup event handlers once the pipe is broken
  4089. dest.removeListener('close', onclose);
  4090. dest.removeListener('finish', onfinish);
  4091. dest.removeListener('drain', ondrain);
  4092. dest.removeListener('error', onerror);
  4093. dest.removeListener('unpipe', onunpipe);
  4094. src.removeListener('end', onend);
  4095. src.removeListener('end', unpipe);
  4096. src.removeListener('data', ondata);
  4097. cleanedUp = true;
  4098. // if the reader is waiting for a drain event from this
  4099. // specific writer, then it would cause it to never start
  4100. // flowing again.
  4101. // So, if this is awaiting a drain, then we just call it now.
  4102. // If we don't know, then assume that we are waiting for one.
  4103. if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
  4104. }
  4105. // If the user pushes more data while we're writing to dest then we'll end up
  4106. // in ondata again. However, we only want to increase awaitDrain once because
  4107. // dest will only emit one 'drain' event for the multiple writes.
  4108. // => Introduce a guard on increasing awaitDrain.
  4109. var increasedAwaitDrain = false;
  4110. src.on('data', ondata);
  4111. function ondata(chunk) {
  4112. debug('ondata');
  4113. increasedAwaitDrain = false;
  4114. var ret = dest.write(chunk);
  4115. if (false === ret && !increasedAwaitDrain) {
  4116. // If the user unpiped during `dest.write()`, it is possible
  4117. // to get stuck in a permanently paused state if that write
  4118. // also returned false.
  4119. // => Check whether `dest` is still a piping destination.
  4120. if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
  4121. debug('false write response, pause', src._readableState.awaitDrain);
  4122. src._readableState.awaitDrain++;
  4123. increasedAwaitDrain = true;
  4124. }
  4125. src.pause();
  4126. }
  4127. }
  4128. // if the dest has an error, then stop piping into it.
  4129. // however, don't suppress the throwing behavior for this.
  4130. function onerror(er) {
  4131. debug('onerror', er);
  4132. unpipe();
  4133. dest.removeListener('error', onerror);
  4134. if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
  4135. }
  4136. // Make sure our error handler is attached before userland ones.
  4137. prependListener(dest, 'error', onerror);
  4138. // Both close and finish should trigger unpipe, but only once.
  4139. function onclose() {
  4140. dest.removeListener('finish', onfinish);
  4141. unpipe();
  4142. }
  4143. dest.once('close', onclose);
  4144. function onfinish() {
  4145. debug('onfinish');
  4146. dest.removeListener('close', onclose);
  4147. unpipe();
  4148. }
  4149. dest.once('finish', onfinish);
  4150. function unpipe() {
  4151. debug('unpipe');
  4152. src.unpipe(dest);
  4153. }
  4154. // tell the dest that it's being piped to
  4155. dest.emit('pipe', src);
  4156. // start the flow if it hasn't been started already.
  4157. if (!state.flowing) {
  4158. debug('pipe resume');
  4159. src.resume();
  4160. }
  4161. return dest;
  4162. };
  4163. function pipeOnDrain(src) {
  4164. return function () {
  4165. var state = src._readableState;
  4166. debug('pipeOnDrain', state.awaitDrain);
  4167. if (state.awaitDrain) state.awaitDrain--;
  4168. if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
  4169. state.flowing = true;
  4170. flow(src);
  4171. }
  4172. };
  4173. }
  4174. Readable.prototype.unpipe = function (dest) {
  4175. var state = this._readableState;
  4176. var unpipeInfo = { hasUnpiped: false };
  4177. // if we're not piping anywhere, then do nothing.
  4178. if (state.pipesCount === 0) return this;
  4179. // just one destination. most common case.
  4180. if (state.pipesCount === 1) {
  4181. // passed in one, but it's not the right one.
  4182. if (dest && dest !== state.pipes) return this;
  4183. if (!dest) dest = state.pipes;
  4184. // got a match.
  4185. state.pipes = null;
  4186. state.pipesCount = 0;
  4187. state.flowing = false;
  4188. if (dest) dest.emit('unpipe', this, unpipeInfo);
  4189. return this;
  4190. }
  4191. // slow case. multiple pipe destinations.
  4192. if (!dest) {
  4193. // remove all.
  4194. var dests = state.pipes;
  4195. var len = state.pipesCount;
  4196. state.pipes = null;
  4197. state.pipesCount = 0;
  4198. state.flowing = false;
  4199. for (var i = 0; i < len; i++) {
  4200. dests[i].emit('unpipe', this, unpipeInfo);
  4201. }return this;
  4202. }
  4203. // try to find the right one.
  4204. var index = indexOf(state.pipes, dest);
  4205. if (index === -1) return this;
  4206. state.pipes.splice(index, 1);
  4207. state.pipesCount -= 1;
  4208. if (state.pipesCount === 1) state.pipes = state.pipes[0];
  4209. dest.emit('unpipe', this, unpipeInfo);
  4210. return this;
  4211. };
  4212. // set up data events if they are asked for
  4213. // Ensure readable listeners eventually get something
  4214. Readable.prototype.on = function (ev, fn) {
  4215. var res = Stream.prototype.on.call(this, ev, fn);
  4216. if (ev === 'data') {
  4217. // Start flowing on next tick if stream isn't explicitly paused
  4218. if (this._readableState.flowing !== false) this.resume();
  4219. } else if (ev === 'readable') {
  4220. var state = this._readableState;
  4221. if (!state.endEmitted && !state.readableListening) {
  4222. state.readableListening = state.needReadable = true;
  4223. state.emittedReadable = false;
  4224. if (!state.reading) {
  4225. processNextTick(nReadingNextTick, this);
  4226. } else if (state.length) {
  4227. emitReadable(this);
  4228. }
  4229. }
  4230. }
  4231. return res;
  4232. };
  4233. Readable.prototype.addListener = Readable.prototype.on;
  4234. function nReadingNextTick(self) {
  4235. debug('readable nexttick read 0');
  4236. self.read(0);
  4237. }
  4238. // pause() and resume() are remnants of the legacy readable stream API
  4239. // If the user uses them, then switch into old mode.
  4240. Readable.prototype.resume = function () {
  4241. var state = this._readableState;
  4242. if (!state.flowing) {
  4243. debug('resume');
  4244. state.flowing = true;
  4245. resume(this, state);
  4246. }
  4247. return this;
  4248. };
  4249. function resume(stream, state) {
  4250. if (!state.resumeScheduled) {
  4251. state.resumeScheduled = true;
  4252. processNextTick(resume_, stream, state);
  4253. }
  4254. }
  4255. function resume_(stream, state) {
  4256. if (!state.reading) {
  4257. debug('resume read 0');
  4258. stream.read(0);
  4259. }
  4260. state.resumeScheduled = false;
  4261. state.awaitDrain = 0;
  4262. stream.emit('resume');
  4263. flow(stream);
  4264. if (state.flowing && !state.reading) stream.read(0);
  4265. }
  4266. Readable.prototype.pause = function () {
  4267. debug('call pause flowing=%j', this._readableState.flowing);
  4268. if (false !== this._readableState.flowing) {
  4269. debug('pause');
  4270. this._readableState.flowing = false;
  4271. this.emit('pause');
  4272. }
  4273. return this;
  4274. };
  4275. function flow(stream) {
  4276. var state = stream._readableState;
  4277. debug('flow', state.flowing);
  4278. while (state.flowing && stream.read() !== null) {}
  4279. }
  4280. // wrap an old-style stream as the async data source.
  4281. // This is *not* part of the readable stream interface.
  4282. // It is an ugly unfortunate mess of history.
  4283. Readable.prototype.wrap = function (stream) {
  4284. var state = this._readableState;
  4285. var paused = false;
  4286. var self = this;
  4287. stream.on('end', function () {
  4288. debug('wrapped end');
  4289. if (state.decoder && !state.ended) {
  4290. var chunk = state.decoder.end();
  4291. if (chunk && chunk.length) self.push(chunk);
  4292. }
  4293. self.push(null);
  4294. });
  4295. stream.on('data', function (chunk) {
  4296. debug('wrapped data');
  4297. if (state.decoder) chunk = state.decoder.write(chunk);
  4298. // don't skip over falsy values in objectMode
  4299. if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
  4300. var ret = self.push(chunk);
  4301. if (!ret) {
  4302. paused = true;
  4303. stream.pause();
  4304. }
  4305. });
  4306. // proxy all the other methods.
  4307. // important when wrapping filters and duplexes.
  4308. for (var i in stream) {
  4309. if (this[i] === undefined && typeof stream[i] === 'function') {
  4310. this[i] = function (method) {
  4311. return function () {
  4312. return stream[method].apply(stream, arguments);
  4313. };
  4314. }(i);
  4315. }
  4316. }
  4317. // proxy certain important events.
  4318. for (var n = 0; n < kProxyEvents.length; n++) {
  4319. stream.on(kProxyEvents[n], self.emit.bind(self, kProxyEvents[n]));
  4320. }
  4321. // when we try to consume some more bytes, simply unpause the
  4322. // underlying stream.
  4323. self._read = function (n) {
  4324. debug('wrapped _read', n);
  4325. if (paused) {
  4326. paused = false;
  4327. stream.resume();
  4328. }
  4329. };
  4330. return self;
  4331. };
  4332. // exposed for testing purposes only.
  4333. Readable._fromList = fromList;
  4334. // Pluck off n bytes from an array of buffers.
  4335. // Length is the combined lengths of all the buffers in the list.
  4336. // This function is designed to be inlinable, so please take care when making
  4337. // changes to the function body.
  4338. function fromList(n, state) {
  4339. // nothing buffered
  4340. if (state.length === 0) return null;
  4341. var ret;
  4342. if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
  4343. // read it all, truncate the list
  4344. 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);
  4345. state.buffer.clear();
  4346. } else {
  4347. // read part of list
  4348. ret = fromListPartial(n, state.buffer, state.decoder);
  4349. }
  4350. return ret;
  4351. }
  4352. // Extracts only enough buffered data to satisfy the amount requested.
  4353. // This function is designed to be inlinable, so please take care when making
  4354. // changes to the function body.
  4355. function fromListPartial(n, list, hasStrings) {
  4356. var ret;
  4357. if (n < list.head.data.length) {
  4358. // slice is the same for buffers and strings
  4359. ret = list.head.data.slice(0, n);
  4360. list.head.data = list.head.data.slice(n);
  4361. } else if (n === list.head.data.length) {
  4362. // first chunk is a perfect match
  4363. ret = list.shift();
  4364. } else {
  4365. // result spans more than one buffer
  4366. ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
  4367. }
  4368. return ret;
  4369. }
  4370. // Copies a specified amount of characters from the list of buffered data
  4371. // chunks.
  4372. // This function is designed to be inlinable, so please take care when making
  4373. // changes to the function body.
  4374. function copyFromBufferString(n, list) {
  4375. var p = list.head;
  4376. var c = 1;
  4377. var ret = p.data;
  4378. n -= ret.length;
  4379. while (p = p.next) {
  4380. var str = p.data;
  4381. var nb = n > str.length ? str.length : n;
  4382. if (nb === str.length) ret += str;else ret += str.slice(0, n);
  4383. n -= nb;
  4384. if (n === 0) {
  4385. if (nb === str.length) {
  4386. ++c;
  4387. if (p.next) list.head = p.next;else list.head = list.tail = null;
  4388. } else {
  4389. list.head = p;
  4390. p.data = str.slice(nb);
  4391. }
  4392. break;
  4393. }
  4394. ++c;
  4395. }
  4396. list.length -= c;
  4397. return ret;
  4398. }
  4399. // Copies a specified amount of bytes from the list of buffered data chunks.
  4400. // This function is designed to be inlinable, so please take care when making
  4401. // changes to the function body.
  4402. function copyFromBuffer(n, list) {
  4403. var ret = Buffer.allocUnsafe(n);
  4404. var p = list.head;
  4405. var c = 1;
  4406. p.data.copy(ret);
  4407. n -= p.data.length;
  4408. while (p = p.next) {
  4409. var buf = p.data;
  4410. var nb = n > buf.length ? buf.length : n;
  4411. buf.copy(ret, ret.length - n, 0, nb);
  4412. n -= nb;
  4413. if (n === 0) {
  4414. if (nb === buf.length) {
  4415. ++c;
  4416. if (p.next) list.head = p.next;else list.head = list.tail = null;
  4417. } else {
  4418. list.head = p;
  4419. p.data = buf.slice(nb);
  4420. }
  4421. break;
  4422. }
  4423. ++c;
  4424. }
  4425. list.length -= c;
  4426. return ret;
  4427. }
  4428. function endReadable(stream) {
  4429. var state = stream._readableState;
  4430. // If we get here before consuming all the bytes, then that is a
  4431. // bug in node. Should never happen.
  4432. if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
  4433. if (!state.endEmitted) {
  4434. state.ended = true;
  4435. processNextTick(endReadableNT, state, stream);
  4436. }
  4437. }
  4438. function endReadableNT(state, stream) {
  4439. // Check that we didn't get one last unshift.
  4440. if (!state.endEmitted && state.length === 0) {
  4441. state.endEmitted = true;
  4442. stream.readable = false;
  4443. stream.emit('end');
  4444. }
  4445. }
  4446. function forEach(xs, f) {
  4447. for (var i = 0, l = xs.length; i < l; i++) {
  4448. f(xs[i], i);
  4449. }
  4450. }
  4451. function indexOf(xs, x) {
  4452. for (var i = 0, l = xs.length; i < l; i++) {
  4453. if (xs[i] === x) return i;
  4454. }
  4455. return -1;
  4456. }
  4457. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2), __webpack_require__(5)))
  4458. /***/ }),
  4459. /* 17 */
  4460. /***/ (function(module, exports, __webpack_require__) {
  4461. module.exports = __webpack_require__(8).EventEmitter;
  4462. /***/ }),
  4463. /* 18 */
  4464. /***/ (function(module, exports, __webpack_require__) {
  4465. "use strict";
  4466. /*<replacement>*/
  4467. var processNextTick = __webpack_require__(6);
  4468. /*</replacement>*/
  4469. // undocumented cb() API, needed for core, not for public API
  4470. function destroy(err, cb) {
  4471. var _this = this;
  4472. var readableDestroyed = this._readableState && this._readableState.destroyed;
  4473. var writableDestroyed = this._writableState && this._writableState.destroyed;
  4474. if (readableDestroyed || writableDestroyed) {
  4475. if (cb) {
  4476. cb(err);
  4477. } else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
  4478. processNextTick(emitErrorNT, this, err);
  4479. }
  4480. return;
  4481. }
  4482. // we set destroyed to true before firing error callbacks in order
  4483. // to make it re-entrance safe in case destroy() is called within callbacks
  4484. if (this._readableState) {
  4485. this._readableState.destroyed = true;
  4486. }
  4487. // if this is a duplex stream mark the writable part as destroyed as well
  4488. if (this._writableState) {
  4489. this._writableState.destroyed = true;
  4490. }
  4491. this._destroy(err || null, function (err) {
  4492. if (!cb && err) {
  4493. processNextTick(emitErrorNT, _this, err);
  4494. if (_this._writableState) {
  4495. _this._writableState.errorEmitted = true;
  4496. }
  4497. } else if (cb) {
  4498. cb(err);
  4499. }
  4500. });
  4501. }
  4502. function undestroy() {
  4503. if (this._readableState) {
  4504. this._readableState.destroyed = false;
  4505. this._readableState.reading = false;
  4506. this._readableState.ended = false;
  4507. this._readableState.endEmitted = false;
  4508. }
  4509. if (this._writableState) {
  4510. this._writableState.destroyed = false;
  4511. this._writableState.ended = false;
  4512. this._writableState.ending = false;
  4513. this._writableState.finished = false;
  4514. this._writableState.errorEmitted = false;
  4515. }
  4516. }
  4517. function emitErrorNT(self, err) {
  4518. self.emit('error', err);
  4519. }
  4520. module.exports = {
  4521. destroy: destroy,
  4522. undestroy: undestroy
  4523. };
  4524. /***/ }),
  4525. /* 19 */
  4526. /***/ (function(module, exports, __webpack_require__) {
  4527. "use strict";
  4528. // Copyright Joyent, Inc. and other Node contributors.
  4529. //
  4530. // Permission is hereby granted, free of charge, to any person obtaining a
  4531. // copy of this software and associated documentation files (the
  4532. // "Software"), to deal in the Software without restriction, including
  4533. // without limitation the rights to use, copy, modify, merge, publish,
  4534. // distribute, sublicense, and/or sell copies of the Software, and to permit
  4535. // persons to whom the Software is furnished to do so, subject to the
  4536. // following conditions:
  4537. //
  4538. // The above copyright notice and this permission notice shall be included
  4539. // in all copies or substantial portions of the Software.
  4540. //
  4541. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  4542. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  4543. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  4544. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  4545. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  4546. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  4547. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  4548. // a transform stream is a readable/writable stream where you do
  4549. // something with the data. Sometimes it's called a "filter",
  4550. // but that's not a great name for it, since that implies a thing where
  4551. // some bits pass through, and others are simply ignored. (That would
  4552. // be a valid example of a transform, of course.)
  4553. //
  4554. // While the output is causally related to the input, it's not a
  4555. // necessarily symmetric or synchronous transformation. For example,
  4556. // a zlib stream might take multiple plain-text writes(), and then
  4557. // emit a single compressed chunk some time in the future.
  4558. //
  4559. // Here's how this works:
  4560. //
  4561. // The Transform stream has all the aspects of the readable and writable
  4562. // stream classes. When you write(chunk), that calls _write(chunk,cb)
  4563. // internally, and returns false if there's a lot of pending writes
  4564. // buffered up. When you call read(), that calls _read(n) until
  4565. // there's enough pending readable data buffered up.
  4566. //
  4567. // In a transform stream, the written data is placed in a buffer. When
  4568. // _read(n) is called, it transforms the queued up data, calling the
  4569. // buffered _write cb's as it consumes chunks. If consuming a single
  4570. // written chunk would result in multiple output chunks, then the first
  4571. // outputted bit calls the readcb, and subsequent chunks just go into
  4572. // the read buffer, and will cause it to emit 'readable' if necessary.
  4573. //
  4574. // This way, back-pressure is actually determined by the reading side,
  4575. // since _read has to be called to start processing a new chunk. However,
  4576. // a pathological inflate type of transform can cause excessive buffering
  4577. // here. For example, imagine a stream where every byte of input is
  4578. // interpreted as an integer from 0-255, and then results in that many
  4579. // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
  4580. // 1kb of data being output. In this case, you could write a very small
  4581. // amount of input, and end up with a very large amount of output. In
  4582. // such a pathological inflating mechanism, there'd be no way to tell
  4583. // the system to stop doing the transform. A single 4MB write could
  4584. // cause the system to run out of memory.
  4585. //
  4586. // However, even in such a pathological case, only a single written chunk
  4587. // would be consumed, and then the rest would wait (un-transformed) until
  4588. // the results of the previous transformed chunk were consumed.
  4589. module.exports = Transform;
  4590. var Duplex = __webpack_require__(0);
  4591. /*<replacement>*/
  4592. var util = __webpack_require__(3);
  4593. util.inherits = __webpack_require__(1);
  4594. /*</replacement>*/
  4595. util.inherits(Transform, Duplex);
  4596. function TransformState(stream) {
  4597. this.afterTransform = function (er, data) {
  4598. return afterTransform(stream, er, data);
  4599. };
  4600. this.needTransform = false;
  4601. this.transforming = false;
  4602. this.writecb = null;
  4603. this.writechunk = null;
  4604. this.writeencoding = null;
  4605. }
  4606. function afterTransform(stream, er, data) {
  4607. var ts = stream._transformState;
  4608. ts.transforming = false;
  4609. var cb = ts.writecb;
  4610. if (!cb) {
  4611. return stream.emit('error', new Error('write callback called multiple times'));
  4612. }
  4613. ts.writechunk = null;
  4614. ts.writecb = null;
  4615. if (data !== null && data !== undefined) stream.push(data);
  4616. cb(er);
  4617. var rs = stream._readableState;
  4618. rs.reading = false;
  4619. if (rs.needReadable || rs.length < rs.highWaterMark) {
  4620. stream._read(rs.highWaterMark);
  4621. }
  4622. }
  4623. function Transform(options) {
  4624. if (!(this instanceof Transform)) return new Transform(options);
  4625. Duplex.call(this, options);
  4626. this._transformState = new TransformState(this);
  4627. var stream = this;
  4628. // start out asking for a readable event once data is transformed.
  4629. this._readableState.needReadable = true;
  4630. // we have implemented the _read method, and done the other things
  4631. // that Readable wants before the first _read call, so unset the
  4632. // sync guard flag.
  4633. this._readableState.sync = false;
  4634. if (options) {
  4635. if (typeof options.transform === 'function') this._transform = options.transform;
  4636. if (typeof options.flush === 'function') this._flush = options.flush;
  4637. }
  4638. // When the writable side finishes, then flush out anything remaining.
  4639. this.once('prefinish', function () {
  4640. if (typeof this._flush === 'function') this._flush(function (er, data) {
  4641. done(stream, er, data);
  4642. });else done(stream);
  4643. });
  4644. }
  4645. Transform.prototype.push = function (chunk, encoding) {
  4646. this._transformState.needTransform = false;
  4647. return Duplex.prototype.push.call(this, chunk, encoding);
  4648. };
  4649. // This is the part where you do stuff!
  4650. // override this function in implementation classes.
  4651. // 'chunk' is an input chunk.
  4652. //
  4653. // Call `push(newChunk)` to pass along transformed output
  4654. // to the readable side. You may call 'push' zero or more times.
  4655. //
  4656. // Call `cb(err)` when you are done with this chunk. If you pass
  4657. // an error, then that'll put the hurt on the whole operation. If you
  4658. // never call cb(), then you'll never get another chunk.
  4659. Transform.prototype._transform = function (chunk, encoding, cb) {
  4660. throw new Error('_transform() is not implemented');
  4661. };
  4662. Transform.prototype._write = function (chunk, encoding, cb) {
  4663. var ts = this._transformState;
  4664. ts.writecb = cb;
  4665. ts.writechunk = chunk;
  4666. ts.writeencoding = encoding;
  4667. if (!ts.transforming) {
  4668. var rs = this._readableState;
  4669. if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
  4670. }
  4671. };
  4672. // Doesn't matter what the args are here.
  4673. // _transform does all the work.
  4674. // That we got here means that the readable side wants more data.
  4675. Transform.prototype._read = function (n) {
  4676. var ts = this._transformState;
  4677. if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
  4678. ts.transforming = true;
  4679. this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
  4680. } else {
  4681. // mark that we need a transform, so that any data that comes in
  4682. // will get processed, now that we've asked for it.
  4683. ts.needTransform = true;
  4684. }
  4685. };
  4686. Transform.prototype._destroy = function (err, cb) {
  4687. var _this = this;
  4688. Duplex.prototype._destroy.call(this, err, function (err2) {
  4689. cb(err2);
  4690. _this.emit('close');
  4691. });
  4692. };
  4693. function done(stream, er, data) {
  4694. if (er) return stream.emit('error', er);
  4695. if (data !== null && data !== undefined) stream.push(data);
  4696. // if there's nothing in the write buffer, then that means
  4697. // that nothing more will ever be provided
  4698. var ws = stream._writableState;
  4699. var ts = stream._transformState;
  4700. if (ws.length) throw new Error('Calling transform done when ws.length != 0');
  4701. if (ts.transforming) throw new Error('Calling transform done when still transforming');
  4702. return stream.push(null);
  4703. }
  4704. /***/ }),
  4705. /* 20 */
  4706. /***/ (function(module, exports, __webpack_require__) {
  4707. var helper = __webpack_require__(12);
  4708. var isArray = __webpack_require__(13).isArray;
  4709. var currentElement, currentElementName;
  4710. function validateOptions(userOptions) {
  4711. var options = helper.copyOptions(userOptions);
  4712. helper.ensureFlagExists('ignoreDeclaration', options);
  4713. helper.ensureFlagExists('ignoreInstruction', options);
  4714. helper.ensureFlagExists('ignoreAttributes', options);
  4715. helper.ensureFlagExists('ignoreText', options);
  4716. helper.ensureFlagExists('ignoreComment', options);
  4717. helper.ensureFlagExists('ignoreCdata', options);
  4718. helper.ensureFlagExists('ignoreDoctype', options);
  4719. helper.ensureFlagExists('compact', options);
  4720. helper.ensureFlagExists('indentText', options);
  4721. helper.ensureFlagExists('indentCdata', options);
  4722. helper.ensureFlagExists('indentAttributes', options);
  4723. helper.ensureFlagExists('indentInstruction', options);
  4724. helper.ensureFlagExists('fullTagEmptyElement', options);
  4725. helper.ensureFlagExists('noQuotesForNativeAttributes', options);
  4726. helper.ensureSpacesExists(options);
  4727. if (typeof options.spaces === 'number') {
  4728. options.spaces = Array(options.spaces + 1).join(' ');
  4729. }
  4730. helper.ensureKeyExists('declaration', options);
  4731. helper.ensureKeyExists('instruction', options);
  4732. helper.ensureKeyExists('attributes', options);
  4733. helper.ensureKeyExists('text', options);
  4734. helper.ensureKeyExists('comment', options);
  4735. helper.ensureKeyExists('cdata', options);
  4736. helper.ensureKeyExists('doctype', options);
  4737. helper.ensureKeyExists('type', options);
  4738. helper.ensureKeyExists('name', options);
  4739. helper.ensureKeyExists('elements', options);
  4740. helper.checkFnExists('doctype', options);
  4741. helper.checkFnExists('instruction', options);
  4742. helper.checkFnExists('cdata', options);
  4743. helper.checkFnExists('comment', options);
  4744. helper.checkFnExists('text', options);
  4745. helper.checkFnExists('instructionName', options);
  4746. helper.checkFnExists('elementName', options);
  4747. helper.checkFnExists('attributeName', options);
  4748. helper.checkFnExists('attributeValue', options);
  4749. helper.checkFnExists('attributes', options);
  4750. helper.checkFnExists('fullTagEmptyElement', options);
  4751. return options;
  4752. }
  4753. function writeIndentation(options, depth, firstLine) {
  4754. return (!firstLine && options.spaces ? '\n' : '') + Array(depth + 1).join(options.spaces);
  4755. }
  4756. function writeAttributes(attributes, options, depth) {
  4757. if (options.ignoreAttributes) {
  4758. return '';
  4759. }
  4760. if ('attributesFn' in options) {
  4761. attributes = options.attributesFn(attributes, currentElementName, currentElement);
  4762. }
  4763. var key, attr, attrName, quote, result = '';
  4764. for (key in attributes) {
  4765. if (attributes.hasOwnProperty(key)) {
  4766. quote = options.noQuotesForNativeAttributes && typeof attributes[key] !== 'string' ? '' : '"';
  4767. attr = '' + attributes[key]; // ensure number and boolean are converted to String
  4768. attr = attr.replace(/"/g, '&quot;');
  4769. attrName = 'attributeNameFn' in options ? options.attributeNameFn(key, attr, currentElementName, currentElement) : key;
  4770. result += (options.spaces && options.indentAttributes? writeIndentation(options, depth+1, false) : ' ');
  4771. result += attrName + '=' + quote + ('attributeValueFn' in options ? options.attributeValueFn(attr, key, currentElementName, currentElement) : attr) + quote;
  4772. }
  4773. }
  4774. if (attributes && Object.keys(attributes).length && options.spaces && options.indentAttributes) {
  4775. result += writeIndentation(options, depth, false);
  4776. }
  4777. return result;
  4778. }
  4779. function writeDeclaration(declaration, options, depth) {
  4780. currentElement = declaration;
  4781. currentElementName = 'xml';
  4782. return options.ignoreDeclaration ? '' : '<?' + 'xml' + writeAttributes(declaration[options.attributesKey], options, depth) + '?>';
  4783. }
  4784. function writeInstruction(instruction, options, depth) {
  4785. if (options.ignoreInstruction) {
  4786. return '';
  4787. }
  4788. var key;
  4789. for (key in instruction) {
  4790. if (instruction.hasOwnProperty(key)) {
  4791. break;
  4792. }
  4793. }
  4794. var instructionName = 'instructionNameFn' in options ? options.instructionNameFn(key, instruction[key], currentElementName, currentElement) : key;
  4795. if (typeof instruction[key] === 'object') {
  4796. currentElement = instruction;
  4797. currentElementName = instructionName;
  4798. return '<?' + instructionName + writeAttributes(instruction[key][options.attributesKey], options, depth) + '?>';
  4799. } else {
  4800. var instructionValue = instruction[key] ? instruction[key] : '';
  4801. if ('instructionFn' in options) instructionValue = options.instructionFn(instructionValue, key, currentElementName, currentElement);
  4802. return '<?' + instructionName + (instructionValue ? ' ' + instructionValue : '') + '?>';
  4803. }
  4804. }
  4805. function writeComment(comment, options) {
  4806. return options.ignoreComment ? '' : '<!--' + ('commentFn' in options ? options.commentFn(comment, currentElementName, currentElement) : comment) + '-->';
  4807. }
  4808. function writeCdata(cdata, options) {
  4809. return options.ignoreCdata ? '' : '<![CDATA[' + ('cdataFn' in options ? options.cdataFn(cdata, currentElementName, currentElement) : cdata) + ']]>';
  4810. }
  4811. function writeDoctype(doctype, options) {
  4812. return options.ignoreDoctype ? '' : '<!DOCTYPE ' + ('doctypeFn' in options ? options.doctypeFn(doctype, currentElementName, currentElement) : doctype) + '>';
  4813. }
  4814. function writeText(text, options) {
  4815. if (options.ignoreText) return '';
  4816. text = '' + text; // ensure Number and Boolean are converted to String
  4817. text = text.replace(/&amp;/g, '&'); // desanitize to avoid double sanitization
  4818. text = text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
  4819. return 'textFn' in options ? options.textFn(text, currentElementName, currentElement) : text;
  4820. }
  4821. function hasContent(element, options) {
  4822. var i;
  4823. if (element.elements && element.elements.length) {
  4824. for (i = 0; i < element.elements.length; ++i) {
  4825. switch (element.elements[i][options.typeKey]) {
  4826. case 'text':
  4827. if (options.indentText) {
  4828. return true;
  4829. }
  4830. break; // skip to next key
  4831. case 'cdata':
  4832. if (options.indentCdata) {
  4833. return true;
  4834. }
  4835. break; // skip to next key
  4836. case 'instruction':
  4837. if (options.indentInstruction) {
  4838. return true;
  4839. }
  4840. break; // skip to next key
  4841. case 'doctype':
  4842. case 'comment':
  4843. case 'element':
  4844. return true;
  4845. default:
  4846. return true;
  4847. }
  4848. }
  4849. }
  4850. return false;
  4851. }
  4852. function writeElement(element, options, depth) {
  4853. currentElement = element;
  4854. currentElementName = element.name;
  4855. var xml = '', elementName = 'elementNameFn' in options ? options.elementNameFn(element.name, element) : element.name;
  4856. xml += '<' + elementName;
  4857. if (element[options.attributesKey]) {
  4858. xml += writeAttributes(element[options.attributesKey], options, depth);
  4859. }
  4860. var withClosingTag = element[options.elementsKey] && element[options.elementsKey].length || element[options.attributesKey] && element[options.attributesKey]['xml:space'] === 'preserve';
  4861. if (!withClosingTag) {
  4862. if ('fullTagEmptyElementFn' in options) {
  4863. withClosingTag = options.fullTagEmptyElementFn(element.name, element);
  4864. } else {
  4865. withClosingTag = options.fullTagEmptyElement;
  4866. }
  4867. }
  4868. if (withClosingTag) {
  4869. xml += '>';
  4870. if (element[options.elementsKey] && element[options.elementsKey].length) {
  4871. xml += writeElements(element[options.elementsKey], options, depth + 1);
  4872. currentElement = element;
  4873. currentElementName = element.name;
  4874. }
  4875. xml += options.spaces && hasContent(element, options) ? '\n' + Array(depth + 1).join(options.spaces) : '';
  4876. xml += '</' + elementName + '>';
  4877. } else {
  4878. xml += '/>';
  4879. }
  4880. return xml;
  4881. }
  4882. function writeElements(elements, options, depth, firstLine) {
  4883. return elements.reduce(function (xml, element) {
  4884. var indent = writeIndentation(options, depth, firstLine && !xml);
  4885. switch (element.type) {
  4886. case 'element': return xml + indent + writeElement(element, options, depth);
  4887. case 'comment': return xml + indent + writeComment(element[options.commentKey], options);
  4888. case 'doctype': return xml + indent + writeDoctype(element[options.doctypeKey], options);
  4889. case 'cdata': return xml + (options.indentCdata ? indent : '') + writeCdata(element[options.cdataKey], options);
  4890. case 'text': return xml + (options.indentText ? indent : '') + writeText(element[options.textKey], options);
  4891. case 'instruction':
  4892. var instruction = {};
  4893. instruction[element[options.nameKey]] = element[options.attributesKey] ? element : element[options.instructionKey];
  4894. return xml + (options.indentInstruction ? indent : '') + writeInstruction(instruction, options, depth);
  4895. }
  4896. }, '');
  4897. }
  4898. function hasContentCompact(element, options, anyContent) {
  4899. var key;
  4900. for (key in element) {
  4901. if (element.hasOwnProperty(key)) {
  4902. switch (key) {
  4903. case options.parentKey:
  4904. case options.attributesKey:
  4905. break; // skip to next key
  4906. case options.textKey:
  4907. if (options.indentText || anyContent) {
  4908. return true;
  4909. }
  4910. break; // skip to next key
  4911. case options.cdataKey:
  4912. if (options.indentCdata || anyContent) {
  4913. return true;
  4914. }
  4915. break; // skip to next key
  4916. case options.instructionKey:
  4917. if (options.indentInstruction || anyContent) {
  4918. return true;
  4919. }
  4920. break; // skip to next key
  4921. case options.doctypeKey:
  4922. case options.commentKey:
  4923. return true;
  4924. default:
  4925. return true;
  4926. }
  4927. }
  4928. }
  4929. return false;
  4930. }
  4931. function writeElementCompact(element, name, options, depth, indent) {
  4932. currentElement = element;
  4933. currentElementName = name;
  4934. var elementName = 'elementNameFn' in options ? options.elementNameFn(name, element) : name;
  4935. if (typeof element === 'undefined' || element === null) {
  4936. return 'fullTagEmptyElementFn' in options && options.fullTagEmptyElementFn(name, element) || options.fullTagEmptyElement ? '<' + elementName + '></' + elementName + '>' : '<' + elementName + '/>';
  4937. }
  4938. var xml = '';
  4939. if (name) {
  4940. xml += '<' + elementName;
  4941. if (typeof element !== 'object') {
  4942. xml += '>' + writeText(element,options) + '</' + elementName + '>';
  4943. return xml;
  4944. }
  4945. if (element[options.attributesKey]) {
  4946. xml += writeAttributes(element[options.attributesKey], options, depth);
  4947. }
  4948. var withClosingTag = hasContentCompact(element, options, true) || element[options.attributesKey] && element[options.attributesKey]['xml:space'] === 'preserve';
  4949. if (!withClosingTag) {
  4950. if ('fullTagEmptyElementFn' in options) {
  4951. withClosingTag = options.fullTagEmptyElementFn(name, element);
  4952. } else {
  4953. withClosingTag = options.fullTagEmptyElement;
  4954. }
  4955. }
  4956. if (withClosingTag) {
  4957. xml += '>';
  4958. } else {
  4959. xml += '/>';
  4960. return xml;
  4961. }
  4962. }
  4963. xml += writeElementsCompact(element, options, depth + 1, false);
  4964. currentElement = element;
  4965. currentElementName = name;
  4966. if (name) {
  4967. xml += (indent ? writeIndentation(options, depth, false) : '') + '</' + elementName + '>';
  4968. }
  4969. return xml;
  4970. }
  4971. function writeElementsCompact(element, options, depth, firstLine) {
  4972. var i, key, nodes, xml = '';
  4973. for (key in element) {
  4974. if (element.hasOwnProperty(key)) {
  4975. nodes = isArray(element[key]) ? element[key] : [element[key]];
  4976. for (i = 0; i < nodes.length; ++i) {
  4977. switch (key) {
  4978. case options.declarationKey: xml += writeDeclaration(nodes[i], options, depth); break;
  4979. case options.instructionKey: xml += (options.indentInstruction ? writeIndentation(options, depth, firstLine) : '') + writeInstruction(nodes[i], options, depth); break;
  4980. case options.attributesKey: case options.parentKey: break; // skip
  4981. case options.textKey: xml += (options.indentText ? writeIndentation(options, depth, firstLine) : '') + writeText(nodes[i], options); break;
  4982. case options.cdataKey: xml += (options.indentCdata ? writeIndentation(options, depth, firstLine) : '') + writeCdata(nodes[i], options); break;
  4983. case options.doctypeKey: xml += writeIndentation(options, depth, firstLine) + writeDoctype(nodes[i], options); break;
  4984. case options.commentKey: xml += writeIndentation(options, depth, firstLine) + writeComment(nodes[i], options); break;
  4985. default: xml += writeIndentation(options, depth, firstLine) + writeElementCompact(nodes[i], key, options, depth, hasContentCompact(nodes[i], options));
  4986. }
  4987. firstLine = firstLine && !xml;
  4988. }
  4989. }
  4990. }
  4991. return xml;
  4992. }
  4993. module.exports = function (js, options) {
  4994. options = validateOptions(options);
  4995. var xml = '';
  4996. currentElement = js;
  4997. currentElementName = '_root_';
  4998. if (options.compact) {
  4999. xml = writeElementsCompact(js, options, 0, true);
  5000. } else {
  5001. if (js[options.declarationKey]) {
  5002. xml += writeDeclaration(js[options.declarationKey], options, 0);
  5003. }
  5004. if (js[options.elementsKey] && js[options.elementsKey].length) {
  5005. xml += writeElements(js[options.elementsKey], options, 0, !xml);
  5006. }
  5007. }
  5008. return xml;
  5009. };
  5010. /***/ }),
  5011. /* 21 */
  5012. /***/ (function(module, exports, __webpack_require__) {
  5013. /*jslint node:true */
  5014. var xml2js = __webpack_require__(14);
  5015. var xml2json = __webpack_require__(36);
  5016. var js2xml = __webpack_require__(20);
  5017. var json2xml = __webpack_require__(37);
  5018. module.exports = {
  5019. xml2js: xml2js,
  5020. xml2json: xml2json,
  5021. js2xml: js2xml,
  5022. json2xml: json2xml
  5023. };
  5024. /***/ }),
  5025. /* 22 */
  5026. /***/ (function(module, exports, __webpack_require__) {
  5027. /* WEBPACK VAR INJECTION */(function(Buffer) {;(function (sax) { // wrapper for non-node envs
  5028. sax.parser = function (strict, opt) { return new SAXParser(strict, opt) }
  5029. sax.SAXParser = SAXParser
  5030. sax.SAXStream = SAXStream
  5031. sax.createStream = createStream
  5032. // When we pass the MAX_BUFFER_LENGTH position, start checking for buffer overruns.
  5033. // When we check, schedule the next check for MAX_BUFFER_LENGTH - (max(buffer lengths)),
  5034. // since that's the earliest that a buffer overrun could occur. This way, checks are
  5035. // as rare as required, but as often as necessary to ensure never crossing this bound.
  5036. // Furthermore, buffers are only tested at most once per write(), so passing a very
  5037. // large string into write() might have undesirable effects, but this is manageable by
  5038. // the caller, so it is assumed to be safe. Thus, a call to write() may, in the extreme
  5039. // edge case, result in creating at most one complete copy of the string passed in.
  5040. // Set to Infinity to have unlimited buffers.
  5041. sax.MAX_BUFFER_LENGTH = 64 * 1024
  5042. var buffers = [
  5043. 'comment', 'sgmlDecl', 'textNode', 'tagName', 'doctype',
  5044. 'procInstName', 'procInstBody', 'entity', 'attribName',
  5045. 'attribValue', 'cdata', 'script'
  5046. ]
  5047. sax.EVENTS = [
  5048. 'text',
  5049. 'processinginstruction',
  5050. 'sgmldeclaration',
  5051. 'doctype',
  5052. 'comment',
  5053. 'opentagstart',
  5054. 'attribute',
  5055. 'opentag',
  5056. 'closetag',
  5057. 'opencdata',
  5058. 'cdata',
  5059. 'closecdata',
  5060. 'error',
  5061. 'end',
  5062. 'ready',
  5063. 'script',
  5064. 'opennamespace',
  5065. 'closenamespace'
  5066. ]
  5067. function SAXParser (strict, opt) {
  5068. if (!(this instanceof SAXParser)) {
  5069. return new SAXParser(strict, opt)
  5070. }
  5071. var parser = this
  5072. clearBuffers(parser)
  5073. parser.q = parser.c = ''
  5074. parser.bufferCheckPosition = sax.MAX_BUFFER_LENGTH
  5075. parser.opt = opt || {}
  5076. parser.opt.lowercase = parser.opt.lowercase || parser.opt.lowercasetags
  5077. parser.looseCase = parser.opt.lowercase ? 'toLowerCase' : 'toUpperCase'
  5078. parser.tags = []
  5079. parser.closed = parser.closedRoot = parser.sawRoot = false
  5080. parser.tag = parser.error = null
  5081. parser.strict = !!strict
  5082. parser.noscript = !!(strict || parser.opt.noscript)
  5083. parser.state = S.BEGIN
  5084. parser.strictEntities = parser.opt.strictEntities
  5085. parser.ENTITIES = parser.strictEntities ? Object.create(sax.XML_ENTITIES) : Object.create(sax.ENTITIES)
  5086. parser.attribList = []
  5087. // namespaces form a prototype chain.
  5088. // it always points at the current tag,
  5089. // which protos to its parent tag.
  5090. if (parser.opt.xmlns) {
  5091. parser.ns = Object.create(rootNS)
  5092. }
  5093. // mostly just for error reporting
  5094. parser.trackPosition = parser.opt.position !== false
  5095. if (parser.trackPosition) {
  5096. parser.position = parser.line = parser.column = 0
  5097. }
  5098. emit(parser, 'onready')
  5099. }
  5100. if (!Object.create) {
  5101. Object.create = function (o) {
  5102. function F () {}
  5103. F.prototype = o
  5104. var newf = new F()
  5105. return newf
  5106. }
  5107. }
  5108. if (!Object.keys) {
  5109. Object.keys = function (o) {
  5110. var a = []
  5111. for (var i in o) if (o.hasOwnProperty(i)) a.push(i)
  5112. return a
  5113. }
  5114. }
  5115. function checkBufferLength (parser) {
  5116. var maxAllowed = Math.max(sax.MAX_BUFFER_LENGTH, 10)
  5117. var maxActual = 0
  5118. for (var i = 0, l = buffers.length; i < l; i++) {
  5119. var len = parser[buffers[i]].length
  5120. if (len > maxAllowed) {
  5121. // Text/cdata nodes can get big, and since they're buffered,
  5122. // we can get here under normal conditions.
  5123. // Avoid issues by emitting the text node now,
  5124. // so at least it won't get any bigger.
  5125. switch (buffers[i]) {
  5126. case 'textNode':
  5127. closeText(parser)
  5128. break
  5129. case 'cdata':
  5130. emitNode(parser, 'oncdata', parser.cdata)
  5131. parser.cdata = ''
  5132. break
  5133. case 'script':
  5134. emitNode(parser, 'onscript', parser.script)
  5135. parser.script = ''
  5136. break
  5137. default:
  5138. error(parser, 'Max buffer length exceeded: ' + buffers[i])
  5139. }
  5140. }
  5141. maxActual = Math.max(maxActual, len)
  5142. }
  5143. // schedule the next check for the earliest possible buffer overrun.
  5144. var m = sax.MAX_BUFFER_LENGTH - maxActual
  5145. parser.bufferCheckPosition = m + parser.position
  5146. }
  5147. function clearBuffers (parser) {
  5148. for (var i = 0, l = buffers.length; i < l; i++) {
  5149. parser[buffers[i]] = ''
  5150. }
  5151. }
  5152. function flushBuffers (parser) {
  5153. closeText(parser)
  5154. if (parser.cdata !== '') {
  5155. emitNode(parser, 'oncdata', parser.cdata)
  5156. parser.cdata = ''
  5157. }
  5158. if (parser.script !== '') {
  5159. emitNode(parser, 'onscript', parser.script)
  5160. parser.script = ''
  5161. }
  5162. }
  5163. SAXParser.prototype = {
  5164. end: function () { end(this) },
  5165. write: write,
  5166. resume: function () { this.error = null; return this },
  5167. close: function () { return this.write(null) },
  5168. flush: function () { flushBuffers(this) }
  5169. }
  5170. var Stream
  5171. try {
  5172. Stream = __webpack_require__(25).Stream
  5173. } catch (ex) {
  5174. Stream = function () {}
  5175. }
  5176. var streamWraps = sax.EVENTS.filter(function (ev) {
  5177. return ev !== 'error' && ev !== 'end'
  5178. })
  5179. function createStream (strict, opt) {
  5180. return new SAXStream(strict, opt)
  5181. }
  5182. function SAXStream (strict, opt) {
  5183. if (!(this instanceof SAXStream)) {
  5184. return new SAXStream(strict, opt)
  5185. }
  5186. Stream.apply(this)
  5187. this._parser = new SAXParser(strict, opt)
  5188. this.writable = true
  5189. this.readable = true
  5190. var me = this
  5191. this._parser.onend = function () {
  5192. me.emit('end')
  5193. }
  5194. this._parser.onerror = function (er) {
  5195. me.emit('error', er)
  5196. // if didn't throw, then means error was handled.
  5197. // go ahead and clear error, so we can write again.
  5198. me._parser.error = null
  5199. }
  5200. this._decoder = null
  5201. streamWraps.forEach(function (ev) {
  5202. Object.defineProperty(me, 'on' + ev, {
  5203. get: function () {
  5204. return me._parser['on' + ev]
  5205. },
  5206. set: function (h) {
  5207. if (!h) {
  5208. me.removeAllListeners(ev)
  5209. me._parser['on' + ev] = h
  5210. return h
  5211. }
  5212. me.on(ev, h)
  5213. },
  5214. enumerable: true,
  5215. configurable: false
  5216. })
  5217. })
  5218. }
  5219. SAXStream.prototype = Object.create(Stream.prototype, {
  5220. constructor: {
  5221. value: SAXStream
  5222. }
  5223. })
  5224. SAXStream.prototype.write = function (data) {
  5225. if (typeof Buffer === 'function' &&
  5226. typeof Buffer.isBuffer === 'function' &&
  5227. Buffer.isBuffer(data)) {
  5228. if (!this._decoder) {
  5229. var SD = __webpack_require__(11).StringDecoder
  5230. this._decoder = new SD('utf8')
  5231. }
  5232. data = this._decoder.write(data)
  5233. }
  5234. this._parser.write(data.toString())
  5235. this.emit('data', data)
  5236. return true
  5237. }
  5238. SAXStream.prototype.end = function (chunk) {
  5239. if (chunk && chunk.length) {
  5240. this.write(chunk)
  5241. }
  5242. this._parser.end()
  5243. return true
  5244. }
  5245. SAXStream.prototype.on = function (ev, handler) {
  5246. var me = this
  5247. if (!me._parser['on' + ev] && streamWraps.indexOf(ev) !== -1) {
  5248. me._parser['on' + ev] = function () {
  5249. var args = arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments)
  5250. args.splice(0, 0, ev)
  5251. me.emit.apply(me, args)
  5252. }
  5253. }
  5254. return Stream.prototype.on.call(me, ev, handler)
  5255. }
  5256. // this really needs to be replaced with character classes.
  5257. // XML allows all manner of ridiculous numbers and digits.
  5258. var CDATA = '[CDATA['
  5259. var DOCTYPE = 'DOCTYPE'
  5260. var XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace'
  5261. var XMLNS_NAMESPACE = 'http://www.w3.org/2000/xmlns/'
  5262. var rootNS = { xml: XML_NAMESPACE, xmlns: XMLNS_NAMESPACE }
  5263. // http://www.w3.org/TR/REC-xml/#NT-NameStartChar
  5264. // This implementation works on strings, a single character at a time
  5265. // as such, it cannot ever support astral-plane characters (10000-EFFFF)
  5266. // without a significant breaking change to either this parser, or the
  5267. // JavaScript language. Implementation of an emoji-capable xml parser
  5268. // is left as an exercise for the reader.
  5269. var nameStart = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/
  5270. var nameBody = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/
  5271. var entityStart = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/
  5272. var entityBody = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/
  5273. function isWhitespace (c) {
  5274. return c === ' ' || c === '\n' || c === '\r' || c === '\t'
  5275. }
  5276. function isQuote (c) {
  5277. return c === '"' || c === '\''
  5278. }
  5279. function isAttribEnd (c) {
  5280. return c === '>' || isWhitespace(c)
  5281. }
  5282. function isMatch (regex, c) {
  5283. return regex.test(c)
  5284. }
  5285. function notMatch (regex, c) {
  5286. return !isMatch(regex, c)
  5287. }
  5288. var S = 0
  5289. sax.STATE = {
  5290. BEGIN: S++, // leading byte order mark or whitespace
  5291. BEGIN_WHITESPACE: S++, // leading whitespace
  5292. TEXT: S++, // general stuff
  5293. TEXT_ENTITY: S++, // &amp and such.
  5294. OPEN_WAKA: S++, // <
  5295. SGML_DECL: S++, // <!BLARG
  5296. SGML_DECL_QUOTED: S++, // <!BLARG foo "bar
  5297. DOCTYPE: S++, // <!DOCTYPE
  5298. DOCTYPE_QUOTED: S++, // <!DOCTYPE "//blah
  5299. DOCTYPE_DTD: S++, // <!DOCTYPE "//blah" [ ...
  5300. DOCTYPE_DTD_QUOTED: S++, // <!DOCTYPE "//blah" [ "foo
  5301. COMMENT_STARTING: S++, // <!-
  5302. COMMENT: S++, // <!--
  5303. COMMENT_ENDING: S++, // <!-- blah -
  5304. COMMENT_ENDED: S++, // <!-- blah --
  5305. CDATA: S++, // <![CDATA[ something
  5306. CDATA_ENDING: S++, // ]
  5307. CDATA_ENDING_2: S++, // ]]
  5308. PROC_INST: S++, // <?hi
  5309. PROC_INST_BODY: S++, // <?hi there
  5310. PROC_INST_ENDING: S++, // <?hi "there" ?
  5311. OPEN_TAG: S++, // <strong
  5312. OPEN_TAG_SLASH: S++, // <strong /
  5313. ATTRIB: S++, // <a
  5314. ATTRIB_NAME: S++, // <a foo
  5315. ATTRIB_NAME_SAW_WHITE: S++, // <a foo _
  5316. ATTRIB_VALUE: S++, // <a foo=
  5317. ATTRIB_VALUE_QUOTED: S++, // <a foo="bar
  5318. ATTRIB_VALUE_CLOSED: S++, // <a foo="bar"
  5319. ATTRIB_VALUE_UNQUOTED: S++, // <a foo=bar
  5320. ATTRIB_VALUE_ENTITY_Q: S++, // <foo bar="&quot;"
  5321. ATTRIB_VALUE_ENTITY_U: S++, // <foo bar=&quot
  5322. CLOSE_TAG: S++, // </a
  5323. CLOSE_TAG_SAW_WHITE: S++, // </a >
  5324. SCRIPT: S++, // <script> ...
  5325. SCRIPT_ENDING: S++ // <script> ... <
  5326. }
  5327. sax.XML_ENTITIES = {
  5328. 'amp': '&',
  5329. 'gt': '>',
  5330. 'lt': '<',
  5331. 'quot': '"',
  5332. 'apos': "'"
  5333. }
  5334. sax.ENTITIES = {
  5335. 'amp': '&',
  5336. 'gt': '>',
  5337. 'lt': '<',
  5338. 'quot': '"',
  5339. 'apos': "'",
  5340. 'AElig': 198,
  5341. 'Aacute': 193,
  5342. 'Acirc': 194,
  5343. 'Agrave': 192,
  5344. 'Aring': 197,
  5345. 'Atilde': 195,
  5346. 'Auml': 196,
  5347. 'Ccedil': 199,
  5348. 'ETH': 208,
  5349. 'Eacute': 201,
  5350. 'Ecirc': 202,
  5351. 'Egrave': 200,
  5352. 'Euml': 203,
  5353. 'Iacute': 205,
  5354. 'Icirc': 206,
  5355. 'Igrave': 204,
  5356. 'Iuml': 207,
  5357. 'Ntilde': 209,
  5358. 'Oacute': 211,
  5359. 'Ocirc': 212,
  5360. 'Ograve': 210,
  5361. 'Oslash': 216,
  5362. 'Otilde': 213,
  5363. 'Ouml': 214,
  5364. 'THORN': 222,
  5365. 'Uacute': 218,
  5366. 'Ucirc': 219,
  5367. 'Ugrave': 217,
  5368. 'Uuml': 220,
  5369. 'Yacute': 221,
  5370. 'aacute': 225,
  5371. 'acirc': 226,
  5372. 'aelig': 230,
  5373. 'agrave': 224,
  5374. 'aring': 229,
  5375. 'atilde': 227,
  5376. 'auml': 228,
  5377. 'ccedil': 231,
  5378. 'eacute': 233,
  5379. 'ecirc': 234,
  5380. 'egrave': 232,
  5381. 'eth': 240,
  5382. 'euml': 235,
  5383. 'iacute': 237,
  5384. 'icirc': 238,
  5385. 'igrave': 236,
  5386. 'iuml': 239,
  5387. 'ntilde': 241,
  5388. 'oacute': 243,
  5389. 'ocirc': 244,
  5390. 'ograve': 242,
  5391. 'oslash': 248,
  5392. 'otilde': 245,
  5393. 'ouml': 246,
  5394. 'szlig': 223,
  5395. 'thorn': 254,
  5396. 'uacute': 250,
  5397. 'ucirc': 251,
  5398. 'ugrave': 249,
  5399. 'uuml': 252,
  5400. 'yacute': 253,
  5401. 'yuml': 255,
  5402. 'copy': 169,
  5403. 'reg': 174,
  5404. 'nbsp': 160,
  5405. 'iexcl': 161,
  5406. 'cent': 162,
  5407. 'pound': 163,
  5408. 'curren': 164,
  5409. 'yen': 165,
  5410. 'brvbar': 166,
  5411. 'sect': 167,
  5412. 'uml': 168,
  5413. 'ordf': 170,
  5414. 'laquo': 171,
  5415. 'not': 172,
  5416. 'shy': 173,
  5417. 'macr': 175,
  5418. 'deg': 176,
  5419. 'plusmn': 177,
  5420. 'sup1': 185,
  5421. 'sup2': 178,
  5422. 'sup3': 179,
  5423. 'acute': 180,
  5424. 'micro': 181,
  5425. 'para': 182,
  5426. 'middot': 183,
  5427. 'cedil': 184,
  5428. 'ordm': 186,
  5429. 'raquo': 187,
  5430. 'frac14': 188,
  5431. 'frac12': 189,
  5432. 'frac34': 190,
  5433. 'iquest': 191,
  5434. 'times': 215,
  5435. 'divide': 247,
  5436. 'OElig': 338,
  5437. 'oelig': 339,
  5438. 'Scaron': 352,
  5439. 'scaron': 353,
  5440. 'Yuml': 376,
  5441. 'fnof': 402,
  5442. 'circ': 710,
  5443. 'tilde': 732,
  5444. 'Alpha': 913,
  5445. 'Beta': 914,
  5446. 'Gamma': 915,
  5447. 'Delta': 916,
  5448. 'Epsilon': 917,
  5449. 'Zeta': 918,
  5450. 'Eta': 919,
  5451. 'Theta': 920,
  5452. 'Iota': 921,
  5453. 'Kappa': 922,
  5454. 'Lambda': 923,
  5455. 'Mu': 924,
  5456. 'Nu': 925,
  5457. 'Xi': 926,
  5458. 'Omicron': 927,
  5459. 'Pi': 928,
  5460. 'Rho': 929,
  5461. 'Sigma': 931,
  5462. 'Tau': 932,
  5463. 'Upsilon': 933,
  5464. 'Phi': 934,
  5465. 'Chi': 935,
  5466. 'Psi': 936,
  5467. 'Omega': 937,
  5468. 'alpha': 945,
  5469. 'beta': 946,
  5470. 'gamma': 947,
  5471. 'delta': 948,
  5472. 'epsilon': 949,
  5473. 'zeta': 950,
  5474. 'eta': 951,
  5475. 'theta': 952,
  5476. 'iota': 953,
  5477. 'kappa': 954,
  5478. 'lambda': 955,
  5479. 'mu': 956,
  5480. 'nu': 957,
  5481. 'xi': 958,
  5482. 'omicron': 959,
  5483. 'pi': 960,
  5484. 'rho': 961,
  5485. 'sigmaf': 962,
  5486. 'sigma': 963,
  5487. 'tau': 964,
  5488. 'upsilon': 965,
  5489. 'phi': 966,
  5490. 'chi': 967,
  5491. 'psi': 968,
  5492. 'omega': 969,
  5493. 'thetasym': 977,
  5494. 'upsih': 978,
  5495. 'piv': 982,
  5496. 'ensp': 8194,
  5497. 'emsp': 8195,
  5498. 'thinsp': 8201,
  5499. 'zwnj': 8204,
  5500. 'zwj': 8205,
  5501. 'lrm': 8206,
  5502. 'rlm': 8207,
  5503. 'ndash': 8211,
  5504. 'mdash': 8212,
  5505. 'lsquo': 8216,
  5506. 'rsquo': 8217,
  5507. 'sbquo': 8218,
  5508. 'ldquo': 8220,
  5509. 'rdquo': 8221,
  5510. 'bdquo': 8222,
  5511. 'dagger': 8224,
  5512. 'Dagger': 8225,
  5513. 'bull': 8226,
  5514. 'hellip': 8230,
  5515. 'permil': 8240,
  5516. 'prime': 8242,
  5517. 'Prime': 8243,
  5518. 'lsaquo': 8249,
  5519. 'rsaquo': 8250,
  5520. 'oline': 8254,
  5521. 'frasl': 8260,
  5522. 'euro': 8364,
  5523. 'image': 8465,
  5524. 'weierp': 8472,
  5525. 'real': 8476,
  5526. 'trade': 8482,
  5527. 'alefsym': 8501,
  5528. 'larr': 8592,
  5529. 'uarr': 8593,
  5530. 'rarr': 8594,
  5531. 'darr': 8595,
  5532. 'harr': 8596,
  5533. 'crarr': 8629,
  5534. 'lArr': 8656,
  5535. 'uArr': 8657,
  5536. 'rArr': 8658,
  5537. 'dArr': 8659,
  5538. 'hArr': 8660,
  5539. 'forall': 8704,
  5540. 'part': 8706,
  5541. 'exist': 8707,
  5542. 'empty': 8709,
  5543. 'nabla': 8711,
  5544. 'isin': 8712,
  5545. 'notin': 8713,
  5546. 'ni': 8715,
  5547. 'prod': 8719,
  5548. 'sum': 8721,
  5549. 'minus': 8722,
  5550. 'lowast': 8727,
  5551. 'radic': 8730,
  5552. 'prop': 8733,
  5553. 'infin': 8734,
  5554. 'ang': 8736,
  5555. 'and': 8743,
  5556. 'or': 8744,
  5557. 'cap': 8745,
  5558. 'cup': 8746,
  5559. 'int': 8747,
  5560. 'there4': 8756,
  5561. 'sim': 8764,
  5562. 'cong': 8773,
  5563. 'asymp': 8776,
  5564. 'ne': 8800,
  5565. 'equiv': 8801,
  5566. 'le': 8804,
  5567. 'ge': 8805,
  5568. 'sub': 8834,
  5569. 'sup': 8835,
  5570. 'nsub': 8836,
  5571. 'sube': 8838,
  5572. 'supe': 8839,
  5573. 'oplus': 8853,
  5574. 'otimes': 8855,
  5575. 'perp': 8869,
  5576. 'sdot': 8901,
  5577. 'lceil': 8968,
  5578. 'rceil': 8969,
  5579. 'lfloor': 8970,
  5580. 'rfloor': 8971,
  5581. 'lang': 9001,
  5582. 'rang': 9002,
  5583. 'loz': 9674,
  5584. 'spades': 9824,
  5585. 'clubs': 9827,
  5586. 'hearts': 9829,
  5587. 'diams': 9830
  5588. }
  5589. Object.keys(sax.ENTITIES).forEach(function (key) {
  5590. var e = sax.ENTITIES[key]
  5591. var s = typeof e === 'number' ? String.fromCharCode(e) : e
  5592. sax.ENTITIES[key] = s
  5593. })
  5594. for (var s in sax.STATE) {
  5595. sax.STATE[sax.STATE[s]] = s
  5596. }
  5597. // shorthand
  5598. S = sax.STATE
  5599. function emit (parser, event, data) {
  5600. parser[event] && parser[event](data)
  5601. }
  5602. function emitNode (parser, nodeType, data) {
  5603. if (parser.textNode) closeText(parser)
  5604. emit(parser, nodeType, data)
  5605. }
  5606. function closeText (parser) {
  5607. parser.textNode = textopts(parser.opt, parser.textNode)
  5608. if (parser.textNode) emit(parser, 'ontext', parser.textNode)
  5609. parser.textNode = ''
  5610. }
  5611. function textopts (opt, text) {
  5612. if (opt.trim) text = text.trim()
  5613. if (opt.normalize) text = text.replace(/\s+/g, ' ')
  5614. return text
  5615. }
  5616. function error (parser, er) {
  5617. closeText(parser)
  5618. if (parser.trackPosition) {
  5619. er += '\nLine: ' + parser.line +
  5620. '\nColumn: ' + parser.column +
  5621. '\nChar: ' + parser.c
  5622. }
  5623. er = new Error(er)
  5624. parser.error = er
  5625. emit(parser, 'onerror', er)
  5626. return parser
  5627. }
  5628. function end (parser) {
  5629. if (parser.sawRoot && !parser.closedRoot) strictFail(parser, 'Unclosed root tag')
  5630. if ((parser.state !== S.BEGIN) &&
  5631. (parser.state !== S.BEGIN_WHITESPACE) &&
  5632. (parser.state !== S.TEXT)) {
  5633. error(parser, 'Unexpected end')
  5634. }
  5635. closeText(parser)
  5636. parser.c = ''
  5637. parser.closed = true
  5638. emit(parser, 'onend')
  5639. SAXParser.call(parser, parser.strict, parser.opt)
  5640. return parser
  5641. }
  5642. function strictFail (parser, message) {
  5643. if (typeof parser !== 'object' || !(parser instanceof SAXParser)) {
  5644. throw new Error('bad call to strictFail')
  5645. }
  5646. if (parser.strict) {
  5647. error(parser, message)
  5648. }
  5649. }
  5650. function newTag (parser) {
  5651. if (!parser.strict) parser.tagName = parser.tagName[parser.looseCase]()
  5652. var parent = parser.tags[parser.tags.length - 1] || parser
  5653. var tag = parser.tag = { name: parser.tagName, attributes: {} }
  5654. // will be overridden if tag contails an xmlns="foo" or xmlns:foo="bar"
  5655. if (parser.opt.xmlns) {
  5656. tag.ns = parent.ns
  5657. }
  5658. parser.attribList.length = 0
  5659. emitNode(parser, 'onopentagstart', tag)
  5660. }
  5661. function qname (name, attribute) {
  5662. var i = name.indexOf(':')
  5663. var qualName = i < 0 ? [ '', name ] : name.split(':')
  5664. var prefix = qualName[0]
  5665. var local = qualName[1]
  5666. // <x "xmlns"="http://foo">
  5667. if (attribute && name === 'xmlns') {
  5668. prefix = 'xmlns'
  5669. local = ''
  5670. }
  5671. return { prefix: prefix, local: local }
  5672. }
  5673. function attrib (parser) {
  5674. if (!parser.strict) {
  5675. parser.attribName = parser.attribName[parser.looseCase]()
  5676. }
  5677. if (parser.attribList.indexOf(parser.attribName) !== -1 ||
  5678. parser.tag.attributes.hasOwnProperty(parser.attribName)) {
  5679. parser.attribName = parser.attribValue = ''
  5680. return
  5681. }
  5682. if (parser.opt.xmlns) {
  5683. var qn = qname(parser.attribName, true)
  5684. var prefix = qn.prefix
  5685. var local = qn.local
  5686. if (prefix === 'xmlns') {
  5687. // namespace binding attribute. push the binding into scope
  5688. if (local === 'xml' && parser.attribValue !== XML_NAMESPACE) {
  5689. strictFail(parser,
  5690. 'xml: prefix must be bound to ' + XML_NAMESPACE + '\n' +
  5691. 'Actual: ' + parser.attribValue)
  5692. } else if (local === 'xmlns' && parser.attribValue !== XMLNS_NAMESPACE) {
  5693. strictFail(parser,
  5694. 'xmlns: prefix must be bound to ' + XMLNS_NAMESPACE + '\n' +
  5695. 'Actual: ' + parser.attribValue)
  5696. } else {
  5697. var tag = parser.tag
  5698. var parent = parser.tags[parser.tags.length - 1] || parser
  5699. if (tag.ns === parent.ns) {
  5700. tag.ns = Object.create(parent.ns)
  5701. }
  5702. tag.ns[local] = parser.attribValue
  5703. }
  5704. }
  5705. // defer onattribute events until all attributes have been seen
  5706. // so any new bindings can take effect. preserve attribute order
  5707. // so deferred events can be emitted in document order
  5708. parser.attribList.push([parser.attribName, parser.attribValue])
  5709. } else {
  5710. // in non-xmlns mode, we can emit the event right away
  5711. parser.tag.attributes[parser.attribName] = parser.attribValue
  5712. emitNode(parser, 'onattribute', {
  5713. name: parser.attribName,
  5714. value: parser.attribValue
  5715. })
  5716. }
  5717. parser.attribName = parser.attribValue = ''
  5718. }
  5719. function openTag (parser, selfClosing) {
  5720. if (parser.opt.xmlns) {
  5721. // emit namespace binding events
  5722. var tag = parser.tag
  5723. // add namespace info to tag
  5724. var qn = qname(parser.tagName)
  5725. tag.prefix = qn.prefix
  5726. tag.local = qn.local
  5727. tag.uri = tag.ns[qn.prefix] || ''
  5728. if (tag.prefix && !tag.uri) {
  5729. strictFail(parser, 'Unbound namespace prefix: ' +
  5730. JSON.stringify(parser.tagName))
  5731. tag.uri = qn.prefix
  5732. }
  5733. var parent = parser.tags[parser.tags.length - 1] || parser
  5734. if (tag.ns && parent.ns !== tag.ns) {
  5735. Object.keys(tag.ns).forEach(function (p) {
  5736. emitNode(parser, 'onopennamespace', {
  5737. prefix: p,
  5738. uri: tag.ns[p]
  5739. })
  5740. })
  5741. }
  5742. // handle deferred onattribute events
  5743. // Note: do not apply default ns to attributes:
  5744. // http://www.w3.org/TR/REC-xml-names/#defaulting
  5745. for (var i = 0, l = parser.attribList.length; i < l; i++) {
  5746. var nv = parser.attribList[i]
  5747. var name = nv[0]
  5748. var value = nv[1]
  5749. var qualName = qname(name, true)
  5750. var prefix = qualName.prefix
  5751. var local = qualName.local
  5752. var uri = prefix === '' ? '' : (tag.ns[prefix] || '')
  5753. var a = {
  5754. name: name,
  5755. value: value,
  5756. prefix: prefix,
  5757. local: local,
  5758. uri: uri
  5759. }
  5760. // if there's any attributes with an undefined namespace,
  5761. // then fail on them now.
  5762. if (prefix && prefix !== 'xmlns' && !uri) {
  5763. strictFail(parser, 'Unbound namespace prefix: ' +
  5764. JSON.stringify(prefix))
  5765. a.uri = prefix
  5766. }
  5767. parser.tag.attributes[name] = a
  5768. emitNode(parser, 'onattribute', a)
  5769. }
  5770. parser.attribList.length = 0
  5771. }
  5772. parser.tag.isSelfClosing = !!selfClosing
  5773. // process the tag
  5774. parser.sawRoot = true
  5775. parser.tags.push(parser.tag)
  5776. emitNode(parser, 'onopentag', parser.tag)
  5777. if (!selfClosing) {
  5778. // special case for <script> in non-strict mode.
  5779. if (!parser.noscript && parser.tagName.toLowerCase() === 'script') {
  5780. parser.state = S.SCRIPT
  5781. } else {
  5782. parser.state = S.TEXT
  5783. }
  5784. parser.tag = null
  5785. parser.tagName = ''
  5786. }
  5787. parser.attribName = parser.attribValue = ''
  5788. parser.attribList.length = 0
  5789. }
  5790. function closeTag (parser) {
  5791. if (!parser.tagName) {
  5792. strictFail(parser, 'Weird empty close tag.')
  5793. parser.textNode += '</>'
  5794. parser.state = S.TEXT
  5795. return
  5796. }
  5797. if (parser.script) {
  5798. if (parser.tagName !== 'script') {
  5799. parser.script += '</' + parser.tagName + '>'
  5800. parser.tagName = ''
  5801. parser.state = S.SCRIPT
  5802. return
  5803. }
  5804. emitNode(parser, 'onscript', parser.script)
  5805. parser.script = ''
  5806. }
  5807. // first make sure that the closing tag actually exists.
  5808. // <a><b></c></b></a> will close everything, otherwise.
  5809. var t = parser.tags.length
  5810. var tagName = parser.tagName
  5811. if (!parser.strict) {
  5812. tagName = tagName[parser.looseCase]()
  5813. }
  5814. var closeTo = tagName
  5815. while (t--) {
  5816. var close = parser.tags[t]
  5817. if (close.name !== closeTo) {
  5818. // fail the first time in strict mode
  5819. strictFail(parser, 'Unexpected close tag')
  5820. } else {
  5821. break
  5822. }
  5823. }
  5824. // didn't find it. we already failed for strict, so just abort.
  5825. if (t < 0) {
  5826. strictFail(parser, 'Unmatched closing tag: ' + parser.tagName)
  5827. parser.textNode += '</' + parser.tagName + '>'
  5828. parser.state = S.TEXT
  5829. return
  5830. }
  5831. parser.tagName = tagName
  5832. var s = parser.tags.length
  5833. while (s-- > t) {
  5834. var tag = parser.tag = parser.tags.pop()
  5835. parser.tagName = parser.tag.name
  5836. emitNode(parser, 'onclosetag', parser.tagName)
  5837. var x = {}
  5838. for (var i in tag.ns) {
  5839. x[i] = tag.ns[i]
  5840. }
  5841. var parent = parser.tags[parser.tags.length - 1] || parser
  5842. if (parser.opt.xmlns && tag.ns !== parent.ns) {
  5843. // remove namespace bindings introduced by tag
  5844. Object.keys(tag.ns).forEach(function (p) {
  5845. var n = tag.ns[p]
  5846. emitNode(parser, 'onclosenamespace', { prefix: p, uri: n })
  5847. })
  5848. }
  5849. }
  5850. if (t === 0) parser.closedRoot = true
  5851. parser.tagName = parser.attribValue = parser.attribName = ''
  5852. parser.attribList.length = 0
  5853. parser.state = S.TEXT
  5854. }
  5855. function parseEntity (parser) {
  5856. var entity = parser.entity
  5857. var entityLC = entity.toLowerCase()
  5858. var num
  5859. var numStr = ''
  5860. if (parser.ENTITIES[entity]) {
  5861. return parser.ENTITIES[entity]
  5862. }
  5863. if (parser.ENTITIES[entityLC]) {
  5864. return parser.ENTITIES[entityLC]
  5865. }
  5866. entity = entityLC
  5867. if (entity.charAt(0) === '#') {
  5868. if (entity.charAt(1) === 'x') {
  5869. entity = entity.slice(2)
  5870. num = parseInt(entity, 16)
  5871. numStr = num.toString(16)
  5872. } else {
  5873. entity = entity.slice(1)
  5874. num = parseInt(entity, 10)
  5875. numStr = num.toString(10)
  5876. }
  5877. }
  5878. entity = entity.replace(/^0+/, '')
  5879. if (isNaN(num) || numStr.toLowerCase() !== entity) {
  5880. strictFail(parser, 'Invalid character entity')
  5881. return '&' + parser.entity + ';'
  5882. }
  5883. return String.fromCodePoint(num)
  5884. }
  5885. function beginWhiteSpace (parser, c) {
  5886. if (c === '<') {
  5887. parser.state = S.OPEN_WAKA
  5888. parser.startTagPosition = parser.position
  5889. } else if (!isWhitespace(c)) {
  5890. // have to process this as a text node.
  5891. // weird, but happens.
  5892. strictFail(parser, 'Non-whitespace before first tag.')
  5893. parser.textNode = c
  5894. parser.state = S.TEXT
  5895. }
  5896. }
  5897. function charAt (chunk, i) {
  5898. var result = ''
  5899. if (i < chunk.length) {
  5900. result = chunk.charAt(i)
  5901. }
  5902. return result
  5903. }
  5904. function write (chunk) {
  5905. var parser = this
  5906. if (this.error) {
  5907. throw this.error
  5908. }
  5909. if (parser.closed) {
  5910. return error(parser,
  5911. 'Cannot write after close. Assign an onready handler.')
  5912. }
  5913. if (chunk === null) {
  5914. return end(parser)
  5915. }
  5916. if (typeof chunk === 'object') {
  5917. chunk = chunk.toString()
  5918. }
  5919. var i = 0
  5920. var c = ''
  5921. while (true) {
  5922. c = charAt(chunk, i++)
  5923. parser.c = c
  5924. if (!c) {
  5925. break
  5926. }
  5927. if (parser.trackPosition) {
  5928. parser.position++
  5929. if (c === '\n') {
  5930. parser.line++
  5931. parser.column = 0
  5932. } else {
  5933. parser.column++
  5934. }
  5935. }
  5936. switch (parser.state) {
  5937. case S.BEGIN:
  5938. parser.state = S.BEGIN_WHITESPACE
  5939. if (c === '\uFEFF') {
  5940. continue
  5941. }
  5942. beginWhiteSpace(parser, c)
  5943. continue
  5944. case S.BEGIN_WHITESPACE:
  5945. beginWhiteSpace(parser, c)
  5946. continue
  5947. case S.TEXT:
  5948. if (parser.sawRoot && !parser.closedRoot) {
  5949. var starti = i - 1
  5950. while (c && c !== '<' && c !== '&') {
  5951. c = charAt(chunk, i++)
  5952. if (c && parser.trackPosition) {
  5953. parser.position++
  5954. if (c === '\n') {
  5955. parser.line++
  5956. parser.column = 0
  5957. } else {
  5958. parser.column++
  5959. }
  5960. }
  5961. }
  5962. parser.textNode += chunk.substring(starti, i - 1)
  5963. }
  5964. if (c === '<' && !(parser.sawRoot && parser.closedRoot && !parser.strict)) {
  5965. parser.state = S.OPEN_WAKA
  5966. parser.startTagPosition = parser.position
  5967. } else {
  5968. if (!isWhitespace(c) && (!parser.sawRoot || parser.closedRoot)) {
  5969. strictFail(parser, 'Text data outside of root node.')
  5970. }
  5971. if (c === '&') {
  5972. parser.state = S.TEXT_ENTITY
  5973. } else {
  5974. parser.textNode += c
  5975. }
  5976. }
  5977. continue
  5978. case S.SCRIPT:
  5979. // only non-strict
  5980. if (c === '<') {
  5981. parser.state = S.SCRIPT_ENDING
  5982. } else {
  5983. parser.script += c
  5984. }
  5985. continue
  5986. case S.SCRIPT_ENDING:
  5987. if (c === '/') {
  5988. parser.state = S.CLOSE_TAG
  5989. } else {
  5990. parser.script += '<' + c
  5991. parser.state = S.SCRIPT
  5992. }
  5993. continue
  5994. case S.OPEN_WAKA:
  5995. // either a /, ?, !, or text is coming next.
  5996. if (c === '!') {
  5997. parser.state = S.SGML_DECL
  5998. parser.sgmlDecl = ''
  5999. } else if (isWhitespace(c)) {
  6000. // wait for it...
  6001. } else if (isMatch(nameStart, c)) {
  6002. parser.state = S.OPEN_TAG
  6003. parser.tagName = c
  6004. } else if (c === '/') {
  6005. parser.state = S.CLOSE_TAG
  6006. parser.tagName = ''
  6007. } else if (c === '?') {
  6008. parser.state = S.PROC_INST
  6009. parser.procInstName = parser.procInstBody = ''
  6010. } else {
  6011. strictFail(parser, 'Unencoded <')
  6012. // if there was some whitespace, then add that in.
  6013. if (parser.startTagPosition + 1 < parser.position) {
  6014. var pad = parser.position - parser.startTagPosition
  6015. c = new Array(pad).join(' ') + c
  6016. }
  6017. parser.textNode += '<' + c
  6018. parser.state = S.TEXT
  6019. }
  6020. continue
  6021. case S.SGML_DECL:
  6022. if ((parser.sgmlDecl + c).toUpperCase() === CDATA) {
  6023. emitNode(parser, 'onopencdata')
  6024. parser.state = S.CDATA
  6025. parser.sgmlDecl = ''
  6026. parser.cdata = ''
  6027. } else if (parser.sgmlDecl + c === '--') {
  6028. parser.state = S.COMMENT
  6029. parser.comment = ''
  6030. parser.sgmlDecl = ''
  6031. } else if ((parser.sgmlDecl + c).toUpperCase() === DOCTYPE) {
  6032. parser.state = S.DOCTYPE
  6033. if (parser.doctype || parser.sawRoot) {
  6034. strictFail(parser,
  6035. 'Inappropriately located doctype declaration')
  6036. }
  6037. parser.doctype = ''
  6038. parser.sgmlDecl = ''
  6039. } else if (c === '>') {
  6040. emitNode(parser, 'onsgmldeclaration', parser.sgmlDecl)
  6041. parser.sgmlDecl = ''
  6042. parser.state = S.TEXT
  6043. } else if (isQuote(c)) {
  6044. parser.state = S.SGML_DECL_QUOTED
  6045. parser.sgmlDecl += c
  6046. } else {
  6047. parser.sgmlDecl += c
  6048. }
  6049. continue
  6050. case S.SGML_DECL_QUOTED:
  6051. if (c === parser.q) {
  6052. parser.state = S.SGML_DECL
  6053. parser.q = ''
  6054. }
  6055. parser.sgmlDecl += c
  6056. continue
  6057. case S.DOCTYPE:
  6058. if (c === '>') {
  6059. parser.state = S.TEXT
  6060. emitNode(parser, 'ondoctype', parser.doctype)
  6061. parser.doctype = true // just remember that we saw it.
  6062. } else {
  6063. parser.doctype += c
  6064. if (c === '[') {
  6065. parser.state = S.DOCTYPE_DTD
  6066. } else if (isQuote(c)) {
  6067. parser.state = S.DOCTYPE_QUOTED
  6068. parser.q = c
  6069. }
  6070. }
  6071. continue
  6072. case S.DOCTYPE_QUOTED:
  6073. parser.doctype += c
  6074. if (c === parser.q) {
  6075. parser.q = ''
  6076. parser.state = S.DOCTYPE
  6077. }
  6078. continue
  6079. case S.DOCTYPE_DTD:
  6080. parser.doctype += c
  6081. if (c === ']') {
  6082. parser.state = S.DOCTYPE
  6083. } else if (isQuote(c)) {
  6084. parser.state = S.DOCTYPE_DTD_QUOTED
  6085. parser.q = c
  6086. }
  6087. continue
  6088. case S.DOCTYPE_DTD_QUOTED:
  6089. parser.doctype += c
  6090. if (c === parser.q) {
  6091. parser.state = S.DOCTYPE_DTD
  6092. parser.q = ''
  6093. }
  6094. continue
  6095. case S.COMMENT:
  6096. if (c === '-') {
  6097. parser.state = S.COMMENT_ENDING
  6098. } else {
  6099. parser.comment += c
  6100. }
  6101. continue
  6102. case S.COMMENT_ENDING:
  6103. if (c === '-') {
  6104. parser.state = S.COMMENT_ENDED
  6105. parser.comment = textopts(parser.opt, parser.comment)
  6106. if (parser.comment) {
  6107. emitNode(parser, 'oncomment', parser.comment)
  6108. }
  6109. parser.comment = ''
  6110. } else {
  6111. parser.comment += '-' + c
  6112. parser.state = S.COMMENT
  6113. }
  6114. continue
  6115. case S.COMMENT_ENDED:
  6116. if (c !== '>') {
  6117. strictFail(parser, 'Malformed comment')
  6118. // allow <!-- blah -- bloo --> in non-strict mode,
  6119. // which is a comment of " blah -- bloo "
  6120. parser.comment += '--' + c
  6121. parser.state = S.COMMENT
  6122. } else {
  6123. parser.state = S.TEXT
  6124. }
  6125. continue
  6126. case S.CDATA:
  6127. if (c === ']') {
  6128. parser.state = S.CDATA_ENDING
  6129. } else {
  6130. parser.cdata += c
  6131. }
  6132. continue
  6133. case S.CDATA_ENDING:
  6134. if (c === ']') {
  6135. parser.state = S.CDATA_ENDING_2
  6136. } else {
  6137. parser.cdata += ']' + c
  6138. parser.state = S.CDATA
  6139. }
  6140. continue
  6141. case S.CDATA_ENDING_2:
  6142. if (c === '>') {
  6143. if (parser.cdata) {
  6144. emitNode(parser, 'oncdata', parser.cdata)
  6145. }
  6146. emitNode(parser, 'onclosecdata')
  6147. parser.cdata = ''
  6148. parser.state = S.TEXT
  6149. } else if (c === ']') {
  6150. parser.cdata += ']'
  6151. } else {
  6152. parser.cdata += ']]' + c
  6153. parser.state = S.CDATA
  6154. }
  6155. continue
  6156. case S.PROC_INST:
  6157. if (c === '?') {
  6158. parser.state = S.PROC_INST_ENDING
  6159. } else if (isWhitespace(c)) {
  6160. parser.state = S.PROC_INST_BODY
  6161. } else {
  6162. parser.procInstName += c
  6163. }
  6164. continue
  6165. case S.PROC_INST_BODY:
  6166. if (!parser.procInstBody && isWhitespace(c)) {
  6167. continue
  6168. } else if (c === '?') {
  6169. parser.state = S.PROC_INST_ENDING
  6170. } else {
  6171. parser.procInstBody += c
  6172. }
  6173. continue
  6174. case S.PROC_INST_ENDING:
  6175. if (c === '>') {
  6176. emitNode(parser, 'onprocessinginstruction', {
  6177. name: parser.procInstName,
  6178. body: parser.procInstBody
  6179. })
  6180. parser.procInstName = parser.procInstBody = ''
  6181. parser.state = S.TEXT
  6182. } else {
  6183. parser.procInstBody += '?' + c
  6184. parser.state = S.PROC_INST_BODY
  6185. }
  6186. continue
  6187. case S.OPEN_TAG:
  6188. if (isMatch(nameBody, c)) {
  6189. parser.tagName += c
  6190. } else {
  6191. newTag(parser)
  6192. if (c === '>') {
  6193. openTag(parser)
  6194. } else if (c === '/') {
  6195. parser.state = S.OPEN_TAG_SLASH
  6196. } else {
  6197. if (!isWhitespace(c)) {
  6198. strictFail(parser, 'Invalid character in tag name')
  6199. }
  6200. parser.state = S.ATTRIB
  6201. }
  6202. }
  6203. continue
  6204. case S.OPEN_TAG_SLASH:
  6205. if (c === '>') {
  6206. openTag(parser, true)
  6207. closeTag(parser)
  6208. } else {
  6209. strictFail(parser, 'Forward-slash in opening tag not followed by >')
  6210. parser.state = S.ATTRIB
  6211. }
  6212. continue
  6213. case S.ATTRIB:
  6214. // haven't read the attribute name yet.
  6215. if (isWhitespace(c)) {
  6216. continue
  6217. } else if (c === '>') {
  6218. openTag(parser)
  6219. } else if (c === '/') {
  6220. parser.state = S.OPEN_TAG_SLASH
  6221. } else if (isMatch(nameStart, c)) {
  6222. parser.attribName = c
  6223. parser.attribValue = ''
  6224. parser.state = S.ATTRIB_NAME
  6225. } else {
  6226. strictFail(parser, 'Invalid attribute name')
  6227. }
  6228. continue
  6229. case S.ATTRIB_NAME:
  6230. if (c === '=') {
  6231. parser.state = S.ATTRIB_VALUE
  6232. } else if (c === '>') {
  6233. strictFail(parser, 'Attribute without value')
  6234. parser.attribValue = parser.attribName
  6235. attrib(parser)
  6236. openTag(parser)
  6237. } else if (isWhitespace(c)) {
  6238. parser.state = S.ATTRIB_NAME_SAW_WHITE
  6239. } else if (isMatch(nameBody, c)) {
  6240. parser.attribName += c
  6241. } else {
  6242. strictFail(parser, 'Invalid attribute name')
  6243. }
  6244. continue
  6245. case S.ATTRIB_NAME_SAW_WHITE:
  6246. if (c === '=') {
  6247. parser.state = S.ATTRIB_VALUE
  6248. } else if (isWhitespace(c)) {
  6249. continue
  6250. } else {
  6251. strictFail(parser, 'Attribute without value')
  6252. parser.tag.attributes[parser.attribName] = ''
  6253. parser.attribValue = ''
  6254. emitNode(parser, 'onattribute', {
  6255. name: parser.attribName,
  6256. value: ''
  6257. })
  6258. parser.attribName = ''
  6259. if (c === '>') {
  6260. openTag(parser)
  6261. } else if (isMatch(nameStart, c)) {
  6262. parser.attribName = c
  6263. parser.state = S.ATTRIB_NAME
  6264. } else {
  6265. strictFail(parser, 'Invalid attribute name')
  6266. parser.state = S.ATTRIB
  6267. }
  6268. }
  6269. continue
  6270. case S.ATTRIB_VALUE:
  6271. if (isWhitespace(c)) {
  6272. continue
  6273. } else if (isQuote(c)) {
  6274. parser.q = c
  6275. parser.state = S.ATTRIB_VALUE_QUOTED
  6276. } else {
  6277. strictFail(parser, 'Unquoted attribute value')
  6278. parser.state = S.ATTRIB_VALUE_UNQUOTED
  6279. parser.attribValue = c
  6280. }
  6281. continue
  6282. case S.ATTRIB_VALUE_QUOTED:
  6283. if (c !== parser.q) {
  6284. if (c === '&') {
  6285. parser.state = S.ATTRIB_VALUE_ENTITY_Q
  6286. } else {
  6287. parser.attribValue += c
  6288. }
  6289. continue
  6290. }
  6291. attrib(parser)
  6292. parser.q = ''
  6293. parser.state = S.ATTRIB_VALUE_CLOSED
  6294. continue
  6295. case S.ATTRIB_VALUE_CLOSED:
  6296. if (isWhitespace(c)) {
  6297. parser.state = S.ATTRIB
  6298. } else if (c === '>') {
  6299. openTag(parser)
  6300. } else if (c === '/') {
  6301. parser.state = S.OPEN_TAG_SLASH
  6302. } else if (isMatch(nameStart, c)) {
  6303. strictFail(parser, 'No whitespace between attributes')
  6304. parser.attribName = c
  6305. parser.attribValue = ''
  6306. parser.state = S.ATTRIB_NAME
  6307. } else {
  6308. strictFail(parser, 'Invalid attribute name')
  6309. }
  6310. continue
  6311. case S.ATTRIB_VALUE_UNQUOTED:
  6312. if (!isAttribEnd(c)) {
  6313. if (c === '&') {
  6314. parser.state = S.ATTRIB_VALUE_ENTITY_U
  6315. } else {
  6316. parser.attribValue += c
  6317. }
  6318. continue
  6319. }
  6320. attrib(parser)
  6321. if (c === '>') {
  6322. openTag(parser)
  6323. } else {
  6324. parser.state = S.ATTRIB
  6325. }
  6326. continue
  6327. case S.CLOSE_TAG:
  6328. if (!parser.tagName) {
  6329. if (isWhitespace(c)) {
  6330. continue
  6331. } else if (notMatch(nameStart, c)) {
  6332. if (parser.script) {
  6333. parser.script += '</' + c
  6334. parser.state = S.SCRIPT
  6335. } else {
  6336. strictFail(parser, 'Invalid tagname in closing tag.')
  6337. }
  6338. } else {
  6339. parser.tagName = c
  6340. }
  6341. } else if (c === '>') {
  6342. closeTag(parser)
  6343. } else if (isMatch(nameBody, c)) {
  6344. parser.tagName += c
  6345. } else if (parser.script) {
  6346. parser.script += '</' + parser.tagName
  6347. parser.tagName = ''
  6348. parser.state = S.SCRIPT
  6349. } else {
  6350. if (!isWhitespace(c)) {
  6351. strictFail(parser, 'Invalid tagname in closing tag')
  6352. }
  6353. parser.state = S.CLOSE_TAG_SAW_WHITE
  6354. }
  6355. continue
  6356. case S.CLOSE_TAG_SAW_WHITE:
  6357. if (isWhitespace(c)) {
  6358. continue
  6359. }
  6360. if (c === '>') {
  6361. closeTag(parser)
  6362. } else {
  6363. strictFail(parser, 'Invalid characters in closing tag')
  6364. }
  6365. continue
  6366. case S.TEXT_ENTITY:
  6367. case S.ATTRIB_VALUE_ENTITY_Q:
  6368. case S.ATTRIB_VALUE_ENTITY_U:
  6369. var returnState
  6370. var buffer
  6371. switch (parser.state) {
  6372. case S.TEXT_ENTITY:
  6373. returnState = S.TEXT
  6374. buffer = 'textNode'
  6375. break
  6376. case S.ATTRIB_VALUE_ENTITY_Q:
  6377. returnState = S.ATTRIB_VALUE_QUOTED
  6378. buffer = 'attribValue'
  6379. break
  6380. case S.ATTRIB_VALUE_ENTITY_U:
  6381. returnState = S.ATTRIB_VALUE_UNQUOTED
  6382. buffer = 'attribValue'
  6383. break
  6384. }
  6385. if (c === ';') {
  6386. parser[buffer] += parseEntity(parser)
  6387. parser.entity = ''
  6388. parser.state = returnState
  6389. } else if (isMatch(parser.entity.length ? entityBody : entityStart, c)) {
  6390. parser.entity += c
  6391. } else {
  6392. strictFail(parser, 'Invalid character in entity name')
  6393. parser[buffer] += '&' + parser.entity + c
  6394. parser.entity = ''
  6395. parser.state = returnState
  6396. }
  6397. continue
  6398. default:
  6399. throw new Error(parser, 'Unknown state: ' + parser.state)
  6400. }
  6401. } // while
  6402. if (parser.position >= parser.bufferCheckPosition) {
  6403. checkBufferLength(parser)
  6404. }
  6405. return parser
  6406. }
  6407. /*! http://mths.be/fromcodepoint v0.1.0 by @mathias */
  6408. /* istanbul ignore next */
  6409. if (!String.fromCodePoint) {
  6410. (function () {
  6411. var stringFromCharCode = String.fromCharCode
  6412. var floor = Math.floor
  6413. var fromCodePoint = function () {
  6414. var MAX_SIZE = 0x4000
  6415. var codeUnits = []
  6416. var highSurrogate
  6417. var lowSurrogate
  6418. var index = -1
  6419. var length = arguments.length
  6420. if (!length) {
  6421. return ''
  6422. }
  6423. var result = ''
  6424. while (++index < length) {
  6425. var codePoint = Number(arguments[index])
  6426. if (
  6427. !isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity`
  6428. codePoint < 0 || // not a valid Unicode code point
  6429. codePoint > 0x10FFFF || // not a valid Unicode code point
  6430. floor(codePoint) !== codePoint // not an integer
  6431. ) {
  6432. throw RangeError('Invalid code point: ' + codePoint)
  6433. }
  6434. if (codePoint <= 0xFFFF) { // BMP code point
  6435. codeUnits.push(codePoint)
  6436. } else { // Astral code point; split in surrogate halves
  6437. // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
  6438. codePoint -= 0x10000
  6439. highSurrogate = (codePoint >> 10) + 0xD800
  6440. lowSurrogate = (codePoint % 0x400) + 0xDC00
  6441. codeUnits.push(highSurrogate, lowSurrogate)
  6442. }
  6443. if (index + 1 === length || codeUnits.length > MAX_SIZE) {
  6444. result += stringFromCharCode.apply(null, codeUnits)
  6445. codeUnits.length = 0
  6446. }
  6447. }
  6448. return result
  6449. }
  6450. /* istanbul ignore next */
  6451. if (Object.defineProperty) {
  6452. Object.defineProperty(String, 'fromCodePoint', {
  6453. value: fromCodePoint,
  6454. configurable: true,
  6455. writable: true
  6456. })
  6457. } else {
  6458. String.fromCodePoint = fromCodePoint
  6459. }
  6460. }())
  6461. }
  6462. })( false ? this.sax = {} : exports)
  6463. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4).Buffer))
  6464. /***/ }),
  6465. /* 23 */
  6466. /***/ (function(module, exports, __webpack_require__) {
  6467. "use strict";
  6468. exports.byteLength = byteLength
  6469. exports.toByteArray = toByteArray
  6470. exports.fromByteArray = fromByteArray
  6471. var lookup = []
  6472. var revLookup = []
  6473. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  6474. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  6475. for (var i = 0, len = code.length; i < len; ++i) {
  6476. lookup[i] = code[i]
  6477. revLookup[code.charCodeAt(i)] = i
  6478. }
  6479. revLookup['-'.charCodeAt(0)] = 62
  6480. revLookup['_'.charCodeAt(0)] = 63
  6481. function placeHoldersCount (b64) {
  6482. var len = b64.length
  6483. if (len % 4 > 0) {
  6484. throw new Error('Invalid string. Length must be a multiple of 4')
  6485. }
  6486. // the number of equal signs (place holders)
  6487. // if there are two placeholders, than the two characters before it
  6488. // represent one byte
  6489. // if there is only one, then the three characters before it represent 2 bytes
  6490. // this is just a cheap hack to not do indexOf twice
  6491. return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0
  6492. }
  6493. function byteLength (b64) {
  6494. // base64 is 4/3 + up to two characters of the original data
  6495. return (b64.length * 3 / 4) - placeHoldersCount(b64)
  6496. }
  6497. function toByteArray (b64) {
  6498. var i, l, tmp, placeHolders, arr
  6499. var len = b64.length
  6500. placeHolders = placeHoldersCount(b64)
  6501. arr = new Arr((len * 3 / 4) - placeHolders)
  6502. // if there are placeholders, only get up to the last complete 4 chars
  6503. l = placeHolders > 0 ? len - 4 : len
  6504. var L = 0
  6505. for (i = 0; i < l; i += 4) {
  6506. tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]
  6507. arr[L++] = (tmp >> 16) & 0xFF
  6508. arr[L++] = (tmp >> 8) & 0xFF
  6509. arr[L++] = tmp & 0xFF
  6510. }
  6511. if (placeHolders === 2) {
  6512. tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4)
  6513. arr[L++] = tmp & 0xFF
  6514. } else if (placeHolders === 1) {
  6515. tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2)
  6516. arr[L++] = (tmp >> 8) & 0xFF
  6517. arr[L++] = tmp & 0xFF
  6518. }
  6519. return arr
  6520. }
  6521. function tripletToBase64 (num) {
  6522. return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
  6523. }
  6524. function encodeChunk (uint8, start, end) {
  6525. var tmp
  6526. var output = []
  6527. for (var i = start; i < end; i += 3) {
  6528. tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
  6529. output.push(tripletToBase64(tmp))
  6530. }
  6531. return output.join('')
  6532. }
  6533. function fromByteArray (uint8) {
  6534. var tmp
  6535. var len = uint8.length
  6536. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  6537. var output = ''
  6538. var parts = []
  6539. var maxChunkLength = 16383 // must be multiple of 3
  6540. // go through the array every three bytes, we'll deal with trailing stuff later
  6541. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  6542. parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
  6543. }
  6544. // pad the end with zeros, but make sure to not forget the extra bytes
  6545. if (extraBytes === 1) {
  6546. tmp = uint8[len - 1]
  6547. output += lookup[tmp >> 2]
  6548. output += lookup[(tmp << 4) & 0x3F]
  6549. output += '=='
  6550. } else if (extraBytes === 2) {
  6551. tmp = (uint8[len - 2] << 8) + (uint8[len - 1])
  6552. output += lookup[tmp >> 10]
  6553. output += lookup[(tmp >> 4) & 0x3F]
  6554. output += lookup[(tmp << 2) & 0x3F]
  6555. output += '='
  6556. }
  6557. parts.push(output)
  6558. return parts.join('')
  6559. }
  6560. /***/ }),
  6561. /* 24 */
  6562. /***/ (function(module, exports) {
  6563. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  6564. var e, m
  6565. var eLen = nBytes * 8 - mLen - 1
  6566. var eMax = (1 << eLen) - 1
  6567. var eBias = eMax >> 1
  6568. var nBits = -7
  6569. var i = isLE ? (nBytes - 1) : 0
  6570. var d = isLE ? -1 : 1
  6571. var s = buffer[offset + i]
  6572. i += d
  6573. e = s & ((1 << (-nBits)) - 1)
  6574. s >>= (-nBits)
  6575. nBits += eLen
  6576. for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
  6577. m = e & ((1 << (-nBits)) - 1)
  6578. e >>= (-nBits)
  6579. nBits += mLen
  6580. for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
  6581. if (e === 0) {
  6582. e = 1 - eBias
  6583. } else if (e === eMax) {
  6584. return m ? NaN : ((s ? -1 : 1) * Infinity)
  6585. } else {
  6586. m = m + Math.pow(2, mLen)
  6587. e = e - eBias
  6588. }
  6589. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  6590. }
  6591. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  6592. var e, m, c
  6593. var eLen = nBytes * 8 - mLen - 1
  6594. var eMax = (1 << eLen) - 1
  6595. var eBias = eMax >> 1
  6596. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  6597. var i = isLE ? 0 : (nBytes - 1)
  6598. var d = isLE ? 1 : -1
  6599. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  6600. value = Math.abs(value)
  6601. if (isNaN(value) || value === Infinity) {
  6602. m = isNaN(value) ? 1 : 0
  6603. e = eMax
  6604. } else {
  6605. e = Math.floor(Math.log(value) / Math.LN2)
  6606. if (value * (c = Math.pow(2, -e)) < 1) {
  6607. e--
  6608. c *= 2
  6609. }
  6610. if (e + eBias >= 1) {
  6611. value += rt / c
  6612. } else {
  6613. value += rt * Math.pow(2, 1 - eBias)
  6614. }
  6615. if (value * c >= 2) {
  6616. e++
  6617. c /= 2
  6618. }
  6619. if (e + eBias >= eMax) {
  6620. m = 0
  6621. e = eMax
  6622. } else if (e + eBias >= 1) {
  6623. m = (value * c - 1) * Math.pow(2, mLen)
  6624. e = e + eBias
  6625. } else {
  6626. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  6627. e = 0
  6628. }
  6629. }
  6630. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  6631. e = (e << mLen) | m
  6632. eLen += mLen
  6633. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  6634. buffer[offset + i - d] |= s * 128
  6635. }
  6636. /***/ }),
  6637. /* 25 */
  6638. /***/ (function(module, exports, __webpack_require__) {
  6639. // Copyright Joyent, Inc. and other Node contributors.
  6640. //
  6641. // Permission is hereby granted, free of charge, to any person obtaining a
  6642. // copy of this software and associated documentation files (the
  6643. // "Software"), to deal in the Software without restriction, including
  6644. // without limitation the rights to use, copy, modify, merge, publish,
  6645. // distribute, sublicense, and/or sell copies of the Software, and to permit
  6646. // persons to whom the Software is furnished to do so, subject to the
  6647. // following conditions:
  6648. //
  6649. // The above copyright notice and this permission notice shall be included
  6650. // in all copies or substantial portions of the Software.
  6651. //
  6652. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  6653. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  6654. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  6655. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  6656. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  6657. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  6658. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  6659. module.exports = Stream;
  6660. var EE = __webpack_require__(8).EventEmitter;
  6661. var inherits = __webpack_require__(1);
  6662. inherits(Stream, EE);
  6663. Stream.Readable = __webpack_require__(9);
  6664. Stream.Writable = __webpack_require__(32);
  6665. Stream.Duplex = __webpack_require__(33);
  6666. Stream.Transform = __webpack_require__(34);
  6667. Stream.PassThrough = __webpack_require__(35);
  6668. // Backwards-compat with node 0.4.x
  6669. Stream.Stream = Stream;
  6670. // old-style streams. Note that the pipe method (the only relevant
  6671. // part of this class) is overridden in the Readable class.
  6672. function Stream() {
  6673. EE.call(this);
  6674. }
  6675. Stream.prototype.pipe = function(dest, options) {
  6676. var source = this;
  6677. function ondata(chunk) {
  6678. if (dest.writable) {
  6679. if (false === dest.write(chunk) && source.pause) {
  6680. source.pause();
  6681. }
  6682. }
  6683. }
  6684. source.on('data', ondata);
  6685. function ondrain() {
  6686. if (source.readable && source.resume) {
  6687. source.resume();
  6688. }
  6689. }
  6690. dest.on('drain', ondrain);
  6691. // If the 'end' option is not supplied, dest.end() will be called when
  6692. // source gets the 'end' or 'close' events. Only dest.end() once.
  6693. if (!dest._isStdio && (!options || options.end !== false)) {
  6694. source.on('end', onend);
  6695. source.on('close', onclose);
  6696. }
  6697. var didOnEnd = false;
  6698. function onend() {
  6699. if (didOnEnd) return;
  6700. didOnEnd = true;
  6701. dest.end();
  6702. }
  6703. function onclose() {
  6704. if (didOnEnd) return;
  6705. didOnEnd = true;
  6706. if (typeof dest.destroy === 'function') dest.destroy();
  6707. }
  6708. // don't leave dangling pipes when there are errors.
  6709. function onerror(er) {
  6710. cleanup();
  6711. if (EE.listenerCount(this, 'error') === 0) {
  6712. throw er; // Unhandled stream error in pipe.
  6713. }
  6714. }
  6715. source.on('error', onerror);
  6716. dest.on('error', onerror);
  6717. // remove all the event listeners that were added.
  6718. function cleanup() {
  6719. source.removeListener('data', ondata);
  6720. dest.removeListener('drain', ondrain);
  6721. source.removeListener('end', onend);
  6722. source.removeListener('close', onclose);
  6723. source.removeListener('error', onerror);
  6724. dest.removeListener('error', onerror);
  6725. source.removeListener('end', cleanup);
  6726. source.removeListener('close', cleanup);
  6727. dest.removeListener('close', cleanup);
  6728. }
  6729. source.on('end', cleanup);
  6730. source.on('close', cleanup);
  6731. dest.on('close', cleanup);
  6732. dest.emit('pipe', source);
  6733. // Allow for unix-like usage: A.pipe(B).pipe(C)
  6734. return dest;
  6735. };
  6736. /***/ }),
  6737. /* 26 */
  6738. /***/ (function(module, exports) {
  6739. /* (ignored) */
  6740. /***/ }),
  6741. /* 27 */
  6742. /***/ (function(module, exports, __webpack_require__) {
  6743. "use strict";
  6744. /*<replacement>*/
  6745. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6746. var Buffer = __webpack_require__(7).Buffer;
  6747. /*</replacement>*/
  6748. function copyBuffer(src, target, offset) {
  6749. src.copy(target, offset);
  6750. }
  6751. module.exports = function () {
  6752. function BufferList() {
  6753. _classCallCheck(this, BufferList);
  6754. this.head = null;
  6755. this.tail = null;
  6756. this.length = 0;
  6757. }
  6758. BufferList.prototype.push = function push(v) {
  6759. var entry = { data: v, next: null };
  6760. if (this.length > 0) this.tail.next = entry;else this.head = entry;
  6761. this.tail = entry;
  6762. ++this.length;
  6763. };
  6764. BufferList.prototype.unshift = function unshift(v) {
  6765. var entry = { data: v, next: this.head };
  6766. if (this.length === 0) this.tail = entry;
  6767. this.head = entry;
  6768. ++this.length;
  6769. };
  6770. BufferList.prototype.shift = function shift() {
  6771. if (this.length === 0) return;
  6772. var ret = this.head.data;
  6773. if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
  6774. --this.length;
  6775. return ret;
  6776. };
  6777. BufferList.prototype.clear = function clear() {
  6778. this.head = this.tail = null;
  6779. this.length = 0;
  6780. };
  6781. BufferList.prototype.join = function join(s) {
  6782. if (this.length === 0) return '';
  6783. var p = this.head;
  6784. var ret = '' + p.data;
  6785. while (p = p.next) {
  6786. ret += s + p.data;
  6787. }return ret;
  6788. };
  6789. BufferList.prototype.concat = function concat(n) {
  6790. if (this.length === 0) return Buffer.alloc(0);
  6791. if (this.length === 1) return this.head.data;
  6792. var ret = Buffer.allocUnsafe(n >>> 0);
  6793. var p = this.head;
  6794. var i = 0;
  6795. while (p) {
  6796. copyBuffer(p.data, ret, i);
  6797. i += p.data.length;
  6798. p = p.next;
  6799. }
  6800. return ret;
  6801. };
  6802. return BufferList;
  6803. }();
  6804. /***/ }),
  6805. /* 28 */
  6806. /***/ (function(module, exports, __webpack_require__) {
  6807. var apply = Function.prototype.apply;
  6808. // DOM APIs, for completeness
  6809. exports.setTimeout = function() {
  6810. return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
  6811. };
  6812. exports.setInterval = function() {
  6813. return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
  6814. };
  6815. exports.clearTimeout =
  6816. exports.clearInterval = function(timeout) {
  6817. if (timeout) {
  6818. timeout.close();
  6819. }
  6820. };
  6821. function Timeout(id, clearFn) {
  6822. this._id = id;
  6823. this._clearFn = clearFn;
  6824. }
  6825. Timeout.prototype.unref = Timeout.prototype.ref = function() {};
  6826. Timeout.prototype.close = function() {
  6827. this._clearFn.call(window, this._id);
  6828. };
  6829. // Does not start the time, just sets up the members needed.
  6830. exports.enroll = function(item, msecs) {
  6831. clearTimeout(item._idleTimeoutId);
  6832. item._idleTimeout = msecs;
  6833. };
  6834. exports.unenroll = function(item) {
  6835. clearTimeout(item._idleTimeoutId);
  6836. item._idleTimeout = -1;
  6837. };
  6838. exports._unrefActive = exports.active = function(item) {
  6839. clearTimeout(item._idleTimeoutId);
  6840. var msecs = item._idleTimeout;
  6841. if (msecs >= 0) {
  6842. item._idleTimeoutId = setTimeout(function onTimeout() {
  6843. if (item._onTimeout)
  6844. item._onTimeout();
  6845. }, msecs);
  6846. }
  6847. };
  6848. // setimmediate attaches itself to the global object
  6849. __webpack_require__(29);
  6850. exports.setImmediate = setImmediate;
  6851. exports.clearImmediate = clearImmediate;
  6852. /***/ }),
  6853. /* 29 */
  6854. /***/ (function(module, exports, __webpack_require__) {
  6855. /* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) {
  6856. "use strict";
  6857. if (global.setImmediate) {
  6858. return;
  6859. }
  6860. var nextHandle = 1; // Spec says greater than zero
  6861. var tasksByHandle = {};
  6862. var currentlyRunningATask = false;
  6863. var doc = global.document;
  6864. var registerImmediate;
  6865. function setImmediate(callback) {
  6866. // Callback can either be a function or a string
  6867. if (typeof callback !== "function") {
  6868. callback = new Function("" + callback);
  6869. }
  6870. // Copy function arguments
  6871. var args = new Array(arguments.length - 1);
  6872. for (var i = 0; i < args.length; i++) {
  6873. args[i] = arguments[i + 1];
  6874. }
  6875. // Store and register the task
  6876. var task = { callback: callback, args: args };
  6877. tasksByHandle[nextHandle] = task;
  6878. registerImmediate(nextHandle);
  6879. return nextHandle++;
  6880. }
  6881. function clearImmediate(handle) {
  6882. delete tasksByHandle[handle];
  6883. }
  6884. function run(task) {
  6885. var callback = task.callback;
  6886. var args = task.args;
  6887. switch (args.length) {
  6888. case 0:
  6889. callback();
  6890. break;
  6891. case 1:
  6892. callback(args[0]);
  6893. break;
  6894. case 2:
  6895. callback(args[0], args[1]);
  6896. break;
  6897. case 3:
  6898. callback(args[0], args[1], args[2]);
  6899. break;
  6900. default:
  6901. callback.apply(undefined, args);
  6902. break;
  6903. }
  6904. }
  6905. function runIfPresent(handle) {
  6906. // From the spec: "Wait until any invocations of this algorithm started before this one have completed."
  6907. // So if we're currently running a task, we'll need to delay this invocation.
  6908. if (currentlyRunningATask) {
  6909. // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
  6910. // "too much recursion" error.
  6911. setTimeout(runIfPresent, 0, handle);
  6912. } else {
  6913. var task = tasksByHandle[handle];
  6914. if (task) {
  6915. currentlyRunningATask = true;
  6916. try {
  6917. run(task);
  6918. } finally {
  6919. clearImmediate(handle);
  6920. currentlyRunningATask = false;
  6921. }
  6922. }
  6923. }
  6924. }
  6925. function installNextTickImplementation() {
  6926. registerImmediate = function(handle) {
  6927. process.nextTick(function () { runIfPresent(handle); });
  6928. };
  6929. }
  6930. function canUsePostMessage() {
  6931. // The test against `importScripts` prevents this implementation from being installed inside a web worker,
  6932. // where `global.postMessage` means something completely different and can't be used for this purpose.
  6933. if (global.postMessage && !global.importScripts) {
  6934. var postMessageIsAsynchronous = true;
  6935. var oldOnMessage = global.onmessage;
  6936. global.onmessage = function() {
  6937. postMessageIsAsynchronous = false;
  6938. };
  6939. global.postMessage("", "*");
  6940. global.onmessage = oldOnMessage;
  6941. return postMessageIsAsynchronous;
  6942. }
  6943. }
  6944. function installPostMessageImplementation() {
  6945. // Installs an event handler on `global` for the `message` event: see
  6946. // * https://developer.mozilla.org/en/DOM/window.postMessage
  6947. // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
  6948. var messagePrefix = "setImmediate$" + Math.random() + "$";
  6949. var onGlobalMessage = function(event) {
  6950. if (event.source === global &&
  6951. typeof event.data === "string" &&
  6952. event.data.indexOf(messagePrefix) === 0) {
  6953. runIfPresent(+event.data.slice(messagePrefix.length));
  6954. }
  6955. };
  6956. if (global.addEventListener) {
  6957. global.addEventListener("message", onGlobalMessage, false);
  6958. } else {
  6959. global.attachEvent("onmessage", onGlobalMessage);
  6960. }
  6961. registerImmediate = function(handle) {
  6962. global.postMessage(messagePrefix + handle, "*");
  6963. };
  6964. }
  6965. function installMessageChannelImplementation() {
  6966. var channel = new MessageChannel();
  6967. channel.port1.onmessage = function(event) {
  6968. var handle = event.data;
  6969. runIfPresent(handle);
  6970. };
  6971. registerImmediate = function(handle) {
  6972. channel.port2.postMessage(handle);
  6973. };
  6974. }
  6975. function installReadyStateChangeImplementation() {
  6976. var html = doc.documentElement;
  6977. registerImmediate = function(handle) {
  6978. // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
  6979. // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
  6980. var script = doc.createElement("script");
  6981. script.onreadystatechange = function () {
  6982. runIfPresent(handle);
  6983. script.onreadystatechange = null;
  6984. html.removeChild(script);
  6985. script = null;
  6986. };
  6987. html.appendChild(script);
  6988. };
  6989. }
  6990. function installSetTimeoutImplementation() {
  6991. registerImmediate = function(handle) {
  6992. setTimeout(runIfPresent, 0, handle);
  6993. };
  6994. }
  6995. // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
  6996. var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
  6997. attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
  6998. // Don't get fooled by e.g. browserify environments.
  6999. if ({}.toString.call(global.process) === "[object process]") {
  7000. // For Node.js before 0.9
  7001. installNextTickImplementation();
  7002. } else if (canUsePostMessage()) {
  7003. // For non-IE10 modern browsers
  7004. installPostMessageImplementation();
  7005. } else if (global.MessageChannel) {
  7006. // For web workers, where supported
  7007. installMessageChannelImplementation();
  7008. } else if (doc && "onreadystatechange" in doc.createElement("script")) {
  7009. // For IE 6–8
  7010. installReadyStateChangeImplementation();
  7011. } else {
  7012. // For older browsers
  7013. installSetTimeoutImplementation();
  7014. }
  7015. attachTo.setImmediate = setImmediate;
  7016. attachTo.clearImmediate = clearImmediate;
  7017. }(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self));
  7018. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2), __webpack_require__(5)))
  7019. /***/ }),
  7020. /* 30 */
  7021. /***/ (function(module, exports, __webpack_require__) {
  7022. /* WEBPACK VAR INJECTION */(function(global) {
  7023. /**
  7024. * Module exports.
  7025. */
  7026. module.exports = deprecate;
  7027. /**
  7028. * Mark that a method should not be used.
  7029. * Returns a modified function which warns once by default.
  7030. *
  7031. * If `localStorage.noDeprecation = true` is set, then it is a no-op.
  7032. *
  7033. * If `localStorage.throwDeprecation = true` is set, then deprecated functions
  7034. * will throw an Error when invoked.
  7035. *
  7036. * If `localStorage.traceDeprecation = true` is set, then deprecated functions
  7037. * will invoke `console.trace()` instead of `console.error()`.
  7038. *
  7039. * @param {Function} fn - the function to deprecate
  7040. * @param {String} msg - the string to print to the console when `fn` is invoked
  7041. * @returns {Function} a new "deprecated" version of `fn`
  7042. * @api public
  7043. */
  7044. function deprecate (fn, msg) {
  7045. if (config('noDeprecation')) {
  7046. return fn;
  7047. }
  7048. var warned = false;
  7049. function deprecated() {
  7050. if (!warned) {
  7051. if (config('throwDeprecation')) {
  7052. throw new Error(msg);
  7053. } else if (config('traceDeprecation')) {
  7054. console.trace(msg);
  7055. } else {
  7056. console.warn(msg);
  7057. }
  7058. warned = true;
  7059. }
  7060. return fn.apply(this, arguments);
  7061. }
  7062. return deprecated;
  7063. }
  7064. /**
  7065. * Checks `localStorage` for boolean values for the given `name`.
  7066. *
  7067. * @param {String} name
  7068. * @returns {Boolean}
  7069. * @api private
  7070. */
  7071. function config (name) {
  7072. // accessing global.localStorage can trigger a DOMException in sandboxed iframes
  7073. try {
  7074. if (!global.localStorage) return false;
  7075. } catch (_) {
  7076. return false;
  7077. }
  7078. var val = global.localStorage[name];
  7079. if (null == val) return false;
  7080. return String(val).toLowerCase() === 'true';
  7081. }
  7082. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)))
  7083. /***/ }),
  7084. /* 31 */
  7085. /***/ (function(module, exports, __webpack_require__) {
  7086. "use strict";
  7087. // Copyright Joyent, Inc. and other Node contributors.
  7088. //
  7089. // Permission is hereby granted, free of charge, to any person obtaining a
  7090. // copy of this software and associated documentation files (the
  7091. // "Software"), to deal in the Software without restriction, including
  7092. // without limitation the rights to use, copy, modify, merge, publish,
  7093. // distribute, sublicense, and/or sell copies of the Software, and to permit
  7094. // persons to whom the Software is furnished to do so, subject to the
  7095. // following conditions:
  7096. //
  7097. // The above copyright notice and this permission notice shall be included
  7098. // in all copies or substantial portions of the Software.
  7099. //
  7100. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  7101. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  7102. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  7103. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  7104. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  7105. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  7106. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  7107. // a passthrough stream.
  7108. // basically just the most minimal sort of Transform stream.
  7109. // Every written chunk gets output as-is.
  7110. module.exports = PassThrough;
  7111. var Transform = __webpack_require__(19);
  7112. /*<replacement>*/
  7113. var util = __webpack_require__(3);
  7114. util.inherits = __webpack_require__(1);
  7115. /*</replacement>*/
  7116. util.inherits(PassThrough, Transform);
  7117. function PassThrough(options) {
  7118. if (!(this instanceof PassThrough)) return new PassThrough(options);
  7119. Transform.call(this, options);
  7120. }
  7121. PassThrough.prototype._transform = function (chunk, encoding, cb) {
  7122. cb(null, chunk);
  7123. };
  7124. /***/ }),
  7125. /* 32 */
  7126. /***/ (function(module, exports, __webpack_require__) {
  7127. module.exports = __webpack_require__(10);
  7128. /***/ }),
  7129. /* 33 */
  7130. /***/ (function(module, exports, __webpack_require__) {
  7131. module.exports = __webpack_require__(0);
  7132. /***/ }),
  7133. /* 34 */
  7134. /***/ (function(module, exports, __webpack_require__) {
  7135. module.exports = __webpack_require__(9).Transform
  7136. /***/ }),
  7137. /* 35 */
  7138. /***/ (function(module, exports, __webpack_require__) {
  7139. module.exports = __webpack_require__(9).PassThrough
  7140. /***/ }),
  7141. /* 36 */
  7142. /***/ (function(module, exports, __webpack_require__) {
  7143. var helper = __webpack_require__(12);
  7144. var xml2js = __webpack_require__(14);
  7145. function validateOptions (userOptions) {
  7146. var options = helper.copyOptions(userOptions);
  7147. helper.ensureSpacesExists(options);
  7148. return options;
  7149. }
  7150. module.exports = function(xml, userOptions) {
  7151. var options, js, json, parentKey;
  7152. options = validateOptions(userOptions);
  7153. js = xml2js(xml, options);
  7154. parentKey = 'compact' in options && options.compact ? '_parent' : 'parent';
  7155. // parentKey = ptions.compact ? '_parent' : 'parent'; // consider this
  7156. if ('addParent' in options && options.addParent) {
  7157. json = JSON.stringify(js, function (k, v) { return k === parentKey? '_' : v; }, options.spaces);
  7158. } else {
  7159. json = JSON.stringify(js, null, options.spaces);
  7160. }
  7161. return json.replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029');
  7162. };
  7163. /***/ }),
  7164. /* 37 */
  7165. /***/ (function(module, exports, __webpack_require__) {
  7166. /* WEBPACK VAR INJECTION */(function(Buffer) {var js2xml = __webpack_require__(20);
  7167. module.exports = function (json, options) {
  7168. if (json instanceof Buffer) {
  7169. json = json.toString();
  7170. }
  7171. var js = null;
  7172. if (typeof (json) === 'string') {
  7173. try {
  7174. js = JSON.parse(json);
  7175. } catch (e) {
  7176. throw new Error('The JSON structure is invalid');
  7177. }
  7178. } else {
  7179. js = json;
  7180. }
  7181. return js2xml(js, options);
  7182. };
  7183. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4).Buffer))
  7184. /***/ })
  7185. /******/ ])));