xml2js.js 381 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783
  1. module.exports =
  2. /******/ (function(modules) { // webpackBootstrap
  3. /******/ // The module cache
  4. /******/ var installedModules = {};
  5. /******/ // The require function
  6. /******/ function __webpack_require__(moduleId) {
  7. /******/ // Check if module is in cache
  8. /******/ if(installedModules[moduleId])
  9. /******/ return installedModules[moduleId].exports;
  10. /******/ // Create a new module (and put it into the cache)
  11. /******/ var module = installedModules[moduleId] = {
  12. /******/ exports: {},
  13. /******/ id: moduleId,
  14. /******/ loaded: false
  15. /******/ };
  16. /******/ // Execute the module function
  17. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  18. /******/ // Flag the module as loaded
  19. /******/ module.loaded = true;
  20. /******/ // Return the exports of the module
  21. /******/ return module.exports;
  22. /******/ }
  23. /******/ // expose the modules object (__webpack_modules__)
  24. /******/ __webpack_require__.m = modules;
  25. /******/ // expose the module cache
  26. /******/ __webpack_require__.c = installedModules;
  27. /******/ // __webpack_public_path__
  28. /******/ __webpack_require__.p = "";
  29. /******/ // Load entry module and return exports
  30. /******/ return __webpack_require__(0);
  31. /******/ })
  32. /************************************************************************/
  33. /******/ ([
  34. /* 0 */
  35. /***/ (function(module, exports, __webpack_require__) {
  36. module.exports = __webpack_require__(1);
  37. /***/ }),
  38. /* 1 */
  39. /***/ (function(module, exports, __webpack_require__) {
  40. // Generated by CoffeeScript 1.12.7
  41. (function() {
  42. "use strict";
  43. var builder, defaults, parser, processors,
  44. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  45. hasProp = {}.hasOwnProperty;
  46. defaults = __webpack_require__(2);
  47. builder = __webpack_require__(3);
  48. parser = __webpack_require__(37);
  49. processors = __webpack_require__(71);
  50. exports.defaults = defaults.defaults;
  51. exports.processors = processors;
  52. exports.ValidationError = (function(superClass) {
  53. extend(ValidationError, superClass);
  54. function ValidationError(message) {
  55. this.message = message;
  56. }
  57. return ValidationError;
  58. })(Error);
  59. exports.Builder = builder.Builder;
  60. exports.Parser = parser.Parser;
  61. exports.parseString = parser.parseString;
  62. exports.parseStringPromise = parser.parseStringPromise;
  63. }).call(this);
  64. /***/ }),
  65. /* 2 */
  66. /***/ (function(module, exports) {
  67. // Generated by CoffeeScript 1.12.7
  68. (function() {
  69. exports.defaults = {
  70. "0.1": {
  71. explicitCharkey: false,
  72. trim: true,
  73. normalize: true,
  74. normalizeTags: false,
  75. attrkey: "@",
  76. charkey: "#",
  77. explicitArray: false,
  78. ignoreAttrs: false,
  79. mergeAttrs: false,
  80. explicitRoot: false,
  81. validator: null,
  82. xmlns: false,
  83. explicitChildren: false,
  84. childkey: '@@',
  85. charsAsChildren: false,
  86. includeWhiteChars: false,
  87. async: false,
  88. strict: true,
  89. attrNameProcessors: null,
  90. attrValueProcessors: null,
  91. tagNameProcessors: null,
  92. valueProcessors: null,
  93. emptyTag: ''
  94. },
  95. "0.2": {
  96. explicitCharkey: false,
  97. trim: false,
  98. normalize: false,
  99. normalizeTags: false,
  100. attrkey: "$",
  101. charkey: "_",
  102. explicitArray: true,
  103. ignoreAttrs: false,
  104. mergeAttrs: false,
  105. explicitRoot: true,
  106. validator: null,
  107. xmlns: false,
  108. explicitChildren: false,
  109. preserveChildrenOrder: false,
  110. childkey: '$$',
  111. charsAsChildren: false,
  112. includeWhiteChars: false,
  113. async: false,
  114. strict: true,
  115. attrNameProcessors: null,
  116. attrValueProcessors: null,
  117. tagNameProcessors: null,
  118. valueProcessors: null,
  119. rootName: 'root',
  120. xmldec: {
  121. 'version': '1.0',
  122. 'encoding': 'UTF-8',
  123. 'standalone': true
  124. },
  125. doctype: null,
  126. renderOpts: {
  127. 'pretty': true,
  128. 'indent': ' ',
  129. 'newline': '\n'
  130. },
  131. headless: false,
  132. chunkSize: 10000,
  133. emptyTag: '',
  134. cdata: false
  135. }
  136. };
  137. }).call(this);
  138. /***/ }),
  139. /* 3 */
  140. /***/ (function(module, exports, __webpack_require__) {
  141. // Generated by CoffeeScript 1.12.7
  142. (function() {
  143. "use strict";
  144. var builder, defaults, escapeCDATA, requiresCDATA, wrapCDATA,
  145. hasProp = {}.hasOwnProperty;
  146. builder = __webpack_require__(4);
  147. defaults = __webpack_require__(2).defaults;
  148. requiresCDATA = function(entry) {
  149. return typeof entry === "string" && (entry.indexOf('&') >= 0 || entry.indexOf('>') >= 0 || entry.indexOf('<') >= 0);
  150. };
  151. wrapCDATA = function(entry) {
  152. return "<![CDATA[" + (escapeCDATA(entry)) + "]]>";
  153. };
  154. escapeCDATA = function(entry) {
  155. return entry.replace(']]>', ']]]]><![CDATA[>');
  156. };
  157. exports.Builder = (function() {
  158. function Builder(opts) {
  159. var key, ref, value;
  160. this.options = {};
  161. ref = defaults["0.2"];
  162. for (key in ref) {
  163. if (!hasProp.call(ref, key)) continue;
  164. value = ref[key];
  165. this.options[key] = value;
  166. }
  167. for (key in opts) {
  168. if (!hasProp.call(opts, key)) continue;
  169. value = opts[key];
  170. this.options[key] = value;
  171. }
  172. }
  173. Builder.prototype.buildObject = function(rootObj) {
  174. var attrkey, charkey, render, rootElement, rootName;
  175. attrkey = this.options.attrkey;
  176. charkey = this.options.charkey;
  177. if ((Object.keys(rootObj).length === 1) && (this.options.rootName === defaults['0.2'].rootName)) {
  178. rootName = Object.keys(rootObj)[0];
  179. rootObj = rootObj[rootName];
  180. } else {
  181. rootName = this.options.rootName;
  182. }
  183. render = (function(_this) {
  184. return function(element, obj) {
  185. var attr, child, entry, index, key, value;
  186. if (typeof obj !== 'object') {
  187. if (_this.options.cdata && requiresCDATA(obj)) {
  188. element.raw(wrapCDATA(obj));
  189. } else {
  190. element.txt(obj);
  191. }
  192. } else if (Array.isArray(obj)) {
  193. for (index in obj) {
  194. if (!hasProp.call(obj, index)) continue;
  195. child = obj[index];
  196. for (key in child) {
  197. entry = child[key];
  198. element = render(element.ele(key), entry).up();
  199. }
  200. }
  201. } else {
  202. for (key in obj) {
  203. if (!hasProp.call(obj, key)) continue;
  204. child = obj[key];
  205. if (key === attrkey) {
  206. if (typeof child === "object") {
  207. for (attr in child) {
  208. value = child[attr];
  209. element = element.att(attr, value);
  210. }
  211. }
  212. } else if (key === charkey) {
  213. if (_this.options.cdata && requiresCDATA(child)) {
  214. element = element.raw(wrapCDATA(child));
  215. } else {
  216. element = element.txt(child);
  217. }
  218. } else if (Array.isArray(child)) {
  219. for (index in child) {
  220. if (!hasProp.call(child, index)) continue;
  221. entry = child[index];
  222. if (typeof entry === 'string') {
  223. if (_this.options.cdata && requiresCDATA(entry)) {
  224. element = element.ele(key).raw(wrapCDATA(entry)).up();
  225. } else {
  226. element = element.ele(key, entry).up();
  227. }
  228. } else {
  229. element = render(element.ele(key), entry).up();
  230. }
  231. }
  232. } else if (typeof child === "object") {
  233. element = render(element.ele(key), child).up();
  234. } else {
  235. if (typeof child === 'string' && _this.options.cdata && requiresCDATA(child)) {
  236. element = element.ele(key).raw(wrapCDATA(child)).up();
  237. } else {
  238. if (child == null) {
  239. child = '';
  240. }
  241. element = element.ele(key, child.toString()).up();
  242. }
  243. }
  244. }
  245. }
  246. return element;
  247. };
  248. })(this);
  249. rootElement = builder.create(rootName, this.options.xmldec, this.options.doctype, {
  250. headless: this.options.headless,
  251. allowSurrogateChars: this.options.allowSurrogateChars
  252. });
  253. return render(rootElement, rootObj).end(this.options.renderOpts);
  254. };
  255. return Builder;
  256. })();
  257. }).call(this);
  258. /***/ }),
  259. /* 4 */
  260. /***/ (function(module, exports, __webpack_require__) {
  261. // Generated by CoffeeScript 1.12.7
  262. (function() {
  263. var NodeType, WriterState, XMLDOMImplementation, XMLDocument, XMLDocumentCB, XMLStreamWriter, XMLStringWriter, assign, isFunction, ref;
  264. ref = __webpack_require__(5), assign = ref.assign, isFunction = ref.isFunction;
  265. XMLDOMImplementation = __webpack_require__(6);
  266. XMLDocument = __webpack_require__(7);
  267. XMLDocumentCB = __webpack_require__(35);
  268. XMLStringWriter = __webpack_require__(32);
  269. XMLStreamWriter = __webpack_require__(36);
  270. NodeType = __webpack_require__(13);
  271. WriterState = __webpack_require__(34);
  272. module.exports.create = function(name, xmldec, doctype, options) {
  273. var doc, root;
  274. if (name == null) {
  275. throw new Error("Root element needs a name.");
  276. }
  277. options = assign({}, xmldec, doctype, options);
  278. doc = new XMLDocument(options);
  279. root = doc.element(name);
  280. if (!options.headless) {
  281. doc.declaration(options);
  282. if ((options.pubID != null) || (options.sysID != null)) {
  283. doc.dtd(options);
  284. }
  285. }
  286. return root;
  287. };
  288. module.exports.begin = function(options, onData, onEnd) {
  289. var ref1;
  290. if (isFunction(options)) {
  291. ref1 = [options, onData], onData = ref1[0], onEnd = ref1[1];
  292. options = {};
  293. }
  294. if (onData) {
  295. return new XMLDocumentCB(options, onData, onEnd);
  296. } else {
  297. return new XMLDocument(options);
  298. }
  299. };
  300. module.exports.stringWriter = function(options) {
  301. return new XMLStringWriter(options);
  302. };
  303. module.exports.streamWriter = function(stream, options) {
  304. return new XMLStreamWriter(stream, options);
  305. };
  306. module.exports.implementation = new XMLDOMImplementation();
  307. module.exports.nodeType = NodeType;
  308. module.exports.writerState = WriterState;
  309. }).call(this);
  310. /***/ }),
  311. /* 5 */
  312. /***/ (function(module, exports) {
  313. // Generated by CoffeeScript 1.12.7
  314. (function() {
  315. var assign, getValue, isArray, isEmpty, isFunction, isObject, isPlainObject,
  316. slice = [].slice,
  317. hasProp = {}.hasOwnProperty;
  318. assign = function() {
  319. var i, key, len, source, sources, target;
  320. target = arguments[0], sources = 2 <= arguments.length ? slice.call(arguments, 1) : [];
  321. if (isFunction(Object.assign)) {
  322. Object.assign.apply(null, arguments);
  323. } else {
  324. for (i = 0, len = sources.length; i < len; i++) {
  325. source = sources[i];
  326. if (source != null) {
  327. for (key in source) {
  328. if (!hasProp.call(source, key)) continue;
  329. target[key] = source[key];
  330. }
  331. }
  332. }
  333. }
  334. return target;
  335. };
  336. isFunction = function(val) {
  337. return !!val && Object.prototype.toString.call(val) === '[object Function]';
  338. };
  339. isObject = function(val) {
  340. var ref;
  341. return !!val && ((ref = typeof val) === 'function' || ref === 'object');
  342. };
  343. isArray = function(val) {
  344. if (isFunction(Array.isArray)) {
  345. return Array.isArray(val);
  346. } else {
  347. return Object.prototype.toString.call(val) === '[object Array]';
  348. }
  349. };
  350. isEmpty = function(val) {
  351. var key;
  352. if (isArray(val)) {
  353. return !val.length;
  354. } else {
  355. for (key in val) {
  356. if (!hasProp.call(val, key)) continue;
  357. return false;
  358. }
  359. return true;
  360. }
  361. };
  362. isPlainObject = function(val) {
  363. var ctor, proto;
  364. return isObject(val) && (proto = Object.getPrototypeOf(val)) && (ctor = proto.constructor) && (typeof ctor === 'function') && (ctor instanceof ctor) && (Function.prototype.toString.call(ctor) === Function.prototype.toString.call(Object));
  365. };
  366. getValue = function(obj) {
  367. if (isFunction(obj.valueOf)) {
  368. return obj.valueOf();
  369. } else {
  370. return obj;
  371. }
  372. };
  373. module.exports.assign = assign;
  374. module.exports.isFunction = isFunction;
  375. module.exports.isObject = isObject;
  376. module.exports.isArray = isArray;
  377. module.exports.isEmpty = isEmpty;
  378. module.exports.isPlainObject = isPlainObject;
  379. module.exports.getValue = getValue;
  380. }).call(this);
  381. /***/ }),
  382. /* 6 */
  383. /***/ (function(module, exports) {
  384. // Generated by CoffeeScript 1.12.7
  385. (function() {
  386. var XMLDOMImplementation;
  387. module.exports = XMLDOMImplementation = (function() {
  388. function XMLDOMImplementation() {}
  389. XMLDOMImplementation.prototype.hasFeature = function(feature, version) {
  390. return true;
  391. };
  392. XMLDOMImplementation.prototype.createDocumentType = function(qualifiedName, publicId, systemId) {
  393. throw new Error("This DOM method is not implemented.");
  394. };
  395. XMLDOMImplementation.prototype.createDocument = function(namespaceURI, qualifiedName, doctype) {
  396. throw new Error("This DOM method is not implemented.");
  397. };
  398. XMLDOMImplementation.prototype.createHTMLDocument = function(title) {
  399. throw new Error("This DOM method is not implemented.");
  400. };
  401. XMLDOMImplementation.prototype.getFeature = function(feature, version) {
  402. throw new Error("This DOM method is not implemented.");
  403. };
  404. return XMLDOMImplementation;
  405. })();
  406. }).call(this);
  407. /***/ }),
  408. /* 7 */
  409. /***/ (function(module, exports, __webpack_require__) {
  410. // Generated by CoffeeScript 1.12.7
  411. (function() {
  412. var NodeType, XMLDOMConfiguration, XMLDOMImplementation, XMLDocument, XMLNode, XMLStringWriter, XMLStringifier, isPlainObject,
  413. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  414. hasProp = {}.hasOwnProperty;
  415. isPlainObject = __webpack_require__(5).isPlainObject;
  416. XMLDOMImplementation = __webpack_require__(6);
  417. XMLDOMConfiguration = __webpack_require__(8);
  418. XMLNode = __webpack_require__(11);
  419. NodeType = __webpack_require__(13);
  420. XMLStringifier = __webpack_require__(31);
  421. XMLStringWriter = __webpack_require__(32);
  422. module.exports = XMLDocument = (function(superClass) {
  423. extend(XMLDocument, superClass);
  424. function XMLDocument(options) {
  425. XMLDocument.__super__.constructor.call(this, null);
  426. this.name = "#document";
  427. this.type = NodeType.Document;
  428. this.documentURI = null;
  429. this.domConfig = new XMLDOMConfiguration();
  430. options || (options = {});
  431. if (!options.writer) {
  432. options.writer = new XMLStringWriter();
  433. }
  434. this.options = options;
  435. this.stringify = new XMLStringifier(options);
  436. }
  437. Object.defineProperty(XMLDocument.prototype, 'implementation', {
  438. value: new XMLDOMImplementation()
  439. });
  440. Object.defineProperty(XMLDocument.prototype, 'doctype', {
  441. get: function() {
  442. var child, i, len, ref;
  443. ref = this.children;
  444. for (i = 0, len = ref.length; i < len; i++) {
  445. child = ref[i];
  446. if (child.type === NodeType.DocType) {
  447. return child;
  448. }
  449. }
  450. return null;
  451. }
  452. });
  453. Object.defineProperty(XMLDocument.prototype, 'documentElement', {
  454. get: function() {
  455. return this.rootObject || null;
  456. }
  457. });
  458. Object.defineProperty(XMLDocument.prototype, 'inputEncoding', {
  459. get: function() {
  460. return null;
  461. }
  462. });
  463. Object.defineProperty(XMLDocument.prototype, 'strictErrorChecking', {
  464. get: function() {
  465. return false;
  466. }
  467. });
  468. Object.defineProperty(XMLDocument.prototype, 'xmlEncoding', {
  469. get: function() {
  470. if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
  471. return this.children[0].encoding;
  472. } else {
  473. return null;
  474. }
  475. }
  476. });
  477. Object.defineProperty(XMLDocument.prototype, 'xmlStandalone', {
  478. get: function() {
  479. if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
  480. return this.children[0].standalone === 'yes';
  481. } else {
  482. return false;
  483. }
  484. }
  485. });
  486. Object.defineProperty(XMLDocument.prototype, 'xmlVersion', {
  487. get: function() {
  488. if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) {
  489. return this.children[0].version;
  490. } else {
  491. return "1.0";
  492. }
  493. }
  494. });
  495. Object.defineProperty(XMLDocument.prototype, 'URL', {
  496. get: function() {
  497. return this.documentURI;
  498. }
  499. });
  500. Object.defineProperty(XMLDocument.prototype, 'origin', {
  501. get: function() {
  502. return null;
  503. }
  504. });
  505. Object.defineProperty(XMLDocument.prototype, 'compatMode', {
  506. get: function() {
  507. return null;
  508. }
  509. });
  510. Object.defineProperty(XMLDocument.prototype, 'characterSet', {
  511. get: function() {
  512. return null;
  513. }
  514. });
  515. Object.defineProperty(XMLDocument.prototype, 'contentType', {
  516. get: function() {
  517. return null;
  518. }
  519. });
  520. XMLDocument.prototype.end = function(writer) {
  521. var writerOptions;
  522. writerOptions = {};
  523. if (!writer) {
  524. writer = this.options.writer;
  525. } else if (isPlainObject(writer)) {
  526. writerOptions = writer;
  527. writer = this.options.writer;
  528. }
  529. return writer.document(this, writer.filterOptions(writerOptions));
  530. };
  531. XMLDocument.prototype.toString = function(options) {
  532. return this.options.writer.document(this, this.options.writer.filterOptions(options));
  533. };
  534. XMLDocument.prototype.createElement = function(tagName) {
  535. throw new Error("This DOM method is not implemented." + this.debugInfo());
  536. };
  537. XMLDocument.prototype.createDocumentFragment = function() {
  538. throw new Error("This DOM method is not implemented." + this.debugInfo());
  539. };
  540. XMLDocument.prototype.createTextNode = function(data) {
  541. throw new Error("This DOM method is not implemented." + this.debugInfo());
  542. };
  543. XMLDocument.prototype.createComment = function(data) {
  544. throw new Error("This DOM method is not implemented." + this.debugInfo());
  545. };
  546. XMLDocument.prototype.createCDATASection = function(data) {
  547. throw new Error("This DOM method is not implemented." + this.debugInfo());
  548. };
  549. XMLDocument.prototype.createProcessingInstruction = function(target, data) {
  550. throw new Error("This DOM method is not implemented." + this.debugInfo());
  551. };
  552. XMLDocument.prototype.createAttribute = function(name) {
  553. throw new Error("This DOM method is not implemented." + this.debugInfo());
  554. };
  555. XMLDocument.prototype.createEntityReference = function(name) {
  556. throw new Error("This DOM method is not implemented." + this.debugInfo());
  557. };
  558. XMLDocument.prototype.getElementsByTagName = function(tagname) {
  559. throw new Error("This DOM method is not implemented." + this.debugInfo());
  560. };
  561. XMLDocument.prototype.importNode = function(importedNode, deep) {
  562. throw new Error("This DOM method is not implemented." + this.debugInfo());
  563. };
  564. XMLDocument.prototype.createElementNS = function(namespaceURI, qualifiedName) {
  565. throw new Error("This DOM method is not implemented." + this.debugInfo());
  566. };
  567. XMLDocument.prototype.createAttributeNS = function(namespaceURI, qualifiedName) {
  568. throw new Error("This DOM method is not implemented." + this.debugInfo());
  569. };
  570. XMLDocument.prototype.getElementsByTagNameNS = function(namespaceURI, localName) {
  571. throw new Error("This DOM method is not implemented." + this.debugInfo());
  572. };
  573. XMLDocument.prototype.getElementById = function(elementId) {
  574. throw new Error("This DOM method is not implemented." + this.debugInfo());
  575. };
  576. XMLDocument.prototype.adoptNode = function(source) {
  577. throw new Error("This DOM method is not implemented." + this.debugInfo());
  578. };
  579. XMLDocument.prototype.normalizeDocument = function() {
  580. throw new Error("This DOM method is not implemented." + this.debugInfo());
  581. };
  582. XMLDocument.prototype.renameNode = function(node, namespaceURI, qualifiedName) {
  583. throw new Error("This DOM method is not implemented." + this.debugInfo());
  584. };
  585. XMLDocument.prototype.getElementsByClassName = function(classNames) {
  586. throw new Error("This DOM method is not implemented." + this.debugInfo());
  587. };
  588. XMLDocument.prototype.createEvent = function(eventInterface) {
  589. throw new Error("This DOM method is not implemented." + this.debugInfo());
  590. };
  591. XMLDocument.prototype.createRange = function() {
  592. throw new Error("This DOM method is not implemented." + this.debugInfo());
  593. };
  594. XMLDocument.prototype.createNodeIterator = function(root, whatToShow, filter) {
  595. throw new Error("This DOM method is not implemented." + this.debugInfo());
  596. };
  597. XMLDocument.prototype.createTreeWalker = function(root, whatToShow, filter) {
  598. throw new Error("This DOM method is not implemented." + this.debugInfo());
  599. };
  600. return XMLDocument;
  601. })(XMLNode);
  602. }).call(this);
  603. /***/ }),
  604. /* 8 */
  605. /***/ (function(module, exports, __webpack_require__) {
  606. // Generated by CoffeeScript 1.12.7
  607. (function() {
  608. var XMLDOMConfiguration, XMLDOMErrorHandler, XMLDOMStringList;
  609. XMLDOMErrorHandler = __webpack_require__(9);
  610. XMLDOMStringList = __webpack_require__(10);
  611. module.exports = XMLDOMConfiguration = (function() {
  612. function XMLDOMConfiguration() {
  613. var clonedSelf;
  614. this.defaultParams = {
  615. "canonical-form": false,
  616. "cdata-sections": false,
  617. "comments": false,
  618. "datatype-normalization": false,
  619. "element-content-whitespace": true,
  620. "entities": true,
  621. "error-handler": new XMLDOMErrorHandler(),
  622. "infoset": true,
  623. "validate-if-schema": false,
  624. "namespaces": true,
  625. "namespace-declarations": true,
  626. "normalize-characters": false,
  627. "schema-location": '',
  628. "schema-type": '',
  629. "split-cdata-sections": true,
  630. "validate": false,
  631. "well-formed": true
  632. };
  633. this.params = clonedSelf = Object.create(this.defaultParams);
  634. }
  635. Object.defineProperty(XMLDOMConfiguration.prototype, 'parameterNames', {
  636. get: function() {
  637. return new XMLDOMStringList(Object.keys(this.defaultParams));
  638. }
  639. });
  640. XMLDOMConfiguration.prototype.getParameter = function(name) {
  641. if (this.params.hasOwnProperty(name)) {
  642. return this.params[name];
  643. } else {
  644. return null;
  645. }
  646. };
  647. XMLDOMConfiguration.prototype.canSetParameter = function(name, value) {
  648. return true;
  649. };
  650. XMLDOMConfiguration.prototype.setParameter = function(name, value) {
  651. if (value != null) {
  652. return this.params[name] = value;
  653. } else {
  654. return delete this.params[name];
  655. }
  656. };
  657. return XMLDOMConfiguration;
  658. })();
  659. }).call(this);
  660. /***/ }),
  661. /* 9 */
  662. /***/ (function(module, exports) {
  663. // Generated by CoffeeScript 1.12.7
  664. (function() {
  665. var XMLDOMErrorHandler;
  666. module.exports = XMLDOMErrorHandler = (function() {
  667. function XMLDOMErrorHandler() {}
  668. XMLDOMErrorHandler.prototype.handleError = function(error) {
  669. throw new Error(error);
  670. };
  671. return XMLDOMErrorHandler;
  672. })();
  673. }).call(this);
  674. /***/ }),
  675. /* 10 */
  676. /***/ (function(module, exports) {
  677. // Generated by CoffeeScript 1.12.7
  678. (function() {
  679. var XMLDOMStringList;
  680. module.exports = XMLDOMStringList = (function() {
  681. function XMLDOMStringList(arr) {
  682. this.arr = arr || [];
  683. }
  684. Object.defineProperty(XMLDOMStringList.prototype, 'length', {
  685. get: function() {
  686. return this.arr.length;
  687. }
  688. });
  689. XMLDOMStringList.prototype.item = function(index) {
  690. return this.arr[index] || null;
  691. };
  692. XMLDOMStringList.prototype.contains = function(str) {
  693. return this.arr.indexOf(str) !== -1;
  694. };
  695. return XMLDOMStringList;
  696. })();
  697. }).call(this);
  698. /***/ }),
  699. /* 11 */
  700. /***/ (function(module, exports, __webpack_require__) {
  701. // Generated by CoffeeScript 1.12.7
  702. (function() {
  703. var DocumentPosition, NodeType, XMLCData, XMLComment, XMLDeclaration, XMLDocType, XMLDummy, XMLElement, XMLNamedNodeMap, XMLNode, XMLNodeList, XMLProcessingInstruction, XMLRaw, XMLText, getValue, isEmpty, isFunction, isObject, ref1,
  704. hasProp = {}.hasOwnProperty;
  705. ref1 = __webpack_require__(5), isObject = ref1.isObject, isFunction = ref1.isFunction, isEmpty = ref1.isEmpty, getValue = ref1.getValue;
  706. XMLElement = null;
  707. XMLCData = null;
  708. XMLComment = null;
  709. XMLDeclaration = null;
  710. XMLDocType = null;
  711. XMLRaw = null;
  712. XMLText = null;
  713. XMLProcessingInstruction = null;
  714. XMLDummy = null;
  715. NodeType = null;
  716. XMLNodeList = null;
  717. XMLNamedNodeMap = null;
  718. DocumentPosition = null;
  719. module.exports = XMLNode = (function() {
  720. function XMLNode(parent1) {
  721. this.parent = parent1;
  722. if (this.parent) {
  723. this.options = this.parent.options;
  724. this.stringify = this.parent.stringify;
  725. }
  726. this.value = null;
  727. this.children = [];
  728. this.baseURI = null;
  729. if (!XMLElement) {
  730. XMLElement = __webpack_require__(12);
  731. XMLCData = __webpack_require__(16);
  732. XMLComment = __webpack_require__(18);
  733. XMLDeclaration = __webpack_require__(19);
  734. XMLDocType = __webpack_require__(20);
  735. XMLRaw = __webpack_require__(25);
  736. XMLText = __webpack_require__(26);
  737. XMLProcessingInstruction = __webpack_require__(27);
  738. XMLDummy = __webpack_require__(28);
  739. NodeType = __webpack_require__(13);
  740. XMLNodeList = __webpack_require__(29);
  741. XMLNamedNodeMap = __webpack_require__(15);
  742. DocumentPosition = __webpack_require__(30);
  743. }
  744. }
  745. Object.defineProperty(XMLNode.prototype, 'nodeName', {
  746. get: function() {
  747. return this.name;
  748. }
  749. });
  750. Object.defineProperty(XMLNode.prototype, 'nodeType', {
  751. get: function() {
  752. return this.type;
  753. }
  754. });
  755. Object.defineProperty(XMLNode.prototype, 'nodeValue', {
  756. get: function() {
  757. return this.value;
  758. }
  759. });
  760. Object.defineProperty(XMLNode.prototype, 'parentNode', {
  761. get: function() {
  762. return this.parent;
  763. }
  764. });
  765. Object.defineProperty(XMLNode.prototype, 'childNodes', {
  766. get: function() {
  767. if (!this.childNodeList || !this.childNodeList.nodes) {
  768. this.childNodeList = new XMLNodeList(this.children);
  769. }
  770. return this.childNodeList;
  771. }
  772. });
  773. Object.defineProperty(XMLNode.prototype, 'firstChild', {
  774. get: function() {
  775. return this.children[0] || null;
  776. }
  777. });
  778. Object.defineProperty(XMLNode.prototype, 'lastChild', {
  779. get: function() {
  780. return this.children[this.children.length - 1] || null;
  781. }
  782. });
  783. Object.defineProperty(XMLNode.prototype, 'previousSibling', {
  784. get: function() {
  785. var i;
  786. i = this.parent.children.indexOf(this);
  787. return this.parent.children[i - 1] || null;
  788. }
  789. });
  790. Object.defineProperty(XMLNode.prototype, 'nextSibling', {
  791. get: function() {
  792. var i;
  793. i = this.parent.children.indexOf(this);
  794. return this.parent.children[i + 1] || null;
  795. }
  796. });
  797. Object.defineProperty(XMLNode.prototype, 'ownerDocument', {
  798. get: function() {
  799. return this.document() || null;
  800. }
  801. });
  802. Object.defineProperty(XMLNode.prototype, 'textContent', {
  803. get: function() {
  804. var child, j, len, ref2, str;
  805. if (this.nodeType === NodeType.Element || this.nodeType === NodeType.DocumentFragment) {
  806. str = '';
  807. ref2 = this.children;
  808. for (j = 0, len = ref2.length; j < len; j++) {
  809. child = ref2[j];
  810. if (child.textContent) {
  811. str += child.textContent;
  812. }
  813. }
  814. return str;
  815. } else {
  816. return null;
  817. }
  818. },
  819. set: function(value) {
  820. throw new Error("This DOM method is not implemented." + this.debugInfo());
  821. }
  822. });
  823. XMLNode.prototype.setParent = function(parent) {
  824. var child, j, len, ref2, results;
  825. this.parent = parent;
  826. if (parent) {
  827. this.options = parent.options;
  828. this.stringify = parent.stringify;
  829. }
  830. ref2 = this.children;
  831. results = [];
  832. for (j = 0, len = ref2.length; j < len; j++) {
  833. child = ref2[j];
  834. results.push(child.setParent(this));
  835. }
  836. return results;
  837. };
  838. XMLNode.prototype.element = function(name, attributes, text) {
  839. var childNode, item, j, k, key, lastChild, len, len1, ref2, ref3, val;
  840. lastChild = null;
  841. if (attributes === null && (text == null)) {
  842. ref2 = [{}, null], attributes = ref2[0], text = ref2[1];
  843. }
  844. if (attributes == null) {
  845. attributes = {};
  846. }
  847. attributes = getValue(attributes);
  848. if (!isObject(attributes)) {
  849. ref3 = [attributes, text], text = ref3[0], attributes = ref3[1];
  850. }
  851. if (name != null) {
  852. name = getValue(name);
  853. }
  854. if (Array.isArray(name)) {
  855. for (j = 0, len = name.length; j < len; j++) {
  856. item = name[j];
  857. lastChild = this.element(item);
  858. }
  859. } else if (isFunction(name)) {
  860. lastChild = this.element(name.apply());
  861. } else if (isObject(name)) {
  862. for (key in name) {
  863. if (!hasProp.call(name, key)) continue;
  864. val = name[key];
  865. if (isFunction(val)) {
  866. val = val.apply();
  867. }
  868. if (!this.options.ignoreDecorators && this.stringify.convertAttKey && key.indexOf(this.stringify.convertAttKey) === 0) {
  869. lastChild = this.attribute(key.substr(this.stringify.convertAttKey.length), val);
  870. } else if (!this.options.separateArrayItems && Array.isArray(val) && isEmpty(val)) {
  871. lastChild = this.dummy();
  872. } else if (isObject(val) && isEmpty(val)) {
  873. lastChild = this.element(key);
  874. } else if (!this.options.keepNullNodes && (val == null)) {
  875. lastChild = this.dummy();
  876. } else if (!this.options.separateArrayItems && Array.isArray(val)) {
  877. for (k = 0, len1 = val.length; k < len1; k++) {
  878. item = val[k];
  879. childNode = {};
  880. childNode[key] = item;
  881. lastChild = this.element(childNode);
  882. }
  883. } else if (isObject(val)) {
  884. if (!this.options.ignoreDecorators && this.stringify.convertTextKey && key.indexOf(this.stringify.convertTextKey) === 0) {
  885. lastChild = this.element(val);
  886. } else {
  887. lastChild = this.element(key);
  888. lastChild.element(val);
  889. }
  890. } else {
  891. lastChild = this.element(key, val);
  892. }
  893. }
  894. } else if (!this.options.keepNullNodes && text === null) {
  895. lastChild = this.dummy();
  896. } else {
  897. if (!this.options.ignoreDecorators && this.stringify.convertTextKey && name.indexOf(this.stringify.convertTextKey) === 0) {
  898. lastChild = this.text(text);
  899. } else if (!this.options.ignoreDecorators && this.stringify.convertCDataKey && name.indexOf(this.stringify.convertCDataKey) === 0) {
  900. lastChild = this.cdata(text);
  901. } else if (!this.options.ignoreDecorators && this.stringify.convertCommentKey && name.indexOf(this.stringify.convertCommentKey) === 0) {
  902. lastChild = this.comment(text);
  903. } else if (!this.options.ignoreDecorators && this.stringify.convertRawKey && name.indexOf(this.stringify.convertRawKey) === 0) {
  904. lastChild = this.raw(text);
  905. } else if (!this.options.ignoreDecorators && this.stringify.convertPIKey && name.indexOf(this.stringify.convertPIKey) === 0) {
  906. lastChild = this.instruction(name.substr(this.stringify.convertPIKey.length), text);
  907. } else {
  908. lastChild = this.node(name, attributes, text);
  909. }
  910. }
  911. if (lastChild == null) {
  912. throw new Error("Could not create any elements with: " + name + ". " + this.debugInfo());
  913. }
  914. return lastChild;
  915. };
  916. XMLNode.prototype.insertBefore = function(name, attributes, text) {
  917. var child, i, newChild, refChild, removed;
  918. if (name != null ? name.type : void 0) {
  919. newChild = name;
  920. refChild = attributes;
  921. newChild.setParent(this);
  922. if (refChild) {
  923. i = children.indexOf(refChild);
  924. removed = children.splice(i);
  925. children.push(newChild);
  926. Array.prototype.push.apply(children, removed);
  927. } else {
  928. children.push(newChild);
  929. }
  930. return newChild;
  931. } else {
  932. if (this.isRoot) {
  933. throw new Error("Cannot insert elements at root level. " + this.debugInfo(name));
  934. }
  935. i = this.parent.children.indexOf(this);
  936. removed = this.parent.children.splice(i);
  937. child = this.parent.element(name, attributes, text);
  938. Array.prototype.push.apply(this.parent.children, removed);
  939. return child;
  940. }
  941. };
  942. XMLNode.prototype.insertAfter = function(name, attributes, text) {
  943. var child, i, removed;
  944. if (this.isRoot) {
  945. throw new Error("Cannot insert elements at root level. " + this.debugInfo(name));
  946. }
  947. i = this.parent.children.indexOf(this);
  948. removed = this.parent.children.splice(i + 1);
  949. child = this.parent.element(name, attributes, text);
  950. Array.prototype.push.apply(this.parent.children, removed);
  951. return child;
  952. };
  953. XMLNode.prototype.remove = function() {
  954. var i, ref2;
  955. if (this.isRoot) {
  956. throw new Error("Cannot remove the root element. " + this.debugInfo());
  957. }
  958. i = this.parent.children.indexOf(this);
  959. [].splice.apply(this.parent.children, [i, i - i + 1].concat(ref2 = [])), ref2;
  960. return this.parent;
  961. };
  962. XMLNode.prototype.node = function(name, attributes, text) {
  963. var child, ref2;
  964. if (name != null) {
  965. name = getValue(name);
  966. }
  967. attributes || (attributes = {});
  968. attributes = getValue(attributes);
  969. if (!isObject(attributes)) {
  970. ref2 = [attributes, text], text = ref2[0], attributes = ref2[1];
  971. }
  972. child = new XMLElement(this, name, attributes);
  973. if (text != null) {
  974. child.text(text);
  975. }
  976. this.children.push(child);
  977. return child;
  978. };
  979. XMLNode.prototype.text = function(value) {
  980. var child;
  981. if (isObject(value)) {
  982. this.element(value);
  983. }
  984. child = new XMLText(this, value);
  985. this.children.push(child);
  986. return this;
  987. };
  988. XMLNode.prototype.cdata = function(value) {
  989. var child;
  990. child = new XMLCData(this, value);
  991. this.children.push(child);
  992. return this;
  993. };
  994. XMLNode.prototype.comment = function(value) {
  995. var child;
  996. child = new XMLComment(this, value);
  997. this.children.push(child);
  998. return this;
  999. };
  1000. XMLNode.prototype.commentBefore = function(value) {
  1001. var child, i, removed;
  1002. i = this.parent.children.indexOf(this);
  1003. removed = this.parent.children.splice(i);
  1004. child = this.parent.comment(value);
  1005. Array.prototype.push.apply(this.parent.children, removed);
  1006. return this;
  1007. };
  1008. XMLNode.prototype.commentAfter = function(value) {
  1009. var child, i, removed;
  1010. i = this.parent.children.indexOf(this);
  1011. removed = this.parent.children.splice(i + 1);
  1012. child = this.parent.comment(value);
  1013. Array.prototype.push.apply(this.parent.children, removed);
  1014. return this;
  1015. };
  1016. XMLNode.prototype.raw = function(value) {
  1017. var child;
  1018. child = new XMLRaw(this, value);
  1019. this.children.push(child);
  1020. return this;
  1021. };
  1022. XMLNode.prototype.dummy = function() {
  1023. var child;
  1024. child = new XMLDummy(this);
  1025. return child;
  1026. };
  1027. XMLNode.prototype.instruction = function(target, value) {
  1028. var insTarget, insValue, instruction, j, len;
  1029. if (target != null) {
  1030. target = getValue(target);
  1031. }
  1032. if (value != null) {
  1033. value = getValue(value);
  1034. }
  1035. if (Array.isArray(target)) {
  1036. for (j = 0, len = target.length; j < len; j++) {
  1037. insTarget = target[j];
  1038. this.instruction(insTarget);
  1039. }
  1040. } else if (isObject(target)) {
  1041. for (insTarget in target) {
  1042. if (!hasProp.call(target, insTarget)) continue;
  1043. insValue = target[insTarget];
  1044. this.instruction(insTarget, insValue);
  1045. }
  1046. } else {
  1047. if (isFunction(value)) {
  1048. value = value.apply();
  1049. }
  1050. instruction = new XMLProcessingInstruction(this, target, value);
  1051. this.children.push(instruction);
  1052. }
  1053. return this;
  1054. };
  1055. XMLNode.prototype.instructionBefore = function(target, value) {
  1056. var child, i, removed;
  1057. i = this.parent.children.indexOf(this);
  1058. removed = this.parent.children.splice(i);
  1059. child = this.parent.instruction(target, value);
  1060. Array.prototype.push.apply(this.parent.children, removed);
  1061. return this;
  1062. };
  1063. XMLNode.prototype.instructionAfter = function(target, value) {
  1064. var child, i, removed;
  1065. i = this.parent.children.indexOf(this);
  1066. removed = this.parent.children.splice(i + 1);
  1067. child = this.parent.instruction(target, value);
  1068. Array.prototype.push.apply(this.parent.children, removed);
  1069. return this;
  1070. };
  1071. XMLNode.prototype.declaration = function(version, encoding, standalone) {
  1072. var doc, xmldec;
  1073. doc = this.document();
  1074. xmldec = new XMLDeclaration(doc, version, encoding, standalone);
  1075. if (doc.children.length === 0) {
  1076. doc.children.unshift(xmldec);
  1077. } else if (doc.children[0].type === NodeType.Declaration) {
  1078. doc.children[0] = xmldec;
  1079. } else {
  1080. doc.children.unshift(xmldec);
  1081. }
  1082. return doc.root() || doc;
  1083. };
  1084. XMLNode.prototype.dtd = function(pubID, sysID) {
  1085. var child, doc, doctype, i, j, k, len, len1, ref2, ref3;
  1086. doc = this.document();
  1087. doctype = new XMLDocType(doc, pubID, sysID);
  1088. ref2 = doc.children;
  1089. for (i = j = 0, len = ref2.length; j < len; i = ++j) {
  1090. child = ref2[i];
  1091. if (child.type === NodeType.DocType) {
  1092. doc.children[i] = doctype;
  1093. return doctype;
  1094. }
  1095. }
  1096. ref3 = doc.children;
  1097. for (i = k = 0, len1 = ref3.length; k < len1; i = ++k) {
  1098. child = ref3[i];
  1099. if (child.isRoot) {
  1100. doc.children.splice(i, 0, doctype);
  1101. return doctype;
  1102. }
  1103. }
  1104. doc.children.push(doctype);
  1105. return doctype;
  1106. };
  1107. XMLNode.prototype.up = function() {
  1108. if (this.isRoot) {
  1109. throw new Error("The root node has no parent. Use doc() if you need to get the document object.");
  1110. }
  1111. return this.parent;
  1112. };
  1113. XMLNode.prototype.root = function() {
  1114. var node;
  1115. node = this;
  1116. while (node) {
  1117. if (node.type === NodeType.Document) {
  1118. return node.rootObject;
  1119. } else if (node.isRoot) {
  1120. return node;
  1121. } else {
  1122. node = node.parent;
  1123. }
  1124. }
  1125. };
  1126. XMLNode.prototype.document = function() {
  1127. var node;
  1128. node = this;
  1129. while (node) {
  1130. if (node.type === NodeType.Document) {
  1131. return node;
  1132. } else {
  1133. node = node.parent;
  1134. }
  1135. }
  1136. };
  1137. XMLNode.prototype.end = function(options) {
  1138. return this.document().end(options);
  1139. };
  1140. XMLNode.prototype.prev = function() {
  1141. var i;
  1142. i = this.parent.children.indexOf(this);
  1143. if (i < 1) {
  1144. throw new Error("Already at the first node. " + this.debugInfo());
  1145. }
  1146. return this.parent.children[i - 1];
  1147. };
  1148. XMLNode.prototype.next = function() {
  1149. var i;
  1150. i = this.parent.children.indexOf(this);
  1151. if (i === -1 || i === this.parent.children.length - 1) {
  1152. throw new Error("Already at the last node. " + this.debugInfo());
  1153. }
  1154. return this.parent.children[i + 1];
  1155. };
  1156. XMLNode.prototype.importDocument = function(doc) {
  1157. var clonedRoot;
  1158. clonedRoot = doc.root().clone();
  1159. clonedRoot.parent = this;
  1160. clonedRoot.isRoot = false;
  1161. this.children.push(clonedRoot);
  1162. return this;
  1163. };
  1164. XMLNode.prototype.debugInfo = function(name) {
  1165. var ref2, ref3;
  1166. name = name || this.name;
  1167. if ((name == null) && !((ref2 = this.parent) != null ? ref2.name : void 0)) {
  1168. return "";
  1169. } else if (name == null) {
  1170. return "parent: <" + this.parent.name + ">";
  1171. } else if (!((ref3 = this.parent) != null ? ref3.name : void 0)) {
  1172. return "node: <" + name + ">";
  1173. } else {
  1174. return "node: <" + name + ">, parent: <" + this.parent.name + ">";
  1175. }
  1176. };
  1177. XMLNode.prototype.ele = function(name, attributes, text) {
  1178. return this.element(name, attributes, text);
  1179. };
  1180. XMLNode.prototype.nod = function(name, attributes, text) {
  1181. return this.node(name, attributes, text);
  1182. };
  1183. XMLNode.prototype.txt = function(value) {
  1184. return this.text(value);
  1185. };
  1186. XMLNode.prototype.dat = function(value) {
  1187. return this.cdata(value);
  1188. };
  1189. XMLNode.prototype.com = function(value) {
  1190. return this.comment(value);
  1191. };
  1192. XMLNode.prototype.ins = function(target, value) {
  1193. return this.instruction(target, value);
  1194. };
  1195. XMLNode.prototype.doc = function() {
  1196. return this.document();
  1197. };
  1198. XMLNode.prototype.dec = function(version, encoding, standalone) {
  1199. return this.declaration(version, encoding, standalone);
  1200. };
  1201. XMLNode.prototype.e = function(name, attributes, text) {
  1202. return this.element(name, attributes, text);
  1203. };
  1204. XMLNode.prototype.n = function(name, attributes, text) {
  1205. return this.node(name, attributes, text);
  1206. };
  1207. XMLNode.prototype.t = function(value) {
  1208. return this.text(value);
  1209. };
  1210. XMLNode.prototype.d = function(value) {
  1211. return this.cdata(value);
  1212. };
  1213. XMLNode.prototype.c = function(value) {
  1214. return this.comment(value);
  1215. };
  1216. XMLNode.prototype.r = function(value) {
  1217. return this.raw(value);
  1218. };
  1219. XMLNode.prototype.i = function(target, value) {
  1220. return this.instruction(target, value);
  1221. };
  1222. XMLNode.prototype.u = function() {
  1223. return this.up();
  1224. };
  1225. XMLNode.prototype.importXMLBuilder = function(doc) {
  1226. return this.importDocument(doc);
  1227. };
  1228. XMLNode.prototype.replaceChild = function(newChild, oldChild) {
  1229. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1230. };
  1231. XMLNode.prototype.removeChild = function(oldChild) {
  1232. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1233. };
  1234. XMLNode.prototype.appendChild = function(newChild) {
  1235. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1236. };
  1237. XMLNode.prototype.hasChildNodes = function() {
  1238. return this.children.length !== 0;
  1239. };
  1240. XMLNode.prototype.cloneNode = function(deep) {
  1241. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1242. };
  1243. XMLNode.prototype.normalize = function() {
  1244. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1245. };
  1246. XMLNode.prototype.isSupported = function(feature, version) {
  1247. return true;
  1248. };
  1249. XMLNode.prototype.hasAttributes = function() {
  1250. return this.attribs.length !== 0;
  1251. };
  1252. XMLNode.prototype.compareDocumentPosition = function(other) {
  1253. var ref, res;
  1254. ref = this;
  1255. if (ref === other) {
  1256. return 0;
  1257. } else if (this.document() !== other.document()) {
  1258. res = DocumentPosition.Disconnected | DocumentPosition.ImplementationSpecific;
  1259. if (Math.random() < 0.5) {
  1260. res |= DocumentPosition.Preceding;
  1261. } else {
  1262. res |= DocumentPosition.Following;
  1263. }
  1264. return res;
  1265. } else if (ref.isAncestor(other)) {
  1266. return DocumentPosition.Contains | DocumentPosition.Preceding;
  1267. } else if (ref.isDescendant(other)) {
  1268. return DocumentPosition.Contains | DocumentPosition.Following;
  1269. } else if (ref.isPreceding(other)) {
  1270. return DocumentPosition.Preceding;
  1271. } else {
  1272. return DocumentPosition.Following;
  1273. }
  1274. };
  1275. XMLNode.prototype.isSameNode = function(other) {
  1276. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1277. };
  1278. XMLNode.prototype.lookupPrefix = function(namespaceURI) {
  1279. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1280. };
  1281. XMLNode.prototype.isDefaultNamespace = function(namespaceURI) {
  1282. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1283. };
  1284. XMLNode.prototype.lookupNamespaceURI = function(prefix) {
  1285. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1286. };
  1287. XMLNode.prototype.isEqualNode = function(node) {
  1288. var i, j, ref2;
  1289. if (node.nodeType !== this.nodeType) {
  1290. return false;
  1291. }
  1292. if (node.children.length !== this.children.length) {
  1293. return false;
  1294. }
  1295. for (i = j = 0, ref2 = this.children.length - 1; 0 <= ref2 ? j <= ref2 : j >= ref2; i = 0 <= ref2 ? ++j : --j) {
  1296. if (!this.children[i].isEqualNode(node.children[i])) {
  1297. return false;
  1298. }
  1299. }
  1300. return true;
  1301. };
  1302. XMLNode.prototype.getFeature = function(feature, version) {
  1303. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1304. };
  1305. XMLNode.prototype.setUserData = function(key, data, handler) {
  1306. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1307. };
  1308. XMLNode.prototype.getUserData = function(key) {
  1309. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1310. };
  1311. XMLNode.prototype.contains = function(other) {
  1312. if (!other) {
  1313. return false;
  1314. }
  1315. return other === this || this.isDescendant(other);
  1316. };
  1317. XMLNode.prototype.isDescendant = function(node) {
  1318. var child, isDescendantChild, j, len, ref2;
  1319. ref2 = this.children;
  1320. for (j = 0, len = ref2.length; j < len; j++) {
  1321. child = ref2[j];
  1322. if (node === child) {
  1323. return true;
  1324. }
  1325. isDescendantChild = child.isDescendant(node);
  1326. if (isDescendantChild) {
  1327. return true;
  1328. }
  1329. }
  1330. return false;
  1331. };
  1332. XMLNode.prototype.isAncestor = function(node) {
  1333. return node.isDescendant(this);
  1334. };
  1335. XMLNode.prototype.isPreceding = function(node) {
  1336. var nodePos, thisPos;
  1337. nodePos = this.treePosition(node);
  1338. thisPos = this.treePosition(this);
  1339. if (nodePos === -1 || thisPos === -1) {
  1340. return false;
  1341. } else {
  1342. return nodePos < thisPos;
  1343. }
  1344. };
  1345. XMLNode.prototype.isFollowing = function(node) {
  1346. var nodePos, thisPos;
  1347. nodePos = this.treePosition(node);
  1348. thisPos = this.treePosition(this);
  1349. if (nodePos === -1 || thisPos === -1) {
  1350. return false;
  1351. } else {
  1352. return nodePos > thisPos;
  1353. }
  1354. };
  1355. XMLNode.prototype.treePosition = function(node) {
  1356. var found, pos;
  1357. pos = 0;
  1358. found = false;
  1359. this.foreachTreeNode(this.document(), function(childNode) {
  1360. pos++;
  1361. if (!found && childNode === node) {
  1362. return found = true;
  1363. }
  1364. });
  1365. if (found) {
  1366. return pos;
  1367. } else {
  1368. return -1;
  1369. }
  1370. };
  1371. XMLNode.prototype.foreachTreeNode = function(node, func) {
  1372. var child, j, len, ref2, res;
  1373. node || (node = this.document());
  1374. ref2 = node.children;
  1375. for (j = 0, len = ref2.length; j < len; j++) {
  1376. child = ref2[j];
  1377. if (res = func(child)) {
  1378. return res;
  1379. } else {
  1380. res = this.foreachTreeNode(child, func);
  1381. if (res) {
  1382. return res;
  1383. }
  1384. }
  1385. }
  1386. };
  1387. return XMLNode;
  1388. })();
  1389. }).call(this);
  1390. /***/ }),
  1391. /* 12 */
  1392. /***/ (function(module, exports, __webpack_require__) {
  1393. // Generated by CoffeeScript 1.12.7
  1394. (function() {
  1395. var NodeType, XMLAttribute, XMLElement, XMLNamedNodeMap, XMLNode, getValue, isFunction, isObject, ref,
  1396. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  1397. hasProp = {}.hasOwnProperty;
  1398. ref = __webpack_require__(5), isObject = ref.isObject, isFunction = ref.isFunction, getValue = ref.getValue;
  1399. XMLNode = __webpack_require__(11);
  1400. NodeType = __webpack_require__(13);
  1401. XMLAttribute = __webpack_require__(14);
  1402. XMLNamedNodeMap = __webpack_require__(15);
  1403. module.exports = XMLElement = (function(superClass) {
  1404. extend(XMLElement, superClass);
  1405. function XMLElement(parent, name, attributes) {
  1406. var child, j, len, ref1;
  1407. XMLElement.__super__.constructor.call(this, parent);
  1408. if (name == null) {
  1409. throw new Error("Missing element name. " + this.debugInfo());
  1410. }
  1411. this.name = this.stringify.name(name);
  1412. this.type = NodeType.Element;
  1413. this.attribs = {};
  1414. this.schemaTypeInfo = null;
  1415. if (attributes != null) {
  1416. this.attribute(attributes);
  1417. }
  1418. if (parent.type === NodeType.Document) {
  1419. this.isRoot = true;
  1420. this.documentObject = parent;
  1421. parent.rootObject = this;
  1422. if (parent.children) {
  1423. ref1 = parent.children;
  1424. for (j = 0, len = ref1.length; j < len; j++) {
  1425. child = ref1[j];
  1426. if (child.type === NodeType.DocType) {
  1427. child.name = this.name;
  1428. break;
  1429. }
  1430. }
  1431. }
  1432. }
  1433. }
  1434. Object.defineProperty(XMLElement.prototype, 'tagName', {
  1435. get: function() {
  1436. return this.name;
  1437. }
  1438. });
  1439. Object.defineProperty(XMLElement.prototype, 'namespaceURI', {
  1440. get: function() {
  1441. return '';
  1442. }
  1443. });
  1444. Object.defineProperty(XMLElement.prototype, 'prefix', {
  1445. get: function() {
  1446. return '';
  1447. }
  1448. });
  1449. Object.defineProperty(XMLElement.prototype, 'localName', {
  1450. get: function() {
  1451. return this.name;
  1452. }
  1453. });
  1454. Object.defineProperty(XMLElement.prototype, 'id', {
  1455. get: function() {
  1456. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1457. }
  1458. });
  1459. Object.defineProperty(XMLElement.prototype, 'className', {
  1460. get: function() {
  1461. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1462. }
  1463. });
  1464. Object.defineProperty(XMLElement.prototype, 'classList', {
  1465. get: function() {
  1466. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1467. }
  1468. });
  1469. Object.defineProperty(XMLElement.prototype, 'attributes', {
  1470. get: function() {
  1471. if (!this.attributeMap || !this.attributeMap.nodes) {
  1472. this.attributeMap = new XMLNamedNodeMap(this.attribs);
  1473. }
  1474. return this.attributeMap;
  1475. }
  1476. });
  1477. XMLElement.prototype.clone = function() {
  1478. var att, attName, clonedSelf, ref1;
  1479. clonedSelf = Object.create(this);
  1480. if (clonedSelf.isRoot) {
  1481. clonedSelf.documentObject = null;
  1482. }
  1483. clonedSelf.attribs = {};
  1484. ref1 = this.attribs;
  1485. for (attName in ref1) {
  1486. if (!hasProp.call(ref1, attName)) continue;
  1487. att = ref1[attName];
  1488. clonedSelf.attribs[attName] = att.clone();
  1489. }
  1490. clonedSelf.children = [];
  1491. this.children.forEach(function(child) {
  1492. var clonedChild;
  1493. clonedChild = child.clone();
  1494. clonedChild.parent = clonedSelf;
  1495. return clonedSelf.children.push(clonedChild);
  1496. });
  1497. return clonedSelf;
  1498. };
  1499. XMLElement.prototype.attribute = function(name, value) {
  1500. var attName, attValue;
  1501. if (name != null) {
  1502. name = getValue(name);
  1503. }
  1504. if (isObject(name)) {
  1505. for (attName in name) {
  1506. if (!hasProp.call(name, attName)) continue;
  1507. attValue = name[attName];
  1508. this.attribute(attName, attValue);
  1509. }
  1510. } else {
  1511. if (isFunction(value)) {
  1512. value = value.apply();
  1513. }
  1514. if (this.options.keepNullAttributes && (value == null)) {
  1515. this.attribs[name] = new XMLAttribute(this, name, "");
  1516. } else if (value != null) {
  1517. this.attribs[name] = new XMLAttribute(this, name, value);
  1518. }
  1519. }
  1520. return this;
  1521. };
  1522. XMLElement.prototype.removeAttribute = function(name) {
  1523. var attName, j, len;
  1524. if (name == null) {
  1525. throw new Error("Missing attribute name. " + this.debugInfo());
  1526. }
  1527. name = getValue(name);
  1528. if (Array.isArray(name)) {
  1529. for (j = 0, len = name.length; j < len; j++) {
  1530. attName = name[j];
  1531. delete this.attribs[attName];
  1532. }
  1533. } else {
  1534. delete this.attribs[name];
  1535. }
  1536. return this;
  1537. };
  1538. XMLElement.prototype.toString = function(options) {
  1539. return this.options.writer.element(this, this.options.writer.filterOptions(options));
  1540. };
  1541. XMLElement.prototype.att = function(name, value) {
  1542. return this.attribute(name, value);
  1543. };
  1544. XMLElement.prototype.a = function(name, value) {
  1545. return this.attribute(name, value);
  1546. };
  1547. XMLElement.prototype.getAttribute = function(name) {
  1548. if (this.attribs.hasOwnProperty(name)) {
  1549. return this.attribs[name].value;
  1550. } else {
  1551. return null;
  1552. }
  1553. };
  1554. XMLElement.prototype.setAttribute = function(name, value) {
  1555. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1556. };
  1557. XMLElement.prototype.getAttributeNode = function(name) {
  1558. if (this.attribs.hasOwnProperty(name)) {
  1559. return this.attribs[name];
  1560. } else {
  1561. return null;
  1562. }
  1563. };
  1564. XMLElement.prototype.setAttributeNode = function(newAttr) {
  1565. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1566. };
  1567. XMLElement.prototype.removeAttributeNode = function(oldAttr) {
  1568. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1569. };
  1570. XMLElement.prototype.getElementsByTagName = function(name) {
  1571. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1572. };
  1573. XMLElement.prototype.getAttributeNS = function(namespaceURI, localName) {
  1574. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1575. };
  1576. XMLElement.prototype.setAttributeNS = function(namespaceURI, qualifiedName, value) {
  1577. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1578. };
  1579. XMLElement.prototype.removeAttributeNS = function(namespaceURI, localName) {
  1580. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1581. };
  1582. XMLElement.prototype.getAttributeNodeNS = function(namespaceURI, localName) {
  1583. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1584. };
  1585. XMLElement.prototype.setAttributeNodeNS = function(newAttr) {
  1586. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1587. };
  1588. XMLElement.prototype.getElementsByTagNameNS = function(namespaceURI, localName) {
  1589. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1590. };
  1591. XMLElement.prototype.hasAttribute = function(name) {
  1592. return this.attribs.hasOwnProperty(name);
  1593. };
  1594. XMLElement.prototype.hasAttributeNS = function(namespaceURI, localName) {
  1595. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1596. };
  1597. XMLElement.prototype.setIdAttribute = function(name, isId) {
  1598. if (this.attribs.hasOwnProperty(name)) {
  1599. return this.attribs[name].isId;
  1600. } else {
  1601. return isId;
  1602. }
  1603. };
  1604. XMLElement.prototype.setIdAttributeNS = function(namespaceURI, localName, isId) {
  1605. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1606. };
  1607. XMLElement.prototype.setIdAttributeNode = function(idAttr, isId) {
  1608. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1609. };
  1610. XMLElement.prototype.getElementsByTagName = function(tagname) {
  1611. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1612. };
  1613. XMLElement.prototype.getElementsByTagNameNS = function(namespaceURI, localName) {
  1614. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1615. };
  1616. XMLElement.prototype.getElementsByClassName = function(classNames) {
  1617. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1618. };
  1619. XMLElement.prototype.isEqualNode = function(node) {
  1620. var i, j, ref1;
  1621. if (!XMLElement.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) {
  1622. return false;
  1623. }
  1624. if (node.namespaceURI !== this.namespaceURI) {
  1625. return false;
  1626. }
  1627. if (node.prefix !== this.prefix) {
  1628. return false;
  1629. }
  1630. if (node.localName !== this.localName) {
  1631. return false;
  1632. }
  1633. if (node.attribs.length !== this.attribs.length) {
  1634. return false;
  1635. }
  1636. for (i = j = 0, ref1 = this.attribs.length - 1; 0 <= ref1 ? j <= ref1 : j >= ref1; i = 0 <= ref1 ? ++j : --j) {
  1637. if (!this.attribs[i].isEqualNode(node.attribs[i])) {
  1638. return false;
  1639. }
  1640. }
  1641. return true;
  1642. };
  1643. return XMLElement;
  1644. })(XMLNode);
  1645. }).call(this);
  1646. /***/ }),
  1647. /* 13 */
  1648. /***/ (function(module, exports) {
  1649. // Generated by CoffeeScript 1.12.7
  1650. (function() {
  1651. module.exports = {
  1652. Element: 1,
  1653. Attribute: 2,
  1654. Text: 3,
  1655. CData: 4,
  1656. EntityReference: 5,
  1657. EntityDeclaration: 6,
  1658. ProcessingInstruction: 7,
  1659. Comment: 8,
  1660. Document: 9,
  1661. DocType: 10,
  1662. DocumentFragment: 11,
  1663. NotationDeclaration: 12,
  1664. Declaration: 201,
  1665. Raw: 202,
  1666. AttributeDeclaration: 203,
  1667. ElementDeclaration: 204,
  1668. Dummy: 205
  1669. };
  1670. }).call(this);
  1671. /***/ }),
  1672. /* 14 */
  1673. /***/ (function(module, exports, __webpack_require__) {
  1674. // Generated by CoffeeScript 1.12.7
  1675. (function() {
  1676. var NodeType, XMLAttribute, XMLNode;
  1677. NodeType = __webpack_require__(13);
  1678. XMLNode = __webpack_require__(11);
  1679. module.exports = XMLAttribute = (function() {
  1680. function XMLAttribute(parent, name, value) {
  1681. this.parent = parent;
  1682. if (this.parent) {
  1683. this.options = this.parent.options;
  1684. this.stringify = this.parent.stringify;
  1685. }
  1686. if (name == null) {
  1687. throw new Error("Missing attribute name. " + this.debugInfo(name));
  1688. }
  1689. this.name = this.stringify.name(name);
  1690. this.value = this.stringify.attValue(value);
  1691. this.type = NodeType.Attribute;
  1692. this.isId = false;
  1693. this.schemaTypeInfo = null;
  1694. }
  1695. Object.defineProperty(XMLAttribute.prototype, 'nodeType', {
  1696. get: function() {
  1697. return this.type;
  1698. }
  1699. });
  1700. Object.defineProperty(XMLAttribute.prototype, 'ownerElement', {
  1701. get: function() {
  1702. return this.parent;
  1703. }
  1704. });
  1705. Object.defineProperty(XMLAttribute.prototype, 'textContent', {
  1706. get: function() {
  1707. return this.value;
  1708. },
  1709. set: function(value) {
  1710. return this.value = value || '';
  1711. }
  1712. });
  1713. Object.defineProperty(XMLAttribute.prototype, 'namespaceURI', {
  1714. get: function() {
  1715. return '';
  1716. }
  1717. });
  1718. Object.defineProperty(XMLAttribute.prototype, 'prefix', {
  1719. get: function() {
  1720. return '';
  1721. }
  1722. });
  1723. Object.defineProperty(XMLAttribute.prototype, 'localName', {
  1724. get: function() {
  1725. return this.name;
  1726. }
  1727. });
  1728. Object.defineProperty(XMLAttribute.prototype, 'specified', {
  1729. get: function() {
  1730. return true;
  1731. }
  1732. });
  1733. XMLAttribute.prototype.clone = function() {
  1734. return Object.create(this);
  1735. };
  1736. XMLAttribute.prototype.toString = function(options) {
  1737. return this.options.writer.attribute(this, this.options.writer.filterOptions(options));
  1738. };
  1739. XMLAttribute.prototype.debugInfo = function(name) {
  1740. name = name || this.name;
  1741. if (name == null) {
  1742. return "parent: <" + this.parent.name + ">";
  1743. } else {
  1744. return "attribute: {" + name + "}, parent: <" + this.parent.name + ">";
  1745. }
  1746. };
  1747. XMLAttribute.prototype.isEqualNode = function(node) {
  1748. if (node.namespaceURI !== this.namespaceURI) {
  1749. return false;
  1750. }
  1751. if (node.prefix !== this.prefix) {
  1752. return false;
  1753. }
  1754. if (node.localName !== this.localName) {
  1755. return false;
  1756. }
  1757. if (node.value !== this.value) {
  1758. return false;
  1759. }
  1760. return true;
  1761. };
  1762. return XMLAttribute;
  1763. })();
  1764. }).call(this);
  1765. /***/ }),
  1766. /* 15 */
  1767. /***/ (function(module, exports) {
  1768. // Generated by CoffeeScript 1.12.7
  1769. (function() {
  1770. var XMLNamedNodeMap;
  1771. module.exports = XMLNamedNodeMap = (function() {
  1772. function XMLNamedNodeMap(nodes) {
  1773. this.nodes = nodes;
  1774. }
  1775. Object.defineProperty(XMLNamedNodeMap.prototype, 'length', {
  1776. get: function() {
  1777. return Object.keys(this.nodes).length || 0;
  1778. }
  1779. });
  1780. XMLNamedNodeMap.prototype.clone = function() {
  1781. return this.nodes = null;
  1782. };
  1783. XMLNamedNodeMap.prototype.getNamedItem = function(name) {
  1784. return this.nodes[name];
  1785. };
  1786. XMLNamedNodeMap.prototype.setNamedItem = function(node) {
  1787. var oldNode;
  1788. oldNode = this.nodes[node.nodeName];
  1789. this.nodes[node.nodeName] = node;
  1790. return oldNode || null;
  1791. };
  1792. XMLNamedNodeMap.prototype.removeNamedItem = function(name) {
  1793. var oldNode;
  1794. oldNode = this.nodes[name];
  1795. delete this.nodes[name];
  1796. return oldNode || null;
  1797. };
  1798. XMLNamedNodeMap.prototype.item = function(index) {
  1799. return this.nodes[Object.keys(this.nodes)[index]] || null;
  1800. };
  1801. XMLNamedNodeMap.prototype.getNamedItemNS = function(namespaceURI, localName) {
  1802. throw new Error("This DOM method is not implemented.");
  1803. };
  1804. XMLNamedNodeMap.prototype.setNamedItemNS = function(node) {
  1805. throw new Error("This DOM method is not implemented.");
  1806. };
  1807. XMLNamedNodeMap.prototype.removeNamedItemNS = function(namespaceURI, localName) {
  1808. throw new Error("This DOM method is not implemented.");
  1809. };
  1810. return XMLNamedNodeMap;
  1811. })();
  1812. }).call(this);
  1813. /***/ }),
  1814. /* 16 */
  1815. /***/ (function(module, exports, __webpack_require__) {
  1816. // Generated by CoffeeScript 1.12.7
  1817. (function() {
  1818. var NodeType, XMLCData, XMLCharacterData,
  1819. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  1820. hasProp = {}.hasOwnProperty;
  1821. NodeType = __webpack_require__(13);
  1822. XMLCharacterData = __webpack_require__(17);
  1823. module.exports = XMLCData = (function(superClass) {
  1824. extend(XMLCData, superClass);
  1825. function XMLCData(parent, text) {
  1826. XMLCData.__super__.constructor.call(this, parent);
  1827. if (text == null) {
  1828. throw new Error("Missing CDATA text. " + this.debugInfo());
  1829. }
  1830. this.name = "#cdata-section";
  1831. this.type = NodeType.CData;
  1832. this.value = this.stringify.cdata(text);
  1833. }
  1834. XMLCData.prototype.clone = function() {
  1835. return Object.create(this);
  1836. };
  1837. XMLCData.prototype.toString = function(options) {
  1838. return this.options.writer.cdata(this, this.options.writer.filterOptions(options));
  1839. };
  1840. return XMLCData;
  1841. })(XMLCharacterData);
  1842. }).call(this);
  1843. /***/ }),
  1844. /* 17 */
  1845. /***/ (function(module, exports, __webpack_require__) {
  1846. // Generated by CoffeeScript 1.12.7
  1847. (function() {
  1848. var XMLCharacterData, XMLNode,
  1849. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  1850. hasProp = {}.hasOwnProperty;
  1851. XMLNode = __webpack_require__(11);
  1852. module.exports = XMLCharacterData = (function(superClass) {
  1853. extend(XMLCharacterData, superClass);
  1854. function XMLCharacterData(parent) {
  1855. XMLCharacterData.__super__.constructor.call(this, parent);
  1856. this.value = '';
  1857. }
  1858. Object.defineProperty(XMLCharacterData.prototype, 'data', {
  1859. get: function() {
  1860. return this.value;
  1861. },
  1862. set: function(value) {
  1863. return this.value = value || '';
  1864. }
  1865. });
  1866. Object.defineProperty(XMLCharacterData.prototype, 'length', {
  1867. get: function() {
  1868. return this.value.length;
  1869. }
  1870. });
  1871. Object.defineProperty(XMLCharacterData.prototype, 'textContent', {
  1872. get: function() {
  1873. return this.value;
  1874. },
  1875. set: function(value) {
  1876. return this.value = value || '';
  1877. }
  1878. });
  1879. XMLCharacterData.prototype.clone = function() {
  1880. return Object.create(this);
  1881. };
  1882. XMLCharacterData.prototype.substringData = function(offset, count) {
  1883. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1884. };
  1885. XMLCharacterData.prototype.appendData = function(arg) {
  1886. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1887. };
  1888. XMLCharacterData.prototype.insertData = function(offset, arg) {
  1889. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1890. };
  1891. XMLCharacterData.prototype.deleteData = function(offset, count) {
  1892. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1893. };
  1894. XMLCharacterData.prototype.replaceData = function(offset, count, arg) {
  1895. throw new Error("This DOM method is not implemented." + this.debugInfo());
  1896. };
  1897. XMLCharacterData.prototype.isEqualNode = function(node) {
  1898. if (!XMLCharacterData.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) {
  1899. return false;
  1900. }
  1901. if (node.data !== this.data) {
  1902. return false;
  1903. }
  1904. return true;
  1905. };
  1906. return XMLCharacterData;
  1907. })(XMLNode);
  1908. }).call(this);
  1909. /***/ }),
  1910. /* 18 */
  1911. /***/ (function(module, exports, __webpack_require__) {
  1912. // Generated by CoffeeScript 1.12.7
  1913. (function() {
  1914. var NodeType, XMLCharacterData, XMLComment,
  1915. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  1916. hasProp = {}.hasOwnProperty;
  1917. NodeType = __webpack_require__(13);
  1918. XMLCharacterData = __webpack_require__(17);
  1919. module.exports = XMLComment = (function(superClass) {
  1920. extend(XMLComment, superClass);
  1921. function XMLComment(parent, text) {
  1922. XMLComment.__super__.constructor.call(this, parent);
  1923. if (text == null) {
  1924. throw new Error("Missing comment text. " + this.debugInfo());
  1925. }
  1926. this.name = "#comment";
  1927. this.type = NodeType.Comment;
  1928. this.value = this.stringify.comment(text);
  1929. }
  1930. XMLComment.prototype.clone = function() {
  1931. return Object.create(this);
  1932. };
  1933. XMLComment.prototype.toString = function(options) {
  1934. return this.options.writer.comment(this, this.options.writer.filterOptions(options));
  1935. };
  1936. return XMLComment;
  1937. })(XMLCharacterData);
  1938. }).call(this);
  1939. /***/ }),
  1940. /* 19 */
  1941. /***/ (function(module, exports, __webpack_require__) {
  1942. // Generated by CoffeeScript 1.12.7
  1943. (function() {
  1944. var NodeType, XMLDeclaration, XMLNode, isObject,
  1945. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  1946. hasProp = {}.hasOwnProperty;
  1947. isObject = __webpack_require__(5).isObject;
  1948. XMLNode = __webpack_require__(11);
  1949. NodeType = __webpack_require__(13);
  1950. module.exports = XMLDeclaration = (function(superClass) {
  1951. extend(XMLDeclaration, superClass);
  1952. function XMLDeclaration(parent, version, encoding, standalone) {
  1953. var ref;
  1954. XMLDeclaration.__super__.constructor.call(this, parent);
  1955. if (isObject(version)) {
  1956. ref = version, version = ref.version, encoding = ref.encoding, standalone = ref.standalone;
  1957. }
  1958. if (!version) {
  1959. version = '1.0';
  1960. }
  1961. this.type = NodeType.Declaration;
  1962. this.version = this.stringify.xmlVersion(version);
  1963. if (encoding != null) {
  1964. this.encoding = this.stringify.xmlEncoding(encoding);
  1965. }
  1966. if (standalone != null) {
  1967. this.standalone = this.stringify.xmlStandalone(standalone);
  1968. }
  1969. }
  1970. XMLDeclaration.prototype.toString = function(options) {
  1971. return this.options.writer.declaration(this, this.options.writer.filterOptions(options));
  1972. };
  1973. return XMLDeclaration;
  1974. })(XMLNode);
  1975. }).call(this);
  1976. /***/ }),
  1977. /* 20 */
  1978. /***/ (function(module, exports, __webpack_require__) {
  1979. // Generated by CoffeeScript 1.12.7
  1980. (function() {
  1981. var NodeType, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDocType, XMLNamedNodeMap, XMLNode, isObject,
  1982. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  1983. hasProp = {}.hasOwnProperty;
  1984. isObject = __webpack_require__(5).isObject;
  1985. XMLNode = __webpack_require__(11);
  1986. NodeType = __webpack_require__(13);
  1987. XMLDTDAttList = __webpack_require__(21);
  1988. XMLDTDEntity = __webpack_require__(22);
  1989. XMLDTDElement = __webpack_require__(23);
  1990. XMLDTDNotation = __webpack_require__(24);
  1991. XMLNamedNodeMap = __webpack_require__(15);
  1992. module.exports = XMLDocType = (function(superClass) {
  1993. extend(XMLDocType, superClass);
  1994. function XMLDocType(parent, pubID, sysID) {
  1995. var child, i, len, ref, ref1, ref2;
  1996. XMLDocType.__super__.constructor.call(this, parent);
  1997. this.type = NodeType.DocType;
  1998. if (parent.children) {
  1999. ref = parent.children;
  2000. for (i = 0, len = ref.length; i < len; i++) {
  2001. child = ref[i];
  2002. if (child.type === NodeType.Element) {
  2003. this.name = child.name;
  2004. break;
  2005. }
  2006. }
  2007. }
  2008. this.documentObject = parent;
  2009. if (isObject(pubID)) {
  2010. ref1 = pubID, pubID = ref1.pubID, sysID = ref1.sysID;
  2011. }
  2012. if (sysID == null) {
  2013. ref2 = [pubID, sysID], sysID = ref2[0], pubID = ref2[1];
  2014. }
  2015. if (pubID != null) {
  2016. this.pubID = this.stringify.dtdPubID(pubID);
  2017. }
  2018. if (sysID != null) {
  2019. this.sysID = this.stringify.dtdSysID(sysID);
  2020. }
  2021. }
  2022. Object.defineProperty(XMLDocType.prototype, 'entities', {
  2023. get: function() {
  2024. var child, i, len, nodes, ref;
  2025. nodes = {};
  2026. ref = this.children;
  2027. for (i = 0, len = ref.length; i < len; i++) {
  2028. child = ref[i];
  2029. if ((child.type === NodeType.EntityDeclaration) && !child.pe) {
  2030. nodes[child.name] = child;
  2031. }
  2032. }
  2033. return new XMLNamedNodeMap(nodes);
  2034. }
  2035. });
  2036. Object.defineProperty(XMLDocType.prototype, 'notations', {
  2037. get: function() {
  2038. var child, i, len, nodes, ref;
  2039. nodes = {};
  2040. ref = this.children;
  2041. for (i = 0, len = ref.length; i < len; i++) {
  2042. child = ref[i];
  2043. if (child.type === NodeType.NotationDeclaration) {
  2044. nodes[child.name] = child;
  2045. }
  2046. }
  2047. return new XMLNamedNodeMap(nodes);
  2048. }
  2049. });
  2050. Object.defineProperty(XMLDocType.prototype, 'publicId', {
  2051. get: function() {
  2052. return this.pubID;
  2053. }
  2054. });
  2055. Object.defineProperty(XMLDocType.prototype, 'systemId', {
  2056. get: function() {
  2057. return this.sysID;
  2058. }
  2059. });
  2060. Object.defineProperty(XMLDocType.prototype, 'internalSubset', {
  2061. get: function() {
  2062. throw new Error("This DOM method is not implemented." + this.debugInfo());
  2063. }
  2064. });
  2065. XMLDocType.prototype.element = function(name, value) {
  2066. var child;
  2067. child = new XMLDTDElement(this, name, value);
  2068. this.children.push(child);
  2069. return this;
  2070. };
  2071. XMLDocType.prototype.attList = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
  2072. var child;
  2073. child = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
  2074. this.children.push(child);
  2075. return this;
  2076. };
  2077. XMLDocType.prototype.entity = function(name, value) {
  2078. var child;
  2079. child = new XMLDTDEntity(this, false, name, value);
  2080. this.children.push(child);
  2081. return this;
  2082. };
  2083. XMLDocType.prototype.pEntity = function(name, value) {
  2084. var child;
  2085. child = new XMLDTDEntity(this, true, name, value);
  2086. this.children.push(child);
  2087. return this;
  2088. };
  2089. XMLDocType.prototype.notation = function(name, value) {
  2090. var child;
  2091. child = new XMLDTDNotation(this, name, value);
  2092. this.children.push(child);
  2093. return this;
  2094. };
  2095. XMLDocType.prototype.toString = function(options) {
  2096. return this.options.writer.docType(this, this.options.writer.filterOptions(options));
  2097. };
  2098. XMLDocType.prototype.ele = function(name, value) {
  2099. return this.element(name, value);
  2100. };
  2101. XMLDocType.prototype.att = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
  2102. return this.attList(elementName, attributeName, attributeType, defaultValueType, defaultValue);
  2103. };
  2104. XMLDocType.prototype.ent = function(name, value) {
  2105. return this.entity(name, value);
  2106. };
  2107. XMLDocType.prototype.pent = function(name, value) {
  2108. return this.pEntity(name, value);
  2109. };
  2110. XMLDocType.prototype.not = function(name, value) {
  2111. return this.notation(name, value);
  2112. };
  2113. XMLDocType.prototype.up = function() {
  2114. return this.root() || this.documentObject;
  2115. };
  2116. XMLDocType.prototype.isEqualNode = function(node) {
  2117. if (!XMLDocType.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) {
  2118. return false;
  2119. }
  2120. if (node.name !== this.name) {
  2121. return false;
  2122. }
  2123. if (node.publicId !== this.publicId) {
  2124. return false;
  2125. }
  2126. if (node.systemId !== this.systemId) {
  2127. return false;
  2128. }
  2129. return true;
  2130. };
  2131. return XMLDocType;
  2132. })(XMLNode);
  2133. }).call(this);
  2134. /***/ }),
  2135. /* 21 */
  2136. /***/ (function(module, exports, __webpack_require__) {
  2137. // Generated by CoffeeScript 1.12.7
  2138. (function() {
  2139. var NodeType, XMLDTDAttList, XMLNode,
  2140. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  2141. hasProp = {}.hasOwnProperty;
  2142. XMLNode = __webpack_require__(11);
  2143. NodeType = __webpack_require__(13);
  2144. module.exports = XMLDTDAttList = (function(superClass) {
  2145. extend(XMLDTDAttList, superClass);
  2146. function XMLDTDAttList(parent, elementName, attributeName, attributeType, defaultValueType, defaultValue) {
  2147. XMLDTDAttList.__super__.constructor.call(this, parent);
  2148. if (elementName == null) {
  2149. throw new Error("Missing DTD element name. " + this.debugInfo());
  2150. }
  2151. if (attributeName == null) {
  2152. throw new Error("Missing DTD attribute name. " + this.debugInfo(elementName));
  2153. }
  2154. if (!attributeType) {
  2155. throw new Error("Missing DTD attribute type. " + this.debugInfo(elementName));
  2156. }
  2157. if (!defaultValueType) {
  2158. throw new Error("Missing DTD attribute default. " + this.debugInfo(elementName));
  2159. }
  2160. if (defaultValueType.indexOf('#') !== 0) {
  2161. defaultValueType = '#' + defaultValueType;
  2162. }
  2163. if (!defaultValueType.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/)) {
  2164. throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT. " + this.debugInfo(elementName));
  2165. }
  2166. if (defaultValue && !defaultValueType.match(/^(#FIXED|#DEFAULT)$/)) {
  2167. throw new Error("Default value only applies to #FIXED or #DEFAULT. " + this.debugInfo(elementName));
  2168. }
  2169. this.elementName = this.stringify.name(elementName);
  2170. this.type = NodeType.AttributeDeclaration;
  2171. this.attributeName = this.stringify.name(attributeName);
  2172. this.attributeType = this.stringify.dtdAttType(attributeType);
  2173. if (defaultValue) {
  2174. this.defaultValue = this.stringify.dtdAttDefault(defaultValue);
  2175. }
  2176. this.defaultValueType = defaultValueType;
  2177. }
  2178. XMLDTDAttList.prototype.toString = function(options) {
  2179. return this.options.writer.dtdAttList(this, this.options.writer.filterOptions(options));
  2180. };
  2181. return XMLDTDAttList;
  2182. })(XMLNode);
  2183. }).call(this);
  2184. /***/ }),
  2185. /* 22 */
  2186. /***/ (function(module, exports, __webpack_require__) {
  2187. // Generated by CoffeeScript 1.12.7
  2188. (function() {
  2189. var NodeType, XMLDTDEntity, XMLNode, isObject,
  2190. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  2191. hasProp = {}.hasOwnProperty;
  2192. isObject = __webpack_require__(5).isObject;
  2193. XMLNode = __webpack_require__(11);
  2194. NodeType = __webpack_require__(13);
  2195. module.exports = XMLDTDEntity = (function(superClass) {
  2196. extend(XMLDTDEntity, superClass);
  2197. function XMLDTDEntity(parent, pe, name, value) {
  2198. XMLDTDEntity.__super__.constructor.call(this, parent);
  2199. if (name == null) {
  2200. throw new Error("Missing DTD entity name. " + this.debugInfo(name));
  2201. }
  2202. if (value == null) {
  2203. throw new Error("Missing DTD entity value. " + this.debugInfo(name));
  2204. }
  2205. this.pe = !!pe;
  2206. this.name = this.stringify.name(name);
  2207. this.type = NodeType.EntityDeclaration;
  2208. if (!isObject(value)) {
  2209. this.value = this.stringify.dtdEntityValue(value);
  2210. this.internal = true;
  2211. } else {
  2212. if (!value.pubID && !value.sysID) {
  2213. throw new Error("Public and/or system identifiers are required for an external entity. " + this.debugInfo(name));
  2214. }
  2215. if (value.pubID && !value.sysID) {
  2216. throw new Error("System identifier is required for a public external entity. " + this.debugInfo(name));
  2217. }
  2218. this.internal = false;
  2219. if (value.pubID != null) {
  2220. this.pubID = this.stringify.dtdPubID(value.pubID);
  2221. }
  2222. if (value.sysID != null) {
  2223. this.sysID = this.stringify.dtdSysID(value.sysID);
  2224. }
  2225. if (value.nData != null) {
  2226. this.nData = this.stringify.dtdNData(value.nData);
  2227. }
  2228. if (this.pe && this.nData) {
  2229. throw new Error("Notation declaration is not allowed in a parameter entity. " + this.debugInfo(name));
  2230. }
  2231. }
  2232. }
  2233. Object.defineProperty(XMLDTDEntity.prototype, 'publicId', {
  2234. get: function() {
  2235. return this.pubID;
  2236. }
  2237. });
  2238. Object.defineProperty(XMLDTDEntity.prototype, 'systemId', {
  2239. get: function() {
  2240. return this.sysID;
  2241. }
  2242. });
  2243. Object.defineProperty(XMLDTDEntity.prototype, 'notationName', {
  2244. get: function() {
  2245. return this.nData || null;
  2246. }
  2247. });
  2248. Object.defineProperty(XMLDTDEntity.prototype, 'inputEncoding', {
  2249. get: function() {
  2250. return null;
  2251. }
  2252. });
  2253. Object.defineProperty(XMLDTDEntity.prototype, 'xmlEncoding', {
  2254. get: function() {
  2255. return null;
  2256. }
  2257. });
  2258. Object.defineProperty(XMLDTDEntity.prototype, 'xmlVersion', {
  2259. get: function() {
  2260. return null;
  2261. }
  2262. });
  2263. XMLDTDEntity.prototype.toString = function(options) {
  2264. return this.options.writer.dtdEntity(this, this.options.writer.filterOptions(options));
  2265. };
  2266. return XMLDTDEntity;
  2267. })(XMLNode);
  2268. }).call(this);
  2269. /***/ }),
  2270. /* 23 */
  2271. /***/ (function(module, exports, __webpack_require__) {
  2272. // Generated by CoffeeScript 1.12.7
  2273. (function() {
  2274. var NodeType, XMLDTDElement, XMLNode,
  2275. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  2276. hasProp = {}.hasOwnProperty;
  2277. XMLNode = __webpack_require__(11);
  2278. NodeType = __webpack_require__(13);
  2279. module.exports = XMLDTDElement = (function(superClass) {
  2280. extend(XMLDTDElement, superClass);
  2281. function XMLDTDElement(parent, name, value) {
  2282. XMLDTDElement.__super__.constructor.call(this, parent);
  2283. if (name == null) {
  2284. throw new Error("Missing DTD element name. " + this.debugInfo());
  2285. }
  2286. if (!value) {
  2287. value = '(#PCDATA)';
  2288. }
  2289. if (Array.isArray(value)) {
  2290. value = '(' + value.join(',') + ')';
  2291. }
  2292. this.name = this.stringify.name(name);
  2293. this.type = NodeType.ElementDeclaration;
  2294. this.value = this.stringify.dtdElementValue(value);
  2295. }
  2296. XMLDTDElement.prototype.toString = function(options) {
  2297. return this.options.writer.dtdElement(this, this.options.writer.filterOptions(options));
  2298. };
  2299. return XMLDTDElement;
  2300. })(XMLNode);
  2301. }).call(this);
  2302. /***/ }),
  2303. /* 24 */
  2304. /***/ (function(module, exports, __webpack_require__) {
  2305. // Generated by CoffeeScript 1.12.7
  2306. (function() {
  2307. var NodeType, XMLDTDNotation, XMLNode,
  2308. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  2309. hasProp = {}.hasOwnProperty;
  2310. XMLNode = __webpack_require__(11);
  2311. NodeType = __webpack_require__(13);
  2312. module.exports = XMLDTDNotation = (function(superClass) {
  2313. extend(XMLDTDNotation, superClass);
  2314. function XMLDTDNotation(parent, name, value) {
  2315. XMLDTDNotation.__super__.constructor.call(this, parent);
  2316. if (name == null) {
  2317. throw new Error("Missing DTD notation name. " + this.debugInfo(name));
  2318. }
  2319. if (!value.pubID && !value.sysID) {
  2320. throw new Error("Public or system identifiers are required for an external entity. " + this.debugInfo(name));
  2321. }
  2322. this.name = this.stringify.name(name);
  2323. this.type = NodeType.NotationDeclaration;
  2324. if (value.pubID != null) {
  2325. this.pubID = this.stringify.dtdPubID(value.pubID);
  2326. }
  2327. if (value.sysID != null) {
  2328. this.sysID = this.stringify.dtdSysID(value.sysID);
  2329. }
  2330. }
  2331. Object.defineProperty(XMLDTDNotation.prototype, 'publicId', {
  2332. get: function() {
  2333. return this.pubID;
  2334. }
  2335. });
  2336. Object.defineProperty(XMLDTDNotation.prototype, 'systemId', {
  2337. get: function() {
  2338. return this.sysID;
  2339. }
  2340. });
  2341. XMLDTDNotation.prototype.toString = function(options) {
  2342. return this.options.writer.dtdNotation(this, this.options.writer.filterOptions(options));
  2343. };
  2344. return XMLDTDNotation;
  2345. })(XMLNode);
  2346. }).call(this);
  2347. /***/ }),
  2348. /* 25 */
  2349. /***/ (function(module, exports, __webpack_require__) {
  2350. // Generated by CoffeeScript 1.12.7
  2351. (function() {
  2352. var NodeType, XMLNode, XMLRaw,
  2353. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  2354. hasProp = {}.hasOwnProperty;
  2355. NodeType = __webpack_require__(13);
  2356. XMLNode = __webpack_require__(11);
  2357. module.exports = XMLRaw = (function(superClass) {
  2358. extend(XMLRaw, superClass);
  2359. function XMLRaw(parent, text) {
  2360. XMLRaw.__super__.constructor.call(this, parent);
  2361. if (text == null) {
  2362. throw new Error("Missing raw text. " + this.debugInfo());
  2363. }
  2364. this.type = NodeType.Raw;
  2365. this.value = this.stringify.raw(text);
  2366. }
  2367. XMLRaw.prototype.clone = function() {
  2368. return Object.create(this);
  2369. };
  2370. XMLRaw.prototype.toString = function(options) {
  2371. return this.options.writer.raw(this, this.options.writer.filterOptions(options));
  2372. };
  2373. return XMLRaw;
  2374. })(XMLNode);
  2375. }).call(this);
  2376. /***/ }),
  2377. /* 26 */
  2378. /***/ (function(module, exports, __webpack_require__) {
  2379. // Generated by CoffeeScript 1.12.7
  2380. (function() {
  2381. var NodeType, XMLCharacterData, XMLText,
  2382. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  2383. hasProp = {}.hasOwnProperty;
  2384. NodeType = __webpack_require__(13);
  2385. XMLCharacterData = __webpack_require__(17);
  2386. module.exports = XMLText = (function(superClass) {
  2387. extend(XMLText, superClass);
  2388. function XMLText(parent, text) {
  2389. XMLText.__super__.constructor.call(this, parent);
  2390. if (text == null) {
  2391. throw new Error("Missing element text. " + this.debugInfo());
  2392. }
  2393. this.name = "#text";
  2394. this.type = NodeType.Text;
  2395. this.value = this.stringify.text(text);
  2396. }
  2397. Object.defineProperty(XMLText.prototype, 'isElementContentWhitespace', {
  2398. get: function() {
  2399. throw new Error("This DOM method is not implemented." + this.debugInfo());
  2400. }
  2401. });
  2402. Object.defineProperty(XMLText.prototype, 'wholeText', {
  2403. get: function() {
  2404. var next, prev, str;
  2405. str = '';
  2406. prev = this.previousSibling;
  2407. while (prev) {
  2408. str = prev.data + str;
  2409. prev = prev.previousSibling;
  2410. }
  2411. str += this.data;
  2412. next = this.nextSibling;
  2413. while (next) {
  2414. str = str + next.data;
  2415. next = next.nextSibling;
  2416. }
  2417. return str;
  2418. }
  2419. });
  2420. XMLText.prototype.clone = function() {
  2421. return Object.create(this);
  2422. };
  2423. XMLText.prototype.toString = function(options) {
  2424. return this.options.writer.text(this, this.options.writer.filterOptions(options));
  2425. };
  2426. XMLText.prototype.splitText = function(offset) {
  2427. throw new Error("This DOM method is not implemented." + this.debugInfo());
  2428. };
  2429. XMLText.prototype.replaceWholeText = function(content) {
  2430. throw new Error("This DOM method is not implemented." + this.debugInfo());
  2431. };
  2432. return XMLText;
  2433. })(XMLCharacterData);
  2434. }).call(this);
  2435. /***/ }),
  2436. /* 27 */
  2437. /***/ (function(module, exports, __webpack_require__) {
  2438. // Generated by CoffeeScript 1.12.7
  2439. (function() {
  2440. var NodeType, XMLCharacterData, XMLProcessingInstruction,
  2441. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  2442. hasProp = {}.hasOwnProperty;
  2443. NodeType = __webpack_require__(13);
  2444. XMLCharacterData = __webpack_require__(17);
  2445. module.exports = XMLProcessingInstruction = (function(superClass) {
  2446. extend(XMLProcessingInstruction, superClass);
  2447. function XMLProcessingInstruction(parent, target, value) {
  2448. XMLProcessingInstruction.__super__.constructor.call(this, parent);
  2449. if (target == null) {
  2450. throw new Error("Missing instruction target. " + this.debugInfo());
  2451. }
  2452. this.type = NodeType.ProcessingInstruction;
  2453. this.target = this.stringify.insTarget(target);
  2454. this.name = this.target;
  2455. if (value) {
  2456. this.value = this.stringify.insValue(value);
  2457. }
  2458. }
  2459. XMLProcessingInstruction.prototype.clone = function() {
  2460. return Object.create(this);
  2461. };
  2462. XMLProcessingInstruction.prototype.toString = function(options) {
  2463. return this.options.writer.processingInstruction(this, this.options.writer.filterOptions(options));
  2464. };
  2465. XMLProcessingInstruction.prototype.isEqualNode = function(node) {
  2466. if (!XMLProcessingInstruction.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) {
  2467. return false;
  2468. }
  2469. if (node.target !== this.target) {
  2470. return false;
  2471. }
  2472. return true;
  2473. };
  2474. return XMLProcessingInstruction;
  2475. })(XMLCharacterData);
  2476. }).call(this);
  2477. /***/ }),
  2478. /* 28 */
  2479. /***/ (function(module, exports, __webpack_require__) {
  2480. // Generated by CoffeeScript 1.12.7
  2481. (function() {
  2482. var NodeType, XMLDummy, XMLNode,
  2483. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  2484. hasProp = {}.hasOwnProperty;
  2485. XMLNode = __webpack_require__(11);
  2486. NodeType = __webpack_require__(13);
  2487. module.exports = XMLDummy = (function(superClass) {
  2488. extend(XMLDummy, superClass);
  2489. function XMLDummy(parent) {
  2490. XMLDummy.__super__.constructor.call(this, parent);
  2491. this.type = NodeType.Dummy;
  2492. }
  2493. XMLDummy.prototype.clone = function() {
  2494. return Object.create(this);
  2495. };
  2496. XMLDummy.prototype.toString = function(options) {
  2497. return '';
  2498. };
  2499. return XMLDummy;
  2500. })(XMLNode);
  2501. }).call(this);
  2502. /***/ }),
  2503. /* 29 */
  2504. /***/ (function(module, exports) {
  2505. // Generated by CoffeeScript 1.12.7
  2506. (function() {
  2507. var XMLNodeList;
  2508. module.exports = XMLNodeList = (function() {
  2509. function XMLNodeList(nodes) {
  2510. this.nodes = nodes;
  2511. }
  2512. Object.defineProperty(XMLNodeList.prototype, 'length', {
  2513. get: function() {
  2514. return this.nodes.length || 0;
  2515. }
  2516. });
  2517. XMLNodeList.prototype.clone = function() {
  2518. return this.nodes = null;
  2519. };
  2520. XMLNodeList.prototype.item = function(index) {
  2521. return this.nodes[index] || null;
  2522. };
  2523. return XMLNodeList;
  2524. })();
  2525. }).call(this);
  2526. /***/ }),
  2527. /* 30 */
  2528. /***/ (function(module, exports) {
  2529. // Generated by CoffeeScript 1.12.7
  2530. (function() {
  2531. module.exports = {
  2532. Disconnected: 1,
  2533. Preceding: 2,
  2534. Following: 4,
  2535. Contains: 8,
  2536. ContainedBy: 16,
  2537. ImplementationSpecific: 32
  2538. };
  2539. }).call(this);
  2540. /***/ }),
  2541. /* 31 */
  2542. /***/ (function(module, exports) {
  2543. // Generated by CoffeeScript 1.12.7
  2544. (function() {
  2545. var XMLStringifier,
  2546. bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
  2547. hasProp = {}.hasOwnProperty;
  2548. module.exports = XMLStringifier = (function() {
  2549. function XMLStringifier(options) {
  2550. this.assertLegalName = bind(this.assertLegalName, this);
  2551. this.assertLegalChar = bind(this.assertLegalChar, this);
  2552. var key, ref, value;
  2553. options || (options = {});
  2554. this.options = options;
  2555. if (!this.options.version) {
  2556. this.options.version = '1.0';
  2557. }
  2558. ref = options.stringify || {};
  2559. for (key in ref) {
  2560. if (!hasProp.call(ref, key)) continue;
  2561. value = ref[key];
  2562. this[key] = value;
  2563. }
  2564. }
  2565. XMLStringifier.prototype.name = function(val) {
  2566. if (this.options.noValidation) {
  2567. return val;
  2568. }
  2569. return this.assertLegalName('' + val || '');
  2570. };
  2571. XMLStringifier.prototype.text = function(val) {
  2572. if (this.options.noValidation) {
  2573. return val;
  2574. }
  2575. return this.assertLegalChar(this.textEscape('' + val || ''));
  2576. };
  2577. XMLStringifier.prototype.cdata = function(val) {
  2578. if (this.options.noValidation) {
  2579. return val;
  2580. }
  2581. val = '' + val || '';
  2582. val = val.replace(']]>', ']]]]><![CDATA[>');
  2583. return this.assertLegalChar(val);
  2584. };
  2585. XMLStringifier.prototype.comment = function(val) {
  2586. if (this.options.noValidation) {
  2587. return val;
  2588. }
  2589. val = '' + val || '';
  2590. if (val.match(/--/)) {
  2591. throw new Error("Comment text cannot contain double-hypen: " + val);
  2592. }
  2593. return this.assertLegalChar(val);
  2594. };
  2595. XMLStringifier.prototype.raw = function(val) {
  2596. if (this.options.noValidation) {
  2597. return val;
  2598. }
  2599. return '' + val || '';
  2600. };
  2601. XMLStringifier.prototype.attValue = function(val) {
  2602. if (this.options.noValidation) {
  2603. return val;
  2604. }
  2605. return this.assertLegalChar(this.attEscape(val = '' + val || ''));
  2606. };
  2607. XMLStringifier.prototype.insTarget = function(val) {
  2608. if (this.options.noValidation) {
  2609. return val;
  2610. }
  2611. return this.assertLegalChar('' + val || '');
  2612. };
  2613. XMLStringifier.prototype.insValue = function(val) {
  2614. if (this.options.noValidation) {
  2615. return val;
  2616. }
  2617. val = '' + val || '';
  2618. if (val.match(/\?>/)) {
  2619. throw new Error("Invalid processing instruction value: " + val);
  2620. }
  2621. return this.assertLegalChar(val);
  2622. };
  2623. XMLStringifier.prototype.xmlVersion = function(val) {
  2624. if (this.options.noValidation) {
  2625. return val;
  2626. }
  2627. val = '' + val || '';
  2628. if (!val.match(/1\.[0-9]+/)) {
  2629. throw new Error("Invalid version number: " + val);
  2630. }
  2631. return val;
  2632. };
  2633. XMLStringifier.prototype.xmlEncoding = function(val) {
  2634. if (this.options.noValidation) {
  2635. return val;
  2636. }
  2637. val = '' + val || '';
  2638. if (!val.match(/^[A-Za-z](?:[A-Za-z0-9._-])*$/)) {
  2639. throw new Error("Invalid encoding: " + val);
  2640. }
  2641. return this.assertLegalChar(val);
  2642. };
  2643. XMLStringifier.prototype.xmlStandalone = function(val) {
  2644. if (this.options.noValidation) {
  2645. return val;
  2646. }
  2647. if (val) {
  2648. return "yes";
  2649. } else {
  2650. return "no";
  2651. }
  2652. };
  2653. XMLStringifier.prototype.dtdPubID = function(val) {
  2654. if (this.options.noValidation) {
  2655. return val;
  2656. }
  2657. return this.assertLegalChar('' + val || '');
  2658. };
  2659. XMLStringifier.prototype.dtdSysID = function(val) {
  2660. if (this.options.noValidation) {
  2661. return val;
  2662. }
  2663. return this.assertLegalChar('' + val || '');
  2664. };
  2665. XMLStringifier.prototype.dtdElementValue = function(val) {
  2666. if (this.options.noValidation) {
  2667. return val;
  2668. }
  2669. return this.assertLegalChar('' + val || '');
  2670. };
  2671. XMLStringifier.prototype.dtdAttType = function(val) {
  2672. if (this.options.noValidation) {
  2673. return val;
  2674. }
  2675. return this.assertLegalChar('' + val || '');
  2676. };
  2677. XMLStringifier.prototype.dtdAttDefault = function(val) {
  2678. if (this.options.noValidation) {
  2679. return val;
  2680. }
  2681. return this.assertLegalChar('' + val || '');
  2682. };
  2683. XMLStringifier.prototype.dtdEntityValue = function(val) {
  2684. if (this.options.noValidation) {
  2685. return val;
  2686. }
  2687. return this.assertLegalChar('' + val || '');
  2688. };
  2689. XMLStringifier.prototype.dtdNData = function(val) {
  2690. if (this.options.noValidation) {
  2691. return val;
  2692. }
  2693. return this.assertLegalChar('' + val || '');
  2694. };
  2695. XMLStringifier.prototype.convertAttKey = '@';
  2696. XMLStringifier.prototype.convertPIKey = '?';
  2697. XMLStringifier.prototype.convertTextKey = '#text';
  2698. XMLStringifier.prototype.convertCDataKey = '#cdata';
  2699. XMLStringifier.prototype.convertCommentKey = '#comment';
  2700. XMLStringifier.prototype.convertRawKey = '#raw';
  2701. XMLStringifier.prototype.assertLegalChar = function(str) {
  2702. var regex, res;
  2703. if (this.options.noValidation) {
  2704. return str;
  2705. }
  2706. regex = '';
  2707. if (this.options.version === '1.0') {
  2708. regex = /[\0-\x08\x0B\f\x0E-\x1F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
  2709. if (res = str.match(regex)) {
  2710. throw new Error("Invalid character in string: " + str + " at index " + res.index);
  2711. }
  2712. } else if (this.options.version === '1.1') {
  2713. regex = /[\0\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
  2714. if (res = str.match(regex)) {
  2715. throw new Error("Invalid character in string: " + str + " at index " + res.index);
  2716. }
  2717. }
  2718. return str;
  2719. };
  2720. XMLStringifier.prototype.assertLegalName = function(str) {
  2721. var regex;
  2722. if (this.options.noValidation) {
  2723. return str;
  2724. }
  2725. this.assertLegalChar(str);
  2726. regex = /^([:A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])([\x2D\.0-:A-Z_a-z\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])*$/;
  2727. if (!str.match(regex)) {
  2728. throw new Error("Invalid character in name");
  2729. }
  2730. return str;
  2731. };
  2732. XMLStringifier.prototype.textEscape = function(str) {
  2733. var ampregex;
  2734. if (this.options.noValidation) {
  2735. return str;
  2736. }
  2737. ampregex = this.options.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g;
  2738. return str.replace(ampregex, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\r/g, '&#xD;');
  2739. };
  2740. XMLStringifier.prototype.attEscape = function(str) {
  2741. var ampregex;
  2742. if (this.options.noValidation) {
  2743. return str;
  2744. }
  2745. ampregex = this.options.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g;
  2746. return str.replace(ampregex, '&amp;').replace(/</g, '&lt;').replace(/"/g, '&quot;').replace(/\t/g, '&#x9;').replace(/\n/g, '&#xA;').replace(/\r/g, '&#xD;');
  2747. };
  2748. return XMLStringifier;
  2749. })();
  2750. }).call(this);
  2751. /***/ }),
  2752. /* 32 */
  2753. /***/ (function(module, exports, __webpack_require__) {
  2754. // Generated by CoffeeScript 1.12.7
  2755. (function() {
  2756. var XMLStringWriter, XMLWriterBase,
  2757. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  2758. hasProp = {}.hasOwnProperty;
  2759. XMLWriterBase = __webpack_require__(33);
  2760. module.exports = XMLStringWriter = (function(superClass) {
  2761. extend(XMLStringWriter, superClass);
  2762. function XMLStringWriter(options) {
  2763. XMLStringWriter.__super__.constructor.call(this, options);
  2764. }
  2765. XMLStringWriter.prototype.document = function(doc, options) {
  2766. var child, i, len, r, ref;
  2767. options = this.filterOptions(options);
  2768. r = '';
  2769. ref = doc.children;
  2770. for (i = 0, len = ref.length; i < len; i++) {
  2771. child = ref[i];
  2772. r += this.writeChildNode(child, options, 0);
  2773. }
  2774. if (options.pretty && r.slice(-options.newline.length) === options.newline) {
  2775. r = r.slice(0, -options.newline.length);
  2776. }
  2777. return r;
  2778. };
  2779. return XMLStringWriter;
  2780. })(XMLWriterBase);
  2781. }).call(this);
  2782. /***/ }),
  2783. /* 33 */
  2784. /***/ (function(module, exports, __webpack_require__) {
  2785. // Generated by CoffeeScript 1.12.7
  2786. (function() {
  2787. var NodeType, WriterState, XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLDummy, XMLElement, XMLProcessingInstruction, XMLRaw, XMLText, XMLWriterBase, assign,
  2788. hasProp = {}.hasOwnProperty;
  2789. assign = __webpack_require__(5).assign;
  2790. NodeType = __webpack_require__(13);
  2791. XMLDeclaration = __webpack_require__(19);
  2792. XMLDocType = __webpack_require__(20);
  2793. XMLCData = __webpack_require__(16);
  2794. XMLComment = __webpack_require__(18);
  2795. XMLElement = __webpack_require__(12);
  2796. XMLRaw = __webpack_require__(25);
  2797. XMLText = __webpack_require__(26);
  2798. XMLProcessingInstruction = __webpack_require__(27);
  2799. XMLDummy = __webpack_require__(28);
  2800. XMLDTDAttList = __webpack_require__(21);
  2801. XMLDTDElement = __webpack_require__(23);
  2802. XMLDTDEntity = __webpack_require__(22);
  2803. XMLDTDNotation = __webpack_require__(24);
  2804. WriterState = __webpack_require__(34);
  2805. module.exports = XMLWriterBase = (function() {
  2806. function XMLWriterBase(options) {
  2807. var key, ref, value;
  2808. options || (options = {});
  2809. this.options = options;
  2810. ref = options.writer || {};
  2811. for (key in ref) {
  2812. if (!hasProp.call(ref, key)) continue;
  2813. value = ref[key];
  2814. this["_" + key] = this[key];
  2815. this[key] = value;
  2816. }
  2817. }
  2818. XMLWriterBase.prototype.filterOptions = function(options) {
  2819. var filteredOptions, ref, ref1, ref2, ref3, ref4, ref5, ref6;
  2820. options || (options = {});
  2821. options = assign({}, this.options, options);
  2822. filteredOptions = {
  2823. writer: this
  2824. };
  2825. filteredOptions.pretty = options.pretty || false;
  2826. filteredOptions.allowEmpty = options.allowEmpty || false;
  2827. filteredOptions.indent = (ref = options.indent) != null ? ref : ' ';
  2828. filteredOptions.newline = (ref1 = options.newline) != null ? ref1 : '\n';
  2829. filteredOptions.offset = (ref2 = options.offset) != null ? ref2 : 0;
  2830. filteredOptions.dontPrettyTextNodes = (ref3 = (ref4 = options.dontPrettyTextNodes) != null ? ref4 : options.dontprettytextnodes) != null ? ref3 : 0;
  2831. filteredOptions.spaceBeforeSlash = (ref5 = (ref6 = options.spaceBeforeSlash) != null ? ref6 : options.spacebeforeslash) != null ? ref5 : '';
  2832. if (filteredOptions.spaceBeforeSlash === true) {
  2833. filteredOptions.spaceBeforeSlash = ' ';
  2834. }
  2835. filteredOptions.suppressPrettyCount = 0;
  2836. filteredOptions.user = {};
  2837. filteredOptions.state = WriterState.None;
  2838. return filteredOptions;
  2839. };
  2840. XMLWriterBase.prototype.indent = function(node, options, level) {
  2841. var indentLevel;
  2842. if (!options.pretty || options.suppressPrettyCount) {
  2843. return '';
  2844. } else if (options.pretty) {
  2845. indentLevel = (level || 0) + options.offset + 1;
  2846. if (indentLevel > 0) {
  2847. return new Array(indentLevel).join(options.indent);
  2848. }
  2849. }
  2850. return '';
  2851. };
  2852. XMLWriterBase.prototype.endline = function(node, options, level) {
  2853. if (!options.pretty || options.suppressPrettyCount) {
  2854. return '';
  2855. } else {
  2856. return options.newline;
  2857. }
  2858. };
  2859. XMLWriterBase.prototype.attribute = function(att, options, level) {
  2860. var r;
  2861. this.openAttribute(att, options, level);
  2862. r = ' ' + att.name + '="' + att.value + '"';
  2863. this.closeAttribute(att, options, level);
  2864. return r;
  2865. };
  2866. XMLWriterBase.prototype.cdata = function(node, options, level) {
  2867. var r;
  2868. this.openNode(node, options, level);
  2869. options.state = WriterState.OpenTag;
  2870. r = this.indent(node, options, level) + '<![CDATA[';
  2871. options.state = WriterState.InsideTag;
  2872. r += node.value;
  2873. options.state = WriterState.CloseTag;
  2874. r += ']]>' + this.endline(node, options, level);
  2875. options.state = WriterState.None;
  2876. this.closeNode(node, options, level);
  2877. return r;
  2878. };
  2879. XMLWriterBase.prototype.comment = function(node, options, level) {
  2880. var r;
  2881. this.openNode(node, options, level);
  2882. options.state = WriterState.OpenTag;
  2883. r = this.indent(node, options, level) + '<!-- ';
  2884. options.state = WriterState.InsideTag;
  2885. r += node.value;
  2886. options.state = WriterState.CloseTag;
  2887. r += ' -->' + this.endline(node, options, level);
  2888. options.state = WriterState.None;
  2889. this.closeNode(node, options, level);
  2890. return r;
  2891. };
  2892. XMLWriterBase.prototype.declaration = function(node, options, level) {
  2893. var r;
  2894. this.openNode(node, options, level);
  2895. options.state = WriterState.OpenTag;
  2896. r = this.indent(node, options, level) + '<?xml';
  2897. options.state = WriterState.InsideTag;
  2898. r += ' version="' + node.version + '"';
  2899. if (node.encoding != null) {
  2900. r += ' encoding="' + node.encoding + '"';
  2901. }
  2902. if (node.standalone != null) {
  2903. r += ' standalone="' + node.standalone + '"';
  2904. }
  2905. options.state = WriterState.CloseTag;
  2906. r += options.spaceBeforeSlash + '?>';
  2907. r += this.endline(node, options, level);
  2908. options.state = WriterState.None;
  2909. this.closeNode(node, options, level);
  2910. return r;
  2911. };
  2912. XMLWriterBase.prototype.docType = function(node, options, level) {
  2913. var child, i, len, r, ref;
  2914. level || (level = 0);
  2915. this.openNode(node, options, level);
  2916. options.state = WriterState.OpenTag;
  2917. r = this.indent(node, options, level);
  2918. r += '<!DOCTYPE ' + node.root().name;
  2919. if (node.pubID && node.sysID) {
  2920. r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
  2921. } else if (node.sysID) {
  2922. r += ' SYSTEM "' + node.sysID + '"';
  2923. }
  2924. if (node.children.length > 0) {
  2925. r += ' [';
  2926. r += this.endline(node, options, level);
  2927. options.state = WriterState.InsideTag;
  2928. ref = node.children;
  2929. for (i = 0, len = ref.length; i < len; i++) {
  2930. child = ref[i];
  2931. r += this.writeChildNode(child, options, level + 1);
  2932. }
  2933. options.state = WriterState.CloseTag;
  2934. r += ']';
  2935. }
  2936. options.state = WriterState.CloseTag;
  2937. r += options.spaceBeforeSlash + '>';
  2938. r += this.endline(node, options, level);
  2939. options.state = WriterState.None;
  2940. this.closeNode(node, options, level);
  2941. return r;
  2942. };
  2943. XMLWriterBase.prototype.element = function(node, options, level) {
  2944. var att, child, childNodeCount, firstChildNode, i, j, len, len1, name, prettySuppressed, r, ref, ref1, ref2;
  2945. level || (level = 0);
  2946. prettySuppressed = false;
  2947. r = '';
  2948. this.openNode(node, options, level);
  2949. options.state = WriterState.OpenTag;
  2950. r += this.indent(node, options, level) + '<' + node.name;
  2951. ref = node.attribs;
  2952. for (name in ref) {
  2953. if (!hasProp.call(ref, name)) continue;
  2954. att = ref[name];
  2955. r += this.attribute(att, options, level);
  2956. }
  2957. childNodeCount = node.children.length;
  2958. firstChildNode = childNodeCount === 0 ? null : node.children[0];
  2959. if (childNodeCount === 0 || node.children.every(function(e) {
  2960. return (e.type === NodeType.Text || e.type === NodeType.Raw) && e.value === '';
  2961. })) {
  2962. if (options.allowEmpty) {
  2963. r += '>';
  2964. options.state = WriterState.CloseTag;
  2965. r += '</' + node.name + '>' + this.endline(node, options, level);
  2966. } else {
  2967. options.state = WriterState.CloseTag;
  2968. r += options.spaceBeforeSlash + '/>' + this.endline(node, options, level);
  2969. }
  2970. } else if (options.pretty && childNodeCount === 1 && (firstChildNode.type === NodeType.Text || firstChildNode.type === NodeType.Raw) && (firstChildNode.value != null)) {
  2971. r += '>';
  2972. options.state = WriterState.InsideTag;
  2973. options.suppressPrettyCount++;
  2974. prettySuppressed = true;
  2975. r += this.writeChildNode(firstChildNode, options, level + 1);
  2976. options.suppressPrettyCount--;
  2977. prettySuppressed = false;
  2978. options.state = WriterState.CloseTag;
  2979. r += '</' + node.name + '>' + this.endline(node, options, level);
  2980. } else {
  2981. if (options.dontPrettyTextNodes) {
  2982. ref1 = node.children;
  2983. for (i = 0, len = ref1.length; i < len; i++) {
  2984. child = ref1[i];
  2985. if ((child.type === NodeType.Text || child.type === NodeType.Raw) && (child.value != null)) {
  2986. options.suppressPrettyCount++;
  2987. prettySuppressed = true;
  2988. break;
  2989. }
  2990. }
  2991. }
  2992. r += '>' + this.endline(node, options, level);
  2993. options.state = WriterState.InsideTag;
  2994. ref2 = node.children;
  2995. for (j = 0, len1 = ref2.length; j < len1; j++) {
  2996. child = ref2[j];
  2997. r += this.writeChildNode(child, options, level + 1);
  2998. }
  2999. options.state = WriterState.CloseTag;
  3000. r += this.indent(node, options, level) + '</' + node.name + '>';
  3001. if (prettySuppressed) {
  3002. options.suppressPrettyCount--;
  3003. }
  3004. r += this.endline(node, options, level);
  3005. options.state = WriterState.None;
  3006. }
  3007. this.closeNode(node, options, level);
  3008. return r;
  3009. };
  3010. XMLWriterBase.prototype.writeChildNode = function(node, options, level) {
  3011. switch (node.type) {
  3012. case NodeType.CData:
  3013. return this.cdata(node, options, level);
  3014. case NodeType.Comment:
  3015. return this.comment(node, options, level);
  3016. case NodeType.Element:
  3017. return this.element(node, options, level);
  3018. case NodeType.Raw:
  3019. return this.raw(node, options, level);
  3020. case NodeType.Text:
  3021. return this.text(node, options, level);
  3022. case NodeType.ProcessingInstruction:
  3023. return this.processingInstruction(node, options, level);
  3024. case NodeType.Dummy:
  3025. return '';
  3026. case NodeType.Declaration:
  3027. return this.declaration(node, options, level);
  3028. case NodeType.DocType:
  3029. return this.docType(node, options, level);
  3030. case NodeType.AttributeDeclaration:
  3031. return this.dtdAttList(node, options, level);
  3032. case NodeType.ElementDeclaration:
  3033. return this.dtdElement(node, options, level);
  3034. case NodeType.EntityDeclaration:
  3035. return this.dtdEntity(node, options, level);
  3036. case NodeType.NotationDeclaration:
  3037. return this.dtdNotation(node, options, level);
  3038. default:
  3039. throw new Error("Unknown XML node type: " + node.constructor.name);
  3040. }
  3041. };
  3042. XMLWriterBase.prototype.processingInstruction = function(node, options, level) {
  3043. var r;
  3044. this.openNode(node, options, level);
  3045. options.state = WriterState.OpenTag;
  3046. r = this.indent(node, options, level) + '<?';
  3047. options.state = WriterState.InsideTag;
  3048. r += node.target;
  3049. if (node.value) {
  3050. r += ' ' + node.value;
  3051. }
  3052. options.state = WriterState.CloseTag;
  3053. r += options.spaceBeforeSlash + '?>';
  3054. r += this.endline(node, options, level);
  3055. options.state = WriterState.None;
  3056. this.closeNode(node, options, level);
  3057. return r;
  3058. };
  3059. XMLWriterBase.prototype.raw = function(node, options, level) {
  3060. var r;
  3061. this.openNode(node, options, level);
  3062. options.state = WriterState.OpenTag;
  3063. r = this.indent(node, options, level);
  3064. options.state = WriterState.InsideTag;
  3065. r += node.value;
  3066. options.state = WriterState.CloseTag;
  3067. r += this.endline(node, options, level);
  3068. options.state = WriterState.None;
  3069. this.closeNode(node, options, level);
  3070. return r;
  3071. };
  3072. XMLWriterBase.prototype.text = function(node, options, level) {
  3073. var r;
  3074. this.openNode(node, options, level);
  3075. options.state = WriterState.OpenTag;
  3076. r = this.indent(node, options, level);
  3077. options.state = WriterState.InsideTag;
  3078. r += node.value;
  3079. options.state = WriterState.CloseTag;
  3080. r += this.endline(node, options, level);
  3081. options.state = WriterState.None;
  3082. this.closeNode(node, options, level);
  3083. return r;
  3084. };
  3085. XMLWriterBase.prototype.dtdAttList = function(node, options, level) {
  3086. var r;
  3087. this.openNode(node, options, level);
  3088. options.state = WriterState.OpenTag;
  3089. r = this.indent(node, options, level) + '<!ATTLIST';
  3090. options.state = WriterState.InsideTag;
  3091. r += ' ' + node.elementName + ' ' + node.attributeName + ' ' + node.attributeType;
  3092. if (node.defaultValueType !== '#DEFAULT') {
  3093. r += ' ' + node.defaultValueType;
  3094. }
  3095. if (node.defaultValue) {
  3096. r += ' "' + node.defaultValue + '"';
  3097. }
  3098. options.state = WriterState.CloseTag;
  3099. r += options.spaceBeforeSlash + '>' + this.endline(node, options, level);
  3100. options.state = WriterState.None;
  3101. this.closeNode(node, options, level);
  3102. return r;
  3103. };
  3104. XMLWriterBase.prototype.dtdElement = function(node, options, level) {
  3105. var r;
  3106. this.openNode(node, options, level);
  3107. options.state = WriterState.OpenTag;
  3108. r = this.indent(node, options, level) + '<!ELEMENT';
  3109. options.state = WriterState.InsideTag;
  3110. r += ' ' + node.name + ' ' + node.value;
  3111. options.state = WriterState.CloseTag;
  3112. r += options.spaceBeforeSlash + '>' + this.endline(node, options, level);
  3113. options.state = WriterState.None;
  3114. this.closeNode(node, options, level);
  3115. return r;
  3116. };
  3117. XMLWriterBase.prototype.dtdEntity = function(node, options, level) {
  3118. var r;
  3119. this.openNode(node, options, level);
  3120. options.state = WriterState.OpenTag;
  3121. r = this.indent(node, options, level) + '<!ENTITY';
  3122. options.state = WriterState.InsideTag;
  3123. if (node.pe) {
  3124. r += ' %';
  3125. }
  3126. r += ' ' + node.name;
  3127. if (node.value) {
  3128. r += ' "' + node.value + '"';
  3129. } else {
  3130. if (node.pubID && node.sysID) {
  3131. r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
  3132. } else if (node.sysID) {
  3133. r += ' SYSTEM "' + node.sysID + '"';
  3134. }
  3135. if (node.nData) {
  3136. r += ' NDATA ' + node.nData;
  3137. }
  3138. }
  3139. options.state = WriterState.CloseTag;
  3140. r += options.spaceBeforeSlash + '>' + this.endline(node, options, level);
  3141. options.state = WriterState.None;
  3142. this.closeNode(node, options, level);
  3143. return r;
  3144. };
  3145. XMLWriterBase.prototype.dtdNotation = function(node, options, level) {
  3146. var r;
  3147. this.openNode(node, options, level);
  3148. options.state = WriterState.OpenTag;
  3149. r = this.indent(node, options, level) + '<!NOTATION';
  3150. options.state = WriterState.InsideTag;
  3151. r += ' ' + node.name;
  3152. if (node.pubID && node.sysID) {
  3153. r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
  3154. } else if (node.pubID) {
  3155. r += ' PUBLIC "' + node.pubID + '"';
  3156. } else if (node.sysID) {
  3157. r += ' SYSTEM "' + node.sysID + '"';
  3158. }
  3159. options.state = WriterState.CloseTag;
  3160. r += options.spaceBeforeSlash + '>' + this.endline(node, options, level);
  3161. options.state = WriterState.None;
  3162. this.closeNode(node, options, level);
  3163. return r;
  3164. };
  3165. XMLWriterBase.prototype.openNode = function(node, options, level) {};
  3166. XMLWriterBase.prototype.closeNode = function(node, options, level) {};
  3167. XMLWriterBase.prototype.openAttribute = function(att, options, level) {};
  3168. XMLWriterBase.prototype.closeAttribute = function(att, options, level) {};
  3169. return XMLWriterBase;
  3170. })();
  3171. }).call(this);
  3172. /***/ }),
  3173. /* 34 */
  3174. /***/ (function(module, exports) {
  3175. // Generated by CoffeeScript 1.12.7
  3176. (function() {
  3177. module.exports = {
  3178. None: 0,
  3179. OpenTag: 1,
  3180. InsideTag: 2,
  3181. CloseTag: 3
  3182. };
  3183. }).call(this);
  3184. /***/ }),
  3185. /* 35 */
  3186. /***/ (function(module, exports, __webpack_require__) {
  3187. // Generated by CoffeeScript 1.12.7
  3188. (function() {
  3189. var NodeType, WriterState, XMLAttribute, XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLDocument, XMLDocumentCB, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStringWriter, XMLStringifier, XMLText, getValue, isFunction, isObject, isPlainObject, ref,
  3190. hasProp = {}.hasOwnProperty;
  3191. ref = __webpack_require__(5), isObject = ref.isObject, isFunction = ref.isFunction, isPlainObject = ref.isPlainObject, getValue = ref.getValue;
  3192. NodeType = __webpack_require__(13);
  3193. XMLDocument = __webpack_require__(7);
  3194. XMLElement = __webpack_require__(12);
  3195. XMLCData = __webpack_require__(16);
  3196. XMLComment = __webpack_require__(18);
  3197. XMLRaw = __webpack_require__(25);
  3198. XMLText = __webpack_require__(26);
  3199. XMLProcessingInstruction = __webpack_require__(27);
  3200. XMLDeclaration = __webpack_require__(19);
  3201. XMLDocType = __webpack_require__(20);
  3202. XMLDTDAttList = __webpack_require__(21);
  3203. XMLDTDEntity = __webpack_require__(22);
  3204. XMLDTDElement = __webpack_require__(23);
  3205. XMLDTDNotation = __webpack_require__(24);
  3206. XMLAttribute = __webpack_require__(14);
  3207. XMLStringifier = __webpack_require__(31);
  3208. XMLStringWriter = __webpack_require__(32);
  3209. WriterState = __webpack_require__(34);
  3210. module.exports = XMLDocumentCB = (function() {
  3211. function XMLDocumentCB(options, onData, onEnd) {
  3212. var writerOptions;
  3213. this.name = "?xml";
  3214. this.type = NodeType.Document;
  3215. options || (options = {});
  3216. writerOptions = {};
  3217. if (!options.writer) {
  3218. options.writer = new XMLStringWriter();
  3219. } else if (isPlainObject(options.writer)) {
  3220. writerOptions = options.writer;
  3221. options.writer = new XMLStringWriter();
  3222. }
  3223. this.options = options;
  3224. this.writer = options.writer;
  3225. this.writerOptions = this.writer.filterOptions(writerOptions);
  3226. this.stringify = new XMLStringifier(options);
  3227. this.onDataCallback = onData || function() {};
  3228. this.onEndCallback = onEnd || function() {};
  3229. this.currentNode = null;
  3230. this.currentLevel = -1;
  3231. this.openTags = {};
  3232. this.documentStarted = false;
  3233. this.documentCompleted = false;
  3234. this.root = null;
  3235. }
  3236. XMLDocumentCB.prototype.createChildNode = function(node) {
  3237. var att, attName, attributes, child, i, len, ref1, ref2;
  3238. switch (node.type) {
  3239. case NodeType.CData:
  3240. this.cdata(node.value);
  3241. break;
  3242. case NodeType.Comment:
  3243. this.comment(node.value);
  3244. break;
  3245. case NodeType.Element:
  3246. attributes = {};
  3247. ref1 = node.attribs;
  3248. for (attName in ref1) {
  3249. if (!hasProp.call(ref1, attName)) continue;
  3250. att = ref1[attName];
  3251. attributes[attName] = att.value;
  3252. }
  3253. this.node(node.name, attributes);
  3254. break;
  3255. case NodeType.Dummy:
  3256. this.dummy();
  3257. break;
  3258. case NodeType.Raw:
  3259. this.raw(node.value);
  3260. break;
  3261. case NodeType.Text:
  3262. this.text(node.value);
  3263. break;
  3264. case NodeType.ProcessingInstruction:
  3265. this.instruction(node.target, node.value);
  3266. break;
  3267. default:
  3268. throw new Error("This XML node type is not supported in a JS object: " + node.constructor.name);
  3269. }
  3270. ref2 = node.children;
  3271. for (i = 0, len = ref2.length; i < len; i++) {
  3272. child = ref2[i];
  3273. this.createChildNode(child);
  3274. if (child.type === NodeType.Element) {
  3275. this.up();
  3276. }
  3277. }
  3278. return this;
  3279. };
  3280. XMLDocumentCB.prototype.dummy = function() {
  3281. return this;
  3282. };
  3283. XMLDocumentCB.prototype.node = function(name, attributes, text) {
  3284. var ref1;
  3285. if (name == null) {
  3286. throw new Error("Missing node name.");
  3287. }
  3288. if (this.root && this.currentLevel === -1) {
  3289. throw new Error("Document can only have one root node. " + this.debugInfo(name));
  3290. }
  3291. this.openCurrent();
  3292. name = getValue(name);
  3293. if (attributes == null) {
  3294. attributes = {};
  3295. }
  3296. attributes = getValue(attributes);
  3297. if (!isObject(attributes)) {
  3298. ref1 = [attributes, text], text = ref1[0], attributes = ref1[1];
  3299. }
  3300. this.currentNode = new XMLElement(this, name, attributes);
  3301. this.currentNode.children = false;
  3302. this.currentLevel++;
  3303. this.openTags[this.currentLevel] = this.currentNode;
  3304. if (text != null) {
  3305. this.text(text);
  3306. }
  3307. return this;
  3308. };
  3309. XMLDocumentCB.prototype.element = function(name, attributes, text) {
  3310. var child, i, len, oldValidationFlag, ref1, root;
  3311. if (this.currentNode && this.currentNode.type === NodeType.DocType) {
  3312. this.dtdElement.apply(this, arguments);
  3313. } else {
  3314. if (Array.isArray(name) || isObject(name) || isFunction(name)) {
  3315. oldValidationFlag = this.options.noValidation;
  3316. this.options.noValidation = true;
  3317. root = new XMLDocument(this.options).element('TEMP_ROOT');
  3318. root.element(name);
  3319. this.options.noValidation = oldValidationFlag;
  3320. ref1 = root.children;
  3321. for (i = 0, len = ref1.length; i < len; i++) {
  3322. child = ref1[i];
  3323. this.createChildNode(child);
  3324. if (child.type === NodeType.Element) {
  3325. this.up();
  3326. }
  3327. }
  3328. } else {
  3329. this.node(name, attributes, text);
  3330. }
  3331. }
  3332. return this;
  3333. };
  3334. XMLDocumentCB.prototype.attribute = function(name, value) {
  3335. var attName, attValue;
  3336. if (!this.currentNode || this.currentNode.children) {
  3337. throw new Error("att() can only be used immediately after an ele() call in callback mode. " + this.debugInfo(name));
  3338. }
  3339. if (name != null) {
  3340. name = getValue(name);
  3341. }
  3342. if (isObject(name)) {
  3343. for (attName in name) {
  3344. if (!hasProp.call(name, attName)) continue;
  3345. attValue = name[attName];
  3346. this.attribute(attName, attValue);
  3347. }
  3348. } else {
  3349. if (isFunction(value)) {
  3350. value = value.apply();
  3351. }
  3352. if (this.options.keepNullAttributes && (value == null)) {
  3353. this.currentNode.attribs[name] = new XMLAttribute(this, name, "");
  3354. } else if (value != null) {
  3355. this.currentNode.attribs[name] = new XMLAttribute(this, name, value);
  3356. }
  3357. }
  3358. return this;
  3359. };
  3360. XMLDocumentCB.prototype.text = function(value) {
  3361. var node;
  3362. this.openCurrent();
  3363. node = new XMLText(this, value);
  3364. this.onData(this.writer.text(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
  3365. return this;
  3366. };
  3367. XMLDocumentCB.prototype.cdata = function(value) {
  3368. var node;
  3369. this.openCurrent();
  3370. node = new XMLCData(this, value);
  3371. this.onData(this.writer.cdata(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
  3372. return this;
  3373. };
  3374. XMLDocumentCB.prototype.comment = function(value) {
  3375. var node;
  3376. this.openCurrent();
  3377. node = new XMLComment(this, value);
  3378. this.onData(this.writer.comment(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
  3379. return this;
  3380. };
  3381. XMLDocumentCB.prototype.raw = function(value) {
  3382. var node;
  3383. this.openCurrent();
  3384. node = new XMLRaw(this, value);
  3385. this.onData(this.writer.raw(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
  3386. return this;
  3387. };
  3388. XMLDocumentCB.prototype.instruction = function(target, value) {
  3389. var i, insTarget, insValue, len, node;
  3390. this.openCurrent();
  3391. if (target != null) {
  3392. target = getValue(target);
  3393. }
  3394. if (value != null) {
  3395. value = getValue(value);
  3396. }
  3397. if (Array.isArray(target)) {
  3398. for (i = 0, len = target.length; i < len; i++) {
  3399. insTarget = target[i];
  3400. this.instruction(insTarget);
  3401. }
  3402. } else if (isObject(target)) {
  3403. for (insTarget in target) {
  3404. if (!hasProp.call(target, insTarget)) continue;
  3405. insValue = target[insTarget];
  3406. this.instruction(insTarget, insValue);
  3407. }
  3408. } else {
  3409. if (isFunction(value)) {
  3410. value = value.apply();
  3411. }
  3412. node = new XMLProcessingInstruction(this, target, value);
  3413. this.onData(this.writer.processingInstruction(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
  3414. }
  3415. return this;
  3416. };
  3417. XMLDocumentCB.prototype.declaration = function(version, encoding, standalone) {
  3418. var node;
  3419. this.openCurrent();
  3420. if (this.documentStarted) {
  3421. throw new Error("declaration() must be the first node.");
  3422. }
  3423. node = new XMLDeclaration(this, version, encoding, standalone);
  3424. this.onData(this.writer.declaration(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
  3425. return this;
  3426. };
  3427. XMLDocumentCB.prototype.doctype = function(root, pubID, sysID) {
  3428. this.openCurrent();
  3429. if (root == null) {
  3430. throw new Error("Missing root node name.");
  3431. }
  3432. if (this.root) {
  3433. throw new Error("dtd() must come before the root node.");
  3434. }
  3435. this.currentNode = new XMLDocType(this, pubID, sysID);
  3436. this.currentNode.rootNodeName = root;
  3437. this.currentNode.children = false;
  3438. this.currentLevel++;
  3439. this.openTags[this.currentLevel] = this.currentNode;
  3440. return this;
  3441. };
  3442. XMLDocumentCB.prototype.dtdElement = function(name, value) {
  3443. var node;
  3444. this.openCurrent();
  3445. node = new XMLDTDElement(this, name, value);
  3446. this.onData(this.writer.dtdElement(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
  3447. return this;
  3448. };
  3449. XMLDocumentCB.prototype.attList = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
  3450. var node;
  3451. this.openCurrent();
  3452. node = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
  3453. this.onData(this.writer.dtdAttList(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
  3454. return this;
  3455. };
  3456. XMLDocumentCB.prototype.entity = function(name, value) {
  3457. var node;
  3458. this.openCurrent();
  3459. node = new XMLDTDEntity(this, false, name, value);
  3460. this.onData(this.writer.dtdEntity(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
  3461. return this;
  3462. };
  3463. XMLDocumentCB.prototype.pEntity = function(name, value) {
  3464. var node;
  3465. this.openCurrent();
  3466. node = new XMLDTDEntity(this, true, name, value);
  3467. this.onData(this.writer.dtdEntity(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
  3468. return this;
  3469. };
  3470. XMLDocumentCB.prototype.notation = function(name, value) {
  3471. var node;
  3472. this.openCurrent();
  3473. node = new XMLDTDNotation(this, name, value);
  3474. this.onData(this.writer.dtdNotation(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1);
  3475. return this;
  3476. };
  3477. XMLDocumentCB.prototype.up = function() {
  3478. if (this.currentLevel < 0) {
  3479. throw new Error("The document node has no parent.");
  3480. }
  3481. if (this.currentNode) {
  3482. if (this.currentNode.children) {
  3483. this.closeNode(this.currentNode);
  3484. } else {
  3485. this.openNode(this.currentNode);
  3486. }
  3487. this.currentNode = null;
  3488. } else {
  3489. this.closeNode(this.openTags[this.currentLevel]);
  3490. }
  3491. delete this.openTags[this.currentLevel];
  3492. this.currentLevel--;
  3493. return this;
  3494. };
  3495. XMLDocumentCB.prototype.end = function() {
  3496. while (this.currentLevel >= 0) {
  3497. this.up();
  3498. }
  3499. return this.onEnd();
  3500. };
  3501. XMLDocumentCB.prototype.openCurrent = function() {
  3502. if (this.currentNode) {
  3503. this.currentNode.children = true;
  3504. return this.openNode(this.currentNode);
  3505. }
  3506. };
  3507. XMLDocumentCB.prototype.openNode = function(node) {
  3508. var att, chunk, name, ref1;
  3509. if (!node.isOpen) {
  3510. if (!this.root && this.currentLevel === 0 && node.type === NodeType.Element) {
  3511. this.root = node;
  3512. }
  3513. chunk = '';
  3514. if (node.type === NodeType.Element) {
  3515. this.writerOptions.state = WriterState.OpenTag;
  3516. chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '<' + node.name;
  3517. ref1 = node.attribs;
  3518. for (name in ref1) {
  3519. if (!hasProp.call(ref1, name)) continue;
  3520. att = ref1[name];
  3521. chunk += this.writer.attribute(att, this.writerOptions, this.currentLevel);
  3522. }
  3523. chunk += (node.children ? '>' : '/>') + this.writer.endline(node, this.writerOptions, this.currentLevel);
  3524. this.writerOptions.state = WriterState.InsideTag;
  3525. } else {
  3526. this.writerOptions.state = WriterState.OpenTag;
  3527. chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '<!DOCTYPE ' + node.rootNodeName;
  3528. if (node.pubID && node.sysID) {
  3529. chunk += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
  3530. } else if (node.sysID) {
  3531. chunk += ' SYSTEM "' + node.sysID + '"';
  3532. }
  3533. if (node.children) {
  3534. chunk += ' [';
  3535. this.writerOptions.state = WriterState.InsideTag;
  3536. } else {
  3537. this.writerOptions.state = WriterState.CloseTag;
  3538. chunk += '>';
  3539. }
  3540. chunk += this.writer.endline(node, this.writerOptions, this.currentLevel);
  3541. }
  3542. this.onData(chunk, this.currentLevel);
  3543. return node.isOpen = true;
  3544. }
  3545. };
  3546. XMLDocumentCB.prototype.closeNode = function(node) {
  3547. var chunk;
  3548. if (!node.isClosed) {
  3549. chunk = '';
  3550. this.writerOptions.state = WriterState.CloseTag;
  3551. if (node.type === NodeType.Element) {
  3552. chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '</' + node.name + '>' + this.writer.endline(node, this.writerOptions, this.currentLevel);
  3553. } else {
  3554. chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + ']>' + this.writer.endline(node, this.writerOptions, this.currentLevel);
  3555. }
  3556. this.writerOptions.state = WriterState.None;
  3557. this.onData(chunk, this.currentLevel);
  3558. return node.isClosed = true;
  3559. }
  3560. };
  3561. XMLDocumentCB.prototype.onData = function(chunk, level) {
  3562. this.documentStarted = true;
  3563. return this.onDataCallback(chunk, level + 1);
  3564. };
  3565. XMLDocumentCB.prototype.onEnd = function() {
  3566. this.documentCompleted = true;
  3567. return this.onEndCallback();
  3568. };
  3569. XMLDocumentCB.prototype.debugInfo = function(name) {
  3570. if (name == null) {
  3571. return "";
  3572. } else {
  3573. return "node: <" + name + ">";
  3574. }
  3575. };
  3576. XMLDocumentCB.prototype.ele = function() {
  3577. return this.element.apply(this, arguments);
  3578. };
  3579. XMLDocumentCB.prototype.nod = function(name, attributes, text) {
  3580. return this.node(name, attributes, text);
  3581. };
  3582. XMLDocumentCB.prototype.txt = function(value) {
  3583. return this.text(value);
  3584. };
  3585. XMLDocumentCB.prototype.dat = function(value) {
  3586. return this.cdata(value);
  3587. };
  3588. XMLDocumentCB.prototype.com = function(value) {
  3589. return this.comment(value);
  3590. };
  3591. XMLDocumentCB.prototype.ins = function(target, value) {
  3592. return this.instruction(target, value);
  3593. };
  3594. XMLDocumentCB.prototype.dec = function(version, encoding, standalone) {
  3595. return this.declaration(version, encoding, standalone);
  3596. };
  3597. XMLDocumentCB.prototype.dtd = function(root, pubID, sysID) {
  3598. return this.doctype(root, pubID, sysID);
  3599. };
  3600. XMLDocumentCB.prototype.e = function(name, attributes, text) {
  3601. return this.element(name, attributes, text);
  3602. };
  3603. XMLDocumentCB.prototype.n = function(name, attributes, text) {
  3604. return this.node(name, attributes, text);
  3605. };
  3606. XMLDocumentCB.prototype.t = function(value) {
  3607. return this.text(value);
  3608. };
  3609. XMLDocumentCB.prototype.d = function(value) {
  3610. return this.cdata(value);
  3611. };
  3612. XMLDocumentCB.prototype.c = function(value) {
  3613. return this.comment(value);
  3614. };
  3615. XMLDocumentCB.prototype.r = function(value) {
  3616. return this.raw(value);
  3617. };
  3618. XMLDocumentCB.prototype.i = function(target, value) {
  3619. return this.instruction(target, value);
  3620. };
  3621. XMLDocumentCB.prototype.att = function() {
  3622. if (this.currentNode && this.currentNode.type === NodeType.DocType) {
  3623. return this.attList.apply(this, arguments);
  3624. } else {
  3625. return this.attribute.apply(this, arguments);
  3626. }
  3627. };
  3628. XMLDocumentCB.prototype.a = function() {
  3629. if (this.currentNode && this.currentNode.type === NodeType.DocType) {
  3630. return this.attList.apply(this, arguments);
  3631. } else {
  3632. return this.attribute.apply(this, arguments);
  3633. }
  3634. };
  3635. XMLDocumentCB.prototype.ent = function(name, value) {
  3636. return this.entity(name, value);
  3637. };
  3638. XMLDocumentCB.prototype.pent = function(name, value) {
  3639. return this.pEntity(name, value);
  3640. };
  3641. XMLDocumentCB.prototype.not = function(name, value) {
  3642. return this.notation(name, value);
  3643. };
  3644. return XMLDocumentCB;
  3645. })();
  3646. }).call(this);
  3647. /***/ }),
  3648. /* 36 */
  3649. /***/ (function(module, exports, __webpack_require__) {
  3650. // Generated by CoffeeScript 1.12.7
  3651. (function() {
  3652. var NodeType, WriterState, XMLStreamWriter, XMLWriterBase,
  3653. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  3654. hasProp = {}.hasOwnProperty;
  3655. NodeType = __webpack_require__(13);
  3656. XMLWriterBase = __webpack_require__(33);
  3657. WriterState = __webpack_require__(34);
  3658. module.exports = XMLStreamWriter = (function(superClass) {
  3659. extend(XMLStreamWriter, superClass);
  3660. function XMLStreamWriter(stream, options) {
  3661. this.stream = stream;
  3662. XMLStreamWriter.__super__.constructor.call(this, options);
  3663. }
  3664. XMLStreamWriter.prototype.endline = function(node, options, level) {
  3665. if (node.isLastRootNode && options.state === WriterState.CloseTag) {
  3666. return '';
  3667. } else {
  3668. return XMLStreamWriter.__super__.endline.call(this, node, options, level);
  3669. }
  3670. };
  3671. XMLStreamWriter.prototype.document = function(doc, options) {
  3672. var child, i, j, k, len, len1, ref, ref1, results;
  3673. ref = doc.children;
  3674. for (i = j = 0, len = ref.length; j < len; i = ++j) {
  3675. child = ref[i];
  3676. child.isLastRootNode = i === doc.children.length - 1;
  3677. }
  3678. options = this.filterOptions(options);
  3679. ref1 = doc.children;
  3680. results = [];
  3681. for (k = 0, len1 = ref1.length; k < len1; k++) {
  3682. child = ref1[k];
  3683. results.push(this.writeChildNode(child, options, 0));
  3684. }
  3685. return results;
  3686. };
  3687. XMLStreamWriter.prototype.attribute = function(att, options, level) {
  3688. return this.stream.write(XMLStreamWriter.__super__.attribute.call(this, att, options, level));
  3689. };
  3690. XMLStreamWriter.prototype.cdata = function(node, options, level) {
  3691. return this.stream.write(XMLStreamWriter.__super__.cdata.call(this, node, options, level));
  3692. };
  3693. XMLStreamWriter.prototype.comment = function(node, options, level) {
  3694. return this.stream.write(XMLStreamWriter.__super__.comment.call(this, node, options, level));
  3695. };
  3696. XMLStreamWriter.prototype.declaration = function(node, options, level) {
  3697. return this.stream.write(XMLStreamWriter.__super__.declaration.call(this, node, options, level));
  3698. };
  3699. XMLStreamWriter.prototype.docType = function(node, options, level) {
  3700. var child, j, len, ref;
  3701. level || (level = 0);
  3702. this.openNode(node, options, level);
  3703. options.state = WriterState.OpenTag;
  3704. this.stream.write(this.indent(node, options, level));
  3705. this.stream.write('<!DOCTYPE ' + node.root().name);
  3706. if (node.pubID && node.sysID) {
  3707. this.stream.write(' PUBLIC "' + node.pubID + '" "' + node.sysID + '"');
  3708. } else if (node.sysID) {
  3709. this.stream.write(' SYSTEM "' + node.sysID + '"');
  3710. }
  3711. if (node.children.length > 0) {
  3712. this.stream.write(' [');
  3713. this.stream.write(this.endline(node, options, level));
  3714. options.state = WriterState.InsideTag;
  3715. ref = node.children;
  3716. for (j = 0, len = ref.length; j < len; j++) {
  3717. child = ref[j];
  3718. this.writeChildNode(child, options, level + 1);
  3719. }
  3720. options.state = WriterState.CloseTag;
  3721. this.stream.write(']');
  3722. }
  3723. options.state = WriterState.CloseTag;
  3724. this.stream.write(options.spaceBeforeSlash + '>');
  3725. this.stream.write(this.endline(node, options, level));
  3726. options.state = WriterState.None;
  3727. return this.closeNode(node, options, level);
  3728. };
  3729. XMLStreamWriter.prototype.element = function(node, options, level) {
  3730. var att, child, childNodeCount, firstChildNode, j, len, name, prettySuppressed, ref, ref1;
  3731. level || (level = 0);
  3732. this.openNode(node, options, level);
  3733. options.state = WriterState.OpenTag;
  3734. this.stream.write(this.indent(node, options, level) + '<' + node.name);
  3735. ref = node.attribs;
  3736. for (name in ref) {
  3737. if (!hasProp.call(ref, name)) continue;
  3738. att = ref[name];
  3739. this.attribute(att, options, level);
  3740. }
  3741. childNodeCount = node.children.length;
  3742. firstChildNode = childNodeCount === 0 ? null : node.children[0];
  3743. if (childNodeCount === 0 || node.children.every(function(e) {
  3744. return (e.type === NodeType.Text || e.type === NodeType.Raw) && e.value === '';
  3745. })) {
  3746. if (options.allowEmpty) {
  3747. this.stream.write('>');
  3748. options.state = WriterState.CloseTag;
  3749. this.stream.write('</' + node.name + '>');
  3750. } else {
  3751. options.state = WriterState.CloseTag;
  3752. this.stream.write(options.spaceBeforeSlash + '/>');
  3753. }
  3754. } else if (options.pretty && childNodeCount === 1 && (firstChildNode.type === NodeType.Text || firstChildNode.type === NodeType.Raw) && (firstChildNode.value != null)) {
  3755. this.stream.write('>');
  3756. options.state = WriterState.InsideTag;
  3757. options.suppressPrettyCount++;
  3758. prettySuppressed = true;
  3759. this.writeChildNode(firstChildNode, options, level + 1);
  3760. options.suppressPrettyCount--;
  3761. prettySuppressed = false;
  3762. options.state = WriterState.CloseTag;
  3763. this.stream.write('</' + node.name + '>');
  3764. } else {
  3765. this.stream.write('>' + this.endline(node, options, level));
  3766. options.state = WriterState.InsideTag;
  3767. ref1 = node.children;
  3768. for (j = 0, len = ref1.length; j < len; j++) {
  3769. child = ref1[j];
  3770. this.writeChildNode(child, options, level + 1);
  3771. }
  3772. options.state = WriterState.CloseTag;
  3773. this.stream.write(this.indent(node, options, level) + '</' + node.name + '>');
  3774. }
  3775. this.stream.write(this.endline(node, options, level));
  3776. options.state = WriterState.None;
  3777. return this.closeNode(node, options, level);
  3778. };
  3779. XMLStreamWriter.prototype.processingInstruction = function(node, options, level) {
  3780. return this.stream.write(XMLStreamWriter.__super__.processingInstruction.call(this, node, options, level));
  3781. };
  3782. XMLStreamWriter.prototype.raw = function(node, options, level) {
  3783. return this.stream.write(XMLStreamWriter.__super__.raw.call(this, node, options, level));
  3784. };
  3785. XMLStreamWriter.prototype.text = function(node, options, level) {
  3786. return this.stream.write(XMLStreamWriter.__super__.text.call(this, node, options, level));
  3787. };
  3788. XMLStreamWriter.prototype.dtdAttList = function(node, options, level) {
  3789. return this.stream.write(XMLStreamWriter.__super__.dtdAttList.call(this, node, options, level));
  3790. };
  3791. XMLStreamWriter.prototype.dtdElement = function(node, options, level) {
  3792. return this.stream.write(XMLStreamWriter.__super__.dtdElement.call(this, node, options, level));
  3793. };
  3794. XMLStreamWriter.prototype.dtdEntity = function(node, options, level) {
  3795. return this.stream.write(XMLStreamWriter.__super__.dtdEntity.call(this, node, options, level));
  3796. };
  3797. XMLStreamWriter.prototype.dtdNotation = function(node, options, level) {
  3798. return this.stream.write(XMLStreamWriter.__super__.dtdNotation.call(this, node, options, level));
  3799. };
  3800. return XMLStreamWriter;
  3801. })(XMLWriterBase);
  3802. }).call(this);
  3803. /***/ }),
  3804. /* 37 */
  3805. /***/ (function(module, exports, __webpack_require__) {
  3806. // Generated by CoffeeScript 1.12.7
  3807. (function() {
  3808. "use strict";
  3809. var bom, defaults, defineProperty, events, isEmpty, processItem, processors, sax, setImmediate,
  3810. bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
  3811. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  3812. hasProp = {}.hasOwnProperty;
  3813. sax = __webpack_require__(38);
  3814. events = __webpack_require__(44);
  3815. bom = __webpack_require__(70);
  3816. processors = __webpack_require__(71);
  3817. setImmediate = __webpack_require__(59).setImmediate;
  3818. defaults = __webpack_require__(2).defaults;
  3819. isEmpty = function(thing) {
  3820. return typeof thing === "object" && (thing != null) && Object.keys(thing).length === 0;
  3821. };
  3822. processItem = function(processors, item, key) {
  3823. var i, len, process;
  3824. for (i = 0, len = processors.length; i < len; i++) {
  3825. process = processors[i];
  3826. item = process(item, key);
  3827. }
  3828. return item;
  3829. };
  3830. defineProperty = function(obj, key, value) {
  3831. var descriptor;
  3832. descriptor = Object.create(null);
  3833. descriptor.value = value;
  3834. descriptor.writable = true;
  3835. descriptor.enumerable = true;
  3836. descriptor.configurable = true;
  3837. return Object.defineProperty(obj, key, descriptor);
  3838. };
  3839. exports.Parser = (function(superClass) {
  3840. extend(Parser, superClass);
  3841. function Parser(opts) {
  3842. this.parseStringPromise = bind(this.parseStringPromise, this);
  3843. this.parseString = bind(this.parseString, this);
  3844. this.reset = bind(this.reset, this);
  3845. this.assignOrPush = bind(this.assignOrPush, this);
  3846. this.processAsync = bind(this.processAsync, this);
  3847. var key, ref, value;
  3848. if (!(this instanceof exports.Parser)) {
  3849. return new exports.Parser(opts);
  3850. }
  3851. this.options = {};
  3852. ref = defaults["0.2"];
  3853. for (key in ref) {
  3854. if (!hasProp.call(ref, key)) continue;
  3855. value = ref[key];
  3856. this.options[key] = value;
  3857. }
  3858. for (key in opts) {
  3859. if (!hasProp.call(opts, key)) continue;
  3860. value = opts[key];
  3861. this.options[key] = value;
  3862. }
  3863. if (this.options.xmlns) {
  3864. this.options.xmlnskey = this.options.attrkey + "ns";
  3865. }
  3866. if (this.options.normalizeTags) {
  3867. if (!this.options.tagNameProcessors) {
  3868. this.options.tagNameProcessors = [];
  3869. }
  3870. this.options.tagNameProcessors.unshift(processors.normalize);
  3871. }
  3872. this.reset();
  3873. }
  3874. Parser.prototype.processAsync = function() {
  3875. var chunk, err;
  3876. try {
  3877. if (this.remaining.length <= this.options.chunkSize) {
  3878. chunk = this.remaining;
  3879. this.remaining = '';
  3880. this.saxParser = this.saxParser.write(chunk);
  3881. return this.saxParser.close();
  3882. } else {
  3883. chunk = this.remaining.substr(0, this.options.chunkSize);
  3884. this.remaining = this.remaining.substr(this.options.chunkSize, this.remaining.length);
  3885. this.saxParser = this.saxParser.write(chunk);
  3886. return setImmediate(this.processAsync);
  3887. }
  3888. } catch (error1) {
  3889. err = error1;
  3890. if (!this.saxParser.errThrown) {
  3891. this.saxParser.errThrown = true;
  3892. return this.emit(err);
  3893. }
  3894. }
  3895. };
  3896. Parser.prototype.assignOrPush = function(obj, key, newValue) {
  3897. if (!(key in obj)) {
  3898. if (!this.options.explicitArray) {
  3899. return defineProperty(obj, key, newValue);
  3900. } else {
  3901. return defineProperty(obj, key, [newValue]);
  3902. }
  3903. } else {
  3904. if (!(obj[key] instanceof Array)) {
  3905. defineProperty(obj, key, [obj[key]]);
  3906. }
  3907. return obj[key].push(newValue);
  3908. }
  3909. };
  3910. Parser.prototype.reset = function() {
  3911. var attrkey, charkey, ontext, stack;
  3912. this.removeAllListeners();
  3913. this.saxParser = sax.parser(this.options.strict, {
  3914. trim: false,
  3915. normalize: false,
  3916. xmlns: this.options.xmlns
  3917. });
  3918. this.saxParser.errThrown = false;
  3919. this.saxParser.onerror = (function(_this) {
  3920. return function(error) {
  3921. _this.saxParser.resume();
  3922. if (!_this.saxParser.errThrown) {
  3923. _this.saxParser.errThrown = true;
  3924. return _this.emit("error", error);
  3925. }
  3926. };
  3927. })(this);
  3928. this.saxParser.onend = (function(_this) {
  3929. return function() {
  3930. if (!_this.saxParser.ended) {
  3931. _this.saxParser.ended = true;
  3932. return _this.emit("end", _this.resultObject);
  3933. }
  3934. };
  3935. })(this);
  3936. this.saxParser.ended = false;
  3937. this.EXPLICIT_CHARKEY = this.options.explicitCharkey;
  3938. this.resultObject = null;
  3939. stack = [];
  3940. attrkey = this.options.attrkey;
  3941. charkey = this.options.charkey;
  3942. this.saxParser.onopentag = (function(_this) {
  3943. return function(node) {
  3944. var key, newValue, obj, processedKey, ref;
  3945. obj = {};
  3946. obj[charkey] = "";
  3947. if (!_this.options.ignoreAttrs) {
  3948. ref = node.attributes;
  3949. for (key in ref) {
  3950. if (!hasProp.call(ref, key)) continue;
  3951. if (!(attrkey in obj) && !_this.options.mergeAttrs) {
  3952. obj[attrkey] = {};
  3953. }
  3954. newValue = _this.options.attrValueProcessors ? processItem(_this.options.attrValueProcessors, node.attributes[key], key) : node.attributes[key];
  3955. processedKey = _this.options.attrNameProcessors ? processItem(_this.options.attrNameProcessors, key) : key;
  3956. if (_this.options.mergeAttrs) {
  3957. _this.assignOrPush(obj, processedKey, newValue);
  3958. } else {
  3959. defineProperty(obj[attrkey], processedKey, newValue);
  3960. }
  3961. }
  3962. }
  3963. obj["#name"] = _this.options.tagNameProcessors ? processItem(_this.options.tagNameProcessors, node.name) : node.name;
  3964. if (_this.options.xmlns) {
  3965. obj[_this.options.xmlnskey] = {
  3966. uri: node.uri,
  3967. local: node.local
  3968. };
  3969. }
  3970. return stack.push(obj);
  3971. };
  3972. })(this);
  3973. this.saxParser.onclosetag = (function(_this) {
  3974. return function() {
  3975. var cdata, emptyStr, key, node, nodeName, obj, objClone, old, s, xpath;
  3976. obj = stack.pop();
  3977. nodeName = obj["#name"];
  3978. if (!_this.options.explicitChildren || !_this.options.preserveChildrenOrder) {
  3979. delete obj["#name"];
  3980. }
  3981. if (obj.cdata === true) {
  3982. cdata = obj.cdata;
  3983. delete obj.cdata;
  3984. }
  3985. s = stack[stack.length - 1];
  3986. if (obj[charkey].match(/^\s*$/) && !cdata) {
  3987. emptyStr = obj[charkey];
  3988. delete obj[charkey];
  3989. } else {
  3990. if (_this.options.trim) {
  3991. obj[charkey] = obj[charkey].trim();
  3992. }
  3993. if (_this.options.normalize) {
  3994. obj[charkey] = obj[charkey].replace(/\s{2,}/g, " ").trim();
  3995. }
  3996. obj[charkey] = _this.options.valueProcessors ? processItem(_this.options.valueProcessors, obj[charkey], nodeName) : obj[charkey];
  3997. if (Object.keys(obj).length === 1 && charkey in obj && !_this.EXPLICIT_CHARKEY) {
  3998. obj = obj[charkey];
  3999. }
  4000. }
  4001. if (isEmpty(obj)) {
  4002. if (typeof _this.options.emptyTag === 'function') {
  4003. obj = _this.options.emptyTag();
  4004. } else {
  4005. obj = _this.options.emptyTag !== '' ? _this.options.emptyTag : emptyStr;
  4006. }
  4007. }
  4008. if (_this.options.validator != null) {
  4009. xpath = "/" + ((function() {
  4010. var i, len, results;
  4011. results = [];
  4012. for (i = 0, len = stack.length; i < len; i++) {
  4013. node = stack[i];
  4014. results.push(node["#name"]);
  4015. }
  4016. return results;
  4017. })()).concat(nodeName).join("/");
  4018. (function() {
  4019. var err;
  4020. try {
  4021. return obj = _this.options.validator(xpath, s && s[nodeName], obj);
  4022. } catch (error1) {
  4023. err = error1;
  4024. return _this.emit("error", err);
  4025. }
  4026. })();
  4027. }
  4028. if (_this.options.explicitChildren && !_this.options.mergeAttrs && typeof obj === 'object') {
  4029. if (!_this.options.preserveChildrenOrder) {
  4030. node = {};
  4031. if (_this.options.attrkey in obj) {
  4032. node[_this.options.attrkey] = obj[_this.options.attrkey];
  4033. delete obj[_this.options.attrkey];
  4034. }
  4035. if (!_this.options.charsAsChildren && _this.options.charkey in obj) {
  4036. node[_this.options.charkey] = obj[_this.options.charkey];
  4037. delete obj[_this.options.charkey];
  4038. }
  4039. if (Object.getOwnPropertyNames(obj).length > 0) {
  4040. node[_this.options.childkey] = obj;
  4041. }
  4042. obj = node;
  4043. } else if (s) {
  4044. s[_this.options.childkey] = s[_this.options.childkey] || [];
  4045. objClone = {};
  4046. for (key in obj) {
  4047. if (!hasProp.call(obj, key)) continue;
  4048. defineProperty(objClone, key, obj[key]);
  4049. }
  4050. s[_this.options.childkey].push(objClone);
  4051. delete obj["#name"];
  4052. if (Object.keys(obj).length === 1 && charkey in obj && !_this.EXPLICIT_CHARKEY) {
  4053. obj = obj[charkey];
  4054. }
  4055. }
  4056. }
  4057. if (stack.length > 0) {
  4058. return _this.assignOrPush(s, nodeName, obj);
  4059. } else {
  4060. if (_this.options.explicitRoot) {
  4061. old = obj;
  4062. obj = {};
  4063. defineProperty(obj, nodeName, old);
  4064. }
  4065. _this.resultObject = obj;
  4066. _this.saxParser.ended = true;
  4067. return _this.emit("end", _this.resultObject);
  4068. }
  4069. };
  4070. })(this);
  4071. ontext = (function(_this) {
  4072. return function(text) {
  4073. var charChild, s;
  4074. s = stack[stack.length - 1];
  4075. if (s) {
  4076. s[charkey] += text;
  4077. if (_this.options.explicitChildren && _this.options.preserveChildrenOrder && _this.options.charsAsChildren && (_this.options.includeWhiteChars || text.replace(/\\n/g, '').trim() !== '')) {
  4078. s[_this.options.childkey] = s[_this.options.childkey] || [];
  4079. charChild = {
  4080. '#name': '__text__'
  4081. };
  4082. charChild[charkey] = text;
  4083. if (_this.options.normalize) {
  4084. charChild[charkey] = charChild[charkey].replace(/\s{2,}/g, " ").trim();
  4085. }
  4086. s[_this.options.childkey].push(charChild);
  4087. }
  4088. return s;
  4089. }
  4090. };
  4091. })(this);
  4092. this.saxParser.ontext = ontext;
  4093. return this.saxParser.oncdata = (function(_this) {
  4094. return function(text) {
  4095. var s;
  4096. s = ontext(text);
  4097. if (s) {
  4098. return s.cdata = true;
  4099. }
  4100. };
  4101. })(this);
  4102. };
  4103. Parser.prototype.parseString = function(str, cb) {
  4104. var err;
  4105. if ((cb != null) && typeof cb === "function") {
  4106. this.on("end", function(result) {
  4107. this.reset();
  4108. return cb(null, result);
  4109. });
  4110. this.on("error", function(err) {
  4111. this.reset();
  4112. return cb(err);
  4113. });
  4114. }
  4115. try {
  4116. str = str.toString();
  4117. if (str.trim() === '') {
  4118. this.emit("end", null);
  4119. return true;
  4120. }
  4121. str = bom.stripBOM(str);
  4122. if (this.options.async) {
  4123. this.remaining = str;
  4124. setImmediate(this.processAsync);
  4125. return this.saxParser;
  4126. }
  4127. return this.saxParser.write(str).close();
  4128. } catch (error1) {
  4129. err = error1;
  4130. if (!(this.saxParser.errThrown || this.saxParser.ended)) {
  4131. this.emit('error', err);
  4132. return this.saxParser.errThrown = true;
  4133. } else if (this.saxParser.ended) {
  4134. throw err;
  4135. }
  4136. }
  4137. };
  4138. Parser.prototype.parseStringPromise = function(str) {
  4139. return new Promise((function(_this) {
  4140. return function(resolve, reject) {
  4141. return _this.parseString(str, function(err, value) {
  4142. if (err) {
  4143. return reject(err);
  4144. } else {
  4145. return resolve(value);
  4146. }
  4147. });
  4148. };
  4149. })(this));
  4150. };
  4151. return Parser;
  4152. })(events);
  4153. exports.parseString = function(str, a, b) {
  4154. var cb, options, parser;
  4155. if (b != null) {
  4156. if (typeof b === 'function') {
  4157. cb = b;
  4158. }
  4159. if (typeof a === 'object') {
  4160. options = a;
  4161. }
  4162. } else {
  4163. if (typeof a === 'function') {
  4164. cb = a;
  4165. }
  4166. options = {};
  4167. }
  4168. parser = new exports.Parser(options);
  4169. return parser.parseString(str, cb);
  4170. };
  4171. exports.parseStringPromise = function(str, a) {
  4172. var options, parser;
  4173. if (typeof a === 'object') {
  4174. options = a;
  4175. }
  4176. parser = new exports.Parser(options);
  4177. return parser.parseStringPromise(str);
  4178. };
  4179. }).call(this);
  4180. /***/ }),
  4181. /* 38 */
  4182. /***/ (function(module, exports, __webpack_require__) {
  4183. /* WEBPACK VAR INJECTION */(function(Buffer) {;(function (sax) { // wrapper for non-node envs
  4184. sax.parser = function (strict, opt) { return new SAXParser(strict, opt) }
  4185. sax.SAXParser = SAXParser
  4186. sax.SAXStream = SAXStream
  4187. sax.createStream = createStream
  4188. // When we pass the MAX_BUFFER_LENGTH position, start checking for buffer overruns.
  4189. // When we check, schedule the next check for MAX_BUFFER_LENGTH - (max(buffer lengths)),
  4190. // since that's the earliest that a buffer overrun could occur. This way, checks are
  4191. // as rare as required, but as often as necessary to ensure never crossing this bound.
  4192. // Furthermore, buffers are only tested at most once per write(), so passing a very
  4193. // large string into write() might have undesirable effects, but this is manageable by
  4194. // the caller, so it is assumed to be safe. Thus, a call to write() may, in the extreme
  4195. // edge case, result in creating at most one complete copy of the string passed in.
  4196. // Set to Infinity to have unlimited buffers.
  4197. sax.MAX_BUFFER_LENGTH = 64 * 1024
  4198. var buffers = [
  4199. 'comment', 'sgmlDecl', 'textNode', 'tagName', 'doctype',
  4200. 'procInstName', 'procInstBody', 'entity', 'attribName',
  4201. 'attribValue', 'cdata', 'script'
  4202. ]
  4203. sax.EVENTS = [
  4204. 'text',
  4205. 'processinginstruction',
  4206. 'sgmldeclaration',
  4207. 'doctype',
  4208. 'comment',
  4209. 'opentagstart',
  4210. 'attribute',
  4211. 'opentag',
  4212. 'closetag',
  4213. 'opencdata',
  4214. 'cdata',
  4215. 'closecdata',
  4216. 'error',
  4217. 'end',
  4218. 'ready',
  4219. 'script',
  4220. 'opennamespace',
  4221. 'closenamespace'
  4222. ]
  4223. function SAXParser (strict, opt) {
  4224. if (!(this instanceof SAXParser)) {
  4225. return new SAXParser(strict, opt)
  4226. }
  4227. var parser = this
  4228. clearBuffers(parser)
  4229. parser.q = parser.c = ''
  4230. parser.bufferCheckPosition = sax.MAX_BUFFER_LENGTH
  4231. parser.opt = opt || {}
  4232. parser.opt.lowercase = parser.opt.lowercase || parser.opt.lowercasetags
  4233. parser.looseCase = parser.opt.lowercase ? 'toLowerCase' : 'toUpperCase'
  4234. parser.tags = []
  4235. parser.closed = parser.closedRoot = parser.sawRoot = false
  4236. parser.tag = parser.error = null
  4237. parser.strict = !!strict
  4238. parser.noscript = !!(strict || parser.opt.noscript)
  4239. parser.state = S.BEGIN
  4240. parser.strictEntities = parser.opt.strictEntities
  4241. parser.ENTITIES = parser.strictEntities ? Object.create(sax.XML_ENTITIES) : Object.create(sax.ENTITIES)
  4242. parser.attribList = []
  4243. // namespaces form a prototype chain.
  4244. // it always points at the current tag,
  4245. // which protos to its parent tag.
  4246. if (parser.opt.xmlns) {
  4247. parser.ns = Object.create(rootNS)
  4248. }
  4249. // mostly just for error reporting
  4250. parser.trackPosition = parser.opt.position !== false
  4251. if (parser.trackPosition) {
  4252. parser.position = parser.line = parser.column = 0
  4253. }
  4254. emit(parser, 'onready')
  4255. }
  4256. if (!Object.create) {
  4257. Object.create = function (o) {
  4258. function F () {}
  4259. F.prototype = o
  4260. var newf = new F()
  4261. return newf
  4262. }
  4263. }
  4264. if (!Object.keys) {
  4265. Object.keys = function (o) {
  4266. var a = []
  4267. for (var i in o) if (o.hasOwnProperty(i)) a.push(i)
  4268. return a
  4269. }
  4270. }
  4271. function checkBufferLength (parser) {
  4272. var maxAllowed = Math.max(sax.MAX_BUFFER_LENGTH, 10)
  4273. var maxActual = 0
  4274. for (var i = 0, l = buffers.length; i < l; i++) {
  4275. var len = parser[buffers[i]].length
  4276. if (len > maxAllowed) {
  4277. // Text/cdata nodes can get big, and since they're buffered,
  4278. // we can get here under normal conditions.
  4279. // Avoid issues by emitting the text node now,
  4280. // so at least it won't get any bigger.
  4281. switch (buffers[i]) {
  4282. case 'textNode':
  4283. closeText(parser)
  4284. break
  4285. case 'cdata':
  4286. emitNode(parser, 'oncdata', parser.cdata)
  4287. parser.cdata = ''
  4288. break
  4289. case 'script':
  4290. emitNode(parser, 'onscript', parser.script)
  4291. parser.script = ''
  4292. break
  4293. default:
  4294. error(parser, 'Max buffer length exceeded: ' + buffers[i])
  4295. }
  4296. }
  4297. maxActual = Math.max(maxActual, len)
  4298. }
  4299. // schedule the next check for the earliest possible buffer overrun.
  4300. var m = sax.MAX_BUFFER_LENGTH - maxActual
  4301. parser.bufferCheckPosition = m + parser.position
  4302. }
  4303. function clearBuffers (parser) {
  4304. for (var i = 0, l = buffers.length; i < l; i++) {
  4305. parser[buffers[i]] = ''
  4306. }
  4307. }
  4308. function flushBuffers (parser) {
  4309. closeText(parser)
  4310. if (parser.cdata !== '') {
  4311. emitNode(parser, 'oncdata', parser.cdata)
  4312. parser.cdata = ''
  4313. }
  4314. if (parser.script !== '') {
  4315. emitNode(parser, 'onscript', parser.script)
  4316. parser.script = ''
  4317. }
  4318. }
  4319. SAXParser.prototype = {
  4320. end: function () { end(this) },
  4321. write: write,
  4322. resume: function () { this.error = null; return this },
  4323. close: function () { return this.write(null) },
  4324. flush: function () { flushBuffers(this) }
  4325. }
  4326. var Stream
  4327. try {
  4328. Stream = __webpack_require__(43).Stream
  4329. } catch (ex) {
  4330. Stream = function () {}
  4331. }
  4332. var streamWraps = sax.EVENTS.filter(function (ev) {
  4333. return ev !== 'error' && ev !== 'end'
  4334. })
  4335. function createStream (strict, opt) {
  4336. return new SAXStream(strict, opt)
  4337. }
  4338. function SAXStream (strict, opt) {
  4339. if (!(this instanceof SAXStream)) {
  4340. return new SAXStream(strict, opt)
  4341. }
  4342. Stream.apply(this)
  4343. this._parser = new SAXParser(strict, opt)
  4344. this.writable = true
  4345. this.readable = true
  4346. var me = this
  4347. this._parser.onend = function () {
  4348. me.emit('end')
  4349. }
  4350. this._parser.onerror = function (er) {
  4351. me.emit('error', er)
  4352. // if didn't throw, then means error was handled.
  4353. // go ahead and clear error, so we can write again.
  4354. me._parser.error = null
  4355. }
  4356. this._decoder = null
  4357. streamWraps.forEach(function (ev) {
  4358. Object.defineProperty(me, 'on' + ev, {
  4359. get: function () {
  4360. return me._parser['on' + ev]
  4361. },
  4362. set: function (h) {
  4363. if (!h) {
  4364. me.removeAllListeners(ev)
  4365. me._parser['on' + ev] = h
  4366. return h
  4367. }
  4368. me.on(ev, h)
  4369. },
  4370. enumerable: true,
  4371. configurable: false
  4372. })
  4373. })
  4374. }
  4375. SAXStream.prototype = Object.create(Stream.prototype, {
  4376. constructor: {
  4377. value: SAXStream
  4378. }
  4379. })
  4380. SAXStream.prototype.write = function (data) {
  4381. if (typeof Buffer === 'function' &&
  4382. typeof Buffer.isBuffer === 'function' &&
  4383. Buffer.isBuffer(data)) {
  4384. if (!this._decoder) {
  4385. var SD = __webpack_require__(69).StringDecoder
  4386. this._decoder = new SD('utf8')
  4387. }
  4388. data = this._decoder.write(data)
  4389. }
  4390. this._parser.write(data.toString())
  4391. this.emit('data', data)
  4392. return true
  4393. }
  4394. SAXStream.prototype.end = function (chunk) {
  4395. if (chunk && chunk.length) {
  4396. this.write(chunk)
  4397. }
  4398. this._parser.end()
  4399. return true
  4400. }
  4401. SAXStream.prototype.on = function (ev, handler) {
  4402. var me = this
  4403. if (!me._parser['on' + ev] && streamWraps.indexOf(ev) !== -1) {
  4404. me._parser['on' + ev] = function () {
  4405. var args = arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments)
  4406. args.splice(0, 0, ev)
  4407. me.emit.apply(me, args)
  4408. }
  4409. }
  4410. return Stream.prototype.on.call(me, ev, handler)
  4411. }
  4412. // character classes and tokens
  4413. var whitespace = '\r\n\t '
  4414. // this really needs to be replaced with character classes.
  4415. // XML allows all manner of ridiculous numbers and digits.
  4416. var number = '0124356789'
  4417. var letter = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
  4418. // (Letter | "_" | ":")
  4419. var quote = '\'"'
  4420. var attribEnd = whitespace + '>'
  4421. var CDATA = '[CDATA['
  4422. var DOCTYPE = 'DOCTYPE'
  4423. var XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace'
  4424. var XMLNS_NAMESPACE = 'http://www.w3.org/2000/xmlns/'
  4425. var rootNS = { xml: XML_NAMESPACE, xmlns: XMLNS_NAMESPACE }
  4426. // turn all the string character sets into character class objects.
  4427. whitespace = charClass(whitespace)
  4428. number = charClass(number)
  4429. letter = charClass(letter)
  4430. // http://www.w3.org/TR/REC-xml/#NT-NameStartChar
  4431. // This implementation works on strings, a single character at a time
  4432. // as such, it cannot ever support astral-plane characters (10000-EFFFF)
  4433. // without a significant breaking change to either this parser, or the
  4434. // JavaScript language. Implementation of an emoji-capable xml parser
  4435. // is left as an exercise for the reader.
  4436. 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]/
  4437. 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-]/
  4438. 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]/
  4439. 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-]/
  4440. quote = charClass(quote)
  4441. attribEnd = charClass(attribEnd)
  4442. function charClass (str) {
  4443. return str.split('').reduce(function (s, c) {
  4444. s[c] = true
  4445. return s
  4446. }, {})
  4447. }
  4448. function isRegExp (c) {
  4449. return Object.prototype.toString.call(c) === '[object RegExp]'
  4450. }
  4451. function is (charclass, c) {
  4452. return isRegExp(charclass) ? !!c.match(charclass) : charclass[c]
  4453. }
  4454. function not (charclass, c) {
  4455. return !is(charclass, c)
  4456. }
  4457. var S = 0
  4458. sax.STATE = {
  4459. BEGIN: S++, // leading byte order mark or whitespace
  4460. BEGIN_WHITESPACE: S++, // leading whitespace
  4461. TEXT: S++, // general stuff
  4462. TEXT_ENTITY: S++, // &amp and such.
  4463. OPEN_WAKA: S++, // <
  4464. SGML_DECL: S++, // <!BLARG
  4465. SGML_DECL_QUOTED: S++, // <!BLARG foo "bar
  4466. DOCTYPE: S++, // <!DOCTYPE
  4467. DOCTYPE_QUOTED: S++, // <!DOCTYPE "//blah
  4468. DOCTYPE_DTD: S++, // <!DOCTYPE "//blah" [ ...
  4469. DOCTYPE_DTD_QUOTED: S++, // <!DOCTYPE "//blah" [ "foo
  4470. COMMENT_STARTING: S++, // <!-
  4471. COMMENT: S++, // <!--
  4472. COMMENT_ENDING: S++, // <!-- blah -
  4473. COMMENT_ENDED: S++, // <!-- blah --
  4474. CDATA: S++, // <![CDATA[ something
  4475. CDATA_ENDING: S++, // ]
  4476. CDATA_ENDING_2: S++, // ]]
  4477. PROC_INST: S++, // <?hi
  4478. PROC_INST_BODY: S++, // <?hi there
  4479. PROC_INST_ENDING: S++, // <?hi "there" ?
  4480. OPEN_TAG: S++, // <strong
  4481. OPEN_TAG_SLASH: S++, // <strong /
  4482. ATTRIB: S++, // <a
  4483. ATTRIB_NAME: S++, // <a foo
  4484. ATTRIB_NAME_SAW_WHITE: S++, // <a foo _
  4485. ATTRIB_VALUE: S++, // <a foo=
  4486. ATTRIB_VALUE_QUOTED: S++, // <a foo="bar
  4487. ATTRIB_VALUE_CLOSED: S++, // <a foo="bar"
  4488. ATTRIB_VALUE_UNQUOTED: S++, // <a foo=bar
  4489. ATTRIB_VALUE_ENTITY_Q: S++, // <foo bar="&quot;"
  4490. ATTRIB_VALUE_ENTITY_U: S++, // <foo bar=&quot
  4491. CLOSE_TAG: S++, // </a
  4492. CLOSE_TAG_SAW_WHITE: S++, // </a >
  4493. SCRIPT: S++, // <script> ...
  4494. SCRIPT_ENDING: S++ // <script> ... <
  4495. }
  4496. sax.XML_ENTITIES = {
  4497. 'amp': '&',
  4498. 'gt': '>',
  4499. 'lt': '<',
  4500. 'quot': '"',
  4501. 'apos': "'"
  4502. }
  4503. sax.ENTITIES = {
  4504. 'amp': '&',
  4505. 'gt': '>',
  4506. 'lt': '<',
  4507. 'quot': '"',
  4508. 'apos': "'",
  4509. 'AElig': 198,
  4510. 'Aacute': 193,
  4511. 'Acirc': 194,
  4512. 'Agrave': 192,
  4513. 'Aring': 197,
  4514. 'Atilde': 195,
  4515. 'Auml': 196,
  4516. 'Ccedil': 199,
  4517. 'ETH': 208,
  4518. 'Eacute': 201,
  4519. 'Ecirc': 202,
  4520. 'Egrave': 200,
  4521. 'Euml': 203,
  4522. 'Iacute': 205,
  4523. 'Icirc': 206,
  4524. 'Igrave': 204,
  4525. 'Iuml': 207,
  4526. 'Ntilde': 209,
  4527. 'Oacute': 211,
  4528. 'Ocirc': 212,
  4529. 'Ograve': 210,
  4530. 'Oslash': 216,
  4531. 'Otilde': 213,
  4532. 'Ouml': 214,
  4533. 'THORN': 222,
  4534. 'Uacute': 218,
  4535. 'Ucirc': 219,
  4536. 'Ugrave': 217,
  4537. 'Uuml': 220,
  4538. 'Yacute': 221,
  4539. 'aacute': 225,
  4540. 'acirc': 226,
  4541. 'aelig': 230,
  4542. 'agrave': 224,
  4543. 'aring': 229,
  4544. 'atilde': 227,
  4545. 'auml': 228,
  4546. 'ccedil': 231,
  4547. 'eacute': 233,
  4548. 'ecirc': 234,
  4549. 'egrave': 232,
  4550. 'eth': 240,
  4551. 'euml': 235,
  4552. 'iacute': 237,
  4553. 'icirc': 238,
  4554. 'igrave': 236,
  4555. 'iuml': 239,
  4556. 'ntilde': 241,
  4557. 'oacute': 243,
  4558. 'ocirc': 244,
  4559. 'ograve': 242,
  4560. 'oslash': 248,
  4561. 'otilde': 245,
  4562. 'ouml': 246,
  4563. 'szlig': 223,
  4564. 'thorn': 254,
  4565. 'uacute': 250,
  4566. 'ucirc': 251,
  4567. 'ugrave': 249,
  4568. 'uuml': 252,
  4569. 'yacute': 253,
  4570. 'yuml': 255,
  4571. 'copy': 169,
  4572. 'reg': 174,
  4573. 'nbsp': 160,
  4574. 'iexcl': 161,
  4575. 'cent': 162,
  4576. 'pound': 163,
  4577. 'curren': 164,
  4578. 'yen': 165,
  4579. 'brvbar': 166,
  4580. 'sect': 167,
  4581. 'uml': 168,
  4582. 'ordf': 170,
  4583. 'laquo': 171,
  4584. 'not': 172,
  4585. 'shy': 173,
  4586. 'macr': 175,
  4587. 'deg': 176,
  4588. 'plusmn': 177,
  4589. 'sup1': 185,
  4590. 'sup2': 178,
  4591. 'sup3': 179,
  4592. 'acute': 180,
  4593. 'micro': 181,
  4594. 'para': 182,
  4595. 'middot': 183,
  4596. 'cedil': 184,
  4597. 'ordm': 186,
  4598. 'raquo': 187,
  4599. 'frac14': 188,
  4600. 'frac12': 189,
  4601. 'frac34': 190,
  4602. 'iquest': 191,
  4603. 'times': 215,
  4604. 'divide': 247,
  4605. 'OElig': 338,
  4606. 'oelig': 339,
  4607. 'Scaron': 352,
  4608. 'scaron': 353,
  4609. 'Yuml': 376,
  4610. 'fnof': 402,
  4611. 'circ': 710,
  4612. 'tilde': 732,
  4613. 'Alpha': 913,
  4614. 'Beta': 914,
  4615. 'Gamma': 915,
  4616. 'Delta': 916,
  4617. 'Epsilon': 917,
  4618. 'Zeta': 918,
  4619. 'Eta': 919,
  4620. 'Theta': 920,
  4621. 'Iota': 921,
  4622. 'Kappa': 922,
  4623. 'Lambda': 923,
  4624. 'Mu': 924,
  4625. 'Nu': 925,
  4626. 'Xi': 926,
  4627. 'Omicron': 927,
  4628. 'Pi': 928,
  4629. 'Rho': 929,
  4630. 'Sigma': 931,
  4631. 'Tau': 932,
  4632. 'Upsilon': 933,
  4633. 'Phi': 934,
  4634. 'Chi': 935,
  4635. 'Psi': 936,
  4636. 'Omega': 937,
  4637. 'alpha': 945,
  4638. 'beta': 946,
  4639. 'gamma': 947,
  4640. 'delta': 948,
  4641. 'epsilon': 949,
  4642. 'zeta': 950,
  4643. 'eta': 951,
  4644. 'theta': 952,
  4645. 'iota': 953,
  4646. 'kappa': 954,
  4647. 'lambda': 955,
  4648. 'mu': 956,
  4649. 'nu': 957,
  4650. 'xi': 958,
  4651. 'omicron': 959,
  4652. 'pi': 960,
  4653. 'rho': 961,
  4654. 'sigmaf': 962,
  4655. 'sigma': 963,
  4656. 'tau': 964,
  4657. 'upsilon': 965,
  4658. 'phi': 966,
  4659. 'chi': 967,
  4660. 'psi': 968,
  4661. 'omega': 969,
  4662. 'thetasym': 977,
  4663. 'upsih': 978,
  4664. 'piv': 982,
  4665. 'ensp': 8194,
  4666. 'emsp': 8195,
  4667. 'thinsp': 8201,
  4668. 'zwnj': 8204,
  4669. 'zwj': 8205,
  4670. 'lrm': 8206,
  4671. 'rlm': 8207,
  4672. 'ndash': 8211,
  4673. 'mdash': 8212,
  4674. 'lsquo': 8216,
  4675. 'rsquo': 8217,
  4676. 'sbquo': 8218,
  4677. 'ldquo': 8220,
  4678. 'rdquo': 8221,
  4679. 'bdquo': 8222,
  4680. 'dagger': 8224,
  4681. 'Dagger': 8225,
  4682. 'bull': 8226,
  4683. 'hellip': 8230,
  4684. 'permil': 8240,
  4685. 'prime': 8242,
  4686. 'Prime': 8243,
  4687. 'lsaquo': 8249,
  4688. 'rsaquo': 8250,
  4689. 'oline': 8254,
  4690. 'frasl': 8260,
  4691. 'euro': 8364,
  4692. 'image': 8465,
  4693. 'weierp': 8472,
  4694. 'real': 8476,
  4695. 'trade': 8482,
  4696. 'alefsym': 8501,
  4697. 'larr': 8592,
  4698. 'uarr': 8593,
  4699. 'rarr': 8594,
  4700. 'darr': 8595,
  4701. 'harr': 8596,
  4702. 'crarr': 8629,
  4703. 'lArr': 8656,
  4704. 'uArr': 8657,
  4705. 'rArr': 8658,
  4706. 'dArr': 8659,
  4707. 'hArr': 8660,
  4708. 'forall': 8704,
  4709. 'part': 8706,
  4710. 'exist': 8707,
  4711. 'empty': 8709,
  4712. 'nabla': 8711,
  4713. 'isin': 8712,
  4714. 'notin': 8713,
  4715. 'ni': 8715,
  4716. 'prod': 8719,
  4717. 'sum': 8721,
  4718. 'minus': 8722,
  4719. 'lowast': 8727,
  4720. 'radic': 8730,
  4721. 'prop': 8733,
  4722. 'infin': 8734,
  4723. 'ang': 8736,
  4724. 'and': 8743,
  4725. 'or': 8744,
  4726. 'cap': 8745,
  4727. 'cup': 8746,
  4728. 'int': 8747,
  4729. 'there4': 8756,
  4730. 'sim': 8764,
  4731. 'cong': 8773,
  4732. 'asymp': 8776,
  4733. 'ne': 8800,
  4734. 'equiv': 8801,
  4735. 'le': 8804,
  4736. 'ge': 8805,
  4737. 'sub': 8834,
  4738. 'sup': 8835,
  4739. 'nsub': 8836,
  4740. 'sube': 8838,
  4741. 'supe': 8839,
  4742. 'oplus': 8853,
  4743. 'otimes': 8855,
  4744. 'perp': 8869,
  4745. 'sdot': 8901,
  4746. 'lceil': 8968,
  4747. 'rceil': 8969,
  4748. 'lfloor': 8970,
  4749. 'rfloor': 8971,
  4750. 'lang': 9001,
  4751. 'rang': 9002,
  4752. 'loz': 9674,
  4753. 'spades': 9824,
  4754. 'clubs': 9827,
  4755. 'hearts': 9829,
  4756. 'diams': 9830
  4757. }
  4758. Object.keys(sax.ENTITIES).forEach(function (key) {
  4759. var e = sax.ENTITIES[key]
  4760. var s = typeof e === 'number' ? String.fromCharCode(e) : e
  4761. sax.ENTITIES[key] = s
  4762. })
  4763. for (var s in sax.STATE) {
  4764. sax.STATE[sax.STATE[s]] = s
  4765. }
  4766. // shorthand
  4767. S = sax.STATE
  4768. function emit (parser, event, data) {
  4769. parser[event] && parser[event](data)
  4770. }
  4771. function emitNode (parser, nodeType, data) {
  4772. if (parser.textNode) closeText(parser)
  4773. emit(parser, nodeType, data)
  4774. }
  4775. function closeText (parser) {
  4776. parser.textNode = textopts(parser.opt, parser.textNode)
  4777. if (parser.textNode) emit(parser, 'ontext', parser.textNode)
  4778. parser.textNode = ''
  4779. }
  4780. function textopts (opt, text) {
  4781. if (opt.trim) text = text.trim()
  4782. if (opt.normalize) text = text.replace(/\s+/g, ' ')
  4783. return text
  4784. }
  4785. function error (parser, er) {
  4786. closeText(parser)
  4787. if (parser.trackPosition) {
  4788. er += '\nLine: ' + parser.line +
  4789. '\nColumn: ' + parser.column +
  4790. '\nChar: ' + parser.c
  4791. }
  4792. er = new Error(er)
  4793. parser.error = er
  4794. emit(parser, 'onerror', er)
  4795. return parser
  4796. }
  4797. function end (parser) {
  4798. if (parser.sawRoot && !parser.closedRoot) strictFail(parser, 'Unclosed root tag')
  4799. if ((parser.state !== S.BEGIN) &&
  4800. (parser.state !== S.BEGIN_WHITESPACE) &&
  4801. (parser.state !== S.TEXT)) {
  4802. error(parser, 'Unexpected end')
  4803. }
  4804. closeText(parser)
  4805. parser.c = ''
  4806. parser.closed = true
  4807. emit(parser, 'onend')
  4808. SAXParser.call(parser, parser.strict, parser.opt)
  4809. return parser
  4810. }
  4811. function strictFail (parser, message) {
  4812. if (typeof parser !== 'object' || !(parser instanceof SAXParser)) {
  4813. throw new Error('bad call to strictFail')
  4814. }
  4815. if (parser.strict) {
  4816. error(parser, message)
  4817. }
  4818. }
  4819. function newTag (parser) {
  4820. if (!parser.strict) parser.tagName = parser.tagName[parser.looseCase]()
  4821. var parent = parser.tags[parser.tags.length - 1] || parser
  4822. var tag = parser.tag = { name: parser.tagName, attributes: {} }
  4823. // will be overridden if tag contails an xmlns="foo" or xmlns:foo="bar"
  4824. if (parser.opt.xmlns) {
  4825. tag.ns = parent.ns
  4826. }
  4827. parser.attribList.length = 0
  4828. emitNode(parser, 'onopentagstart', tag)
  4829. }
  4830. function qname (name, attribute) {
  4831. var i = name.indexOf(':')
  4832. var qualName = i < 0 ? [ '', name ] : name.split(':')
  4833. var prefix = qualName[0]
  4834. var local = qualName[1]
  4835. // <x "xmlns"="http://foo">
  4836. if (attribute && name === 'xmlns') {
  4837. prefix = 'xmlns'
  4838. local = ''
  4839. }
  4840. return { prefix: prefix, local: local }
  4841. }
  4842. function attrib (parser) {
  4843. if (!parser.strict) {
  4844. parser.attribName = parser.attribName[parser.looseCase]()
  4845. }
  4846. if (parser.attribList.indexOf(parser.attribName) !== -1 ||
  4847. parser.tag.attributes.hasOwnProperty(parser.attribName)) {
  4848. parser.attribName = parser.attribValue = ''
  4849. return
  4850. }
  4851. if (parser.opt.xmlns) {
  4852. var qn = qname(parser.attribName, true)
  4853. var prefix = qn.prefix
  4854. var local = qn.local
  4855. if (prefix === 'xmlns') {
  4856. // namespace binding attribute. push the binding into scope
  4857. if (local === 'xml' && parser.attribValue !== XML_NAMESPACE) {
  4858. strictFail(parser,
  4859. 'xml: prefix must be bound to ' + XML_NAMESPACE + '\n' +
  4860. 'Actual: ' + parser.attribValue)
  4861. } else if (local === 'xmlns' && parser.attribValue !== XMLNS_NAMESPACE) {
  4862. strictFail(parser,
  4863. 'xmlns: prefix must be bound to ' + XMLNS_NAMESPACE + '\n' +
  4864. 'Actual: ' + parser.attribValue)
  4865. } else {
  4866. var tag = parser.tag
  4867. var parent = parser.tags[parser.tags.length - 1] || parser
  4868. if (tag.ns === parent.ns) {
  4869. tag.ns = Object.create(parent.ns)
  4870. }
  4871. tag.ns[local] = parser.attribValue
  4872. }
  4873. }
  4874. // defer onattribute events until all attributes have been seen
  4875. // so any new bindings can take effect. preserve attribute order
  4876. // so deferred events can be emitted in document order
  4877. parser.attribList.push([parser.attribName, parser.attribValue])
  4878. } else {
  4879. // in non-xmlns mode, we can emit the event right away
  4880. parser.tag.attributes[parser.attribName] = parser.attribValue
  4881. emitNode(parser, 'onattribute', {
  4882. name: parser.attribName,
  4883. value: parser.attribValue
  4884. })
  4885. }
  4886. parser.attribName = parser.attribValue = ''
  4887. }
  4888. function openTag (parser, selfClosing) {
  4889. if (parser.opt.xmlns) {
  4890. // emit namespace binding events
  4891. var tag = parser.tag
  4892. // add namespace info to tag
  4893. var qn = qname(parser.tagName)
  4894. tag.prefix = qn.prefix
  4895. tag.local = qn.local
  4896. tag.uri = tag.ns[qn.prefix] || ''
  4897. if (tag.prefix && !tag.uri) {
  4898. strictFail(parser, 'Unbound namespace prefix: ' +
  4899. JSON.stringify(parser.tagName))
  4900. tag.uri = qn.prefix
  4901. }
  4902. var parent = parser.tags[parser.tags.length - 1] || parser
  4903. if (tag.ns && parent.ns !== tag.ns) {
  4904. Object.keys(tag.ns).forEach(function (p) {
  4905. emitNode(parser, 'onopennamespace', {
  4906. prefix: p,
  4907. uri: tag.ns[p]
  4908. })
  4909. })
  4910. }
  4911. // handle deferred onattribute events
  4912. // Note: do not apply default ns to attributes:
  4913. // http://www.w3.org/TR/REC-xml-names/#defaulting
  4914. for (var i = 0, l = parser.attribList.length; i < l; i++) {
  4915. var nv = parser.attribList[i]
  4916. var name = nv[0]
  4917. var value = nv[1]
  4918. var qualName = qname(name, true)
  4919. var prefix = qualName.prefix
  4920. var local = qualName.local
  4921. var uri = prefix === '' ? '' : (tag.ns[prefix] || '')
  4922. var a = {
  4923. name: name,
  4924. value: value,
  4925. prefix: prefix,
  4926. local: local,
  4927. uri: uri
  4928. }
  4929. // if there's any attributes with an undefined namespace,
  4930. // then fail on them now.
  4931. if (prefix && prefix !== 'xmlns' && !uri) {
  4932. strictFail(parser, 'Unbound namespace prefix: ' +
  4933. JSON.stringify(prefix))
  4934. a.uri = prefix
  4935. }
  4936. parser.tag.attributes[name] = a
  4937. emitNode(parser, 'onattribute', a)
  4938. }
  4939. parser.attribList.length = 0
  4940. }
  4941. parser.tag.isSelfClosing = !!selfClosing
  4942. // process the tag
  4943. parser.sawRoot = true
  4944. parser.tags.push(parser.tag)
  4945. emitNode(parser, 'onopentag', parser.tag)
  4946. if (!selfClosing) {
  4947. // special case for <script> in non-strict mode.
  4948. if (!parser.noscript && parser.tagName.toLowerCase() === 'script') {
  4949. parser.state = S.SCRIPT
  4950. } else {
  4951. parser.state = S.TEXT
  4952. }
  4953. parser.tag = null
  4954. parser.tagName = ''
  4955. }
  4956. parser.attribName = parser.attribValue = ''
  4957. parser.attribList.length = 0
  4958. }
  4959. function closeTag (parser) {
  4960. if (!parser.tagName) {
  4961. strictFail(parser, 'Weird empty close tag.')
  4962. parser.textNode += '</>'
  4963. parser.state = S.TEXT
  4964. return
  4965. }
  4966. if (parser.script) {
  4967. if (parser.tagName !== 'script') {
  4968. parser.script += '</' + parser.tagName + '>'
  4969. parser.tagName = ''
  4970. parser.state = S.SCRIPT
  4971. return
  4972. }
  4973. emitNode(parser, 'onscript', parser.script)
  4974. parser.script = ''
  4975. }
  4976. // first make sure that the closing tag actually exists.
  4977. // <a><b></c></b></a> will close everything, otherwise.
  4978. var t = parser.tags.length
  4979. var tagName = parser.tagName
  4980. if (!parser.strict) {
  4981. tagName = tagName[parser.looseCase]()
  4982. }
  4983. var closeTo = tagName
  4984. while (t--) {
  4985. var close = parser.tags[t]
  4986. if (close.name !== closeTo) {
  4987. // fail the first time in strict mode
  4988. strictFail(parser, 'Unexpected close tag')
  4989. } else {
  4990. break
  4991. }
  4992. }
  4993. // didn't find it. we already failed for strict, so just abort.
  4994. if (t < 0) {
  4995. strictFail(parser, 'Unmatched closing tag: ' + parser.tagName)
  4996. parser.textNode += '</' + parser.tagName + '>'
  4997. parser.state = S.TEXT
  4998. return
  4999. }
  5000. parser.tagName = tagName
  5001. var s = parser.tags.length
  5002. while (s-- > t) {
  5003. var tag = parser.tag = parser.tags.pop()
  5004. parser.tagName = parser.tag.name
  5005. emitNode(parser, 'onclosetag', parser.tagName)
  5006. var x = {}
  5007. for (var i in tag.ns) {
  5008. x[i] = tag.ns[i]
  5009. }
  5010. var parent = parser.tags[parser.tags.length - 1] || parser
  5011. if (parser.opt.xmlns && tag.ns !== parent.ns) {
  5012. // remove namespace bindings introduced by tag
  5013. Object.keys(tag.ns).forEach(function (p) {
  5014. var n = tag.ns[p]
  5015. emitNode(parser, 'onclosenamespace', { prefix: p, uri: n })
  5016. })
  5017. }
  5018. }
  5019. if (t === 0) parser.closedRoot = true
  5020. parser.tagName = parser.attribValue = parser.attribName = ''
  5021. parser.attribList.length = 0
  5022. parser.state = S.TEXT
  5023. }
  5024. function parseEntity (parser) {
  5025. var entity = parser.entity
  5026. var entityLC = entity.toLowerCase()
  5027. var num
  5028. var numStr = ''
  5029. if (parser.ENTITIES[entity]) {
  5030. return parser.ENTITIES[entity]
  5031. }
  5032. if (parser.ENTITIES[entityLC]) {
  5033. return parser.ENTITIES[entityLC]
  5034. }
  5035. entity = entityLC
  5036. if (entity.charAt(0) === '#') {
  5037. if (entity.charAt(1) === 'x') {
  5038. entity = entity.slice(2)
  5039. num = parseInt(entity, 16)
  5040. numStr = num.toString(16)
  5041. } else {
  5042. entity = entity.slice(1)
  5043. num = parseInt(entity, 10)
  5044. numStr = num.toString(10)
  5045. }
  5046. }
  5047. entity = entity.replace(/^0+/, '')
  5048. if (numStr.toLowerCase() !== entity) {
  5049. strictFail(parser, 'Invalid character entity')
  5050. return '&' + parser.entity + ';'
  5051. }
  5052. return String.fromCodePoint(num)
  5053. }
  5054. function beginWhiteSpace (parser, c) {
  5055. if (c === '<') {
  5056. parser.state = S.OPEN_WAKA
  5057. parser.startTagPosition = parser.position
  5058. } else if (not(whitespace, c)) {
  5059. // have to process this as a text node.
  5060. // weird, but happens.
  5061. strictFail(parser, 'Non-whitespace before first tag.')
  5062. parser.textNode = c
  5063. parser.state = S.TEXT
  5064. }
  5065. }
  5066. function charAt (chunk, i) {
  5067. var result = ''
  5068. if (i < chunk.length) {
  5069. result = chunk.charAt(i)
  5070. }
  5071. return result
  5072. }
  5073. function write (chunk) {
  5074. var parser = this
  5075. if (this.error) {
  5076. throw this.error
  5077. }
  5078. if (parser.closed) {
  5079. return error(parser,
  5080. 'Cannot write after close. Assign an onready handler.')
  5081. }
  5082. if (chunk === null) {
  5083. return end(parser)
  5084. }
  5085. if (typeof chunk === 'object') {
  5086. chunk = chunk.toString()
  5087. }
  5088. var i = 0
  5089. var c = ''
  5090. while (true) {
  5091. c = charAt(chunk, i++)
  5092. parser.c = c
  5093. if (!c) {
  5094. break
  5095. }
  5096. if (parser.trackPosition) {
  5097. parser.position++
  5098. if (c === '\n') {
  5099. parser.line++
  5100. parser.column = 0
  5101. } else {
  5102. parser.column++
  5103. }
  5104. }
  5105. switch (parser.state) {
  5106. case S.BEGIN:
  5107. parser.state = S.BEGIN_WHITESPACE
  5108. if (c === '\uFEFF') {
  5109. continue
  5110. }
  5111. beginWhiteSpace(parser, c)
  5112. continue
  5113. case S.BEGIN_WHITESPACE:
  5114. beginWhiteSpace(parser, c)
  5115. continue
  5116. case S.TEXT:
  5117. if (parser.sawRoot && !parser.closedRoot) {
  5118. var starti = i - 1
  5119. while (c && c !== '<' && c !== '&') {
  5120. c = charAt(chunk, i++)
  5121. if (c && parser.trackPosition) {
  5122. parser.position++
  5123. if (c === '\n') {
  5124. parser.line++
  5125. parser.column = 0
  5126. } else {
  5127. parser.column++
  5128. }
  5129. }
  5130. }
  5131. parser.textNode += chunk.substring(starti, i - 1)
  5132. }
  5133. if (c === '<' && !(parser.sawRoot && parser.closedRoot && !parser.strict)) {
  5134. parser.state = S.OPEN_WAKA
  5135. parser.startTagPosition = parser.position
  5136. } else {
  5137. if (not(whitespace, c) && (!parser.sawRoot || parser.closedRoot)) {
  5138. strictFail(parser, 'Text data outside of root node.')
  5139. }
  5140. if (c === '&') {
  5141. parser.state = S.TEXT_ENTITY
  5142. } else {
  5143. parser.textNode += c
  5144. }
  5145. }
  5146. continue
  5147. case S.SCRIPT:
  5148. // only non-strict
  5149. if (c === '<') {
  5150. parser.state = S.SCRIPT_ENDING
  5151. } else {
  5152. parser.script += c
  5153. }
  5154. continue
  5155. case S.SCRIPT_ENDING:
  5156. if (c === '/') {
  5157. parser.state = S.CLOSE_TAG
  5158. } else {
  5159. parser.script += '<' + c
  5160. parser.state = S.SCRIPT
  5161. }
  5162. continue
  5163. case S.OPEN_WAKA:
  5164. // either a /, ?, !, or text is coming next.
  5165. if (c === '!') {
  5166. parser.state = S.SGML_DECL
  5167. parser.sgmlDecl = ''
  5168. } else if (is(whitespace, c)) {
  5169. // wait for it...
  5170. } else if (is(nameStart, c)) {
  5171. parser.state = S.OPEN_TAG
  5172. parser.tagName = c
  5173. } else if (c === '/') {
  5174. parser.state = S.CLOSE_TAG
  5175. parser.tagName = ''
  5176. } else if (c === '?') {
  5177. parser.state = S.PROC_INST
  5178. parser.procInstName = parser.procInstBody = ''
  5179. } else {
  5180. strictFail(parser, 'Unencoded <')
  5181. // if there was some whitespace, then add that in.
  5182. if (parser.startTagPosition + 1 < parser.position) {
  5183. var pad = parser.position - parser.startTagPosition
  5184. c = new Array(pad).join(' ') + c
  5185. }
  5186. parser.textNode += '<' + c
  5187. parser.state = S.TEXT
  5188. }
  5189. continue
  5190. case S.SGML_DECL:
  5191. if ((parser.sgmlDecl + c).toUpperCase() === CDATA) {
  5192. emitNode(parser, 'onopencdata')
  5193. parser.state = S.CDATA
  5194. parser.sgmlDecl = ''
  5195. parser.cdata = ''
  5196. } else if (parser.sgmlDecl + c === '--') {
  5197. parser.state = S.COMMENT
  5198. parser.comment = ''
  5199. parser.sgmlDecl = ''
  5200. } else if ((parser.sgmlDecl + c).toUpperCase() === DOCTYPE) {
  5201. parser.state = S.DOCTYPE
  5202. if (parser.doctype || parser.sawRoot) {
  5203. strictFail(parser,
  5204. 'Inappropriately located doctype declaration')
  5205. }
  5206. parser.doctype = ''
  5207. parser.sgmlDecl = ''
  5208. } else if (c === '>') {
  5209. emitNode(parser, 'onsgmldeclaration', parser.sgmlDecl)
  5210. parser.sgmlDecl = ''
  5211. parser.state = S.TEXT
  5212. } else if (is(quote, c)) {
  5213. parser.state = S.SGML_DECL_QUOTED
  5214. parser.sgmlDecl += c
  5215. } else {
  5216. parser.sgmlDecl += c
  5217. }
  5218. continue
  5219. case S.SGML_DECL_QUOTED:
  5220. if (c === parser.q) {
  5221. parser.state = S.SGML_DECL
  5222. parser.q = ''
  5223. }
  5224. parser.sgmlDecl += c
  5225. continue
  5226. case S.DOCTYPE:
  5227. if (c === '>') {
  5228. parser.state = S.TEXT
  5229. emitNode(parser, 'ondoctype', parser.doctype)
  5230. parser.doctype = true // just remember that we saw it.
  5231. } else {
  5232. parser.doctype += c
  5233. if (c === '[') {
  5234. parser.state = S.DOCTYPE_DTD
  5235. } else if (is(quote, c)) {
  5236. parser.state = S.DOCTYPE_QUOTED
  5237. parser.q = c
  5238. }
  5239. }
  5240. continue
  5241. case S.DOCTYPE_QUOTED:
  5242. parser.doctype += c
  5243. if (c === parser.q) {
  5244. parser.q = ''
  5245. parser.state = S.DOCTYPE
  5246. }
  5247. continue
  5248. case S.DOCTYPE_DTD:
  5249. parser.doctype += c
  5250. if (c === ']') {
  5251. parser.state = S.DOCTYPE
  5252. } else if (is(quote, c)) {
  5253. parser.state = S.DOCTYPE_DTD_QUOTED
  5254. parser.q = c
  5255. }
  5256. continue
  5257. case S.DOCTYPE_DTD_QUOTED:
  5258. parser.doctype += c
  5259. if (c === parser.q) {
  5260. parser.state = S.DOCTYPE_DTD
  5261. parser.q = ''
  5262. }
  5263. continue
  5264. case S.COMMENT:
  5265. if (c === '-') {
  5266. parser.state = S.COMMENT_ENDING
  5267. } else {
  5268. parser.comment += c
  5269. }
  5270. continue
  5271. case S.COMMENT_ENDING:
  5272. if (c === '-') {
  5273. parser.state = S.COMMENT_ENDED
  5274. parser.comment = textopts(parser.opt, parser.comment)
  5275. if (parser.comment) {
  5276. emitNode(parser, 'oncomment', parser.comment)
  5277. }
  5278. parser.comment = ''
  5279. } else {
  5280. parser.comment += '-' + c
  5281. parser.state = S.COMMENT
  5282. }
  5283. continue
  5284. case S.COMMENT_ENDED:
  5285. if (c !== '>') {
  5286. strictFail(parser, 'Malformed comment')
  5287. // allow <!-- blah -- bloo --> in non-strict mode,
  5288. // which is a comment of " blah -- bloo "
  5289. parser.comment += '--' + c
  5290. parser.state = S.COMMENT
  5291. } else {
  5292. parser.state = S.TEXT
  5293. }
  5294. continue
  5295. case S.CDATA:
  5296. if (c === ']') {
  5297. parser.state = S.CDATA_ENDING
  5298. } else {
  5299. parser.cdata += c
  5300. }
  5301. continue
  5302. case S.CDATA_ENDING:
  5303. if (c === ']') {
  5304. parser.state = S.CDATA_ENDING_2
  5305. } else {
  5306. parser.cdata += ']' + c
  5307. parser.state = S.CDATA
  5308. }
  5309. continue
  5310. case S.CDATA_ENDING_2:
  5311. if (c === '>') {
  5312. if (parser.cdata) {
  5313. emitNode(parser, 'oncdata', parser.cdata)
  5314. }
  5315. emitNode(parser, 'onclosecdata')
  5316. parser.cdata = ''
  5317. parser.state = S.TEXT
  5318. } else if (c === ']') {
  5319. parser.cdata += ']'
  5320. } else {
  5321. parser.cdata += ']]' + c
  5322. parser.state = S.CDATA
  5323. }
  5324. continue
  5325. case S.PROC_INST:
  5326. if (c === '?') {
  5327. parser.state = S.PROC_INST_ENDING
  5328. } else if (is(whitespace, c)) {
  5329. parser.state = S.PROC_INST_BODY
  5330. } else {
  5331. parser.procInstName += c
  5332. }
  5333. continue
  5334. case S.PROC_INST_BODY:
  5335. if (!parser.procInstBody && is(whitespace, c)) {
  5336. continue
  5337. } else if (c === '?') {
  5338. parser.state = S.PROC_INST_ENDING
  5339. } else {
  5340. parser.procInstBody += c
  5341. }
  5342. continue
  5343. case S.PROC_INST_ENDING:
  5344. if (c === '>') {
  5345. emitNode(parser, 'onprocessinginstruction', {
  5346. name: parser.procInstName,
  5347. body: parser.procInstBody
  5348. })
  5349. parser.procInstName = parser.procInstBody = ''
  5350. parser.state = S.TEXT
  5351. } else {
  5352. parser.procInstBody += '?' + c
  5353. parser.state = S.PROC_INST_BODY
  5354. }
  5355. continue
  5356. case S.OPEN_TAG:
  5357. if (is(nameBody, c)) {
  5358. parser.tagName += c
  5359. } else {
  5360. newTag(parser)
  5361. if (c === '>') {
  5362. openTag(parser)
  5363. } else if (c === '/') {
  5364. parser.state = S.OPEN_TAG_SLASH
  5365. } else {
  5366. if (not(whitespace, c)) {
  5367. strictFail(parser, 'Invalid character in tag name')
  5368. }
  5369. parser.state = S.ATTRIB
  5370. }
  5371. }
  5372. continue
  5373. case S.OPEN_TAG_SLASH:
  5374. if (c === '>') {
  5375. openTag(parser, true)
  5376. closeTag(parser)
  5377. } else {
  5378. strictFail(parser, 'Forward-slash in opening tag not followed by >')
  5379. parser.state = S.ATTRIB
  5380. }
  5381. continue
  5382. case S.ATTRIB:
  5383. // haven't read the attribute name yet.
  5384. if (is(whitespace, c)) {
  5385. continue
  5386. } else if (c === '>') {
  5387. openTag(parser)
  5388. } else if (c === '/') {
  5389. parser.state = S.OPEN_TAG_SLASH
  5390. } else if (is(nameStart, c)) {
  5391. parser.attribName = c
  5392. parser.attribValue = ''
  5393. parser.state = S.ATTRIB_NAME
  5394. } else {
  5395. strictFail(parser, 'Invalid attribute name')
  5396. }
  5397. continue
  5398. case S.ATTRIB_NAME:
  5399. if (c === '=') {
  5400. parser.state = S.ATTRIB_VALUE
  5401. } else if (c === '>') {
  5402. strictFail(parser, 'Attribute without value')
  5403. parser.attribValue = parser.attribName
  5404. attrib(parser)
  5405. openTag(parser)
  5406. } else if (is(whitespace, c)) {
  5407. parser.state = S.ATTRIB_NAME_SAW_WHITE
  5408. } else if (is(nameBody, c)) {
  5409. parser.attribName += c
  5410. } else {
  5411. strictFail(parser, 'Invalid attribute name')
  5412. }
  5413. continue
  5414. case S.ATTRIB_NAME_SAW_WHITE:
  5415. if (c === '=') {
  5416. parser.state = S.ATTRIB_VALUE
  5417. } else if (is(whitespace, c)) {
  5418. continue
  5419. } else {
  5420. strictFail(parser, 'Attribute without value')
  5421. parser.tag.attributes[parser.attribName] = ''
  5422. parser.attribValue = ''
  5423. emitNode(parser, 'onattribute', {
  5424. name: parser.attribName,
  5425. value: ''
  5426. })
  5427. parser.attribName = ''
  5428. if (c === '>') {
  5429. openTag(parser)
  5430. } else if (is(nameStart, c)) {
  5431. parser.attribName = c
  5432. parser.state = S.ATTRIB_NAME
  5433. } else {
  5434. strictFail(parser, 'Invalid attribute name')
  5435. parser.state = S.ATTRIB
  5436. }
  5437. }
  5438. continue
  5439. case S.ATTRIB_VALUE:
  5440. if (is(whitespace, c)) {
  5441. continue
  5442. } else if (is(quote, c)) {
  5443. parser.q = c
  5444. parser.state = S.ATTRIB_VALUE_QUOTED
  5445. } else {
  5446. strictFail(parser, 'Unquoted attribute value')
  5447. parser.state = S.ATTRIB_VALUE_UNQUOTED
  5448. parser.attribValue = c
  5449. }
  5450. continue
  5451. case S.ATTRIB_VALUE_QUOTED:
  5452. if (c !== parser.q) {
  5453. if (c === '&') {
  5454. parser.state = S.ATTRIB_VALUE_ENTITY_Q
  5455. } else {
  5456. parser.attribValue += c
  5457. }
  5458. continue
  5459. }
  5460. attrib(parser)
  5461. parser.q = ''
  5462. parser.state = S.ATTRIB_VALUE_CLOSED
  5463. continue
  5464. case S.ATTRIB_VALUE_CLOSED:
  5465. if (is(whitespace, c)) {
  5466. parser.state = S.ATTRIB
  5467. } else if (c === '>') {
  5468. openTag(parser)
  5469. } else if (c === '/') {
  5470. parser.state = S.OPEN_TAG_SLASH
  5471. } else if (is(nameStart, c)) {
  5472. strictFail(parser, 'No whitespace between attributes')
  5473. parser.attribName = c
  5474. parser.attribValue = ''
  5475. parser.state = S.ATTRIB_NAME
  5476. } else {
  5477. strictFail(parser, 'Invalid attribute name')
  5478. }
  5479. continue
  5480. case S.ATTRIB_VALUE_UNQUOTED:
  5481. if (not(attribEnd, c)) {
  5482. if (c === '&') {
  5483. parser.state = S.ATTRIB_VALUE_ENTITY_U
  5484. } else {
  5485. parser.attribValue += c
  5486. }
  5487. continue
  5488. }
  5489. attrib(parser)
  5490. if (c === '>') {
  5491. openTag(parser)
  5492. } else {
  5493. parser.state = S.ATTRIB
  5494. }
  5495. continue
  5496. case S.CLOSE_TAG:
  5497. if (!parser.tagName) {
  5498. if (is(whitespace, c)) {
  5499. continue
  5500. } else if (not(nameStart, c)) {
  5501. if (parser.script) {
  5502. parser.script += '</' + c
  5503. parser.state = S.SCRIPT
  5504. } else {
  5505. strictFail(parser, 'Invalid tagname in closing tag.')
  5506. }
  5507. } else {
  5508. parser.tagName = c
  5509. }
  5510. } else if (c === '>') {
  5511. closeTag(parser)
  5512. } else if (is(nameBody, c)) {
  5513. parser.tagName += c
  5514. } else if (parser.script) {
  5515. parser.script += '</' + parser.tagName
  5516. parser.tagName = ''
  5517. parser.state = S.SCRIPT
  5518. } else {
  5519. if (not(whitespace, c)) {
  5520. strictFail(parser, 'Invalid tagname in closing tag')
  5521. }
  5522. parser.state = S.CLOSE_TAG_SAW_WHITE
  5523. }
  5524. continue
  5525. case S.CLOSE_TAG_SAW_WHITE:
  5526. if (is(whitespace, c)) {
  5527. continue
  5528. }
  5529. if (c === '>') {
  5530. closeTag(parser)
  5531. } else {
  5532. strictFail(parser, 'Invalid characters in closing tag')
  5533. }
  5534. continue
  5535. case S.TEXT_ENTITY:
  5536. case S.ATTRIB_VALUE_ENTITY_Q:
  5537. case S.ATTRIB_VALUE_ENTITY_U:
  5538. var returnState
  5539. var buffer
  5540. switch (parser.state) {
  5541. case S.TEXT_ENTITY:
  5542. returnState = S.TEXT
  5543. buffer = 'textNode'
  5544. break
  5545. case S.ATTRIB_VALUE_ENTITY_Q:
  5546. returnState = S.ATTRIB_VALUE_QUOTED
  5547. buffer = 'attribValue'
  5548. break
  5549. case S.ATTRIB_VALUE_ENTITY_U:
  5550. returnState = S.ATTRIB_VALUE_UNQUOTED
  5551. buffer = 'attribValue'
  5552. break
  5553. }
  5554. if (c === ';') {
  5555. parser[buffer] += parseEntity(parser)
  5556. parser.entity = ''
  5557. parser.state = returnState
  5558. } else if (is(parser.entity.length ? entityBody : entityStart, c)) {
  5559. parser.entity += c
  5560. } else {
  5561. strictFail(parser, 'Invalid character in entity name')
  5562. parser[buffer] += '&' + parser.entity + c
  5563. parser.entity = ''
  5564. parser.state = returnState
  5565. }
  5566. continue
  5567. default:
  5568. throw new Error(parser, 'Unknown state: ' + parser.state)
  5569. }
  5570. } // while
  5571. if (parser.position >= parser.bufferCheckPosition) {
  5572. checkBufferLength(parser)
  5573. }
  5574. return parser
  5575. }
  5576. /*! http://mths.be/fromcodepoint v0.1.0 by @mathias */
  5577. if (!String.fromCodePoint) {
  5578. (function () {
  5579. var stringFromCharCode = String.fromCharCode
  5580. var floor = Math.floor
  5581. var fromCodePoint = function () {
  5582. var MAX_SIZE = 0x4000
  5583. var codeUnits = []
  5584. var highSurrogate
  5585. var lowSurrogate
  5586. var index = -1
  5587. var length = arguments.length
  5588. if (!length) {
  5589. return ''
  5590. }
  5591. var result = ''
  5592. while (++index < length) {
  5593. var codePoint = Number(arguments[index])
  5594. if (
  5595. !isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity`
  5596. codePoint < 0 || // not a valid Unicode code point
  5597. codePoint > 0x10FFFF || // not a valid Unicode code point
  5598. floor(codePoint) !== codePoint // not an integer
  5599. ) {
  5600. throw RangeError('Invalid code point: ' + codePoint)
  5601. }
  5602. if (codePoint <= 0xFFFF) { // BMP code point
  5603. codeUnits.push(codePoint)
  5604. } else { // Astral code point; split in surrogate halves
  5605. // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
  5606. codePoint -= 0x10000
  5607. highSurrogate = (codePoint >> 10) + 0xD800
  5608. lowSurrogate = (codePoint % 0x400) + 0xDC00
  5609. codeUnits.push(highSurrogate, lowSurrogate)
  5610. }
  5611. if (index + 1 === length || codeUnits.length > MAX_SIZE) {
  5612. result += stringFromCharCode.apply(null, codeUnits)
  5613. codeUnits.length = 0
  5614. }
  5615. }
  5616. return result
  5617. }
  5618. if (Object.defineProperty) {
  5619. Object.defineProperty(String, 'fromCodePoint', {
  5620. value: fromCodePoint,
  5621. configurable: true,
  5622. writable: true
  5623. })
  5624. } else {
  5625. String.fromCodePoint = fromCodePoint
  5626. }
  5627. }())
  5628. }
  5629. })( false ? this.sax = {} : exports)
  5630. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(39).Buffer))
  5631. /***/ }),
  5632. /* 39 */
  5633. /***/ (function(module, exports, __webpack_require__) {
  5634. /* WEBPACK VAR INJECTION */(function(global) {/*!
  5635. * The buffer module from node.js, for the browser.
  5636. *
  5637. * @author Feross Aboukhadijeh <http://feross.org>
  5638. * @license MIT
  5639. */
  5640. /* eslint-disable no-proto */
  5641. 'use strict'
  5642. var base64 = __webpack_require__(40)
  5643. var ieee754 = __webpack_require__(41)
  5644. var isArray = __webpack_require__(42)
  5645. exports.Buffer = Buffer
  5646. exports.SlowBuffer = SlowBuffer
  5647. exports.INSPECT_MAX_BYTES = 50
  5648. /**
  5649. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  5650. * === true Use Uint8Array implementation (fastest)
  5651. * === false Use Object implementation (most compatible, even IE6)
  5652. *
  5653. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  5654. * Opera 11.6+, iOS 4.2+.
  5655. *
  5656. * Due to various browser bugs, sometimes the Object implementation will be used even
  5657. * when the browser supports typed arrays.
  5658. *
  5659. * Note:
  5660. *
  5661. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  5662. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  5663. *
  5664. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  5665. *
  5666. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  5667. * incorrect length in some situations.
  5668. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  5669. * get the Object implementation, which is slower but behaves correctly.
  5670. */
  5671. Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
  5672. ? global.TYPED_ARRAY_SUPPORT
  5673. : typedArraySupport()
  5674. /*
  5675. * Export kMaxLength after typed array support is determined.
  5676. */
  5677. exports.kMaxLength = kMaxLength()
  5678. function typedArraySupport () {
  5679. try {
  5680. var arr = new Uint8Array(1)
  5681. arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
  5682. return arr.foo() === 42 && // typed array instances can be augmented
  5683. typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
  5684. arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
  5685. } catch (e) {
  5686. return false
  5687. }
  5688. }
  5689. function kMaxLength () {
  5690. return Buffer.TYPED_ARRAY_SUPPORT
  5691. ? 0x7fffffff
  5692. : 0x3fffffff
  5693. }
  5694. function createBuffer (that, length) {
  5695. if (kMaxLength() < length) {
  5696. throw new RangeError('Invalid typed array length')
  5697. }
  5698. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5699. // Return an augmented `Uint8Array` instance, for best performance
  5700. that = new Uint8Array(length)
  5701. that.__proto__ = Buffer.prototype
  5702. } else {
  5703. // Fallback: Return an object instance of the Buffer class
  5704. if (that === null) {
  5705. that = new Buffer(length)
  5706. }
  5707. that.length = length
  5708. }
  5709. return that
  5710. }
  5711. /**
  5712. * The Buffer constructor returns instances of `Uint8Array` that have their
  5713. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  5714. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  5715. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  5716. * returns a single octet.
  5717. *
  5718. * The `Uint8Array` prototype remains unmodified.
  5719. */
  5720. function Buffer (arg, encodingOrOffset, length) {
  5721. if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
  5722. return new Buffer(arg, encodingOrOffset, length)
  5723. }
  5724. // Common case.
  5725. if (typeof arg === 'number') {
  5726. if (typeof encodingOrOffset === 'string') {
  5727. throw new Error(
  5728. 'If encoding is specified then the first argument must be a string'
  5729. )
  5730. }
  5731. return allocUnsafe(this, arg)
  5732. }
  5733. return from(this, arg, encodingOrOffset, length)
  5734. }
  5735. Buffer.poolSize = 8192 // not used by this implementation
  5736. // TODO: Legacy, not needed anymore. Remove in next major version.
  5737. Buffer._augment = function (arr) {
  5738. arr.__proto__ = Buffer.prototype
  5739. return arr
  5740. }
  5741. function from (that, value, encodingOrOffset, length) {
  5742. if (typeof value === 'number') {
  5743. throw new TypeError('"value" argument must not be a number')
  5744. }
  5745. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  5746. return fromArrayBuffer(that, value, encodingOrOffset, length)
  5747. }
  5748. if (typeof value === 'string') {
  5749. return fromString(that, value, encodingOrOffset)
  5750. }
  5751. return fromObject(that, value)
  5752. }
  5753. /**
  5754. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  5755. * if value is a number.
  5756. * Buffer.from(str[, encoding])
  5757. * Buffer.from(array)
  5758. * Buffer.from(buffer)
  5759. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  5760. **/
  5761. Buffer.from = function (value, encodingOrOffset, length) {
  5762. return from(null, value, encodingOrOffset, length)
  5763. }
  5764. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5765. Buffer.prototype.__proto__ = Uint8Array.prototype
  5766. Buffer.__proto__ = Uint8Array
  5767. if (typeof Symbol !== 'undefined' && Symbol.species &&
  5768. Buffer[Symbol.species] === Buffer) {
  5769. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  5770. Object.defineProperty(Buffer, Symbol.species, {
  5771. value: null,
  5772. configurable: true
  5773. })
  5774. }
  5775. }
  5776. function assertSize (size) {
  5777. if (typeof size !== 'number') {
  5778. throw new TypeError('"size" argument must be a number')
  5779. } else if (size < 0) {
  5780. throw new RangeError('"size" argument must not be negative')
  5781. }
  5782. }
  5783. function alloc (that, size, fill, encoding) {
  5784. assertSize(size)
  5785. if (size <= 0) {
  5786. return createBuffer(that, size)
  5787. }
  5788. if (fill !== undefined) {
  5789. // Only pay attention to encoding if it's a string. This
  5790. // prevents accidentally sending in a number that would
  5791. // be interpretted as a start offset.
  5792. return typeof encoding === 'string'
  5793. ? createBuffer(that, size).fill(fill, encoding)
  5794. : createBuffer(that, size).fill(fill)
  5795. }
  5796. return createBuffer(that, size)
  5797. }
  5798. /**
  5799. * Creates a new filled Buffer instance.
  5800. * alloc(size[, fill[, encoding]])
  5801. **/
  5802. Buffer.alloc = function (size, fill, encoding) {
  5803. return alloc(null, size, fill, encoding)
  5804. }
  5805. function allocUnsafe (that, size) {
  5806. assertSize(size)
  5807. that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
  5808. if (!Buffer.TYPED_ARRAY_SUPPORT) {
  5809. for (var i = 0; i < size; ++i) {
  5810. that[i] = 0
  5811. }
  5812. }
  5813. return that
  5814. }
  5815. /**
  5816. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  5817. * */
  5818. Buffer.allocUnsafe = function (size) {
  5819. return allocUnsafe(null, size)
  5820. }
  5821. /**
  5822. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  5823. */
  5824. Buffer.allocUnsafeSlow = function (size) {
  5825. return allocUnsafe(null, size)
  5826. }
  5827. function fromString (that, string, encoding) {
  5828. if (typeof encoding !== 'string' || encoding === '') {
  5829. encoding = 'utf8'
  5830. }
  5831. if (!Buffer.isEncoding(encoding)) {
  5832. throw new TypeError('"encoding" must be a valid string encoding')
  5833. }
  5834. var length = byteLength(string, encoding) | 0
  5835. that = createBuffer(that, length)
  5836. var actual = that.write(string, encoding)
  5837. if (actual !== length) {
  5838. // Writing a hex string, for example, that contains invalid characters will
  5839. // cause everything after the first invalid character to be ignored. (e.g.
  5840. // 'abxxcd' will be treated as 'ab')
  5841. that = that.slice(0, actual)
  5842. }
  5843. return that
  5844. }
  5845. function fromArrayLike (that, array) {
  5846. var length = array.length < 0 ? 0 : checked(array.length) | 0
  5847. that = createBuffer(that, length)
  5848. for (var i = 0; i < length; i += 1) {
  5849. that[i] = array[i] & 255
  5850. }
  5851. return that
  5852. }
  5853. function fromArrayBuffer (that, array, byteOffset, length) {
  5854. array.byteLength // this throws if `array` is not a valid ArrayBuffer
  5855. if (byteOffset < 0 || array.byteLength < byteOffset) {
  5856. throw new RangeError('\'offset\' is out of bounds')
  5857. }
  5858. if (array.byteLength < byteOffset + (length || 0)) {
  5859. throw new RangeError('\'length\' is out of bounds')
  5860. }
  5861. if (byteOffset === undefined && length === undefined) {
  5862. array = new Uint8Array(array)
  5863. } else if (length === undefined) {
  5864. array = new Uint8Array(array, byteOffset)
  5865. } else {
  5866. array = new Uint8Array(array, byteOffset, length)
  5867. }
  5868. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5869. // Return an augmented `Uint8Array` instance, for best performance
  5870. that = array
  5871. that.__proto__ = Buffer.prototype
  5872. } else {
  5873. // Fallback: Return an object instance of the Buffer class
  5874. that = fromArrayLike(that, array)
  5875. }
  5876. return that
  5877. }
  5878. function fromObject (that, obj) {
  5879. if (Buffer.isBuffer(obj)) {
  5880. var len = checked(obj.length) | 0
  5881. that = createBuffer(that, len)
  5882. if (that.length === 0) {
  5883. return that
  5884. }
  5885. obj.copy(that, 0, 0, len)
  5886. return that
  5887. }
  5888. if (obj) {
  5889. if ((typeof ArrayBuffer !== 'undefined' &&
  5890. obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
  5891. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  5892. return createBuffer(that, 0)
  5893. }
  5894. return fromArrayLike(that, obj)
  5895. }
  5896. if (obj.type === 'Buffer' && isArray(obj.data)) {
  5897. return fromArrayLike(that, obj.data)
  5898. }
  5899. }
  5900. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
  5901. }
  5902. function checked (length) {
  5903. // Note: cannot use `length < kMaxLength()` here because that fails when
  5904. // length is NaN (which is otherwise coerced to zero.)
  5905. if (length >= kMaxLength()) {
  5906. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  5907. 'size: 0x' + kMaxLength().toString(16) + ' bytes')
  5908. }
  5909. return length | 0
  5910. }
  5911. function SlowBuffer (length) {
  5912. if (+length != length) { // eslint-disable-line eqeqeq
  5913. length = 0
  5914. }
  5915. return Buffer.alloc(+length)
  5916. }
  5917. Buffer.isBuffer = function isBuffer (b) {
  5918. return !!(b != null && b._isBuffer)
  5919. }
  5920. Buffer.compare = function compare (a, b) {
  5921. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  5922. throw new TypeError('Arguments must be Buffers')
  5923. }
  5924. if (a === b) return 0
  5925. var x = a.length
  5926. var y = b.length
  5927. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  5928. if (a[i] !== b[i]) {
  5929. x = a[i]
  5930. y = b[i]
  5931. break
  5932. }
  5933. }
  5934. if (x < y) return -1
  5935. if (y < x) return 1
  5936. return 0
  5937. }
  5938. Buffer.isEncoding = function isEncoding (encoding) {
  5939. switch (String(encoding).toLowerCase()) {
  5940. case 'hex':
  5941. case 'utf8':
  5942. case 'utf-8':
  5943. case 'ascii':
  5944. case 'latin1':
  5945. case 'binary':
  5946. case 'base64':
  5947. case 'ucs2':
  5948. case 'ucs-2':
  5949. case 'utf16le':
  5950. case 'utf-16le':
  5951. return true
  5952. default:
  5953. return false
  5954. }
  5955. }
  5956. Buffer.concat = function concat (list, length) {
  5957. if (!isArray(list)) {
  5958. throw new TypeError('"list" argument must be an Array of Buffers')
  5959. }
  5960. if (list.length === 0) {
  5961. return Buffer.alloc(0)
  5962. }
  5963. var i
  5964. if (length === undefined) {
  5965. length = 0
  5966. for (i = 0; i < list.length; ++i) {
  5967. length += list[i].length
  5968. }
  5969. }
  5970. var buffer = Buffer.allocUnsafe(length)
  5971. var pos = 0
  5972. for (i = 0; i < list.length; ++i) {
  5973. var buf = list[i]
  5974. if (!Buffer.isBuffer(buf)) {
  5975. throw new TypeError('"list" argument must be an Array of Buffers')
  5976. }
  5977. buf.copy(buffer, pos)
  5978. pos += buf.length
  5979. }
  5980. return buffer
  5981. }
  5982. function byteLength (string, encoding) {
  5983. if (Buffer.isBuffer(string)) {
  5984. return string.length
  5985. }
  5986. if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
  5987. (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
  5988. return string.byteLength
  5989. }
  5990. if (typeof string !== 'string') {
  5991. string = '' + string
  5992. }
  5993. var len = string.length
  5994. if (len === 0) return 0
  5995. // Use a for loop to avoid recursion
  5996. var loweredCase = false
  5997. for (;;) {
  5998. switch (encoding) {
  5999. case 'ascii':
  6000. case 'latin1':
  6001. case 'binary':
  6002. return len
  6003. case 'utf8':
  6004. case 'utf-8':
  6005. case undefined:
  6006. return utf8ToBytes(string).length
  6007. case 'ucs2':
  6008. case 'ucs-2':
  6009. case 'utf16le':
  6010. case 'utf-16le':
  6011. return len * 2
  6012. case 'hex':
  6013. return len >>> 1
  6014. case 'base64':
  6015. return base64ToBytes(string).length
  6016. default:
  6017. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  6018. encoding = ('' + encoding).toLowerCase()
  6019. loweredCase = true
  6020. }
  6021. }
  6022. }
  6023. Buffer.byteLength = byteLength
  6024. function slowToString (encoding, start, end) {
  6025. var loweredCase = false
  6026. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  6027. // property of a typed array.
  6028. // This behaves neither like String nor Uint8Array in that we set start/end
  6029. // to their upper/lower bounds if the value passed is out of range.
  6030. // undefined is handled specially as per ECMA-262 6th Edition,
  6031. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  6032. if (start === undefined || start < 0) {
  6033. start = 0
  6034. }
  6035. // Return early if start > this.length. Done here to prevent potential uint32
  6036. // coercion fail below.
  6037. if (start > this.length) {
  6038. return ''
  6039. }
  6040. if (end === undefined || end > this.length) {
  6041. end = this.length
  6042. }
  6043. if (end <= 0) {
  6044. return ''
  6045. }
  6046. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  6047. end >>>= 0
  6048. start >>>= 0
  6049. if (end <= start) {
  6050. return ''
  6051. }
  6052. if (!encoding) encoding = 'utf8'
  6053. while (true) {
  6054. switch (encoding) {
  6055. case 'hex':
  6056. return hexSlice(this, start, end)
  6057. case 'utf8':
  6058. case 'utf-8':
  6059. return utf8Slice(this, start, end)
  6060. case 'ascii':
  6061. return asciiSlice(this, start, end)
  6062. case 'latin1':
  6063. case 'binary':
  6064. return latin1Slice(this, start, end)
  6065. case 'base64':
  6066. return base64Slice(this, start, end)
  6067. case 'ucs2':
  6068. case 'ucs-2':
  6069. case 'utf16le':
  6070. case 'utf-16le':
  6071. return utf16leSlice(this, start, end)
  6072. default:
  6073. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  6074. encoding = (encoding + '').toLowerCase()
  6075. loweredCase = true
  6076. }
  6077. }
  6078. }
  6079. // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
  6080. // Buffer instances.
  6081. Buffer.prototype._isBuffer = true
  6082. function swap (b, n, m) {
  6083. var i = b[n]
  6084. b[n] = b[m]
  6085. b[m] = i
  6086. }
  6087. Buffer.prototype.swap16 = function swap16 () {
  6088. var len = this.length
  6089. if (len % 2 !== 0) {
  6090. throw new RangeError('Buffer size must be a multiple of 16-bits')
  6091. }
  6092. for (var i = 0; i < len; i += 2) {
  6093. swap(this, i, i + 1)
  6094. }
  6095. return this
  6096. }
  6097. Buffer.prototype.swap32 = function swap32 () {
  6098. var len = this.length
  6099. if (len % 4 !== 0) {
  6100. throw new RangeError('Buffer size must be a multiple of 32-bits')
  6101. }
  6102. for (var i = 0; i < len; i += 4) {
  6103. swap(this, i, i + 3)
  6104. swap(this, i + 1, i + 2)
  6105. }
  6106. return this
  6107. }
  6108. Buffer.prototype.swap64 = function swap64 () {
  6109. var len = this.length
  6110. if (len % 8 !== 0) {
  6111. throw new RangeError('Buffer size must be a multiple of 64-bits')
  6112. }
  6113. for (var i = 0; i < len; i += 8) {
  6114. swap(this, i, i + 7)
  6115. swap(this, i + 1, i + 6)
  6116. swap(this, i + 2, i + 5)
  6117. swap(this, i + 3, i + 4)
  6118. }
  6119. return this
  6120. }
  6121. Buffer.prototype.toString = function toString () {
  6122. var length = this.length | 0
  6123. if (length === 0) return ''
  6124. if (arguments.length === 0) return utf8Slice(this, 0, length)
  6125. return slowToString.apply(this, arguments)
  6126. }
  6127. Buffer.prototype.equals = function equals (b) {
  6128. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  6129. if (this === b) return true
  6130. return Buffer.compare(this, b) === 0
  6131. }
  6132. Buffer.prototype.inspect = function inspect () {
  6133. var str = ''
  6134. var max = exports.INSPECT_MAX_BYTES
  6135. if (this.length > 0) {
  6136. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
  6137. if (this.length > max) str += ' ... '
  6138. }
  6139. return '<Buffer ' + str + '>'
  6140. }
  6141. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  6142. if (!Buffer.isBuffer(target)) {
  6143. throw new TypeError('Argument must be a Buffer')
  6144. }
  6145. if (start === undefined) {
  6146. start = 0
  6147. }
  6148. if (end === undefined) {
  6149. end = target ? target.length : 0
  6150. }
  6151. if (thisStart === undefined) {
  6152. thisStart = 0
  6153. }
  6154. if (thisEnd === undefined) {
  6155. thisEnd = this.length
  6156. }
  6157. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  6158. throw new RangeError('out of range index')
  6159. }
  6160. if (thisStart >= thisEnd && start >= end) {
  6161. return 0
  6162. }
  6163. if (thisStart >= thisEnd) {
  6164. return -1
  6165. }
  6166. if (start >= end) {
  6167. return 1
  6168. }
  6169. start >>>= 0
  6170. end >>>= 0
  6171. thisStart >>>= 0
  6172. thisEnd >>>= 0
  6173. if (this === target) return 0
  6174. var x = thisEnd - thisStart
  6175. var y = end - start
  6176. var len = Math.min(x, y)
  6177. var thisCopy = this.slice(thisStart, thisEnd)
  6178. var targetCopy = target.slice(start, end)
  6179. for (var i = 0; i < len; ++i) {
  6180. if (thisCopy[i] !== targetCopy[i]) {
  6181. x = thisCopy[i]
  6182. y = targetCopy[i]
  6183. break
  6184. }
  6185. }
  6186. if (x < y) return -1
  6187. if (y < x) return 1
  6188. return 0
  6189. }
  6190. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  6191. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  6192. //
  6193. // Arguments:
  6194. // - buffer - a Buffer to search
  6195. // - val - a string, Buffer, or number
  6196. // - byteOffset - an index into `buffer`; will be clamped to an int32
  6197. // - encoding - an optional encoding, relevant is val is a string
  6198. // - dir - true for indexOf, false for lastIndexOf
  6199. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  6200. // Empty buffer means no match
  6201. if (buffer.length === 0) return -1
  6202. // Normalize byteOffset
  6203. if (typeof byteOffset === 'string') {
  6204. encoding = byteOffset
  6205. byteOffset = 0
  6206. } else if (byteOffset > 0x7fffffff) {
  6207. byteOffset = 0x7fffffff
  6208. } else if (byteOffset < -0x80000000) {
  6209. byteOffset = -0x80000000
  6210. }
  6211. byteOffset = +byteOffset // Coerce to Number.
  6212. if (isNaN(byteOffset)) {
  6213. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  6214. byteOffset = dir ? 0 : (buffer.length - 1)
  6215. }
  6216. // Normalize byteOffset: negative offsets start from the end of the buffer
  6217. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  6218. if (byteOffset >= buffer.length) {
  6219. if (dir) return -1
  6220. else byteOffset = buffer.length - 1
  6221. } else if (byteOffset < 0) {
  6222. if (dir) byteOffset = 0
  6223. else return -1
  6224. }
  6225. // Normalize val
  6226. if (typeof val === 'string') {
  6227. val = Buffer.from(val, encoding)
  6228. }
  6229. // Finally, search either indexOf (if dir is true) or lastIndexOf
  6230. if (Buffer.isBuffer(val)) {
  6231. // Special case: looking for empty string/buffer always fails
  6232. if (val.length === 0) {
  6233. return -1
  6234. }
  6235. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  6236. } else if (typeof val === 'number') {
  6237. val = val & 0xFF // Search for a byte value [0-255]
  6238. if (Buffer.TYPED_ARRAY_SUPPORT &&
  6239. typeof Uint8Array.prototype.indexOf === 'function') {
  6240. if (dir) {
  6241. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  6242. } else {
  6243. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  6244. }
  6245. }
  6246. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  6247. }
  6248. throw new TypeError('val must be string, number or Buffer')
  6249. }
  6250. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  6251. var indexSize = 1
  6252. var arrLength = arr.length
  6253. var valLength = val.length
  6254. if (encoding !== undefined) {
  6255. encoding = String(encoding).toLowerCase()
  6256. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  6257. encoding === 'utf16le' || encoding === 'utf-16le') {
  6258. if (arr.length < 2 || val.length < 2) {
  6259. return -1
  6260. }
  6261. indexSize = 2
  6262. arrLength /= 2
  6263. valLength /= 2
  6264. byteOffset /= 2
  6265. }
  6266. }
  6267. function read (buf, i) {
  6268. if (indexSize === 1) {
  6269. return buf[i]
  6270. } else {
  6271. return buf.readUInt16BE(i * indexSize)
  6272. }
  6273. }
  6274. var i
  6275. if (dir) {
  6276. var foundIndex = -1
  6277. for (i = byteOffset; i < arrLength; i++) {
  6278. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  6279. if (foundIndex === -1) foundIndex = i
  6280. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  6281. } else {
  6282. if (foundIndex !== -1) i -= i - foundIndex
  6283. foundIndex = -1
  6284. }
  6285. }
  6286. } else {
  6287. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  6288. for (i = byteOffset; i >= 0; i--) {
  6289. var found = true
  6290. for (var j = 0; j < valLength; j++) {
  6291. if (read(arr, i + j) !== read(val, j)) {
  6292. found = false
  6293. break
  6294. }
  6295. }
  6296. if (found) return i
  6297. }
  6298. }
  6299. return -1
  6300. }
  6301. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  6302. return this.indexOf(val, byteOffset, encoding) !== -1
  6303. }
  6304. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  6305. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  6306. }
  6307. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  6308. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  6309. }
  6310. function hexWrite (buf, string, offset, length) {
  6311. offset = Number(offset) || 0
  6312. var remaining = buf.length - offset
  6313. if (!length) {
  6314. length = remaining
  6315. } else {
  6316. length = Number(length)
  6317. if (length > remaining) {
  6318. length = remaining
  6319. }
  6320. }
  6321. // must be an even number of digits
  6322. var strLen = string.length
  6323. if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
  6324. if (length > strLen / 2) {
  6325. length = strLen / 2
  6326. }
  6327. for (var i = 0; i < length; ++i) {
  6328. var parsed = parseInt(string.substr(i * 2, 2), 16)
  6329. if (isNaN(parsed)) return i
  6330. buf[offset + i] = parsed
  6331. }
  6332. return i
  6333. }
  6334. function utf8Write (buf, string, offset, length) {
  6335. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  6336. }
  6337. function asciiWrite (buf, string, offset, length) {
  6338. return blitBuffer(asciiToBytes(string), buf, offset, length)
  6339. }
  6340. function latin1Write (buf, string, offset, length) {
  6341. return asciiWrite(buf, string, offset, length)
  6342. }
  6343. function base64Write (buf, string, offset, length) {
  6344. return blitBuffer(base64ToBytes(string), buf, offset, length)
  6345. }
  6346. function ucs2Write (buf, string, offset, length) {
  6347. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  6348. }
  6349. Buffer.prototype.write = function write (string, offset, length, encoding) {
  6350. // Buffer#write(string)
  6351. if (offset === undefined) {
  6352. encoding = 'utf8'
  6353. length = this.length
  6354. offset = 0
  6355. // Buffer#write(string, encoding)
  6356. } else if (length === undefined && typeof offset === 'string') {
  6357. encoding = offset
  6358. length = this.length
  6359. offset = 0
  6360. // Buffer#write(string, offset[, length][, encoding])
  6361. } else if (isFinite(offset)) {
  6362. offset = offset | 0
  6363. if (isFinite(length)) {
  6364. length = length | 0
  6365. if (encoding === undefined) encoding = 'utf8'
  6366. } else {
  6367. encoding = length
  6368. length = undefined
  6369. }
  6370. // legacy write(string, encoding, offset, length) - remove in v0.13
  6371. } else {
  6372. throw new Error(
  6373. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  6374. )
  6375. }
  6376. var remaining = this.length - offset
  6377. if (length === undefined || length > remaining) length = remaining
  6378. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  6379. throw new RangeError('Attempt to write outside buffer bounds')
  6380. }
  6381. if (!encoding) encoding = 'utf8'
  6382. var loweredCase = false
  6383. for (;;) {
  6384. switch (encoding) {
  6385. case 'hex':
  6386. return hexWrite(this, string, offset, length)
  6387. case 'utf8':
  6388. case 'utf-8':
  6389. return utf8Write(this, string, offset, length)
  6390. case 'ascii':
  6391. return asciiWrite(this, string, offset, length)
  6392. case 'latin1':
  6393. case 'binary':
  6394. return latin1Write(this, string, offset, length)
  6395. case 'base64':
  6396. // Warning: maxLength not taken into account in base64Write
  6397. return base64Write(this, string, offset, length)
  6398. case 'ucs2':
  6399. case 'ucs-2':
  6400. case 'utf16le':
  6401. case 'utf-16le':
  6402. return ucs2Write(this, string, offset, length)
  6403. default:
  6404. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  6405. encoding = ('' + encoding).toLowerCase()
  6406. loweredCase = true
  6407. }
  6408. }
  6409. }
  6410. Buffer.prototype.toJSON = function toJSON () {
  6411. return {
  6412. type: 'Buffer',
  6413. data: Array.prototype.slice.call(this._arr || this, 0)
  6414. }
  6415. }
  6416. function base64Slice (buf, start, end) {
  6417. if (start === 0 && end === buf.length) {
  6418. return base64.fromByteArray(buf)
  6419. } else {
  6420. return base64.fromByteArray(buf.slice(start, end))
  6421. }
  6422. }
  6423. function utf8Slice (buf, start, end) {
  6424. end = Math.min(buf.length, end)
  6425. var res = []
  6426. var i = start
  6427. while (i < end) {
  6428. var firstByte = buf[i]
  6429. var codePoint = null
  6430. var bytesPerSequence = (firstByte > 0xEF) ? 4
  6431. : (firstByte > 0xDF) ? 3
  6432. : (firstByte > 0xBF) ? 2
  6433. : 1
  6434. if (i + bytesPerSequence <= end) {
  6435. var secondByte, thirdByte, fourthByte, tempCodePoint
  6436. switch (bytesPerSequence) {
  6437. case 1:
  6438. if (firstByte < 0x80) {
  6439. codePoint = firstByte
  6440. }
  6441. break
  6442. case 2:
  6443. secondByte = buf[i + 1]
  6444. if ((secondByte & 0xC0) === 0x80) {
  6445. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  6446. if (tempCodePoint > 0x7F) {
  6447. codePoint = tempCodePoint
  6448. }
  6449. }
  6450. break
  6451. case 3:
  6452. secondByte = buf[i + 1]
  6453. thirdByte = buf[i + 2]
  6454. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  6455. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  6456. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  6457. codePoint = tempCodePoint
  6458. }
  6459. }
  6460. break
  6461. case 4:
  6462. secondByte = buf[i + 1]
  6463. thirdByte = buf[i + 2]
  6464. fourthByte = buf[i + 3]
  6465. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  6466. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  6467. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  6468. codePoint = tempCodePoint
  6469. }
  6470. }
  6471. }
  6472. }
  6473. if (codePoint === null) {
  6474. // we did not generate a valid codePoint so insert a
  6475. // replacement char (U+FFFD) and advance only 1 byte
  6476. codePoint = 0xFFFD
  6477. bytesPerSequence = 1
  6478. } else if (codePoint > 0xFFFF) {
  6479. // encode to utf16 (surrogate pair dance)
  6480. codePoint -= 0x10000
  6481. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  6482. codePoint = 0xDC00 | codePoint & 0x3FF
  6483. }
  6484. res.push(codePoint)
  6485. i += bytesPerSequence
  6486. }
  6487. return decodeCodePointsArray(res)
  6488. }
  6489. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  6490. // the lowest limit is Chrome, with 0x10000 args.
  6491. // We go 1 magnitude less, for safety
  6492. var MAX_ARGUMENTS_LENGTH = 0x1000
  6493. function decodeCodePointsArray (codePoints) {
  6494. var len = codePoints.length
  6495. if (len <= MAX_ARGUMENTS_LENGTH) {
  6496. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  6497. }
  6498. // Decode in chunks to avoid "call stack size exceeded".
  6499. var res = ''
  6500. var i = 0
  6501. while (i < len) {
  6502. res += String.fromCharCode.apply(
  6503. String,
  6504. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  6505. )
  6506. }
  6507. return res
  6508. }
  6509. function asciiSlice (buf, start, end) {
  6510. var ret = ''
  6511. end = Math.min(buf.length, end)
  6512. for (var i = start; i < end; ++i) {
  6513. ret += String.fromCharCode(buf[i] & 0x7F)
  6514. }
  6515. return ret
  6516. }
  6517. function latin1Slice (buf, start, end) {
  6518. var ret = ''
  6519. end = Math.min(buf.length, end)
  6520. for (var i = start; i < end; ++i) {
  6521. ret += String.fromCharCode(buf[i])
  6522. }
  6523. return ret
  6524. }
  6525. function hexSlice (buf, start, end) {
  6526. var len = buf.length
  6527. if (!start || start < 0) start = 0
  6528. if (!end || end < 0 || end > len) end = len
  6529. var out = ''
  6530. for (var i = start; i < end; ++i) {
  6531. out += toHex(buf[i])
  6532. }
  6533. return out
  6534. }
  6535. function utf16leSlice (buf, start, end) {
  6536. var bytes = buf.slice(start, end)
  6537. var res = ''
  6538. for (var i = 0; i < bytes.length; i += 2) {
  6539. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
  6540. }
  6541. return res
  6542. }
  6543. Buffer.prototype.slice = function slice (start, end) {
  6544. var len = this.length
  6545. start = ~~start
  6546. end = end === undefined ? len : ~~end
  6547. if (start < 0) {
  6548. start += len
  6549. if (start < 0) start = 0
  6550. } else if (start > len) {
  6551. start = len
  6552. }
  6553. if (end < 0) {
  6554. end += len
  6555. if (end < 0) end = 0
  6556. } else if (end > len) {
  6557. end = len
  6558. }
  6559. if (end < start) end = start
  6560. var newBuf
  6561. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6562. newBuf = this.subarray(start, end)
  6563. newBuf.__proto__ = Buffer.prototype
  6564. } else {
  6565. var sliceLen = end - start
  6566. newBuf = new Buffer(sliceLen, undefined)
  6567. for (var i = 0; i < sliceLen; ++i) {
  6568. newBuf[i] = this[i + start]
  6569. }
  6570. }
  6571. return newBuf
  6572. }
  6573. /*
  6574. * Need to make sure that buffer isn't trying to write out of bounds.
  6575. */
  6576. function checkOffset (offset, ext, length) {
  6577. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  6578. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  6579. }
  6580. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  6581. offset = offset | 0
  6582. byteLength = byteLength | 0
  6583. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6584. var val = this[offset]
  6585. var mul = 1
  6586. var i = 0
  6587. while (++i < byteLength && (mul *= 0x100)) {
  6588. val += this[offset + i] * mul
  6589. }
  6590. return val
  6591. }
  6592. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  6593. offset = offset | 0
  6594. byteLength = byteLength | 0
  6595. if (!noAssert) {
  6596. checkOffset(offset, byteLength, this.length)
  6597. }
  6598. var val = this[offset + --byteLength]
  6599. var mul = 1
  6600. while (byteLength > 0 && (mul *= 0x100)) {
  6601. val += this[offset + --byteLength] * mul
  6602. }
  6603. return val
  6604. }
  6605. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  6606. if (!noAssert) checkOffset(offset, 1, this.length)
  6607. return this[offset]
  6608. }
  6609. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  6610. if (!noAssert) checkOffset(offset, 2, this.length)
  6611. return this[offset] | (this[offset + 1] << 8)
  6612. }
  6613. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  6614. if (!noAssert) checkOffset(offset, 2, this.length)
  6615. return (this[offset] << 8) | this[offset + 1]
  6616. }
  6617. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  6618. if (!noAssert) checkOffset(offset, 4, this.length)
  6619. return ((this[offset]) |
  6620. (this[offset + 1] << 8) |
  6621. (this[offset + 2] << 16)) +
  6622. (this[offset + 3] * 0x1000000)
  6623. }
  6624. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  6625. if (!noAssert) checkOffset(offset, 4, this.length)
  6626. return (this[offset] * 0x1000000) +
  6627. ((this[offset + 1] << 16) |
  6628. (this[offset + 2] << 8) |
  6629. this[offset + 3])
  6630. }
  6631. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  6632. offset = offset | 0
  6633. byteLength = byteLength | 0
  6634. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6635. var val = this[offset]
  6636. var mul = 1
  6637. var i = 0
  6638. while (++i < byteLength && (mul *= 0x100)) {
  6639. val += this[offset + i] * mul
  6640. }
  6641. mul *= 0x80
  6642. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  6643. return val
  6644. }
  6645. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  6646. offset = offset | 0
  6647. byteLength = byteLength | 0
  6648. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6649. var i = byteLength
  6650. var mul = 1
  6651. var val = this[offset + --i]
  6652. while (i > 0 && (mul *= 0x100)) {
  6653. val += this[offset + --i] * mul
  6654. }
  6655. mul *= 0x80
  6656. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  6657. return val
  6658. }
  6659. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  6660. if (!noAssert) checkOffset(offset, 1, this.length)
  6661. if (!(this[offset] & 0x80)) return (this[offset])
  6662. return ((0xff - this[offset] + 1) * -1)
  6663. }
  6664. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  6665. if (!noAssert) checkOffset(offset, 2, this.length)
  6666. var val = this[offset] | (this[offset + 1] << 8)
  6667. return (val & 0x8000) ? val | 0xFFFF0000 : val
  6668. }
  6669. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  6670. if (!noAssert) checkOffset(offset, 2, this.length)
  6671. var val = this[offset + 1] | (this[offset] << 8)
  6672. return (val & 0x8000) ? val | 0xFFFF0000 : val
  6673. }
  6674. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  6675. if (!noAssert) checkOffset(offset, 4, this.length)
  6676. return (this[offset]) |
  6677. (this[offset + 1] << 8) |
  6678. (this[offset + 2] << 16) |
  6679. (this[offset + 3] << 24)
  6680. }
  6681. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  6682. if (!noAssert) checkOffset(offset, 4, this.length)
  6683. return (this[offset] << 24) |
  6684. (this[offset + 1] << 16) |
  6685. (this[offset + 2] << 8) |
  6686. (this[offset + 3])
  6687. }
  6688. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  6689. if (!noAssert) checkOffset(offset, 4, this.length)
  6690. return ieee754.read(this, offset, true, 23, 4)
  6691. }
  6692. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  6693. if (!noAssert) checkOffset(offset, 4, this.length)
  6694. return ieee754.read(this, offset, false, 23, 4)
  6695. }
  6696. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  6697. if (!noAssert) checkOffset(offset, 8, this.length)
  6698. return ieee754.read(this, offset, true, 52, 8)
  6699. }
  6700. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  6701. if (!noAssert) checkOffset(offset, 8, this.length)
  6702. return ieee754.read(this, offset, false, 52, 8)
  6703. }
  6704. function checkInt (buf, value, offset, ext, max, min) {
  6705. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  6706. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  6707. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  6708. }
  6709. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  6710. value = +value
  6711. offset = offset | 0
  6712. byteLength = byteLength | 0
  6713. if (!noAssert) {
  6714. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  6715. checkInt(this, value, offset, byteLength, maxBytes, 0)
  6716. }
  6717. var mul = 1
  6718. var i = 0
  6719. this[offset] = value & 0xFF
  6720. while (++i < byteLength && (mul *= 0x100)) {
  6721. this[offset + i] = (value / mul) & 0xFF
  6722. }
  6723. return offset + byteLength
  6724. }
  6725. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  6726. value = +value
  6727. offset = offset | 0
  6728. byteLength = byteLength | 0
  6729. if (!noAssert) {
  6730. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  6731. checkInt(this, value, offset, byteLength, maxBytes, 0)
  6732. }
  6733. var i = byteLength - 1
  6734. var mul = 1
  6735. this[offset + i] = value & 0xFF
  6736. while (--i >= 0 && (mul *= 0x100)) {
  6737. this[offset + i] = (value / mul) & 0xFF
  6738. }
  6739. return offset + byteLength
  6740. }
  6741. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  6742. value = +value
  6743. offset = offset | 0
  6744. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  6745. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  6746. this[offset] = (value & 0xff)
  6747. return offset + 1
  6748. }
  6749. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  6750. if (value < 0) value = 0xffff + value + 1
  6751. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
  6752. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  6753. (littleEndian ? i : 1 - i) * 8
  6754. }
  6755. }
  6756. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  6757. value = +value
  6758. offset = offset | 0
  6759. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  6760. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6761. this[offset] = (value & 0xff)
  6762. this[offset + 1] = (value >>> 8)
  6763. } else {
  6764. objectWriteUInt16(this, value, offset, true)
  6765. }
  6766. return offset + 2
  6767. }
  6768. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  6769. value = +value
  6770. offset = offset | 0
  6771. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  6772. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6773. this[offset] = (value >>> 8)
  6774. this[offset + 1] = (value & 0xff)
  6775. } else {
  6776. objectWriteUInt16(this, value, offset, false)
  6777. }
  6778. return offset + 2
  6779. }
  6780. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  6781. if (value < 0) value = 0xffffffff + value + 1
  6782. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
  6783. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
  6784. }
  6785. }
  6786. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  6787. value = +value
  6788. offset = offset | 0
  6789. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  6790. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6791. this[offset + 3] = (value >>> 24)
  6792. this[offset + 2] = (value >>> 16)
  6793. this[offset + 1] = (value >>> 8)
  6794. this[offset] = (value & 0xff)
  6795. } else {
  6796. objectWriteUInt32(this, value, offset, true)
  6797. }
  6798. return offset + 4
  6799. }
  6800. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  6801. value = +value
  6802. offset = offset | 0
  6803. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  6804. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6805. this[offset] = (value >>> 24)
  6806. this[offset + 1] = (value >>> 16)
  6807. this[offset + 2] = (value >>> 8)
  6808. this[offset + 3] = (value & 0xff)
  6809. } else {
  6810. objectWriteUInt32(this, value, offset, false)
  6811. }
  6812. return offset + 4
  6813. }
  6814. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  6815. value = +value
  6816. offset = offset | 0
  6817. if (!noAssert) {
  6818. var limit = Math.pow(2, 8 * byteLength - 1)
  6819. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  6820. }
  6821. var i = 0
  6822. var mul = 1
  6823. var sub = 0
  6824. this[offset] = value & 0xFF
  6825. while (++i < byteLength && (mul *= 0x100)) {
  6826. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  6827. sub = 1
  6828. }
  6829. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  6830. }
  6831. return offset + byteLength
  6832. }
  6833. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  6834. value = +value
  6835. offset = offset | 0
  6836. if (!noAssert) {
  6837. var limit = Math.pow(2, 8 * byteLength - 1)
  6838. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  6839. }
  6840. var i = byteLength - 1
  6841. var mul = 1
  6842. var sub = 0
  6843. this[offset + i] = value & 0xFF
  6844. while (--i >= 0 && (mul *= 0x100)) {
  6845. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  6846. sub = 1
  6847. }
  6848. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  6849. }
  6850. return offset + byteLength
  6851. }
  6852. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  6853. value = +value
  6854. offset = offset | 0
  6855. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  6856. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  6857. if (value < 0) value = 0xff + value + 1
  6858. this[offset] = (value & 0xff)
  6859. return offset + 1
  6860. }
  6861. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  6862. value = +value
  6863. offset = offset | 0
  6864. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  6865. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6866. this[offset] = (value & 0xff)
  6867. this[offset + 1] = (value >>> 8)
  6868. } else {
  6869. objectWriteUInt16(this, value, offset, true)
  6870. }
  6871. return offset + 2
  6872. }
  6873. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  6874. value = +value
  6875. offset = offset | 0
  6876. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  6877. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6878. this[offset] = (value >>> 8)
  6879. this[offset + 1] = (value & 0xff)
  6880. } else {
  6881. objectWriteUInt16(this, value, offset, false)
  6882. }
  6883. return offset + 2
  6884. }
  6885. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  6886. value = +value
  6887. offset = offset | 0
  6888. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  6889. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6890. this[offset] = (value & 0xff)
  6891. this[offset + 1] = (value >>> 8)
  6892. this[offset + 2] = (value >>> 16)
  6893. this[offset + 3] = (value >>> 24)
  6894. } else {
  6895. objectWriteUInt32(this, value, offset, true)
  6896. }
  6897. return offset + 4
  6898. }
  6899. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  6900. value = +value
  6901. offset = offset | 0
  6902. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  6903. if (value < 0) value = 0xffffffff + value + 1
  6904. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6905. this[offset] = (value >>> 24)
  6906. this[offset + 1] = (value >>> 16)
  6907. this[offset + 2] = (value >>> 8)
  6908. this[offset + 3] = (value & 0xff)
  6909. } else {
  6910. objectWriteUInt32(this, value, offset, false)
  6911. }
  6912. return offset + 4
  6913. }
  6914. function checkIEEE754 (buf, value, offset, ext, max, min) {
  6915. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  6916. if (offset < 0) throw new RangeError('Index out of range')
  6917. }
  6918. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  6919. if (!noAssert) {
  6920. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  6921. }
  6922. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  6923. return offset + 4
  6924. }
  6925. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  6926. return writeFloat(this, value, offset, true, noAssert)
  6927. }
  6928. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  6929. return writeFloat(this, value, offset, false, noAssert)
  6930. }
  6931. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  6932. if (!noAssert) {
  6933. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  6934. }
  6935. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  6936. return offset + 8
  6937. }
  6938. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  6939. return writeDouble(this, value, offset, true, noAssert)
  6940. }
  6941. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  6942. return writeDouble(this, value, offset, false, noAssert)
  6943. }
  6944. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  6945. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  6946. if (!start) start = 0
  6947. if (!end && end !== 0) end = this.length
  6948. if (targetStart >= target.length) targetStart = target.length
  6949. if (!targetStart) targetStart = 0
  6950. if (end > 0 && end < start) end = start
  6951. // Copy 0 bytes; we're done
  6952. if (end === start) return 0
  6953. if (target.length === 0 || this.length === 0) return 0
  6954. // Fatal error conditions
  6955. if (targetStart < 0) {
  6956. throw new RangeError('targetStart out of bounds')
  6957. }
  6958. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  6959. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  6960. // Are we oob?
  6961. if (end > this.length) end = this.length
  6962. if (target.length - targetStart < end - start) {
  6963. end = target.length - targetStart + start
  6964. }
  6965. var len = end - start
  6966. var i
  6967. if (this === target && start < targetStart && targetStart < end) {
  6968. // descending copy from end
  6969. for (i = len - 1; i >= 0; --i) {
  6970. target[i + targetStart] = this[i + start]
  6971. }
  6972. } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
  6973. // ascending copy from start
  6974. for (i = 0; i < len; ++i) {
  6975. target[i + targetStart] = this[i + start]
  6976. }
  6977. } else {
  6978. Uint8Array.prototype.set.call(
  6979. target,
  6980. this.subarray(start, start + len),
  6981. targetStart
  6982. )
  6983. }
  6984. return len
  6985. }
  6986. // Usage:
  6987. // buffer.fill(number[, offset[, end]])
  6988. // buffer.fill(buffer[, offset[, end]])
  6989. // buffer.fill(string[, offset[, end]][, encoding])
  6990. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  6991. // Handle string cases:
  6992. if (typeof val === 'string') {
  6993. if (typeof start === 'string') {
  6994. encoding = start
  6995. start = 0
  6996. end = this.length
  6997. } else if (typeof end === 'string') {
  6998. encoding = end
  6999. end = this.length
  7000. }
  7001. if (val.length === 1) {
  7002. var code = val.charCodeAt(0)
  7003. if (code < 256) {
  7004. val = code
  7005. }
  7006. }
  7007. if (encoding !== undefined && typeof encoding !== 'string') {
  7008. throw new TypeError('encoding must be a string')
  7009. }
  7010. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  7011. throw new TypeError('Unknown encoding: ' + encoding)
  7012. }
  7013. } else if (typeof val === 'number') {
  7014. val = val & 255
  7015. }
  7016. // Invalid ranges are not set to a default, so can range check early.
  7017. if (start < 0 || this.length < start || this.length < end) {
  7018. throw new RangeError('Out of range index')
  7019. }
  7020. if (end <= start) {
  7021. return this
  7022. }
  7023. start = start >>> 0
  7024. end = end === undefined ? this.length : end >>> 0
  7025. if (!val) val = 0
  7026. var i
  7027. if (typeof val === 'number') {
  7028. for (i = start; i < end; ++i) {
  7029. this[i] = val
  7030. }
  7031. } else {
  7032. var bytes = Buffer.isBuffer(val)
  7033. ? val
  7034. : utf8ToBytes(new Buffer(val, encoding).toString())
  7035. var len = bytes.length
  7036. for (i = 0; i < end - start; ++i) {
  7037. this[i + start] = bytes[i % len]
  7038. }
  7039. }
  7040. return this
  7041. }
  7042. // HELPER FUNCTIONS
  7043. // ================
  7044. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
  7045. function base64clean (str) {
  7046. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  7047. str = stringtrim(str).replace(INVALID_BASE64_RE, '')
  7048. // Node converts strings with length < 2 to ''
  7049. if (str.length < 2) return ''
  7050. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  7051. while (str.length % 4 !== 0) {
  7052. str = str + '='
  7053. }
  7054. return str
  7055. }
  7056. function stringtrim (str) {
  7057. if (str.trim) return str.trim()
  7058. return str.replace(/^\s+|\s+$/g, '')
  7059. }
  7060. function toHex (n) {
  7061. if (n < 16) return '0' + n.toString(16)
  7062. return n.toString(16)
  7063. }
  7064. function utf8ToBytes (string, units) {
  7065. units = units || Infinity
  7066. var codePoint
  7067. var length = string.length
  7068. var leadSurrogate = null
  7069. var bytes = []
  7070. for (var i = 0; i < length; ++i) {
  7071. codePoint = string.charCodeAt(i)
  7072. // is surrogate component
  7073. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  7074. // last char was a lead
  7075. if (!leadSurrogate) {
  7076. // no lead yet
  7077. if (codePoint > 0xDBFF) {
  7078. // unexpected trail
  7079. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  7080. continue
  7081. } else if (i + 1 === length) {
  7082. // unpaired lead
  7083. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  7084. continue
  7085. }
  7086. // valid lead
  7087. leadSurrogate = codePoint
  7088. continue
  7089. }
  7090. // 2 leads in a row
  7091. if (codePoint < 0xDC00) {
  7092. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  7093. leadSurrogate = codePoint
  7094. continue
  7095. }
  7096. // valid surrogate pair
  7097. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  7098. } else if (leadSurrogate) {
  7099. // valid bmp char, but last char was a lead
  7100. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  7101. }
  7102. leadSurrogate = null
  7103. // encode utf8
  7104. if (codePoint < 0x80) {
  7105. if ((units -= 1) < 0) break
  7106. bytes.push(codePoint)
  7107. } else if (codePoint < 0x800) {
  7108. if ((units -= 2) < 0) break
  7109. bytes.push(
  7110. codePoint >> 0x6 | 0xC0,
  7111. codePoint & 0x3F | 0x80
  7112. )
  7113. } else if (codePoint < 0x10000) {
  7114. if ((units -= 3) < 0) break
  7115. bytes.push(
  7116. codePoint >> 0xC | 0xE0,
  7117. codePoint >> 0x6 & 0x3F | 0x80,
  7118. codePoint & 0x3F | 0x80
  7119. )
  7120. } else if (codePoint < 0x110000) {
  7121. if ((units -= 4) < 0) break
  7122. bytes.push(
  7123. codePoint >> 0x12 | 0xF0,
  7124. codePoint >> 0xC & 0x3F | 0x80,
  7125. codePoint >> 0x6 & 0x3F | 0x80,
  7126. codePoint & 0x3F | 0x80
  7127. )
  7128. } else {
  7129. throw new Error('Invalid code point')
  7130. }
  7131. }
  7132. return bytes
  7133. }
  7134. function asciiToBytes (str) {
  7135. var byteArray = []
  7136. for (var i = 0; i < str.length; ++i) {
  7137. // Node's code seems to be doing this and not & 0x7F..
  7138. byteArray.push(str.charCodeAt(i) & 0xFF)
  7139. }
  7140. return byteArray
  7141. }
  7142. function utf16leToBytes (str, units) {
  7143. var c, hi, lo
  7144. var byteArray = []
  7145. for (var i = 0; i < str.length; ++i) {
  7146. if ((units -= 2) < 0) break
  7147. c = str.charCodeAt(i)
  7148. hi = c >> 8
  7149. lo = c % 256
  7150. byteArray.push(lo)
  7151. byteArray.push(hi)
  7152. }
  7153. return byteArray
  7154. }
  7155. function base64ToBytes (str) {
  7156. return base64.toByteArray(base64clean(str))
  7157. }
  7158. function blitBuffer (src, dst, offset, length) {
  7159. for (var i = 0; i < length; ++i) {
  7160. if ((i + offset >= dst.length) || (i >= src.length)) break
  7161. dst[i + offset] = src[i]
  7162. }
  7163. return i
  7164. }
  7165. function isnan (val) {
  7166. return val !== val // eslint-disable-line no-self-compare
  7167. }
  7168. /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
  7169. /***/ }),
  7170. /* 40 */
  7171. /***/ (function(module, exports) {
  7172. 'use strict'
  7173. exports.byteLength = byteLength
  7174. exports.toByteArray = toByteArray
  7175. exports.fromByteArray = fromByteArray
  7176. var lookup = []
  7177. var revLookup = []
  7178. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  7179. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  7180. for (var i = 0, len = code.length; i < len; ++i) {
  7181. lookup[i] = code[i]
  7182. revLookup[code.charCodeAt(i)] = i
  7183. }
  7184. // Support decoding URL-safe base64 strings, as Node.js does.
  7185. // See: https://en.wikipedia.org/wiki/Base64#URL_applications
  7186. revLookup['-'.charCodeAt(0)] = 62
  7187. revLookup['_'.charCodeAt(0)] = 63
  7188. function getLens (b64) {
  7189. var len = b64.length
  7190. if (len % 4 > 0) {
  7191. throw new Error('Invalid string. Length must be a multiple of 4')
  7192. }
  7193. // Trim off extra bytes after placeholder bytes are found
  7194. // See: https://github.com/beatgammit/base64-js/issues/42
  7195. var validLen = b64.indexOf('=')
  7196. if (validLen === -1) validLen = len
  7197. var placeHoldersLen = validLen === len
  7198. ? 0
  7199. : 4 - (validLen % 4)
  7200. return [validLen, placeHoldersLen]
  7201. }
  7202. // base64 is 4/3 + up to two characters of the original data
  7203. function byteLength (b64) {
  7204. var lens = getLens(b64)
  7205. var validLen = lens[0]
  7206. var placeHoldersLen = lens[1]
  7207. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  7208. }
  7209. function _byteLength (b64, validLen, placeHoldersLen) {
  7210. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  7211. }
  7212. function toByteArray (b64) {
  7213. var tmp
  7214. var lens = getLens(b64)
  7215. var validLen = lens[0]
  7216. var placeHoldersLen = lens[1]
  7217. var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
  7218. var curByte = 0
  7219. // if there are placeholders, only get up to the last complete 4 chars
  7220. var len = placeHoldersLen > 0
  7221. ? validLen - 4
  7222. : validLen
  7223. var i
  7224. for (i = 0; i < len; i += 4) {
  7225. tmp =
  7226. (revLookup[b64.charCodeAt(i)] << 18) |
  7227. (revLookup[b64.charCodeAt(i + 1)] << 12) |
  7228. (revLookup[b64.charCodeAt(i + 2)] << 6) |
  7229. revLookup[b64.charCodeAt(i + 3)]
  7230. arr[curByte++] = (tmp >> 16) & 0xFF
  7231. arr[curByte++] = (tmp >> 8) & 0xFF
  7232. arr[curByte++] = tmp & 0xFF
  7233. }
  7234. if (placeHoldersLen === 2) {
  7235. tmp =
  7236. (revLookup[b64.charCodeAt(i)] << 2) |
  7237. (revLookup[b64.charCodeAt(i + 1)] >> 4)
  7238. arr[curByte++] = tmp & 0xFF
  7239. }
  7240. if (placeHoldersLen === 1) {
  7241. tmp =
  7242. (revLookup[b64.charCodeAt(i)] << 10) |
  7243. (revLookup[b64.charCodeAt(i + 1)] << 4) |
  7244. (revLookup[b64.charCodeAt(i + 2)] >> 2)
  7245. arr[curByte++] = (tmp >> 8) & 0xFF
  7246. arr[curByte++] = tmp & 0xFF
  7247. }
  7248. return arr
  7249. }
  7250. function tripletToBase64 (num) {
  7251. return lookup[num >> 18 & 0x3F] +
  7252. lookup[num >> 12 & 0x3F] +
  7253. lookup[num >> 6 & 0x3F] +
  7254. lookup[num & 0x3F]
  7255. }
  7256. function encodeChunk (uint8, start, end) {
  7257. var tmp
  7258. var output = []
  7259. for (var i = start; i < end; i += 3) {
  7260. tmp =
  7261. ((uint8[i] << 16) & 0xFF0000) +
  7262. ((uint8[i + 1] << 8) & 0xFF00) +
  7263. (uint8[i + 2] & 0xFF)
  7264. output.push(tripletToBase64(tmp))
  7265. }
  7266. return output.join('')
  7267. }
  7268. function fromByteArray (uint8) {
  7269. var tmp
  7270. var len = uint8.length
  7271. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  7272. var parts = []
  7273. var maxChunkLength = 16383 // must be multiple of 3
  7274. // go through the array every three bytes, we'll deal with trailing stuff later
  7275. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  7276. parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
  7277. }
  7278. // pad the end with zeros, but make sure to not forget the extra bytes
  7279. if (extraBytes === 1) {
  7280. tmp = uint8[len - 1]
  7281. parts.push(
  7282. lookup[tmp >> 2] +
  7283. lookup[(tmp << 4) & 0x3F] +
  7284. '=='
  7285. )
  7286. } else if (extraBytes === 2) {
  7287. tmp = (uint8[len - 2] << 8) + uint8[len - 1]
  7288. parts.push(
  7289. lookup[tmp >> 10] +
  7290. lookup[(tmp >> 4) & 0x3F] +
  7291. lookup[(tmp << 2) & 0x3F] +
  7292. '='
  7293. )
  7294. }
  7295. return parts.join('')
  7296. }
  7297. /***/ }),
  7298. /* 41 */
  7299. /***/ (function(module, exports) {
  7300. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  7301. var e, m
  7302. var eLen = (nBytes * 8) - mLen - 1
  7303. var eMax = (1 << eLen) - 1
  7304. var eBias = eMax >> 1
  7305. var nBits = -7
  7306. var i = isLE ? (nBytes - 1) : 0
  7307. var d = isLE ? -1 : 1
  7308. var s = buffer[offset + i]
  7309. i += d
  7310. e = s & ((1 << (-nBits)) - 1)
  7311. s >>= (-nBits)
  7312. nBits += eLen
  7313. for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  7314. m = e & ((1 << (-nBits)) - 1)
  7315. e >>= (-nBits)
  7316. nBits += mLen
  7317. for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  7318. if (e === 0) {
  7319. e = 1 - eBias
  7320. } else if (e === eMax) {
  7321. return m ? NaN : ((s ? -1 : 1) * Infinity)
  7322. } else {
  7323. m = m + Math.pow(2, mLen)
  7324. e = e - eBias
  7325. }
  7326. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  7327. }
  7328. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  7329. var e, m, c
  7330. var eLen = (nBytes * 8) - mLen - 1
  7331. var eMax = (1 << eLen) - 1
  7332. var eBias = eMax >> 1
  7333. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  7334. var i = isLE ? 0 : (nBytes - 1)
  7335. var d = isLE ? 1 : -1
  7336. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  7337. value = Math.abs(value)
  7338. if (isNaN(value) || value === Infinity) {
  7339. m = isNaN(value) ? 1 : 0
  7340. e = eMax
  7341. } else {
  7342. e = Math.floor(Math.log(value) / Math.LN2)
  7343. if (value * (c = Math.pow(2, -e)) < 1) {
  7344. e--
  7345. c *= 2
  7346. }
  7347. if (e + eBias >= 1) {
  7348. value += rt / c
  7349. } else {
  7350. value += rt * Math.pow(2, 1 - eBias)
  7351. }
  7352. if (value * c >= 2) {
  7353. e++
  7354. c /= 2
  7355. }
  7356. if (e + eBias >= eMax) {
  7357. m = 0
  7358. e = eMax
  7359. } else if (e + eBias >= 1) {
  7360. m = ((value * c) - 1) * Math.pow(2, mLen)
  7361. e = e + eBias
  7362. } else {
  7363. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  7364. e = 0
  7365. }
  7366. }
  7367. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  7368. e = (e << mLen) | m
  7369. eLen += mLen
  7370. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  7371. buffer[offset + i - d] |= s * 128
  7372. }
  7373. /***/ }),
  7374. /* 42 */
  7375. /***/ (function(module, exports) {
  7376. var toString = {}.toString;
  7377. module.exports = Array.isArray || function (arr) {
  7378. return toString.call(arr) == '[object Array]';
  7379. };
  7380. /***/ }),
  7381. /* 43 */
  7382. /***/ (function(module, exports, __webpack_require__) {
  7383. // Copyright Joyent, Inc. and other Node contributors.
  7384. //
  7385. // Permission is hereby granted, free of charge, to any person obtaining a
  7386. // copy of this software and associated documentation files (the
  7387. // "Software"), to deal in the Software without restriction, including
  7388. // without limitation the rights to use, copy, modify, merge, publish,
  7389. // distribute, sublicense, and/or sell copies of the Software, and to permit
  7390. // persons to whom the Software is furnished to do so, subject to the
  7391. // following conditions:
  7392. //
  7393. // The above copyright notice and this permission notice shall be included
  7394. // in all copies or substantial portions of the Software.
  7395. //
  7396. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  7397. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  7398. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  7399. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  7400. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  7401. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  7402. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  7403. module.exports = Stream;
  7404. var EE = __webpack_require__(44).EventEmitter;
  7405. var inherits = __webpack_require__(45);
  7406. inherits(Stream, EE);
  7407. Stream.Readable = __webpack_require__(46);
  7408. Stream.Writable = __webpack_require__(65);
  7409. Stream.Duplex = __webpack_require__(66);
  7410. Stream.Transform = __webpack_require__(67);
  7411. Stream.PassThrough = __webpack_require__(68);
  7412. // Backwards-compat with node 0.4.x
  7413. Stream.Stream = Stream;
  7414. // old-style streams. Note that the pipe method (the only relevant
  7415. // part of this class) is overridden in the Readable class.
  7416. function Stream() {
  7417. EE.call(this);
  7418. }
  7419. Stream.prototype.pipe = function(dest, options) {
  7420. var source = this;
  7421. function ondata(chunk) {
  7422. if (dest.writable) {
  7423. if (false === dest.write(chunk) && source.pause) {
  7424. source.pause();
  7425. }
  7426. }
  7427. }
  7428. source.on('data', ondata);
  7429. function ondrain() {
  7430. if (source.readable && source.resume) {
  7431. source.resume();
  7432. }
  7433. }
  7434. dest.on('drain', ondrain);
  7435. // If the 'end' option is not supplied, dest.end() will be called when
  7436. // source gets the 'end' or 'close' events. Only dest.end() once.
  7437. if (!dest._isStdio && (!options || options.end !== false)) {
  7438. source.on('end', onend);
  7439. source.on('close', onclose);
  7440. }
  7441. var didOnEnd = false;
  7442. function onend() {
  7443. if (didOnEnd) return;
  7444. didOnEnd = true;
  7445. dest.end();
  7446. }
  7447. function onclose() {
  7448. if (didOnEnd) return;
  7449. didOnEnd = true;
  7450. if (typeof dest.destroy === 'function') dest.destroy();
  7451. }
  7452. // don't leave dangling pipes when there are errors.
  7453. function onerror(er) {
  7454. cleanup();
  7455. if (EE.listenerCount(this, 'error') === 0) {
  7456. throw er; // Unhandled stream error in pipe.
  7457. }
  7458. }
  7459. source.on('error', onerror);
  7460. dest.on('error', onerror);
  7461. // remove all the event listeners that were added.
  7462. function cleanup() {
  7463. source.removeListener('data', ondata);
  7464. dest.removeListener('drain', ondrain);
  7465. source.removeListener('end', onend);
  7466. source.removeListener('close', onclose);
  7467. source.removeListener('error', onerror);
  7468. dest.removeListener('error', onerror);
  7469. source.removeListener('end', cleanup);
  7470. source.removeListener('close', cleanup);
  7471. dest.removeListener('close', cleanup);
  7472. }
  7473. source.on('end', cleanup);
  7474. source.on('close', cleanup);
  7475. dest.on('close', cleanup);
  7476. dest.emit('pipe', source);
  7477. // Allow for unix-like usage: A.pipe(B).pipe(C)
  7478. return dest;
  7479. };
  7480. /***/ }),
  7481. /* 44 */
  7482. /***/ (function(module, exports) {
  7483. // Copyright Joyent, Inc. and other Node contributors.
  7484. //
  7485. // Permission is hereby granted, free of charge, to any person obtaining a
  7486. // copy of this software and associated documentation files (the
  7487. // "Software"), to deal in the Software without restriction, including
  7488. // without limitation the rights to use, copy, modify, merge, publish,
  7489. // distribute, sublicense, and/or sell copies of the Software, and to permit
  7490. // persons to whom the Software is furnished to do so, subject to the
  7491. // following conditions:
  7492. //
  7493. // The above copyright notice and this permission notice shall be included
  7494. // in all copies or substantial portions of the Software.
  7495. //
  7496. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  7497. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  7498. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  7499. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  7500. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  7501. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  7502. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  7503. function EventEmitter() {
  7504. this._events = this._events || {};
  7505. this._maxListeners = this._maxListeners || undefined;
  7506. }
  7507. module.exports = EventEmitter;
  7508. // Backwards-compat with node 0.10.x
  7509. EventEmitter.EventEmitter = EventEmitter;
  7510. EventEmitter.prototype._events = undefined;
  7511. EventEmitter.prototype._maxListeners = undefined;
  7512. // By default EventEmitters will print a warning if more than 10 listeners are
  7513. // added to it. This is a useful default which helps finding memory leaks.
  7514. EventEmitter.defaultMaxListeners = 10;
  7515. // Obviously not all Emitters should be limited to 10. This function allows
  7516. // that to be increased. Set to zero for unlimited.
  7517. EventEmitter.prototype.setMaxListeners = function(n) {
  7518. if (!isNumber(n) || n < 0 || isNaN(n))
  7519. throw TypeError('n must be a positive number');
  7520. this._maxListeners = n;
  7521. return this;
  7522. };
  7523. EventEmitter.prototype.emit = function(type) {
  7524. var er, handler, len, args, i, listeners;
  7525. if (!this._events)
  7526. this._events = {};
  7527. // If there is no 'error' event listener then throw.
  7528. if (type === 'error') {
  7529. if (!this._events.error ||
  7530. (isObject(this._events.error) && !this._events.error.length)) {
  7531. er = arguments[1];
  7532. if (er instanceof Error) {
  7533. throw er; // Unhandled 'error' event
  7534. } else {
  7535. // At least give some kind of context to the user
  7536. var err = new Error('Uncaught, unspecified "error" event. (' + er + ')');
  7537. err.context = er;
  7538. throw err;
  7539. }
  7540. }
  7541. }
  7542. handler = this._events[type];
  7543. if (isUndefined(handler))
  7544. return false;
  7545. if (isFunction(handler)) {
  7546. switch (arguments.length) {
  7547. // fast cases
  7548. case 1:
  7549. handler.call(this);
  7550. break;
  7551. case 2:
  7552. handler.call(this, arguments[1]);
  7553. break;
  7554. case 3:
  7555. handler.call(this, arguments[1], arguments[2]);
  7556. break;
  7557. // slower
  7558. default:
  7559. args = Array.prototype.slice.call(arguments, 1);
  7560. handler.apply(this, args);
  7561. }
  7562. } else if (isObject(handler)) {
  7563. args = Array.prototype.slice.call(arguments, 1);
  7564. listeners = handler.slice();
  7565. len = listeners.length;
  7566. for (i = 0; i < len; i++)
  7567. listeners[i].apply(this, args);
  7568. }
  7569. return true;
  7570. };
  7571. EventEmitter.prototype.addListener = function(type, listener) {
  7572. var m;
  7573. if (!isFunction(listener))
  7574. throw TypeError('listener must be a function');
  7575. if (!this._events)
  7576. this._events = {};
  7577. // To avoid recursion in the case that type === "newListener"! Before
  7578. // adding it to the listeners, first emit "newListener".
  7579. if (this._events.newListener)
  7580. this.emit('newListener', type,
  7581. isFunction(listener.listener) ?
  7582. listener.listener : listener);
  7583. if (!this._events[type])
  7584. // Optimize the case of one listener. Don't need the extra array object.
  7585. this._events[type] = listener;
  7586. else if (isObject(this._events[type]))
  7587. // If we've already got an array, just append.
  7588. this._events[type].push(listener);
  7589. else
  7590. // Adding the second element, need to change to array.
  7591. this._events[type] = [this._events[type], listener];
  7592. // Check for listener leak
  7593. if (isObject(this._events[type]) && !this._events[type].warned) {
  7594. if (!isUndefined(this._maxListeners)) {
  7595. m = this._maxListeners;
  7596. } else {
  7597. m = EventEmitter.defaultMaxListeners;
  7598. }
  7599. if (m && m > 0 && this._events[type].length > m) {
  7600. this._events[type].warned = true;
  7601. console.error('(node) warning: possible EventEmitter memory ' +
  7602. 'leak detected. %d listeners added. ' +
  7603. 'Use emitter.setMaxListeners() to increase limit.',
  7604. this._events[type].length);
  7605. if (typeof console.trace === 'function') {
  7606. // not supported in IE 10
  7607. console.trace();
  7608. }
  7609. }
  7610. }
  7611. return this;
  7612. };
  7613. EventEmitter.prototype.on = EventEmitter.prototype.addListener;
  7614. EventEmitter.prototype.once = function(type, listener) {
  7615. if (!isFunction(listener))
  7616. throw TypeError('listener must be a function');
  7617. var fired = false;
  7618. function g() {
  7619. this.removeListener(type, g);
  7620. if (!fired) {
  7621. fired = true;
  7622. listener.apply(this, arguments);
  7623. }
  7624. }
  7625. g.listener = listener;
  7626. this.on(type, g);
  7627. return this;
  7628. };
  7629. // emits a 'removeListener' event iff the listener was removed
  7630. EventEmitter.prototype.removeListener = function(type, listener) {
  7631. var list, position, length, i;
  7632. if (!isFunction(listener))
  7633. throw TypeError('listener must be a function');
  7634. if (!this._events || !this._events[type])
  7635. return this;
  7636. list = this._events[type];
  7637. length = list.length;
  7638. position = -1;
  7639. if (list === listener ||
  7640. (isFunction(list.listener) && list.listener === listener)) {
  7641. delete this._events[type];
  7642. if (this._events.removeListener)
  7643. this.emit('removeListener', type, listener);
  7644. } else if (isObject(list)) {
  7645. for (i = length; i-- > 0;) {
  7646. if (list[i] === listener ||
  7647. (list[i].listener && list[i].listener === listener)) {
  7648. position = i;
  7649. break;
  7650. }
  7651. }
  7652. if (position < 0)
  7653. return this;
  7654. if (list.length === 1) {
  7655. list.length = 0;
  7656. delete this._events[type];
  7657. } else {
  7658. list.splice(position, 1);
  7659. }
  7660. if (this._events.removeListener)
  7661. this.emit('removeListener', type, listener);
  7662. }
  7663. return this;
  7664. };
  7665. EventEmitter.prototype.removeAllListeners = function(type) {
  7666. var key, listeners;
  7667. if (!this._events)
  7668. return this;
  7669. // not listening for removeListener, no need to emit
  7670. if (!this._events.removeListener) {
  7671. if (arguments.length === 0)
  7672. this._events = {};
  7673. else if (this._events[type])
  7674. delete this._events[type];
  7675. return this;
  7676. }
  7677. // emit removeListener for all listeners on all events
  7678. if (arguments.length === 0) {
  7679. for (key in this._events) {
  7680. if (key === 'removeListener') continue;
  7681. this.removeAllListeners(key);
  7682. }
  7683. this.removeAllListeners('removeListener');
  7684. this._events = {};
  7685. return this;
  7686. }
  7687. listeners = this._events[type];
  7688. if (isFunction(listeners)) {
  7689. this.removeListener(type, listeners);
  7690. } else if (listeners) {
  7691. // LIFO order
  7692. while (listeners.length)
  7693. this.removeListener(type, listeners[listeners.length - 1]);
  7694. }
  7695. delete this._events[type];
  7696. return this;
  7697. };
  7698. EventEmitter.prototype.listeners = function(type) {
  7699. var ret;
  7700. if (!this._events || !this._events[type])
  7701. ret = [];
  7702. else if (isFunction(this._events[type]))
  7703. ret = [this._events[type]];
  7704. else
  7705. ret = this._events[type].slice();
  7706. return ret;
  7707. };
  7708. EventEmitter.prototype.listenerCount = function(type) {
  7709. if (this._events) {
  7710. var evlistener = this._events[type];
  7711. if (isFunction(evlistener))
  7712. return 1;
  7713. else if (evlistener)
  7714. return evlistener.length;
  7715. }
  7716. return 0;
  7717. };
  7718. EventEmitter.listenerCount = function(emitter, type) {
  7719. return emitter.listenerCount(type);
  7720. };
  7721. function isFunction(arg) {
  7722. return typeof arg === 'function';
  7723. }
  7724. function isNumber(arg) {
  7725. return typeof arg === 'number';
  7726. }
  7727. function isObject(arg) {
  7728. return typeof arg === 'object' && arg !== null;
  7729. }
  7730. function isUndefined(arg) {
  7731. return arg === void 0;
  7732. }
  7733. /***/ }),
  7734. /* 45 */
  7735. /***/ (function(module, exports) {
  7736. if (typeof Object.create === 'function') {
  7737. // implementation from standard node.js 'util' module
  7738. module.exports = function inherits(ctor, superCtor) {
  7739. if (superCtor) {
  7740. ctor.super_ = superCtor
  7741. ctor.prototype = Object.create(superCtor.prototype, {
  7742. constructor: {
  7743. value: ctor,
  7744. enumerable: false,
  7745. writable: true,
  7746. configurable: true
  7747. }
  7748. })
  7749. }
  7750. };
  7751. } else {
  7752. // old school shim for old browsers
  7753. module.exports = function inherits(ctor, superCtor) {
  7754. if (superCtor) {
  7755. ctor.super_ = superCtor
  7756. var TempCtor = function () {}
  7757. TempCtor.prototype = superCtor.prototype
  7758. ctor.prototype = new TempCtor()
  7759. ctor.prototype.constructor = ctor
  7760. }
  7761. }
  7762. }
  7763. /***/ }),
  7764. /* 46 */
  7765. /***/ (function(module, exports, __webpack_require__) {
  7766. exports = module.exports = __webpack_require__(47);
  7767. exports.Stream = exports;
  7768. exports.Readable = exports;
  7769. exports.Writable = __webpack_require__(58);
  7770. exports.Duplex = __webpack_require__(57);
  7771. exports.Transform = __webpack_require__(63);
  7772. exports.PassThrough = __webpack_require__(64);
  7773. /***/ }),
  7774. /* 47 */
  7775. /***/ (function(module, exports, __webpack_require__) {
  7776. /* WEBPACK VAR INJECTION */(function(global, process) {// Copyright Joyent, Inc. and other Node contributors.
  7777. //
  7778. // Permission is hereby granted, free of charge, to any person obtaining a
  7779. // copy of this software and associated documentation files (the
  7780. // "Software"), to deal in the Software without restriction, including
  7781. // without limitation the rights to use, copy, modify, merge, publish,
  7782. // distribute, sublicense, and/or sell copies of the Software, and to permit
  7783. // persons to whom the Software is furnished to do so, subject to the
  7784. // following conditions:
  7785. //
  7786. // The above copyright notice and this permission notice shall be included
  7787. // in all copies or substantial portions of the Software.
  7788. //
  7789. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  7790. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  7791. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  7792. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  7793. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  7794. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  7795. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  7796. 'use strict';
  7797. /*<replacement>*/
  7798. var pna = __webpack_require__(49);
  7799. /*</replacement>*/
  7800. module.exports = Readable;
  7801. /*<replacement>*/
  7802. var isArray = __webpack_require__(42);
  7803. /*</replacement>*/
  7804. /*<replacement>*/
  7805. var Duplex;
  7806. /*</replacement>*/
  7807. Readable.ReadableState = ReadableState;
  7808. /*<replacement>*/
  7809. var EE = __webpack_require__(44).EventEmitter;
  7810. var EElistenerCount = function (emitter, type) {
  7811. return emitter.listeners(type).length;
  7812. };
  7813. /*</replacement>*/
  7814. /*<replacement>*/
  7815. var Stream = __webpack_require__(50);
  7816. /*</replacement>*/
  7817. /*<replacement>*/
  7818. var Buffer = __webpack_require__(51).Buffer;
  7819. var OurUint8Array = (typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}).Uint8Array || function () {};
  7820. function _uint8ArrayToBuffer(chunk) {
  7821. return Buffer.from(chunk);
  7822. }
  7823. function _isUint8Array(obj) {
  7824. return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
  7825. }
  7826. /*</replacement>*/
  7827. /*<replacement>*/
  7828. var util = Object.create(__webpack_require__(52));
  7829. util.inherits = __webpack_require__(45);
  7830. /*</replacement>*/
  7831. /*<replacement>*/
  7832. var debugUtil = __webpack_require__(53);
  7833. var debug = void 0;
  7834. if (debugUtil && debugUtil.debuglog) {
  7835. debug = debugUtil.debuglog('stream');
  7836. } else {
  7837. debug = function () {};
  7838. }
  7839. /*</replacement>*/
  7840. var BufferList = __webpack_require__(54);
  7841. var destroyImpl = __webpack_require__(56);
  7842. var StringDecoder;
  7843. util.inherits(Readable, Stream);
  7844. var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
  7845. function prependListener(emitter, event, fn) {
  7846. // Sadly this is not cacheable as some libraries bundle their own
  7847. // event emitter implementation with them.
  7848. if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);
  7849. // This is a hack to make sure that our error handler is attached before any
  7850. // userland ones. NEVER DO THIS. This is here only because this code needs
  7851. // to continue to work with older versions of Node.js that do not include
  7852. // the prependListener() method. The goal is to eventually remove this hack.
  7853. 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]];
  7854. }
  7855. function ReadableState(options, stream) {
  7856. Duplex = Duplex || __webpack_require__(57);
  7857. options = options || {};
  7858. // Duplex streams are both readable and writable, but share
  7859. // the same options object.
  7860. // However, some cases require setting options to different
  7861. // values for the readable and the writable sides of the duplex stream.
  7862. // These options can be provided separately as readableXXX and writableXXX.
  7863. var isDuplex = stream instanceof Duplex;
  7864. // object stream flag. Used to make read(n) ignore n and to
  7865. // make all the buffer merging and length checks go away
  7866. this.objectMode = !!options.objectMode;
  7867. if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
  7868. // the point at which it stops calling _read() to fill the buffer
  7869. // Note: 0 is a valid value, means "don't call _read preemptively ever"
  7870. var hwm = options.highWaterMark;
  7871. var readableHwm = options.readableHighWaterMark;
  7872. var defaultHwm = this.objectMode ? 16 : 16 * 1024;
  7873. if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;
  7874. // cast to ints.
  7875. this.highWaterMark = Math.floor(this.highWaterMark);
  7876. // A linked list is used to store data chunks instead of an array because the
  7877. // linked list can remove elements from the beginning faster than
  7878. // array.shift()
  7879. this.buffer = new BufferList();
  7880. this.length = 0;
  7881. this.pipes = null;
  7882. this.pipesCount = 0;
  7883. this.flowing = null;
  7884. this.ended = false;
  7885. this.endEmitted = false;
  7886. this.reading = false;
  7887. // a flag to be able to tell if the event 'readable'/'data' is emitted
  7888. // immediately, or on a later tick. We set this to true at first, because
  7889. // any actions that shouldn't happen until "later" should generally also
  7890. // not happen before the first read call.
  7891. this.sync = true;
  7892. // whenever we return null, then we set a flag to say
  7893. // that we're awaiting a 'readable' event emission.
  7894. this.needReadable = false;
  7895. this.emittedReadable = false;
  7896. this.readableListening = false;
  7897. this.resumeScheduled = false;
  7898. // has it been destroyed
  7899. this.destroyed = false;
  7900. // Crypto is kind of old and crusty. Historically, its default string
  7901. // encoding is 'binary' so we have to make this configurable.
  7902. // Everything else in the universe uses 'utf8', though.
  7903. this.defaultEncoding = options.defaultEncoding || 'utf8';
  7904. // the number of writers that are awaiting a drain event in .pipe()s
  7905. this.awaitDrain = 0;
  7906. // if true, a maybeReadMore has been scheduled
  7907. this.readingMore = false;
  7908. this.decoder = null;
  7909. this.encoding = null;
  7910. if (options.encoding) {
  7911. if (!StringDecoder) StringDecoder = __webpack_require__(62).StringDecoder;
  7912. this.decoder = new StringDecoder(options.encoding);
  7913. this.encoding = options.encoding;
  7914. }
  7915. }
  7916. function Readable(options) {
  7917. Duplex = Duplex || __webpack_require__(57);
  7918. if (!(this instanceof Readable)) return new Readable(options);
  7919. this._readableState = new ReadableState(options, this);
  7920. // legacy
  7921. this.readable = true;
  7922. if (options) {
  7923. if (typeof options.read === 'function') this._read = options.read;
  7924. if (typeof options.destroy === 'function') this._destroy = options.destroy;
  7925. }
  7926. Stream.call(this);
  7927. }
  7928. Object.defineProperty(Readable.prototype, 'destroyed', {
  7929. get: function () {
  7930. if (this._readableState === undefined) {
  7931. return false;
  7932. }
  7933. return this._readableState.destroyed;
  7934. },
  7935. set: function (value) {
  7936. // we ignore the value if the stream
  7937. // has not been initialized yet
  7938. if (!this._readableState) {
  7939. return;
  7940. }
  7941. // backward compatibility, the user is explicitly
  7942. // managing destroyed
  7943. this._readableState.destroyed = value;
  7944. }
  7945. });
  7946. Readable.prototype.destroy = destroyImpl.destroy;
  7947. Readable.prototype._undestroy = destroyImpl.undestroy;
  7948. Readable.prototype._destroy = function (err, cb) {
  7949. this.push(null);
  7950. cb(err);
  7951. };
  7952. // Manually shove something into the read() buffer.
  7953. // This returns true if the highWaterMark has not been hit yet,
  7954. // similar to how Writable.write() returns true if you should
  7955. // write() some more.
  7956. Readable.prototype.push = function (chunk, encoding) {
  7957. var state = this._readableState;
  7958. var skipChunkCheck;
  7959. if (!state.objectMode) {
  7960. if (typeof chunk === 'string') {
  7961. encoding = encoding || state.defaultEncoding;
  7962. if (encoding !== state.encoding) {
  7963. chunk = Buffer.from(chunk, encoding);
  7964. encoding = '';
  7965. }
  7966. skipChunkCheck = true;
  7967. }
  7968. } else {
  7969. skipChunkCheck = true;
  7970. }
  7971. return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
  7972. };
  7973. // Unshift should *always* be something directly out of read()
  7974. Readable.prototype.unshift = function (chunk) {
  7975. return readableAddChunk(this, chunk, null, true, false);
  7976. };
  7977. function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
  7978. var state = stream._readableState;
  7979. if (chunk === null) {
  7980. state.reading = false;
  7981. onEofChunk(stream, state);
  7982. } else {
  7983. var er;
  7984. if (!skipChunkCheck) er = chunkInvalid(state, chunk);
  7985. if (er) {
  7986. stream.emit('error', er);
  7987. } else if (state.objectMode || chunk && chunk.length > 0) {
  7988. if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
  7989. chunk = _uint8ArrayToBuffer(chunk);
  7990. }
  7991. if (addToFront) {
  7992. if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);
  7993. } else if (state.ended) {
  7994. stream.emit('error', new Error('stream.push() after EOF'));
  7995. } else {
  7996. state.reading = false;
  7997. if (state.decoder && !encoding) {
  7998. chunk = state.decoder.write(chunk);
  7999. if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
  8000. } else {
  8001. addChunk(stream, state, chunk, false);
  8002. }
  8003. }
  8004. } else if (!addToFront) {
  8005. state.reading = false;
  8006. }
  8007. }
  8008. return needMoreData(state);
  8009. }
  8010. function addChunk(stream, state, chunk, addToFront) {
  8011. if (state.flowing && state.length === 0 && !state.sync) {
  8012. stream.emit('data', chunk);
  8013. stream.read(0);
  8014. } else {
  8015. // update the buffer info.
  8016. state.length += state.objectMode ? 1 : chunk.length;
  8017. if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
  8018. if (state.needReadable) emitReadable(stream);
  8019. }
  8020. maybeReadMore(stream, state);
  8021. }
  8022. function chunkInvalid(state, chunk) {
  8023. var er;
  8024. if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
  8025. er = new TypeError('Invalid non-string/buffer chunk');
  8026. }
  8027. return er;
  8028. }
  8029. // if it's past the high water mark, we can push in some more.
  8030. // Also, if we have no data yet, we can stand some
  8031. // more bytes. This is to work around cases where hwm=0,
  8032. // such as the repl. Also, if the push() triggered a
  8033. // readable event, and the user called read(largeNumber) such that
  8034. // needReadable was set, then we ought to push more, so that another
  8035. // 'readable' event will be triggered.
  8036. function needMoreData(state) {
  8037. return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
  8038. }
  8039. Readable.prototype.isPaused = function () {
  8040. return this._readableState.flowing === false;
  8041. };
  8042. // backwards compatibility.
  8043. Readable.prototype.setEncoding = function (enc) {
  8044. if (!StringDecoder) StringDecoder = __webpack_require__(62).StringDecoder;
  8045. this._readableState.decoder = new StringDecoder(enc);
  8046. this._readableState.encoding = enc;
  8047. return this;
  8048. };
  8049. // Don't raise the hwm > 8MB
  8050. var MAX_HWM = 0x800000;
  8051. function computeNewHighWaterMark(n) {
  8052. if (n >= MAX_HWM) {
  8053. n = MAX_HWM;
  8054. } else {
  8055. // Get the next highest power of 2 to prevent increasing hwm excessively in
  8056. // tiny amounts
  8057. n--;
  8058. n |= n >>> 1;
  8059. n |= n >>> 2;
  8060. n |= n >>> 4;
  8061. n |= n >>> 8;
  8062. n |= n >>> 16;
  8063. n++;
  8064. }
  8065. return n;
  8066. }
  8067. // This function is designed to be inlinable, so please take care when making
  8068. // changes to the function body.
  8069. function howMuchToRead(n, state) {
  8070. if (n <= 0 || state.length === 0 && state.ended) return 0;
  8071. if (state.objectMode) return 1;
  8072. if (n !== n) {
  8073. // Only flow one buffer at a time
  8074. if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
  8075. }
  8076. // If we're asking for more than the current hwm, then raise the hwm.
  8077. if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
  8078. if (n <= state.length) return n;
  8079. // Don't have enough
  8080. if (!state.ended) {
  8081. state.needReadable = true;
  8082. return 0;
  8083. }
  8084. return state.length;
  8085. }
  8086. // you can override either this method, or the async _read(n) below.
  8087. Readable.prototype.read = function (n) {
  8088. debug('read', n);
  8089. n = parseInt(n, 10);
  8090. var state = this._readableState;
  8091. var nOrig = n;
  8092. if (n !== 0) state.emittedReadable = false;
  8093. // if we're doing read(0) to trigger a readable event, but we
  8094. // already have a bunch of data in the buffer, then just trigger
  8095. // the 'readable' event and move on.
  8096. if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
  8097. debug('read: emitReadable', state.length, state.ended);
  8098. if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
  8099. return null;
  8100. }
  8101. n = howMuchToRead(n, state);
  8102. // if we've ended, and we're now clear, then finish it up.
  8103. if (n === 0 && state.ended) {
  8104. if (state.length === 0) endReadable(this);
  8105. return null;
  8106. }
  8107. // All the actual chunk generation logic needs to be
  8108. // *below* the call to _read. The reason is that in certain
  8109. // synthetic stream cases, such as passthrough streams, _read
  8110. // may be a completely synchronous operation which may change
  8111. // the state of the read buffer, providing enough data when
  8112. // before there was *not* enough.
  8113. //
  8114. // So, the steps are:
  8115. // 1. Figure out what the state of things will be after we do
  8116. // a read from the buffer.
  8117. //
  8118. // 2. If that resulting state will trigger a _read, then call _read.
  8119. // Note that this may be asynchronous, or synchronous. Yes, it is
  8120. // deeply ugly to write APIs this way, but that still doesn't mean
  8121. // that the Readable class should behave improperly, as streams are
  8122. // designed to be sync/async agnostic.
  8123. // Take note if the _read call is sync or async (ie, if the read call
  8124. // has returned yet), so that we know whether or not it's safe to emit
  8125. // 'readable' etc.
  8126. //
  8127. // 3. Actually pull the requested chunks out of the buffer and return.
  8128. // if we need a readable event, then we need to do some reading.
  8129. var doRead = state.needReadable;
  8130. debug('need readable', doRead);
  8131. // if we currently have less than the highWaterMark, then also read some
  8132. if (state.length === 0 || state.length - n < state.highWaterMark) {
  8133. doRead = true;
  8134. debug('length less than watermark', doRead);
  8135. }
  8136. // however, if we've ended, then there's no point, and if we're already
  8137. // reading, then it's unnecessary.
  8138. if (state.ended || state.reading) {
  8139. doRead = false;
  8140. debug('reading or ended', doRead);
  8141. } else if (doRead) {
  8142. debug('do read');
  8143. state.reading = true;
  8144. state.sync = true;
  8145. // if the length is currently zero, then we *need* a readable event.
  8146. if (state.length === 0) state.needReadable = true;
  8147. // call internal read method
  8148. this._read(state.highWaterMark);
  8149. state.sync = false;
  8150. // If _read pushed data synchronously, then `reading` will be false,
  8151. // and we need to re-evaluate how much data we can return to the user.
  8152. if (!state.reading) n = howMuchToRead(nOrig, state);
  8153. }
  8154. var ret;
  8155. if (n > 0) ret = fromList(n, state);else ret = null;
  8156. if (ret === null) {
  8157. state.needReadable = true;
  8158. n = 0;
  8159. } else {
  8160. state.length -= n;
  8161. }
  8162. if (state.length === 0) {
  8163. // If we have nothing in the buffer, then we want to know
  8164. // as soon as we *do* get something into the buffer.
  8165. if (!state.ended) state.needReadable = true;
  8166. // If we tried to read() past the EOF, then emit end on the next tick.
  8167. if (nOrig !== n && state.ended) endReadable(this);
  8168. }
  8169. if (ret !== null) this.emit('data', ret);
  8170. return ret;
  8171. };
  8172. function onEofChunk(stream, state) {
  8173. if (state.ended) return;
  8174. if (state.decoder) {
  8175. var chunk = state.decoder.end();
  8176. if (chunk && chunk.length) {
  8177. state.buffer.push(chunk);
  8178. state.length += state.objectMode ? 1 : chunk.length;
  8179. }
  8180. }
  8181. state.ended = true;
  8182. // emit 'readable' now to make sure it gets picked up.
  8183. emitReadable(stream);
  8184. }
  8185. // Don't emit readable right away in sync mode, because this can trigger
  8186. // another read() call => stack overflow. This way, it might trigger
  8187. // a nextTick recursion warning, but that's not so bad.
  8188. function emitReadable(stream) {
  8189. var state = stream._readableState;
  8190. state.needReadable = false;
  8191. if (!state.emittedReadable) {
  8192. debug('emitReadable', state.flowing);
  8193. state.emittedReadable = true;
  8194. if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);
  8195. }
  8196. }
  8197. function emitReadable_(stream) {
  8198. debug('emit readable');
  8199. stream.emit('readable');
  8200. flow(stream);
  8201. }
  8202. // at this point, the user has presumably seen the 'readable' event,
  8203. // and called read() to consume some data. that may have triggered
  8204. // in turn another _read(n) call, in which case reading = true if
  8205. // it's in progress.
  8206. // However, if we're not ended, or reading, and the length < hwm,
  8207. // then go ahead and try to read some more preemptively.
  8208. function maybeReadMore(stream, state) {
  8209. if (!state.readingMore) {
  8210. state.readingMore = true;
  8211. pna.nextTick(maybeReadMore_, stream, state);
  8212. }
  8213. }
  8214. function maybeReadMore_(stream, state) {
  8215. var len = state.length;
  8216. while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
  8217. debug('maybeReadMore read 0');
  8218. stream.read(0);
  8219. if (len === state.length)
  8220. // didn't get any data, stop spinning.
  8221. break;else len = state.length;
  8222. }
  8223. state.readingMore = false;
  8224. }
  8225. // abstract method. to be overridden in specific implementation classes.
  8226. // call cb(er, data) where data is <= n in length.
  8227. // for virtual (non-string, non-buffer) streams, "length" is somewhat
  8228. // arbitrary, and perhaps not very meaningful.
  8229. Readable.prototype._read = function (n) {
  8230. this.emit('error', new Error('_read() is not implemented'));
  8231. };
  8232. Readable.prototype.pipe = function (dest, pipeOpts) {
  8233. var src = this;
  8234. var state = this._readableState;
  8235. switch (state.pipesCount) {
  8236. case 0:
  8237. state.pipes = dest;
  8238. break;
  8239. case 1:
  8240. state.pipes = [state.pipes, dest];
  8241. break;
  8242. default:
  8243. state.pipes.push(dest);
  8244. break;
  8245. }
  8246. state.pipesCount += 1;
  8247. debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
  8248. var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
  8249. var endFn = doEnd ? onend : unpipe;
  8250. if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);
  8251. dest.on('unpipe', onunpipe);
  8252. function onunpipe(readable, unpipeInfo) {
  8253. debug('onunpipe');
  8254. if (readable === src) {
  8255. if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
  8256. unpipeInfo.hasUnpiped = true;
  8257. cleanup();
  8258. }
  8259. }
  8260. }
  8261. function onend() {
  8262. debug('onend');
  8263. dest.end();
  8264. }
  8265. // when the dest drains, it reduces the awaitDrain counter
  8266. // on the source. This would be more elegant with a .once()
  8267. // handler in flow(), but adding and removing repeatedly is
  8268. // too slow.
  8269. var ondrain = pipeOnDrain(src);
  8270. dest.on('drain', ondrain);
  8271. var cleanedUp = false;
  8272. function cleanup() {
  8273. debug('cleanup');
  8274. // cleanup event handlers once the pipe is broken
  8275. dest.removeListener('close', onclose);
  8276. dest.removeListener('finish', onfinish);
  8277. dest.removeListener('drain', ondrain);
  8278. dest.removeListener('error', onerror);
  8279. dest.removeListener('unpipe', onunpipe);
  8280. src.removeListener('end', onend);
  8281. src.removeListener('end', unpipe);
  8282. src.removeListener('data', ondata);
  8283. cleanedUp = true;
  8284. // if the reader is waiting for a drain event from this
  8285. // specific writer, then it would cause it to never start
  8286. // flowing again.
  8287. // So, if this is awaiting a drain, then we just call it now.
  8288. // If we don't know, then assume that we are waiting for one.
  8289. if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
  8290. }
  8291. // If the user pushes more data while we're writing to dest then we'll end up
  8292. // in ondata again. However, we only want to increase awaitDrain once because
  8293. // dest will only emit one 'drain' event for the multiple writes.
  8294. // => Introduce a guard on increasing awaitDrain.
  8295. var increasedAwaitDrain = false;
  8296. src.on('data', ondata);
  8297. function ondata(chunk) {
  8298. debug('ondata');
  8299. increasedAwaitDrain = false;
  8300. var ret = dest.write(chunk);
  8301. if (false === ret && !increasedAwaitDrain) {
  8302. // If the user unpiped during `dest.write()`, it is possible
  8303. // to get stuck in a permanently paused state if that write
  8304. // also returned false.
  8305. // => Check whether `dest` is still a piping destination.
  8306. if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
  8307. debug('false write response, pause', state.awaitDrain);
  8308. state.awaitDrain++;
  8309. increasedAwaitDrain = true;
  8310. }
  8311. src.pause();
  8312. }
  8313. }
  8314. // if the dest has an error, then stop piping into it.
  8315. // however, don't suppress the throwing behavior for this.
  8316. function onerror(er) {
  8317. debug('onerror', er);
  8318. unpipe();
  8319. dest.removeListener('error', onerror);
  8320. if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
  8321. }
  8322. // Make sure our error handler is attached before userland ones.
  8323. prependListener(dest, 'error', onerror);
  8324. // Both close and finish should trigger unpipe, but only once.
  8325. function onclose() {
  8326. dest.removeListener('finish', onfinish);
  8327. unpipe();
  8328. }
  8329. dest.once('close', onclose);
  8330. function onfinish() {
  8331. debug('onfinish');
  8332. dest.removeListener('close', onclose);
  8333. unpipe();
  8334. }
  8335. dest.once('finish', onfinish);
  8336. function unpipe() {
  8337. debug('unpipe');
  8338. src.unpipe(dest);
  8339. }
  8340. // tell the dest that it's being piped to
  8341. dest.emit('pipe', src);
  8342. // start the flow if it hasn't been started already.
  8343. if (!state.flowing) {
  8344. debug('pipe resume');
  8345. src.resume();
  8346. }
  8347. return dest;
  8348. };
  8349. function pipeOnDrain(src) {
  8350. return function () {
  8351. var state = src._readableState;
  8352. debug('pipeOnDrain', state.awaitDrain);
  8353. if (state.awaitDrain) state.awaitDrain--;
  8354. if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
  8355. state.flowing = true;
  8356. flow(src);
  8357. }
  8358. };
  8359. }
  8360. Readable.prototype.unpipe = function (dest) {
  8361. var state = this._readableState;
  8362. var unpipeInfo = { hasUnpiped: false };
  8363. // if we're not piping anywhere, then do nothing.
  8364. if (state.pipesCount === 0) return this;
  8365. // just one destination. most common case.
  8366. if (state.pipesCount === 1) {
  8367. // passed in one, but it's not the right one.
  8368. if (dest && dest !== state.pipes) return this;
  8369. if (!dest) dest = state.pipes;
  8370. // got a match.
  8371. state.pipes = null;
  8372. state.pipesCount = 0;
  8373. state.flowing = false;
  8374. if (dest) dest.emit('unpipe', this, unpipeInfo);
  8375. return this;
  8376. }
  8377. // slow case. multiple pipe destinations.
  8378. if (!dest) {
  8379. // remove all.
  8380. var dests = state.pipes;
  8381. var len = state.pipesCount;
  8382. state.pipes = null;
  8383. state.pipesCount = 0;
  8384. state.flowing = false;
  8385. for (var i = 0; i < len; i++) {
  8386. dests[i].emit('unpipe', this, { hasUnpiped: false });
  8387. }return this;
  8388. }
  8389. // try to find the right one.
  8390. var index = indexOf(state.pipes, dest);
  8391. if (index === -1) return this;
  8392. state.pipes.splice(index, 1);
  8393. state.pipesCount -= 1;
  8394. if (state.pipesCount === 1) state.pipes = state.pipes[0];
  8395. dest.emit('unpipe', this, unpipeInfo);
  8396. return this;
  8397. };
  8398. // set up data events if they are asked for
  8399. // Ensure readable listeners eventually get something
  8400. Readable.prototype.on = function (ev, fn) {
  8401. var res = Stream.prototype.on.call(this, ev, fn);
  8402. if (ev === 'data') {
  8403. // Start flowing on next tick if stream isn't explicitly paused
  8404. if (this._readableState.flowing !== false) this.resume();
  8405. } else if (ev === 'readable') {
  8406. var state = this._readableState;
  8407. if (!state.endEmitted && !state.readableListening) {
  8408. state.readableListening = state.needReadable = true;
  8409. state.emittedReadable = false;
  8410. if (!state.reading) {
  8411. pna.nextTick(nReadingNextTick, this);
  8412. } else if (state.length) {
  8413. emitReadable(this);
  8414. }
  8415. }
  8416. }
  8417. return res;
  8418. };
  8419. Readable.prototype.addListener = Readable.prototype.on;
  8420. function nReadingNextTick(self) {
  8421. debug('readable nexttick read 0');
  8422. self.read(0);
  8423. }
  8424. // pause() and resume() are remnants of the legacy readable stream API
  8425. // If the user uses them, then switch into old mode.
  8426. Readable.prototype.resume = function () {
  8427. var state = this._readableState;
  8428. if (!state.flowing) {
  8429. debug('resume');
  8430. state.flowing = true;
  8431. resume(this, state);
  8432. }
  8433. return this;
  8434. };
  8435. function resume(stream, state) {
  8436. if (!state.resumeScheduled) {
  8437. state.resumeScheduled = true;
  8438. pna.nextTick(resume_, stream, state);
  8439. }
  8440. }
  8441. function resume_(stream, state) {
  8442. if (!state.reading) {
  8443. debug('resume read 0');
  8444. stream.read(0);
  8445. }
  8446. state.resumeScheduled = false;
  8447. state.awaitDrain = 0;
  8448. stream.emit('resume');
  8449. flow(stream);
  8450. if (state.flowing && !state.reading) stream.read(0);
  8451. }
  8452. Readable.prototype.pause = function () {
  8453. debug('call pause flowing=%j', this._readableState.flowing);
  8454. if (false !== this._readableState.flowing) {
  8455. debug('pause');
  8456. this._readableState.flowing = false;
  8457. this.emit('pause');
  8458. }
  8459. return this;
  8460. };
  8461. function flow(stream) {
  8462. var state = stream._readableState;
  8463. debug('flow', state.flowing);
  8464. while (state.flowing && stream.read() !== null) {}
  8465. }
  8466. // wrap an old-style stream as the async data source.
  8467. // This is *not* part of the readable stream interface.
  8468. // It is an ugly unfortunate mess of history.
  8469. Readable.prototype.wrap = function (stream) {
  8470. var _this = this;
  8471. var state = this._readableState;
  8472. var paused = false;
  8473. stream.on('end', function () {
  8474. debug('wrapped end');
  8475. if (state.decoder && !state.ended) {
  8476. var chunk = state.decoder.end();
  8477. if (chunk && chunk.length) _this.push(chunk);
  8478. }
  8479. _this.push(null);
  8480. });
  8481. stream.on('data', function (chunk) {
  8482. debug('wrapped data');
  8483. if (state.decoder) chunk = state.decoder.write(chunk);
  8484. // don't skip over falsy values in objectMode
  8485. if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
  8486. var ret = _this.push(chunk);
  8487. if (!ret) {
  8488. paused = true;
  8489. stream.pause();
  8490. }
  8491. });
  8492. // proxy all the other methods.
  8493. // important when wrapping filters and duplexes.
  8494. for (var i in stream) {
  8495. if (this[i] === undefined && typeof stream[i] === 'function') {
  8496. this[i] = function (method) {
  8497. return function () {
  8498. return stream[method].apply(stream, arguments);
  8499. };
  8500. }(i);
  8501. }
  8502. }
  8503. // proxy certain important events.
  8504. for (var n = 0; n < kProxyEvents.length; n++) {
  8505. stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
  8506. }
  8507. // when we try to consume some more bytes, simply unpause the
  8508. // underlying stream.
  8509. this._read = function (n) {
  8510. debug('wrapped _read', n);
  8511. if (paused) {
  8512. paused = false;
  8513. stream.resume();
  8514. }
  8515. };
  8516. return this;
  8517. };
  8518. Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
  8519. // making it explicit this property is not enumerable
  8520. // because otherwise some prototype manipulation in
  8521. // userland will fail
  8522. enumerable: false,
  8523. get: function () {
  8524. return this._readableState.highWaterMark;
  8525. }
  8526. });
  8527. // exposed for testing purposes only.
  8528. Readable._fromList = fromList;
  8529. // Pluck off n bytes from an array of buffers.
  8530. // Length is the combined lengths of all the buffers in the list.
  8531. // This function is designed to be inlinable, so please take care when making
  8532. // changes to the function body.
  8533. function fromList(n, state) {
  8534. // nothing buffered
  8535. if (state.length === 0) return null;
  8536. var ret;
  8537. if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
  8538. // read it all, truncate the list
  8539. 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);
  8540. state.buffer.clear();
  8541. } else {
  8542. // read part of list
  8543. ret = fromListPartial(n, state.buffer, state.decoder);
  8544. }
  8545. return ret;
  8546. }
  8547. // Extracts only enough buffered data to satisfy the amount requested.
  8548. // This function is designed to be inlinable, so please take care when making
  8549. // changes to the function body.
  8550. function fromListPartial(n, list, hasStrings) {
  8551. var ret;
  8552. if (n < list.head.data.length) {
  8553. // slice is the same for buffers and strings
  8554. ret = list.head.data.slice(0, n);
  8555. list.head.data = list.head.data.slice(n);
  8556. } else if (n === list.head.data.length) {
  8557. // first chunk is a perfect match
  8558. ret = list.shift();
  8559. } else {
  8560. // result spans more than one buffer
  8561. ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
  8562. }
  8563. return ret;
  8564. }
  8565. // Copies a specified amount of characters from the list of buffered data
  8566. // chunks.
  8567. // This function is designed to be inlinable, so please take care when making
  8568. // changes to the function body.
  8569. function copyFromBufferString(n, list) {
  8570. var p = list.head;
  8571. var c = 1;
  8572. var ret = p.data;
  8573. n -= ret.length;
  8574. while (p = p.next) {
  8575. var str = p.data;
  8576. var nb = n > str.length ? str.length : n;
  8577. if (nb === str.length) ret += str;else ret += str.slice(0, n);
  8578. n -= nb;
  8579. if (n === 0) {
  8580. if (nb === str.length) {
  8581. ++c;
  8582. if (p.next) list.head = p.next;else list.head = list.tail = null;
  8583. } else {
  8584. list.head = p;
  8585. p.data = str.slice(nb);
  8586. }
  8587. break;
  8588. }
  8589. ++c;
  8590. }
  8591. list.length -= c;
  8592. return ret;
  8593. }
  8594. // Copies a specified amount of bytes from the list of buffered data chunks.
  8595. // This function is designed to be inlinable, so please take care when making
  8596. // changes to the function body.
  8597. function copyFromBuffer(n, list) {
  8598. var ret = Buffer.allocUnsafe(n);
  8599. var p = list.head;
  8600. var c = 1;
  8601. p.data.copy(ret);
  8602. n -= p.data.length;
  8603. while (p = p.next) {
  8604. var buf = p.data;
  8605. var nb = n > buf.length ? buf.length : n;
  8606. buf.copy(ret, ret.length - n, 0, nb);
  8607. n -= nb;
  8608. if (n === 0) {
  8609. if (nb === buf.length) {
  8610. ++c;
  8611. if (p.next) list.head = p.next;else list.head = list.tail = null;
  8612. } else {
  8613. list.head = p;
  8614. p.data = buf.slice(nb);
  8615. }
  8616. break;
  8617. }
  8618. ++c;
  8619. }
  8620. list.length -= c;
  8621. return ret;
  8622. }
  8623. function endReadable(stream) {
  8624. var state = stream._readableState;
  8625. // If we get here before consuming all the bytes, then that is a
  8626. // bug in node. Should never happen.
  8627. if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
  8628. if (!state.endEmitted) {
  8629. state.ended = true;
  8630. pna.nextTick(endReadableNT, state, stream);
  8631. }
  8632. }
  8633. function endReadableNT(state, stream) {
  8634. // Check that we didn't get one last unshift.
  8635. if (!state.endEmitted && state.length === 0) {
  8636. state.endEmitted = true;
  8637. stream.readable = false;
  8638. stream.emit('end');
  8639. }
  8640. }
  8641. function indexOf(xs, x) {
  8642. for (var i = 0, l = xs.length; i < l; i++) {
  8643. if (xs[i] === x) return i;
  8644. }
  8645. return -1;
  8646. }
  8647. /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()), __webpack_require__(48)))
  8648. /***/ }),
  8649. /* 48 */
  8650. /***/ (function(module, exports) {
  8651. // shim for using process in browser
  8652. var process = module.exports = {};
  8653. // cached from whatever global is present so that test runners that stub it
  8654. // don't break things. But we need to wrap it in a try catch in case it is
  8655. // wrapped in strict mode code which doesn't define any globals. It's inside a
  8656. // function because try/catches deoptimize in certain engines.
  8657. var cachedSetTimeout;
  8658. var cachedClearTimeout;
  8659. function defaultSetTimout() {
  8660. throw new Error('setTimeout has not been defined');
  8661. }
  8662. function defaultClearTimeout () {
  8663. throw new Error('clearTimeout has not been defined');
  8664. }
  8665. (function () {
  8666. try {
  8667. if (typeof setTimeout === 'function') {
  8668. cachedSetTimeout = setTimeout;
  8669. } else {
  8670. cachedSetTimeout = defaultSetTimout;
  8671. }
  8672. } catch (e) {
  8673. cachedSetTimeout = defaultSetTimout;
  8674. }
  8675. try {
  8676. if (typeof clearTimeout === 'function') {
  8677. cachedClearTimeout = clearTimeout;
  8678. } else {
  8679. cachedClearTimeout = defaultClearTimeout;
  8680. }
  8681. } catch (e) {
  8682. cachedClearTimeout = defaultClearTimeout;
  8683. }
  8684. } ())
  8685. function runTimeout(fun) {
  8686. if (cachedSetTimeout === setTimeout) {
  8687. //normal enviroments in sane situations
  8688. return setTimeout(fun, 0);
  8689. }
  8690. // if setTimeout wasn't available but was latter defined
  8691. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  8692. cachedSetTimeout = setTimeout;
  8693. return setTimeout(fun, 0);
  8694. }
  8695. try {
  8696. // when when somebody has screwed with setTimeout but no I.E. maddness
  8697. return cachedSetTimeout(fun, 0);
  8698. } catch(e){
  8699. try {
  8700. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  8701. return cachedSetTimeout.call(null, fun, 0);
  8702. } catch(e){
  8703. // 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
  8704. return cachedSetTimeout.call(this, fun, 0);
  8705. }
  8706. }
  8707. }
  8708. function runClearTimeout(marker) {
  8709. if (cachedClearTimeout === clearTimeout) {
  8710. //normal enviroments in sane situations
  8711. return clearTimeout(marker);
  8712. }
  8713. // if clearTimeout wasn't available but was latter defined
  8714. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  8715. cachedClearTimeout = clearTimeout;
  8716. return clearTimeout(marker);
  8717. }
  8718. try {
  8719. // when when somebody has screwed with setTimeout but no I.E. maddness
  8720. return cachedClearTimeout(marker);
  8721. } catch (e){
  8722. try {
  8723. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  8724. return cachedClearTimeout.call(null, marker);
  8725. } catch (e){
  8726. // 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.
  8727. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  8728. return cachedClearTimeout.call(this, marker);
  8729. }
  8730. }
  8731. }
  8732. var queue = [];
  8733. var draining = false;
  8734. var currentQueue;
  8735. var queueIndex = -1;
  8736. function cleanUpNextTick() {
  8737. if (!draining || !currentQueue) {
  8738. return;
  8739. }
  8740. draining = false;
  8741. if (currentQueue.length) {
  8742. queue = currentQueue.concat(queue);
  8743. } else {
  8744. queueIndex = -1;
  8745. }
  8746. if (queue.length) {
  8747. drainQueue();
  8748. }
  8749. }
  8750. function drainQueue() {
  8751. if (draining) {
  8752. return;
  8753. }
  8754. var timeout = runTimeout(cleanUpNextTick);
  8755. draining = true;
  8756. var len = queue.length;
  8757. while(len) {
  8758. currentQueue = queue;
  8759. queue = [];
  8760. while (++queueIndex < len) {
  8761. if (currentQueue) {
  8762. currentQueue[queueIndex].run();
  8763. }
  8764. }
  8765. queueIndex = -1;
  8766. len = queue.length;
  8767. }
  8768. currentQueue = null;
  8769. draining = false;
  8770. runClearTimeout(timeout);
  8771. }
  8772. process.nextTick = function (fun) {
  8773. var args = new Array(arguments.length - 1);
  8774. if (arguments.length > 1) {
  8775. for (var i = 1; i < arguments.length; i++) {
  8776. args[i - 1] = arguments[i];
  8777. }
  8778. }
  8779. queue.push(new Item(fun, args));
  8780. if (queue.length === 1 && !draining) {
  8781. runTimeout(drainQueue);
  8782. }
  8783. };
  8784. // v8 likes predictible objects
  8785. function Item(fun, array) {
  8786. this.fun = fun;
  8787. this.array = array;
  8788. }
  8789. Item.prototype.run = function () {
  8790. this.fun.apply(null, this.array);
  8791. };
  8792. process.title = 'browser';
  8793. process.browser = true;
  8794. process.env = {};
  8795. process.argv = [];
  8796. process.version = ''; // empty string to avoid regexp issues
  8797. process.versions = {};
  8798. function noop() {}
  8799. process.on = noop;
  8800. process.addListener = noop;
  8801. process.once = noop;
  8802. process.off = noop;
  8803. process.removeListener = noop;
  8804. process.removeAllListeners = noop;
  8805. process.emit = noop;
  8806. process.prependListener = noop;
  8807. process.prependOnceListener = noop;
  8808. process.listeners = function (name) { return [] }
  8809. process.binding = function (name) {
  8810. throw new Error('process.binding is not supported');
  8811. };
  8812. process.cwd = function () { return '/' };
  8813. process.chdir = function (dir) {
  8814. throw new Error('process.chdir is not supported');
  8815. };
  8816. process.umask = function() { return 0; };
  8817. /***/ }),
  8818. /* 49 */
  8819. /***/ (function(module, exports, __webpack_require__) {
  8820. /* WEBPACK VAR INJECTION */(function(process) {'use strict';
  8821. if (typeof process === 'undefined' ||
  8822. !process.version ||
  8823. process.version.indexOf('v0.') === 0 ||
  8824. process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
  8825. module.exports = { nextTick: nextTick };
  8826. } else {
  8827. module.exports = process
  8828. }
  8829. function nextTick(fn, arg1, arg2, arg3) {
  8830. if (typeof fn !== 'function') {
  8831. throw new TypeError('"callback" argument must be a function');
  8832. }
  8833. var len = arguments.length;
  8834. var args, i;
  8835. switch (len) {
  8836. case 0:
  8837. case 1:
  8838. return process.nextTick(fn);
  8839. case 2:
  8840. return process.nextTick(function afterTickOne() {
  8841. fn.call(null, arg1);
  8842. });
  8843. case 3:
  8844. return process.nextTick(function afterTickTwo() {
  8845. fn.call(null, arg1, arg2);
  8846. });
  8847. case 4:
  8848. return process.nextTick(function afterTickThree() {
  8849. fn.call(null, arg1, arg2, arg3);
  8850. });
  8851. default:
  8852. args = new Array(len - 1);
  8853. i = 0;
  8854. while (i < args.length) {
  8855. args[i++] = arguments[i];
  8856. }
  8857. return process.nextTick(function afterTick() {
  8858. fn.apply(null, args);
  8859. });
  8860. }
  8861. }
  8862. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(48)))
  8863. /***/ }),
  8864. /* 50 */
  8865. /***/ (function(module, exports, __webpack_require__) {
  8866. module.exports = __webpack_require__(44).EventEmitter;
  8867. /***/ }),
  8868. /* 51 */
  8869. /***/ (function(module, exports, __webpack_require__) {
  8870. /* eslint-disable node/no-deprecated-api */
  8871. var buffer = __webpack_require__(39)
  8872. var Buffer = buffer.Buffer
  8873. // alternative to using Object.keys for old browsers
  8874. function copyProps (src, dst) {
  8875. for (var key in src) {
  8876. dst[key] = src[key]
  8877. }
  8878. }
  8879. if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
  8880. module.exports = buffer
  8881. } else {
  8882. // Copy properties from require('buffer')
  8883. copyProps(buffer, exports)
  8884. exports.Buffer = SafeBuffer
  8885. }
  8886. function SafeBuffer (arg, encodingOrOffset, length) {
  8887. return Buffer(arg, encodingOrOffset, length)
  8888. }
  8889. // Copy static methods from Buffer
  8890. copyProps(Buffer, SafeBuffer)
  8891. SafeBuffer.from = function (arg, encodingOrOffset, length) {
  8892. if (typeof arg === 'number') {
  8893. throw new TypeError('Argument must not be a number')
  8894. }
  8895. return Buffer(arg, encodingOrOffset, length)
  8896. }
  8897. SafeBuffer.alloc = function (size, fill, encoding) {
  8898. if (typeof size !== 'number') {
  8899. throw new TypeError('Argument must be a number')
  8900. }
  8901. var buf = Buffer(size)
  8902. if (fill !== undefined) {
  8903. if (typeof encoding === 'string') {
  8904. buf.fill(fill, encoding)
  8905. } else {
  8906. buf.fill(fill)
  8907. }
  8908. } else {
  8909. buf.fill(0)
  8910. }
  8911. return buf
  8912. }
  8913. SafeBuffer.allocUnsafe = function (size) {
  8914. if (typeof size !== 'number') {
  8915. throw new TypeError('Argument must be a number')
  8916. }
  8917. return Buffer(size)
  8918. }
  8919. SafeBuffer.allocUnsafeSlow = function (size) {
  8920. if (typeof size !== 'number') {
  8921. throw new TypeError('Argument must be a number')
  8922. }
  8923. return buffer.SlowBuffer(size)
  8924. }
  8925. /***/ }),
  8926. /* 52 */
  8927. /***/ (function(module, exports, __webpack_require__) {
  8928. // Copyright Joyent, Inc. and other Node contributors.
  8929. //
  8930. // Permission is hereby granted, free of charge, to any person obtaining a
  8931. // copy of this software and associated documentation files (the
  8932. // "Software"), to deal in the Software without restriction, including
  8933. // without limitation the rights to use, copy, modify, merge, publish,
  8934. // distribute, sublicense, and/or sell copies of the Software, and to permit
  8935. // persons to whom the Software is furnished to do so, subject to the
  8936. // following conditions:
  8937. //
  8938. // The above copyright notice and this permission notice shall be included
  8939. // in all copies or substantial portions of the Software.
  8940. //
  8941. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  8942. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  8943. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  8944. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  8945. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  8946. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  8947. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  8948. // NOTE: These type checking functions intentionally don't use `instanceof`
  8949. // because it is fragile and can be easily faked with `Object.create()`.
  8950. function isArray(arg) {
  8951. if (Array.isArray) {
  8952. return Array.isArray(arg);
  8953. }
  8954. return objectToString(arg) === '[object Array]';
  8955. }
  8956. exports.isArray = isArray;
  8957. function isBoolean(arg) {
  8958. return typeof arg === 'boolean';
  8959. }
  8960. exports.isBoolean = isBoolean;
  8961. function isNull(arg) {
  8962. return arg === null;
  8963. }
  8964. exports.isNull = isNull;
  8965. function isNullOrUndefined(arg) {
  8966. return arg == null;
  8967. }
  8968. exports.isNullOrUndefined = isNullOrUndefined;
  8969. function isNumber(arg) {
  8970. return typeof arg === 'number';
  8971. }
  8972. exports.isNumber = isNumber;
  8973. function isString(arg) {
  8974. return typeof arg === 'string';
  8975. }
  8976. exports.isString = isString;
  8977. function isSymbol(arg) {
  8978. return typeof arg === 'symbol';
  8979. }
  8980. exports.isSymbol = isSymbol;
  8981. function isUndefined(arg) {
  8982. return arg === void 0;
  8983. }
  8984. exports.isUndefined = isUndefined;
  8985. function isRegExp(re) {
  8986. return objectToString(re) === '[object RegExp]';
  8987. }
  8988. exports.isRegExp = isRegExp;
  8989. function isObject(arg) {
  8990. return typeof arg === 'object' && arg !== null;
  8991. }
  8992. exports.isObject = isObject;
  8993. function isDate(d) {
  8994. return objectToString(d) === '[object Date]';
  8995. }
  8996. exports.isDate = isDate;
  8997. function isError(e) {
  8998. return (objectToString(e) === '[object Error]' || e instanceof Error);
  8999. }
  9000. exports.isError = isError;
  9001. function isFunction(arg) {
  9002. return typeof arg === 'function';
  9003. }
  9004. exports.isFunction = isFunction;
  9005. function isPrimitive(arg) {
  9006. return arg === null ||
  9007. typeof arg === 'boolean' ||
  9008. typeof arg === 'number' ||
  9009. typeof arg === 'string' ||
  9010. typeof arg === 'symbol' || // ES6 symbol
  9011. typeof arg === 'undefined';
  9012. }
  9013. exports.isPrimitive = isPrimitive;
  9014. exports.isBuffer = __webpack_require__(39).Buffer.isBuffer;
  9015. function objectToString(o) {
  9016. return Object.prototype.toString.call(o);
  9017. }
  9018. /***/ }),
  9019. /* 53 */
  9020. /***/ (function(module, exports) {
  9021. /* (ignored) */
  9022. /***/ }),
  9023. /* 54 */
  9024. /***/ (function(module, exports, __webpack_require__) {
  9025. 'use strict';
  9026. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9027. var Buffer = __webpack_require__(51).Buffer;
  9028. var util = __webpack_require__(55);
  9029. function copyBuffer(src, target, offset) {
  9030. src.copy(target, offset);
  9031. }
  9032. module.exports = function () {
  9033. function BufferList() {
  9034. _classCallCheck(this, BufferList);
  9035. this.head = null;
  9036. this.tail = null;
  9037. this.length = 0;
  9038. }
  9039. BufferList.prototype.push = function push(v) {
  9040. var entry = { data: v, next: null };
  9041. if (this.length > 0) this.tail.next = entry;else this.head = entry;
  9042. this.tail = entry;
  9043. ++this.length;
  9044. };
  9045. BufferList.prototype.unshift = function unshift(v) {
  9046. var entry = { data: v, next: this.head };
  9047. if (this.length === 0) this.tail = entry;
  9048. this.head = entry;
  9049. ++this.length;
  9050. };
  9051. BufferList.prototype.shift = function shift() {
  9052. if (this.length === 0) return;
  9053. var ret = this.head.data;
  9054. if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
  9055. --this.length;
  9056. return ret;
  9057. };
  9058. BufferList.prototype.clear = function clear() {
  9059. this.head = this.tail = null;
  9060. this.length = 0;
  9061. };
  9062. BufferList.prototype.join = function join(s) {
  9063. if (this.length === 0) return '';
  9064. var p = this.head;
  9065. var ret = '' + p.data;
  9066. while (p = p.next) {
  9067. ret += s + p.data;
  9068. }return ret;
  9069. };
  9070. BufferList.prototype.concat = function concat(n) {
  9071. if (this.length === 0) return Buffer.alloc(0);
  9072. var ret = Buffer.allocUnsafe(n >>> 0);
  9073. var p = this.head;
  9074. var i = 0;
  9075. while (p) {
  9076. copyBuffer(p.data, ret, i);
  9077. i += p.data.length;
  9078. p = p.next;
  9079. }
  9080. return ret;
  9081. };
  9082. return BufferList;
  9083. }();
  9084. if (util && util.inspect && util.inspect.custom) {
  9085. module.exports.prototype[util.inspect.custom] = function () {
  9086. var obj = util.inspect({ length: this.length });
  9087. return this.constructor.name + ' ' + obj;
  9088. };
  9089. }
  9090. /***/ }),
  9091. /* 55 */
  9092. /***/ (function(module, exports) {
  9093. /* (ignored) */
  9094. /***/ }),
  9095. /* 56 */
  9096. /***/ (function(module, exports, __webpack_require__) {
  9097. 'use strict';
  9098. /*<replacement>*/
  9099. var pna = __webpack_require__(49);
  9100. /*</replacement>*/
  9101. // undocumented cb() API, needed for core, not for public API
  9102. function destroy(err, cb) {
  9103. var _this = this;
  9104. var readableDestroyed = this._readableState && this._readableState.destroyed;
  9105. var writableDestroyed = this._writableState && this._writableState.destroyed;
  9106. if (readableDestroyed || writableDestroyed) {
  9107. if (cb) {
  9108. cb(err);
  9109. } else if (err) {
  9110. if (!this._writableState) {
  9111. pna.nextTick(emitErrorNT, this, err);
  9112. } else if (!this._writableState.errorEmitted) {
  9113. this._writableState.errorEmitted = true;
  9114. pna.nextTick(emitErrorNT, this, err);
  9115. }
  9116. }
  9117. return this;
  9118. }
  9119. // we set destroyed to true before firing error callbacks in order
  9120. // to make it re-entrance safe in case destroy() is called within callbacks
  9121. if (this._readableState) {
  9122. this._readableState.destroyed = true;
  9123. }
  9124. // if this is a duplex stream mark the writable part as destroyed as well
  9125. if (this._writableState) {
  9126. this._writableState.destroyed = true;
  9127. }
  9128. this._destroy(err || null, function (err) {
  9129. if (!cb && err) {
  9130. if (!_this._writableState) {
  9131. pna.nextTick(emitErrorNT, _this, err);
  9132. } else if (!_this._writableState.errorEmitted) {
  9133. _this._writableState.errorEmitted = true;
  9134. pna.nextTick(emitErrorNT, _this, err);
  9135. }
  9136. } else if (cb) {
  9137. cb(err);
  9138. }
  9139. });
  9140. return this;
  9141. }
  9142. function undestroy() {
  9143. if (this._readableState) {
  9144. this._readableState.destroyed = false;
  9145. this._readableState.reading = false;
  9146. this._readableState.ended = false;
  9147. this._readableState.endEmitted = false;
  9148. }
  9149. if (this._writableState) {
  9150. this._writableState.destroyed = false;
  9151. this._writableState.ended = false;
  9152. this._writableState.ending = false;
  9153. this._writableState.finalCalled = false;
  9154. this._writableState.prefinished = false;
  9155. this._writableState.finished = false;
  9156. this._writableState.errorEmitted = false;
  9157. }
  9158. }
  9159. function emitErrorNT(self, err) {
  9160. self.emit('error', err);
  9161. }
  9162. module.exports = {
  9163. destroy: destroy,
  9164. undestroy: undestroy
  9165. };
  9166. /***/ }),
  9167. /* 57 */
  9168. /***/ (function(module, exports, __webpack_require__) {
  9169. // Copyright Joyent, Inc. and other Node contributors.
  9170. //
  9171. // Permission is hereby granted, free of charge, to any person obtaining a
  9172. // copy of this software and associated documentation files (the
  9173. // "Software"), to deal in the Software without restriction, including
  9174. // without limitation the rights to use, copy, modify, merge, publish,
  9175. // distribute, sublicense, and/or sell copies of the Software, and to permit
  9176. // persons to whom the Software is furnished to do so, subject to the
  9177. // following conditions:
  9178. //
  9179. // The above copyright notice and this permission notice shall be included
  9180. // in all copies or substantial portions of the Software.
  9181. //
  9182. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  9183. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  9184. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  9185. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  9186. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  9187. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  9188. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  9189. // a duplex stream is just a stream that is both readable and writable.
  9190. // Since JS doesn't have multiple prototypal inheritance, this class
  9191. // prototypally inherits from Readable, and then parasitically from
  9192. // Writable.
  9193. 'use strict';
  9194. /*<replacement>*/
  9195. var pna = __webpack_require__(49);
  9196. /*</replacement>*/
  9197. /*<replacement>*/
  9198. var objectKeys = Object.keys || function (obj) {
  9199. var keys = [];
  9200. for (var key in obj) {
  9201. keys.push(key);
  9202. }return keys;
  9203. };
  9204. /*</replacement>*/
  9205. module.exports = Duplex;
  9206. /*<replacement>*/
  9207. var util = Object.create(__webpack_require__(52));
  9208. util.inherits = __webpack_require__(45);
  9209. /*</replacement>*/
  9210. var Readable = __webpack_require__(47);
  9211. var Writable = __webpack_require__(58);
  9212. util.inherits(Duplex, Readable);
  9213. {
  9214. // avoid scope creep, the keys array can then be collected
  9215. var keys = objectKeys(Writable.prototype);
  9216. for (var v = 0; v < keys.length; v++) {
  9217. var method = keys[v];
  9218. if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
  9219. }
  9220. }
  9221. function Duplex(options) {
  9222. if (!(this instanceof Duplex)) return new Duplex(options);
  9223. Readable.call(this, options);
  9224. Writable.call(this, options);
  9225. if (options && options.readable === false) this.readable = false;
  9226. if (options && options.writable === false) this.writable = false;
  9227. this.allowHalfOpen = true;
  9228. if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
  9229. this.once('end', onend);
  9230. }
  9231. Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
  9232. // making it explicit this property is not enumerable
  9233. // because otherwise some prototype manipulation in
  9234. // userland will fail
  9235. enumerable: false,
  9236. get: function () {
  9237. return this._writableState.highWaterMark;
  9238. }
  9239. });
  9240. // the no-half-open enforcer
  9241. function onend() {
  9242. // if we allow half-open state, or if the writable side ended,
  9243. // then we're ok.
  9244. if (this.allowHalfOpen || this._writableState.ended) return;
  9245. // no more data can be written.
  9246. // But allow more writes to happen in this tick.
  9247. pna.nextTick(onEndNT, this);
  9248. }
  9249. function onEndNT(self) {
  9250. self.end();
  9251. }
  9252. Object.defineProperty(Duplex.prototype, 'destroyed', {
  9253. get: function () {
  9254. if (this._readableState === undefined || this._writableState === undefined) {
  9255. return false;
  9256. }
  9257. return this._readableState.destroyed && this._writableState.destroyed;
  9258. },
  9259. set: function (value) {
  9260. // we ignore the value if the stream
  9261. // has not been initialized yet
  9262. if (this._readableState === undefined || this._writableState === undefined) {
  9263. return;
  9264. }
  9265. // backward compatibility, the user is explicitly
  9266. // managing destroyed
  9267. this._readableState.destroyed = value;
  9268. this._writableState.destroyed = value;
  9269. }
  9270. });
  9271. Duplex.prototype._destroy = function (err, cb) {
  9272. this.push(null);
  9273. this.end();
  9274. pna.nextTick(cb, err);
  9275. };
  9276. /***/ }),
  9277. /* 58 */
  9278. /***/ (function(module, exports, __webpack_require__) {
  9279. /* WEBPACK VAR INJECTION */(function(process, setImmediate, global) {// Copyright Joyent, Inc. and other Node contributors.
  9280. //
  9281. // Permission is hereby granted, free of charge, to any person obtaining a
  9282. // copy of this software and associated documentation files (the
  9283. // "Software"), to deal in the Software without restriction, including
  9284. // without limitation the rights to use, copy, modify, merge, publish,
  9285. // distribute, sublicense, and/or sell copies of the Software, and to permit
  9286. // persons to whom the Software is furnished to do so, subject to the
  9287. // following conditions:
  9288. //
  9289. // The above copyright notice and this permission notice shall be included
  9290. // in all copies or substantial portions of the Software.
  9291. //
  9292. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  9293. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  9294. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  9295. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  9296. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  9297. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  9298. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  9299. // A bit simpler than readable streams.
  9300. // Implement an async ._write(chunk, encoding, cb), and it'll handle all
  9301. // the drain event emission and buffering.
  9302. 'use strict';
  9303. /*<replacement>*/
  9304. var pna = __webpack_require__(49);
  9305. /*</replacement>*/
  9306. module.exports = Writable;
  9307. /* <replacement> */
  9308. function WriteReq(chunk, encoding, cb) {
  9309. this.chunk = chunk;
  9310. this.encoding = encoding;
  9311. this.callback = cb;
  9312. this.next = null;
  9313. }
  9314. // It seems a linked list but it is not
  9315. // there will be only 2 of these for each stream
  9316. function CorkedRequest(state) {
  9317. var _this = this;
  9318. this.next = null;
  9319. this.entry = null;
  9320. this.finish = function () {
  9321. onCorkedFinish(_this, state);
  9322. };
  9323. }
  9324. /* </replacement> */
  9325. /*<replacement>*/
  9326. var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;
  9327. /*</replacement>*/
  9328. /*<replacement>*/
  9329. var Duplex;
  9330. /*</replacement>*/
  9331. Writable.WritableState = WritableState;
  9332. /*<replacement>*/
  9333. var util = Object.create(__webpack_require__(52));
  9334. util.inherits = __webpack_require__(45);
  9335. /*</replacement>*/
  9336. /*<replacement>*/
  9337. var internalUtil = {
  9338. deprecate: __webpack_require__(61)
  9339. };
  9340. /*</replacement>*/
  9341. /*<replacement>*/
  9342. var Stream = __webpack_require__(50);
  9343. /*</replacement>*/
  9344. /*<replacement>*/
  9345. var Buffer = __webpack_require__(51).Buffer;
  9346. var OurUint8Array = (typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}).Uint8Array || function () {};
  9347. function _uint8ArrayToBuffer(chunk) {
  9348. return Buffer.from(chunk);
  9349. }
  9350. function _isUint8Array(obj) {
  9351. return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
  9352. }
  9353. /*</replacement>*/
  9354. var destroyImpl = __webpack_require__(56);
  9355. util.inherits(Writable, Stream);
  9356. function nop() {}
  9357. function WritableState(options, stream) {
  9358. Duplex = Duplex || __webpack_require__(57);
  9359. options = options || {};
  9360. // Duplex streams are both readable and writable, but share
  9361. // the same options object.
  9362. // However, some cases require setting options to different
  9363. // values for the readable and the writable sides of the duplex stream.
  9364. // These options can be provided separately as readableXXX and writableXXX.
  9365. var isDuplex = stream instanceof Duplex;
  9366. // object stream flag to indicate whether or not this stream
  9367. // contains buffers or objects.
  9368. this.objectMode = !!options.objectMode;
  9369. if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
  9370. // the point at which write() starts returning false
  9371. // Note: 0 is a valid value, means that we always return false if
  9372. // the entire buffer is not flushed immediately on write()
  9373. var hwm = options.highWaterMark;
  9374. var writableHwm = options.writableHighWaterMark;
  9375. var defaultHwm = this.objectMode ? 16 : 16 * 1024;
  9376. if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;
  9377. // cast to ints.
  9378. this.highWaterMark = Math.floor(this.highWaterMark);
  9379. // if _final has been called
  9380. this.finalCalled = false;
  9381. // drain event flag.
  9382. this.needDrain = false;
  9383. // at the start of calling end()
  9384. this.ending = false;
  9385. // when end() has been called, and returned
  9386. this.ended = false;
  9387. // when 'finish' is emitted
  9388. this.finished = false;
  9389. // has it been destroyed
  9390. this.destroyed = false;
  9391. // should we decode strings into buffers before passing to _write?
  9392. // this is here so that some node-core streams can optimize string
  9393. // handling at a lower level.
  9394. var noDecode = options.decodeStrings === false;
  9395. this.decodeStrings = !noDecode;
  9396. // Crypto is kind of old and crusty. Historically, its default string
  9397. // encoding is 'binary' so we have to make this configurable.
  9398. // Everything else in the universe uses 'utf8', though.
  9399. this.defaultEncoding = options.defaultEncoding || 'utf8';
  9400. // not an actual buffer we keep track of, but a measurement
  9401. // of how much we're waiting to get pushed to some underlying
  9402. // socket or file.
  9403. this.length = 0;
  9404. // a flag to see when we're in the middle of a write.
  9405. this.writing = false;
  9406. // when true all writes will be buffered until .uncork() call
  9407. this.corked = 0;
  9408. // a flag to be able to tell if the onwrite cb is called immediately,
  9409. // or on a later tick. We set this to true at first, because any
  9410. // actions that shouldn't happen until "later" should generally also
  9411. // not happen before the first write call.
  9412. this.sync = true;
  9413. // a flag to know if we're processing previously buffered items, which
  9414. // may call the _write() callback in the same tick, so that we don't
  9415. // end up in an overlapped onwrite situation.
  9416. this.bufferProcessing = false;
  9417. // the callback that's passed to _write(chunk,cb)
  9418. this.onwrite = function (er) {
  9419. onwrite(stream, er);
  9420. };
  9421. // the callback that the user supplies to write(chunk,encoding,cb)
  9422. this.writecb = null;
  9423. // the amount that is being written when _write is called.
  9424. this.writelen = 0;
  9425. this.bufferedRequest = null;
  9426. this.lastBufferedRequest = null;
  9427. // number of pending user-supplied write callbacks
  9428. // this must be 0 before 'finish' can be emitted
  9429. this.pendingcb = 0;
  9430. // emit prefinish if the only thing we're waiting for is _write cbs
  9431. // This is relevant for synchronous Transform streams
  9432. this.prefinished = false;
  9433. // True if the error was already emitted and should not be thrown again
  9434. this.errorEmitted = false;
  9435. // count buffered requests
  9436. this.bufferedRequestCount = 0;
  9437. // allocate the first CorkedRequest, there is always
  9438. // one allocated and free to use, and we maintain at most two
  9439. this.corkedRequestsFree = new CorkedRequest(this);
  9440. }
  9441. WritableState.prototype.getBuffer = function getBuffer() {
  9442. var current = this.bufferedRequest;
  9443. var out = [];
  9444. while (current) {
  9445. out.push(current);
  9446. current = current.next;
  9447. }
  9448. return out;
  9449. };
  9450. (function () {
  9451. try {
  9452. Object.defineProperty(WritableState.prototype, 'buffer', {
  9453. get: internalUtil.deprecate(function () {
  9454. return this.getBuffer();
  9455. }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
  9456. });
  9457. } catch (_) {}
  9458. })();
  9459. // Test _writableState for inheritance to account for Duplex streams,
  9460. // whose prototype chain only points to Readable.
  9461. var realHasInstance;
  9462. if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
  9463. realHasInstance = Function.prototype[Symbol.hasInstance];
  9464. Object.defineProperty(Writable, Symbol.hasInstance, {
  9465. value: function (object) {
  9466. if (realHasInstance.call(this, object)) return true;
  9467. if (this !== Writable) return false;
  9468. return object && object._writableState instanceof WritableState;
  9469. }
  9470. });
  9471. } else {
  9472. realHasInstance = function (object) {
  9473. return object instanceof this;
  9474. };
  9475. }
  9476. function Writable(options) {
  9477. Duplex = Duplex || __webpack_require__(57);
  9478. // Writable ctor is applied to Duplexes, too.
  9479. // `realHasInstance` is necessary because using plain `instanceof`
  9480. // would return false, as no `_writableState` property is attached.
  9481. // Trying to use the custom `instanceof` for Writable here will also break the
  9482. // Node.js LazyTransform implementation, which has a non-trivial getter for
  9483. // `_writableState` that would lead to infinite recursion.
  9484. if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
  9485. return new Writable(options);
  9486. }
  9487. this._writableState = new WritableState(options, this);
  9488. // legacy.
  9489. this.writable = true;
  9490. if (options) {
  9491. if (typeof options.write === 'function') this._write = options.write;
  9492. if (typeof options.writev === 'function') this._writev = options.writev;
  9493. if (typeof options.destroy === 'function') this._destroy = options.destroy;
  9494. if (typeof options.final === 'function') this._final = options.final;
  9495. }
  9496. Stream.call(this);
  9497. }
  9498. // Otherwise people can pipe Writable streams, which is just wrong.
  9499. Writable.prototype.pipe = function () {
  9500. this.emit('error', new Error('Cannot pipe, not readable'));
  9501. };
  9502. function writeAfterEnd(stream, cb) {
  9503. var er = new Error('write after end');
  9504. // TODO: defer error events consistently everywhere, not just the cb
  9505. stream.emit('error', er);
  9506. pna.nextTick(cb, er);
  9507. }
  9508. // Checks that a user-supplied chunk is valid, especially for the particular
  9509. // mode the stream is in. Currently this means that `null` is never accepted
  9510. // and undefined/non-string values are only allowed in object mode.
  9511. function validChunk(stream, state, chunk, cb) {
  9512. var valid = true;
  9513. var er = false;
  9514. if (chunk === null) {
  9515. er = new TypeError('May not write null values to stream');
  9516. } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
  9517. er = new TypeError('Invalid non-string/buffer chunk');
  9518. }
  9519. if (er) {
  9520. stream.emit('error', er);
  9521. pna.nextTick(cb, er);
  9522. valid = false;
  9523. }
  9524. return valid;
  9525. }
  9526. Writable.prototype.write = function (chunk, encoding, cb) {
  9527. var state = this._writableState;
  9528. var ret = false;
  9529. var isBuf = !state.objectMode && _isUint8Array(chunk);
  9530. if (isBuf && !Buffer.isBuffer(chunk)) {
  9531. chunk = _uint8ArrayToBuffer(chunk);
  9532. }
  9533. if (typeof encoding === 'function') {
  9534. cb = encoding;
  9535. encoding = null;
  9536. }
  9537. if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
  9538. if (typeof cb !== 'function') cb = nop;
  9539. if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
  9540. state.pendingcb++;
  9541. ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
  9542. }
  9543. return ret;
  9544. };
  9545. Writable.prototype.cork = function () {
  9546. var state = this._writableState;
  9547. state.corked++;
  9548. };
  9549. Writable.prototype.uncork = function () {
  9550. var state = this._writableState;
  9551. if (state.corked) {
  9552. state.corked--;
  9553. if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
  9554. }
  9555. };
  9556. Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
  9557. // node::ParseEncoding() requires lower case.
  9558. if (typeof encoding === 'string') encoding = encoding.toLowerCase();
  9559. 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);
  9560. this._writableState.defaultEncoding = encoding;
  9561. return this;
  9562. };
  9563. function decodeChunk(state, chunk, encoding) {
  9564. if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
  9565. chunk = Buffer.from(chunk, encoding);
  9566. }
  9567. return chunk;
  9568. }
  9569. Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
  9570. // making it explicit this property is not enumerable
  9571. // because otherwise some prototype manipulation in
  9572. // userland will fail
  9573. enumerable: false,
  9574. get: function () {
  9575. return this._writableState.highWaterMark;
  9576. }
  9577. });
  9578. // if we're already writing something, then just put this
  9579. // in the queue, and wait our turn. Otherwise, call _write
  9580. // If we return false, then we need a drain event, so set that flag.
  9581. function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
  9582. if (!isBuf) {
  9583. var newChunk = decodeChunk(state, chunk, encoding);
  9584. if (chunk !== newChunk) {
  9585. isBuf = true;
  9586. encoding = 'buffer';
  9587. chunk = newChunk;
  9588. }
  9589. }
  9590. var len = state.objectMode ? 1 : chunk.length;
  9591. state.length += len;
  9592. var ret = state.length < state.highWaterMark;
  9593. // we must ensure that previous needDrain will not be reset to false.
  9594. if (!ret) state.needDrain = true;
  9595. if (state.writing || state.corked) {
  9596. var last = state.lastBufferedRequest;
  9597. state.lastBufferedRequest = {
  9598. chunk: chunk,
  9599. encoding: encoding,
  9600. isBuf: isBuf,
  9601. callback: cb,
  9602. next: null
  9603. };
  9604. if (last) {
  9605. last.next = state.lastBufferedRequest;
  9606. } else {
  9607. state.bufferedRequest = state.lastBufferedRequest;
  9608. }
  9609. state.bufferedRequestCount += 1;
  9610. } else {
  9611. doWrite(stream, state, false, len, chunk, encoding, cb);
  9612. }
  9613. return ret;
  9614. }
  9615. function doWrite(stream, state, writev, len, chunk, encoding, cb) {
  9616. state.writelen = len;
  9617. state.writecb = cb;
  9618. state.writing = true;
  9619. state.sync = true;
  9620. if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
  9621. state.sync = false;
  9622. }
  9623. function onwriteError(stream, state, sync, er, cb) {
  9624. --state.pendingcb;
  9625. if (sync) {
  9626. // defer the callback if we are being called synchronously
  9627. // to avoid piling up things on the stack
  9628. pna.nextTick(cb, er);
  9629. // this can emit finish, and it will always happen
  9630. // after error
  9631. pna.nextTick(finishMaybe, stream, state);
  9632. stream._writableState.errorEmitted = true;
  9633. stream.emit('error', er);
  9634. } else {
  9635. // the caller expect this to happen before if
  9636. // it is async
  9637. cb(er);
  9638. stream._writableState.errorEmitted = true;
  9639. stream.emit('error', er);
  9640. // this can emit finish, but finish must
  9641. // always follow error
  9642. finishMaybe(stream, state);
  9643. }
  9644. }
  9645. function onwriteStateUpdate(state) {
  9646. state.writing = false;
  9647. state.writecb = null;
  9648. state.length -= state.writelen;
  9649. state.writelen = 0;
  9650. }
  9651. function onwrite(stream, er) {
  9652. var state = stream._writableState;
  9653. var sync = state.sync;
  9654. var cb = state.writecb;
  9655. onwriteStateUpdate(state);
  9656. if (er) onwriteError(stream, state, sync, er, cb);else {
  9657. // Check if we're actually ready to finish, but don't emit yet
  9658. var finished = needFinish(state);
  9659. if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
  9660. clearBuffer(stream, state);
  9661. }
  9662. if (sync) {
  9663. /*<replacement>*/
  9664. asyncWrite(afterWrite, stream, state, finished, cb);
  9665. /*</replacement>*/
  9666. } else {
  9667. afterWrite(stream, state, finished, cb);
  9668. }
  9669. }
  9670. }
  9671. function afterWrite(stream, state, finished, cb) {
  9672. if (!finished) onwriteDrain(stream, state);
  9673. state.pendingcb--;
  9674. cb();
  9675. finishMaybe(stream, state);
  9676. }
  9677. // Must force callback to be called on nextTick, so that we don't
  9678. // emit 'drain' before the write() consumer gets the 'false' return
  9679. // value, and has a chance to attach a 'drain' listener.
  9680. function onwriteDrain(stream, state) {
  9681. if (state.length === 0 && state.needDrain) {
  9682. state.needDrain = false;
  9683. stream.emit('drain');
  9684. }
  9685. }
  9686. // if there's something in the buffer waiting, then process it
  9687. function clearBuffer(stream, state) {
  9688. state.bufferProcessing = true;
  9689. var entry = state.bufferedRequest;
  9690. if (stream._writev && entry && entry.next) {
  9691. // Fast case, write everything using _writev()
  9692. var l = state.bufferedRequestCount;
  9693. var buffer = new Array(l);
  9694. var holder = state.corkedRequestsFree;
  9695. holder.entry = entry;
  9696. var count = 0;
  9697. var allBuffers = true;
  9698. while (entry) {
  9699. buffer[count] = entry;
  9700. if (!entry.isBuf) allBuffers = false;
  9701. entry = entry.next;
  9702. count += 1;
  9703. }
  9704. buffer.allBuffers = allBuffers;
  9705. doWrite(stream, state, true, state.length, buffer, '', holder.finish);
  9706. // doWrite is almost always async, defer these to save a bit of time
  9707. // as the hot path ends with doWrite
  9708. state.pendingcb++;
  9709. state.lastBufferedRequest = null;
  9710. if (holder.next) {
  9711. state.corkedRequestsFree = holder.next;
  9712. holder.next = null;
  9713. } else {
  9714. state.corkedRequestsFree = new CorkedRequest(state);
  9715. }
  9716. state.bufferedRequestCount = 0;
  9717. } else {
  9718. // Slow case, write chunks one-by-one
  9719. while (entry) {
  9720. var chunk = entry.chunk;
  9721. var encoding = entry.encoding;
  9722. var cb = entry.callback;
  9723. var len = state.objectMode ? 1 : chunk.length;
  9724. doWrite(stream, state, false, len, chunk, encoding, cb);
  9725. entry = entry.next;
  9726. state.bufferedRequestCount--;
  9727. // if we didn't call the onwrite immediately, then
  9728. // it means that we need to wait until it does.
  9729. // also, that means that the chunk and cb are currently
  9730. // being processed, so move the buffer counter past them.
  9731. if (state.writing) {
  9732. break;
  9733. }
  9734. }
  9735. if (entry === null) state.lastBufferedRequest = null;
  9736. }
  9737. state.bufferedRequest = entry;
  9738. state.bufferProcessing = false;
  9739. }
  9740. Writable.prototype._write = function (chunk, encoding, cb) {
  9741. cb(new Error('_write() is not implemented'));
  9742. };
  9743. Writable.prototype._writev = null;
  9744. Writable.prototype.end = function (chunk, encoding, cb) {
  9745. var state = this._writableState;
  9746. if (typeof chunk === 'function') {
  9747. cb = chunk;
  9748. chunk = null;
  9749. encoding = null;
  9750. } else if (typeof encoding === 'function') {
  9751. cb = encoding;
  9752. encoding = null;
  9753. }
  9754. if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
  9755. // .end() fully uncorks
  9756. if (state.corked) {
  9757. state.corked = 1;
  9758. this.uncork();
  9759. }
  9760. // ignore unnecessary end() calls.
  9761. if (!state.ending) endWritable(this, state, cb);
  9762. };
  9763. function needFinish(state) {
  9764. return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
  9765. }
  9766. function callFinal(stream, state) {
  9767. stream._final(function (err) {
  9768. state.pendingcb--;
  9769. if (err) {
  9770. stream.emit('error', err);
  9771. }
  9772. state.prefinished = true;
  9773. stream.emit('prefinish');
  9774. finishMaybe(stream, state);
  9775. });
  9776. }
  9777. function prefinish(stream, state) {
  9778. if (!state.prefinished && !state.finalCalled) {
  9779. if (typeof stream._final === 'function') {
  9780. state.pendingcb++;
  9781. state.finalCalled = true;
  9782. pna.nextTick(callFinal, stream, state);
  9783. } else {
  9784. state.prefinished = true;
  9785. stream.emit('prefinish');
  9786. }
  9787. }
  9788. }
  9789. function finishMaybe(stream, state) {
  9790. var need = needFinish(state);
  9791. if (need) {
  9792. prefinish(stream, state);
  9793. if (state.pendingcb === 0) {
  9794. state.finished = true;
  9795. stream.emit('finish');
  9796. }
  9797. }
  9798. return need;
  9799. }
  9800. function endWritable(stream, state, cb) {
  9801. state.ending = true;
  9802. finishMaybe(stream, state);
  9803. if (cb) {
  9804. if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);
  9805. }
  9806. state.ended = true;
  9807. stream.writable = false;
  9808. }
  9809. function onCorkedFinish(corkReq, state, err) {
  9810. var entry = corkReq.entry;
  9811. corkReq.entry = null;
  9812. while (entry) {
  9813. var cb = entry.callback;
  9814. state.pendingcb--;
  9815. cb(err);
  9816. entry = entry.next;
  9817. }
  9818. // reuse the free corkReq.
  9819. state.corkedRequestsFree.next = corkReq;
  9820. }
  9821. Object.defineProperty(Writable.prototype, 'destroyed', {
  9822. get: function () {
  9823. if (this._writableState === undefined) {
  9824. return false;
  9825. }
  9826. return this._writableState.destroyed;
  9827. },
  9828. set: function (value) {
  9829. // we ignore the value if the stream
  9830. // has not been initialized yet
  9831. if (!this._writableState) {
  9832. return;
  9833. }
  9834. // backward compatibility, the user is explicitly
  9835. // managing destroyed
  9836. this._writableState.destroyed = value;
  9837. }
  9838. });
  9839. Writable.prototype.destroy = destroyImpl.destroy;
  9840. Writable.prototype._undestroy = destroyImpl.undestroy;
  9841. Writable.prototype._destroy = function (err, cb) {
  9842. this.end();
  9843. cb(err);
  9844. };
  9845. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(48), __webpack_require__(59).setImmediate, (function() { return this; }())))
  9846. /***/ }),
  9847. /* 59 */
  9848. /***/ (function(module, exports, __webpack_require__) {
  9849. /* WEBPACK VAR INJECTION */(function(global) {var scope = (typeof global !== "undefined" && global) ||
  9850. (typeof self !== "undefined" && self) ||
  9851. window;
  9852. var apply = Function.prototype.apply;
  9853. // DOM APIs, for completeness
  9854. exports.setTimeout = function() {
  9855. return new Timeout(apply.call(setTimeout, scope, arguments), clearTimeout);
  9856. };
  9857. exports.setInterval = function() {
  9858. return new Timeout(apply.call(setInterval, scope, arguments), clearInterval);
  9859. };
  9860. exports.clearTimeout =
  9861. exports.clearInterval = function(timeout) {
  9862. if (timeout) {
  9863. timeout.close();
  9864. }
  9865. };
  9866. function Timeout(id, clearFn) {
  9867. this._id = id;
  9868. this._clearFn = clearFn;
  9869. }
  9870. Timeout.prototype.unref = Timeout.prototype.ref = function() {};
  9871. Timeout.prototype.close = function() {
  9872. this._clearFn.call(scope, this._id);
  9873. };
  9874. // Does not start the time, just sets up the members needed.
  9875. exports.enroll = function(item, msecs) {
  9876. clearTimeout(item._idleTimeoutId);
  9877. item._idleTimeout = msecs;
  9878. };
  9879. exports.unenroll = function(item) {
  9880. clearTimeout(item._idleTimeoutId);
  9881. item._idleTimeout = -1;
  9882. };
  9883. exports._unrefActive = exports.active = function(item) {
  9884. clearTimeout(item._idleTimeoutId);
  9885. var msecs = item._idleTimeout;
  9886. if (msecs >= 0) {
  9887. item._idleTimeoutId = setTimeout(function onTimeout() {
  9888. if (item._onTimeout)
  9889. item._onTimeout();
  9890. }, msecs);
  9891. }
  9892. };
  9893. // setimmediate attaches itself to the global object
  9894. __webpack_require__(60);
  9895. // On some exotic environments, it's not clear which object `setimmediate` was
  9896. // able to install onto. Search each possibility in the same order as the
  9897. // `setimmediate` library.
  9898. exports.setImmediate = (typeof self !== "undefined" && self.setImmediate) ||
  9899. (typeof global !== "undefined" && global.setImmediate) ||
  9900. (this && this.setImmediate);
  9901. exports.clearImmediate = (typeof self !== "undefined" && self.clearImmediate) ||
  9902. (typeof global !== "undefined" && global.clearImmediate) ||
  9903. (this && this.clearImmediate);
  9904. /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
  9905. /***/ }),
  9906. /* 60 */
  9907. /***/ (function(module, exports, __webpack_require__) {
  9908. /* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) {
  9909. "use strict";
  9910. if (global.setImmediate) {
  9911. return;
  9912. }
  9913. var nextHandle = 1; // Spec says greater than zero
  9914. var tasksByHandle = {};
  9915. var currentlyRunningATask = false;
  9916. var doc = global.document;
  9917. var registerImmediate;
  9918. function setImmediate(callback) {
  9919. // Callback can either be a function or a string
  9920. if (typeof callback !== "function") {
  9921. callback = new Function("" + callback);
  9922. }
  9923. // Copy function arguments
  9924. var args = new Array(arguments.length - 1);
  9925. for (var i = 0; i < args.length; i++) {
  9926. args[i] = arguments[i + 1];
  9927. }
  9928. // Store and register the task
  9929. var task = { callback: callback, args: args };
  9930. tasksByHandle[nextHandle] = task;
  9931. registerImmediate(nextHandle);
  9932. return nextHandle++;
  9933. }
  9934. function clearImmediate(handle) {
  9935. delete tasksByHandle[handle];
  9936. }
  9937. function run(task) {
  9938. var callback = task.callback;
  9939. var args = task.args;
  9940. switch (args.length) {
  9941. case 0:
  9942. callback();
  9943. break;
  9944. case 1:
  9945. callback(args[0]);
  9946. break;
  9947. case 2:
  9948. callback(args[0], args[1]);
  9949. break;
  9950. case 3:
  9951. callback(args[0], args[1], args[2]);
  9952. break;
  9953. default:
  9954. callback.apply(undefined, args);
  9955. break;
  9956. }
  9957. }
  9958. function runIfPresent(handle) {
  9959. // From the spec: "Wait until any invocations of this algorithm started before this one have completed."
  9960. // So if we're currently running a task, we'll need to delay this invocation.
  9961. if (currentlyRunningATask) {
  9962. // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
  9963. // "too much recursion" error.
  9964. setTimeout(runIfPresent, 0, handle);
  9965. } else {
  9966. var task = tasksByHandle[handle];
  9967. if (task) {
  9968. currentlyRunningATask = true;
  9969. try {
  9970. run(task);
  9971. } finally {
  9972. clearImmediate(handle);
  9973. currentlyRunningATask = false;
  9974. }
  9975. }
  9976. }
  9977. }
  9978. function installNextTickImplementation() {
  9979. registerImmediate = function(handle) {
  9980. process.nextTick(function () { runIfPresent(handle); });
  9981. };
  9982. }
  9983. function canUsePostMessage() {
  9984. // The test against `importScripts` prevents this implementation from being installed inside a web worker,
  9985. // where `global.postMessage` means something completely different and can't be used for this purpose.
  9986. if (global.postMessage && !global.importScripts) {
  9987. var postMessageIsAsynchronous = true;
  9988. var oldOnMessage = global.onmessage;
  9989. global.onmessage = function() {
  9990. postMessageIsAsynchronous = false;
  9991. };
  9992. global.postMessage("", "*");
  9993. global.onmessage = oldOnMessage;
  9994. return postMessageIsAsynchronous;
  9995. }
  9996. }
  9997. function installPostMessageImplementation() {
  9998. // Installs an event handler on `global` for the `message` event: see
  9999. // * https://developer.mozilla.org/en/DOM/window.postMessage
  10000. // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
  10001. var messagePrefix = "setImmediate$" + Math.random() + "$";
  10002. var onGlobalMessage = function(event) {
  10003. if (event.source === global &&
  10004. typeof event.data === "string" &&
  10005. event.data.indexOf(messagePrefix) === 0) {
  10006. runIfPresent(+event.data.slice(messagePrefix.length));
  10007. }
  10008. };
  10009. if (global.addEventListener) {
  10010. global.addEventListener("message", onGlobalMessage, false);
  10011. } else {
  10012. global.attachEvent("onmessage", onGlobalMessage);
  10013. }
  10014. registerImmediate = function(handle) {
  10015. global.postMessage(messagePrefix + handle, "*");
  10016. };
  10017. }
  10018. function installMessageChannelImplementation() {
  10019. var channel = new MessageChannel();
  10020. channel.port1.onmessage = function(event) {
  10021. var handle = event.data;
  10022. runIfPresent(handle);
  10023. };
  10024. registerImmediate = function(handle) {
  10025. channel.port2.postMessage(handle);
  10026. };
  10027. }
  10028. function installReadyStateChangeImplementation() {
  10029. var html = doc.documentElement;
  10030. registerImmediate = function(handle) {
  10031. // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
  10032. // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
  10033. var script = doc.createElement("script");
  10034. script.onreadystatechange = function () {
  10035. runIfPresent(handle);
  10036. script.onreadystatechange = null;
  10037. html.removeChild(script);
  10038. script = null;
  10039. };
  10040. html.appendChild(script);
  10041. };
  10042. }
  10043. function installSetTimeoutImplementation() {
  10044. registerImmediate = function(handle) {
  10045. setTimeout(runIfPresent, 0, handle);
  10046. };
  10047. }
  10048. // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
  10049. var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
  10050. attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
  10051. // Don't get fooled by e.g. browserify environments.
  10052. if ({}.toString.call(global.process) === "[object process]") {
  10053. // For Node.js before 0.9
  10054. installNextTickImplementation();
  10055. } else if (canUsePostMessage()) {
  10056. // For non-IE10 modern browsers
  10057. installPostMessageImplementation();
  10058. } else if (global.MessageChannel) {
  10059. // For web workers, where supported
  10060. installMessageChannelImplementation();
  10061. } else if (doc && "onreadystatechange" in doc.createElement("script")) {
  10062. // For IE 6–8
  10063. installReadyStateChangeImplementation();
  10064. } else {
  10065. // For older browsers
  10066. installSetTimeoutImplementation();
  10067. }
  10068. attachTo.setImmediate = setImmediate;
  10069. attachTo.clearImmediate = clearImmediate;
  10070. }(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self));
  10071. /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()), __webpack_require__(48)))
  10072. /***/ }),
  10073. /* 61 */
  10074. /***/ (function(module, exports) {
  10075. /* WEBPACK VAR INJECTION */(function(global) {
  10076. /**
  10077. * Module exports.
  10078. */
  10079. module.exports = deprecate;
  10080. /**
  10081. * Mark that a method should not be used.
  10082. * Returns a modified function which warns once by default.
  10083. *
  10084. * If `localStorage.noDeprecation = true` is set, then it is a no-op.
  10085. *
  10086. * If `localStorage.throwDeprecation = true` is set, then deprecated functions
  10087. * will throw an Error when invoked.
  10088. *
  10089. * If `localStorage.traceDeprecation = true` is set, then deprecated functions
  10090. * will invoke `console.trace()` instead of `console.error()`.
  10091. *
  10092. * @param {Function} fn - the function to deprecate
  10093. * @param {String} msg - the string to print to the console when `fn` is invoked
  10094. * @returns {Function} a new "deprecated" version of `fn`
  10095. * @api public
  10096. */
  10097. function deprecate (fn, msg) {
  10098. if (config('noDeprecation')) {
  10099. return fn;
  10100. }
  10101. var warned = false;
  10102. function deprecated() {
  10103. if (!warned) {
  10104. if (config('throwDeprecation')) {
  10105. throw new Error(msg);
  10106. } else if (config('traceDeprecation')) {
  10107. console.trace(msg);
  10108. } else {
  10109. console.warn(msg);
  10110. }
  10111. warned = true;
  10112. }
  10113. return fn.apply(this, arguments);
  10114. }
  10115. return deprecated;
  10116. }
  10117. /**
  10118. * Checks `localStorage` for boolean values for the given `name`.
  10119. *
  10120. * @param {String} name
  10121. * @returns {Boolean}
  10122. * @api private
  10123. */
  10124. function config (name) {
  10125. // accessing global.localStorage can trigger a DOMException in sandboxed iframes
  10126. try {
  10127. if (!global.localStorage) return false;
  10128. } catch (_) {
  10129. return false;
  10130. }
  10131. var val = global.localStorage[name];
  10132. if (null == val) return false;
  10133. return String(val).toLowerCase() === 'true';
  10134. }
  10135. /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
  10136. /***/ }),
  10137. /* 62 */
  10138. /***/ (function(module, exports, __webpack_require__) {
  10139. // Copyright Joyent, Inc. and other Node contributors.
  10140. //
  10141. // Permission is hereby granted, free of charge, to any person obtaining a
  10142. // copy of this software and associated documentation files (the
  10143. // "Software"), to deal in the Software without restriction, including
  10144. // without limitation the rights to use, copy, modify, merge, publish,
  10145. // distribute, sublicense, and/or sell copies of the Software, and to permit
  10146. // persons to whom the Software is furnished to do so, subject to the
  10147. // following conditions:
  10148. //
  10149. // The above copyright notice and this permission notice shall be included
  10150. // in all copies or substantial portions of the Software.
  10151. //
  10152. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  10153. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  10154. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  10155. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  10156. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  10157. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  10158. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  10159. 'use strict';
  10160. /*<replacement>*/
  10161. var Buffer = __webpack_require__(51).Buffer;
  10162. /*</replacement>*/
  10163. var isEncoding = Buffer.isEncoding || function (encoding) {
  10164. encoding = '' + encoding;
  10165. switch (encoding && encoding.toLowerCase()) {
  10166. 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':
  10167. return true;
  10168. default:
  10169. return false;
  10170. }
  10171. };
  10172. function _normalizeEncoding(enc) {
  10173. if (!enc) return 'utf8';
  10174. var retried;
  10175. while (true) {
  10176. switch (enc) {
  10177. case 'utf8':
  10178. case 'utf-8':
  10179. return 'utf8';
  10180. case 'ucs2':
  10181. case 'ucs-2':
  10182. case 'utf16le':
  10183. case 'utf-16le':
  10184. return 'utf16le';
  10185. case 'latin1':
  10186. case 'binary':
  10187. return 'latin1';
  10188. case 'base64':
  10189. case 'ascii':
  10190. case 'hex':
  10191. return enc;
  10192. default:
  10193. if (retried) return; // undefined
  10194. enc = ('' + enc).toLowerCase();
  10195. retried = true;
  10196. }
  10197. }
  10198. };
  10199. // Do not cache `Buffer.isEncoding` when checking encoding names as some
  10200. // modules monkey-patch it to support additional encodings
  10201. function normalizeEncoding(enc) {
  10202. var nenc = _normalizeEncoding(enc);
  10203. if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
  10204. return nenc || enc;
  10205. }
  10206. // StringDecoder provides an interface for efficiently splitting a series of
  10207. // buffers into a series of JS strings without breaking apart multi-byte
  10208. // characters.
  10209. exports.StringDecoder = StringDecoder;
  10210. function StringDecoder(encoding) {
  10211. this.encoding = normalizeEncoding(encoding);
  10212. var nb;
  10213. switch (this.encoding) {
  10214. case 'utf16le':
  10215. this.text = utf16Text;
  10216. this.end = utf16End;
  10217. nb = 4;
  10218. break;
  10219. case 'utf8':
  10220. this.fillLast = utf8FillLast;
  10221. nb = 4;
  10222. break;
  10223. case 'base64':
  10224. this.text = base64Text;
  10225. this.end = base64End;
  10226. nb = 3;
  10227. break;
  10228. default:
  10229. this.write = simpleWrite;
  10230. this.end = simpleEnd;
  10231. return;
  10232. }
  10233. this.lastNeed = 0;
  10234. this.lastTotal = 0;
  10235. this.lastChar = Buffer.allocUnsafe(nb);
  10236. }
  10237. StringDecoder.prototype.write = function (buf) {
  10238. if (buf.length === 0) return '';
  10239. var r;
  10240. var i;
  10241. if (this.lastNeed) {
  10242. r = this.fillLast(buf);
  10243. if (r === undefined) return '';
  10244. i = this.lastNeed;
  10245. this.lastNeed = 0;
  10246. } else {
  10247. i = 0;
  10248. }
  10249. if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
  10250. return r || '';
  10251. };
  10252. StringDecoder.prototype.end = utf8End;
  10253. // Returns only complete characters in a Buffer
  10254. StringDecoder.prototype.text = utf8Text;
  10255. // Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
  10256. StringDecoder.prototype.fillLast = function (buf) {
  10257. if (this.lastNeed <= buf.length) {
  10258. buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
  10259. return this.lastChar.toString(this.encoding, 0, this.lastTotal);
  10260. }
  10261. buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
  10262. this.lastNeed -= buf.length;
  10263. };
  10264. // Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
  10265. // continuation byte. If an invalid byte is detected, -2 is returned.
  10266. function utf8CheckByte(byte) {
  10267. 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;
  10268. return byte >> 6 === 0x02 ? -1 : -2;
  10269. }
  10270. // Checks at most 3 bytes at the end of a Buffer in order to detect an
  10271. // incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
  10272. // needed to complete the UTF-8 character (if applicable) are returned.
  10273. function utf8CheckIncomplete(self, buf, i) {
  10274. var j = buf.length - 1;
  10275. if (j < i) return 0;
  10276. var nb = utf8CheckByte(buf[j]);
  10277. if (nb >= 0) {
  10278. if (nb > 0) self.lastNeed = nb - 1;
  10279. return nb;
  10280. }
  10281. if (--j < i || nb === -2) return 0;
  10282. nb = utf8CheckByte(buf[j]);
  10283. if (nb >= 0) {
  10284. if (nb > 0) self.lastNeed = nb - 2;
  10285. return nb;
  10286. }
  10287. if (--j < i || nb === -2) return 0;
  10288. nb = utf8CheckByte(buf[j]);
  10289. if (nb >= 0) {
  10290. if (nb > 0) {
  10291. if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
  10292. }
  10293. return nb;
  10294. }
  10295. return 0;
  10296. }
  10297. // Validates as many continuation bytes for a multi-byte UTF-8 character as
  10298. // needed or are available. If we see a non-continuation byte where we expect
  10299. // one, we "replace" the validated continuation bytes we've seen so far with
  10300. // a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
  10301. // behavior. The continuation byte check is included three times in the case
  10302. // where all of the continuation bytes for a character exist in the same buffer.
  10303. // It is also done this way as a slight performance increase instead of using a
  10304. // loop.
  10305. function utf8CheckExtraBytes(self, buf, p) {
  10306. if ((buf[0] & 0xC0) !== 0x80) {
  10307. self.lastNeed = 0;
  10308. return '\ufffd';
  10309. }
  10310. if (self.lastNeed > 1 && buf.length > 1) {
  10311. if ((buf[1] & 0xC0) !== 0x80) {
  10312. self.lastNeed = 1;
  10313. return '\ufffd';
  10314. }
  10315. if (self.lastNeed > 2 && buf.length > 2) {
  10316. if ((buf[2] & 0xC0) !== 0x80) {
  10317. self.lastNeed = 2;
  10318. return '\ufffd';
  10319. }
  10320. }
  10321. }
  10322. }
  10323. // Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
  10324. function utf8FillLast(buf) {
  10325. var p = this.lastTotal - this.lastNeed;
  10326. var r = utf8CheckExtraBytes(this, buf, p);
  10327. if (r !== undefined) return r;
  10328. if (this.lastNeed <= buf.length) {
  10329. buf.copy(this.lastChar, p, 0, this.lastNeed);
  10330. return this.lastChar.toString(this.encoding, 0, this.lastTotal);
  10331. }
  10332. buf.copy(this.lastChar, p, 0, buf.length);
  10333. this.lastNeed -= buf.length;
  10334. }
  10335. // Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
  10336. // partial character, the character's bytes are buffered until the required
  10337. // number of bytes are available.
  10338. function utf8Text(buf, i) {
  10339. var total = utf8CheckIncomplete(this, buf, i);
  10340. if (!this.lastNeed) return buf.toString('utf8', i);
  10341. this.lastTotal = total;
  10342. var end = buf.length - (total - this.lastNeed);
  10343. buf.copy(this.lastChar, 0, end);
  10344. return buf.toString('utf8', i, end);
  10345. }
  10346. // For UTF-8, a replacement character is added when ending on a partial
  10347. // character.
  10348. function utf8End(buf) {
  10349. var r = buf && buf.length ? this.write(buf) : '';
  10350. if (this.lastNeed) return r + '\ufffd';
  10351. return r;
  10352. }
  10353. // UTF-16LE typically needs two bytes per character, but even if we have an even
  10354. // number of bytes available, we need to check if we end on a leading/high
  10355. // surrogate. In that case, we need to wait for the next two bytes in order to
  10356. // decode the last character properly.
  10357. function utf16Text(buf, i) {
  10358. if ((buf.length - i) % 2 === 0) {
  10359. var r = buf.toString('utf16le', i);
  10360. if (r) {
  10361. var c = r.charCodeAt(r.length - 1);
  10362. if (c >= 0xD800 && c <= 0xDBFF) {
  10363. this.lastNeed = 2;
  10364. this.lastTotal = 4;
  10365. this.lastChar[0] = buf[buf.length - 2];
  10366. this.lastChar[1] = buf[buf.length - 1];
  10367. return r.slice(0, -1);
  10368. }
  10369. }
  10370. return r;
  10371. }
  10372. this.lastNeed = 1;
  10373. this.lastTotal = 2;
  10374. this.lastChar[0] = buf[buf.length - 1];
  10375. return buf.toString('utf16le', i, buf.length - 1);
  10376. }
  10377. // For UTF-16LE we do not explicitly append special replacement characters if we
  10378. // end on a partial character, we simply let v8 handle that.
  10379. function utf16End(buf) {
  10380. var r = buf && buf.length ? this.write(buf) : '';
  10381. if (this.lastNeed) {
  10382. var end = this.lastTotal - this.lastNeed;
  10383. return r + this.lastChar.toString('utf16le', 0, end);
  10384. }
  10385. return r;
  10386. }
  10387. function base64Text(buf, i) {
  10388. var n = (buf.length - i) % 3;
  10389. if (n === 0) return buf.toString('base64', i);
  10390. this.lastNeed = 3 - n;
  10391. this.lastTotal = 3;
  10392. if (n === 1) {
  10393. this.lastChar[0] = buf[buf.length - 1];
  10394. } else {
  10395. this.lastChar[0] = buf[buf.length - 2];
  10396. this.lastChar[1] = buf[buf.length - 1];
  10397. }
  10398. return buf.toString('base64', i, buf.length - n);
  10399. }
  10400. function base64End(buf) {
  10401. var r = buf && buf.length ? this.write(buf) : '';
  10402. if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
  10403. return r;
  10404. }
  10405. // Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
  10406. function simpleWrite(buf) {
  10407. return buf.toString(this.encoding);
  10408. }
  10409. function simpleEnd(buf) {
  10410. return buf && buf.length ? this.write(buf) : '';
  10411. }
  10412. /***/ }),
  10413. /* 63 */
  10414. /***/ (function(module, exports, __webpack_require__) {
  10415. // Copyright Joyent, Inc. and other Node contributors.
  10416. //
  10417. // Permission is hereby granted, free of charge, to any person obtaining a
  10418. // copy of this software and associated documentation files (the
  10419. // "Software"), to deal in the Software without restriction, including
  10420. // without limitation the rights to use, copy, modify, merge, publish,
  10421. // distribute, sublicense, and/or sell copies of the Software, and to permit
  10422. // persons to whom the Software is furnished to do so, subject to the
  10423. // following conditions:
  10424. //
  10425. // The above copyright notice and this permission notice shall be included
  10426. // in all copies or substantial portions of the Software.
  10427. //
  10428. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  10429. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  10430. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  10431. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  10432. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  10433. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  10434. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  10435. // a transform stream is a readable/writable stream where you do
  10436. // something with the data. Sometimes it's called a "filter",
  10437. // but that's not a great name for it, since that implies a thing where
  10438. // some bits pass through, and others are simply ignored. (That would
  10439. // be a valid example of a transform, of course.)
  10440. //
  10441. // While the output is causally related to the input, it's not a
  10442. // necessarily symmetric or synchronous transformation. For example,
  10443. // a zlib stream might take multiple plain-text writes(), and then
  10444. // emit a single compressed chunk some time in the future.
  10445. //
  10446. // Here's how this works:
  10447. //
  10448. // The Transform stream has all the aspects of the readable and writable
  10449. // stream classes. When you write(chunk), that calls _write(chunk,cb)
  10450. // internally, and returns false if there's a lot of pending writes
  10451. // buffered up. When you call read(), that calls _read(n) until
  10452. // there's enough pending readable data buffered up.
  10453. //
  10454. // In a transform stream, the written data is placed in a buffer. When
  10455. // _read(n) is called, it transforms the queued up data, calling the
  10456. // buffered _write cb's as it consumes chunks. If consuming a single
  10457. // written chunk would result in multiple output chunks, then the first
  10458. // outputted bit calls the readcb, and subsequent chunks just go into
  10459. // the read buffer, and will cause it to emit 'readable' if necessary.
  10460. //
  10461. // This way, back-pressure is actually determined by the reading side,
  10462. // since _read has to be called to start processing a new chunk. However,
  10463. // a pathological inflate type of transform can cause excessive buffering
  10464. // here. For example, imagine a stream where every byte of input is
  10465. // interpreted as an integer from 0-255, and then results in that many
  10466. // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
  10467. // 1kb of data being output. In this case, you could write a very small
  10468. // amount of input, and end up with a very large amount of output. In
  10469. // such a pathological inflating mechanism, there'd be no way to tell
  10470. // the system to stop doing the transform. A single 4MB write could
  10471. // cause the system to run out of memory.
  10472. //
  10473. // However, even in such a pathological case, only a single written chunk
  10474. // would be consumed, and then the rest would wait (un-transformed) until
  10475. // the results of the previous transformed chunk were consumed.
  10476. 'use strict';
  10477. module.exports = Transform;
  10478. var Duplex = __webpack_require__(57);
  10479. /*<replacement>*/
  10480. var util = Object.create(__webpack_require__(52));
  10481. util.inherits = __webpack_require__(45);
  10482. /*</replacement>*/
  10483. util.inherits(Transform, Duplex);
  10484. function afterTransform(er, data) {
  10485. var ts = this._transformState;
  10486. ts.transforming = false;
  10487. var cb = ts.writecb;
  10488. if (!cb) {
  10489. return this.emit('error', new Error('write callback called multiple times'));
  10490. }
  10491. ts.writechunk = null;
  10492. ts.writecb = null;
  10493. if (data != null) // single equals check for both `null` and `undefined`
  10494. this.push(data);
  10495. cb(er);
  10496. var rs = this._readableState;
  10497. rs.reading = false;
  10498. if (rs.needReadable || rs.length < rs.highWaterMark) {
  10499. this._read(rs.highWaterMark);
  10500. }
  10501. }
  10502. function Transform(options) {
  10503. if (!(this instanceof Transform)) return new Transform(options);
  10504. Duplex.call(this, options);
  10505. this._transformState = {
  10506. afterTransform: afterTransform.bind(this),
  10507. needTransform: false,
  10508. transforming: false,
  10509. writecb: null,
  10510. writechunk: null,
  10511. writeencoding: null
  10512. };
  10513. // start out asking for a readable event once data is transformed.
  10514. this._readableState.needReadable = true;
  10515. // we have implemented the _read method, and done the other things
  10516. // that Readable wants before the first _read call, so unset the
  10517. // sync guard flag.
  10518. this._readableState.sync = false;
  10519. if (options) {
  10520. if (typeof options.transform === 'function') this._transform = options.transform;
  10521. if (typeof options.flush === 'function') this._flush = options.flush;
  10522. }
  10523. // When the writable side finishes, then flush out anything remaining.
  10524. this.on('prefinish', prefinish);
  10525. }
  10526. function prefinish() {
  10527. var _this = this;
  10528. if (typeof this._flush === 'function') {
  10529. this._flush(function (er, data) {
  10530. done(_this, er, data);
  10531. });
  10532. } else {
  10533. done(this, null, null);
  10534. }
  10535. }
  10536. Transform.prototype.push = function (chunk, encoding) {
  10537. this._transformState.needTransform = false;
  10538. return Duplex.prototype.push.call(this, chunk, encoding);
  10539. };
  10540. // This is the part where you do stuff!
  10541. // override this function in implementation classes.
  10542. // 'chunk' is an input chunk.
  10543. //
  10544. // Call `push(newChunk)` to pass along transformed output
  10545. // to the readable side. You may call 'push' zero or more times.
  10546. //
  10547. // Call `cb(err)` when you are done with this chunk. If you pass
  10548. // an error, then that'll put the hurt on the whole operation. If you
  10549. // never call cb(), then you'll never get another chunk.
  10550. Transform.prototype._transform = function (chunk, encoding, cb) {
  10551. throw new Error('_transform() is not implemented');
  10552. };
  10553. Transform.prototype._write = function (chunk, encoding, cb) {
  10554. var ts = this._transformState;
  10555. ts.writecb = cb;
  10556. ts.writechunk = chunk;
  10557. ts.writeencoding = encoding;
  10558. if (!ts.transforming) {
  10559. var rs = this._readableState;
  10560. if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
  10561. }
  10562. };
  10563. // Doesn't matter what the args are here.
  10564. // _transform does all the work.
  10565. // That we got here means that the readable side wants more data.
  10566. Transform.prototype._read = function (n) {
  10567. var ts = this._transformState;
  10568. if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
  10569. ts.transforming = true;
  10570. this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
  10571. } else {
  10572. // mark that we need a transform, so that any data that comes in
  10573. // will get processed, now that we've asked for it.
  10574. ts.needTransform = true;
  10575. }
  10576. };
  10577. Transform.prototype._destroy = function (err, cb) {
  10578. var _this2 = this;
  10579. Duplex.prototype._destroy.call(this, err, function (err2) {
  10580. cb(err2);
  10581. _this2.emit('close');
  10582. });
  10583. };
  10584. function done(stream, er, data) {
  10585. if (er) return stream.emit('error', er);
  10586. if (data != null) // single equals check for both `null` and `undefined`
  10587. stream.push(data);
  10588. // if there's nothing in the write buffer, then that means
  10589. // that nothing more will ever be provided
  10590. if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');
  10591. if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');
  10592. return stream.push(null);
  10593. }
  10594. /***/ }),
  10595. /* 64 */
  10596. /***/ (function(module, exports, __webpack_require__) {
  10597. // Copyright Joyent, Inc. and other Node contributors.
  10598. //
  10599. // Permission is hereby granted, free of charge, to any person obtaining a
  10600. // copy of this software and associated documentation files (the
  10601. // "Software"), to deal in the Software without restriction, including
  10602. // without limitation the rights to use, copy, modify, merge, publish,
  10603. // distribute, sublicense, and/or sell copies of the Software, and to permit
  10604. // persons to whom the Software is furnished to do so, subject to the
  10605. // following conditions:
  10606. //
  10607. // The above copyright notice and this permission notice shall be included
  10608. // in all copies or substantial portions of the Software.
  10609. //
  10610. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  10611. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  10612. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  10613. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  10614. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  10615. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  10616. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  10617. // a passthrough stream.
  10618. // basically just the most minimal sort of Transform stream.
  10619. // Every written chunk gets output as-is.
  10620. 'use strict';
  10621. module.exports = PassThrough;
  10622. var Transform = __webpack_require__(63);
  10623. /*<replacement>*/
  10624. var util = Object.create(__webpack_require__(52));
  10625. util.inherits = __webpack_require__(45);
  10626. /*</replacement>*/
  10627. util.inherits(PassThrough, Transform);
  10628. function PassThrough(options) {
  10629. if (!(this instanceof PassThrough)) return new PassThrough(options);
  10630. Transform.call(this, options);
  10631. }
  10632. PassThrough.prototype._transform = function (chunk, encoding, cb) {
  10633. cb(null, chunk);
  10634. };
  10635. /***/ }),
  10636. /* 65 */
  10637. /***/ (function(module, exports, __webpack_require__) {
  10638. module.exports = __webpack_require__(58);
  10639. /***/ }),
  10640. /* 66 */
  10641. /***/ (function(module, exports, __webpack_require__) {
  10642. module.exports = __webpack_require__(57);
  10643. /***/ }),
  10644. /* 67 */
  10645. /***/ (function(module, exports, __webpack_require__) {
  10646. module.exports = __webpack_require__(46).Transform
  10647. /***/ }),
  10648. /* 68 */
  10649. /***/ (function(module, exports, __webpack_require__) {
  10650. module.exports = __webpack_require__(46).PassThrough
  10651. /***/ }),
  10652. /* 69 */
  10653. /***/ (function(module, exports, __webpack_require__) {
  10654. // Copyright Joyent, Inc. and other Node contributors.
  10655. //
  10656. // Permission is hereby granted, free of charge, to any person obtaining a
  10657. // copy of this software and associated documentation files (the
  10658. // "Software"), to deal in the Software without restriction, including
  10659. // without limitation the rights to use, copy, modify, merge, publish,
  10660. // distribute, sublicense, and/or sell copies of the Software, and to permit
  10661. // persons to whom the Software is furnished to do so, subject to the
  10662. // following conditions:
  10663. //
  10664. // The above copyright notice and this permission notice shall be included
  10665. // in all copies or substantial portions of the Software.
  10666. //
  10667. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  10668. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  10669. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  10670. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  10671. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  10672. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  10673. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  10674. var Buffer = __webpack_require__(39).Buffer;
  10675. var isBufferEncoding = Buffer.isEncoding
  10676. || function(encoding) {
  10677. switch (encoding && encoding.toLowerCase()) {
  10678. 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': return true;
  10679. default: return false;
  10680. }
  10681. }
  10682. function assertEncoding(encoding) {
  10683. if (encoding && !isBufferEncoding(encoding)) {
  10684. throw new Error('Unknown encoding: ' + encoding);
  10685. }
  10686. }
  10687. // StringDecoder provides an interface for efficiently splitting a series of
  10688. // buffers into a series of JS strings without breaking apart multi-byte
  10689. // characters. CESU-8 is handled as part of the UTF-8 encoding.
  10690. //
  10691. // @TODO Handling all encodings inside a single object makes it very difficult
  10692. // to reason about this code, so it should be split up in the future.
  10693. // @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code
  10694. // points as used by CESU-8.
  10695. var StringDecoder = exports.StringDecoder = function(encoding) {
  10696. this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, '');
  10697. assertEncoding(encoding);
  10698. switch (this.encoding) {
  10699. case 'utf8':
  10700. // CESU-8 represents each of Surrogate Pair by 3-bytes
  10701. this.surrogateSize = 3;
  10702. break;
  10703. case 'ucs2':
  10704. case 'utf16le':
  10705. // UTF-16 represents each of Surrogate Pair by 2-bytes
  10706. this.surrogateSize = 2;
  10707. this.detectIncompleteChar = utf16DetectIncompleteChar;
  10708. break;
  10709. case 'base64':
  10710. // Base-64 stores 3 bytes in 4 chars, and pads the remainder.
  10711. this.surrogateSize = 3;
  10712. this.detectIncompleteChar = base64DetectIncompleteChar;
  10713. break;
  10714. default:
  10715. this.write = passThroughWrite;
  10716. return;
  10717. }
  10718. // Enough space to store all bytes of a single character. UTF-8 needs 4
  10719. // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate).
  10720. this.charBuffer = new Buffer(6);
  10721. // Number of bytes received for the current incomplete multi-byte character.
  10722. this.charReceived = 0;
  10723. // Number of bytes expected for the current incomplete multi-byte character.
  10724. this.charLength = 0;
  10725. };
  10726. // write decodes the given buffer and returns it as JS string that is
  10727. // guaranteed to not contain any partial multi-byte characters. Any partial
  10728. // character found at the end of the buffer is buffered up, and will be
  10729. // returned when calling write again with the remaining bytes.
  10730. //
  10731. // Note: Converting a Buffer containing an orphan surrogate to a String
  10732. // currently works, but converting a String to a Buffer (via `new Buffer`, or
  10733. // Buffer#write) will replace incomplete surrogates with the unicode
  10734. // replacement character. See https://codereview.chromium.org/121173009/ .
  10735. StringDecoder.prototype.write = function(buffer) {
  10736. var charStr = '';
  10737. // if our last write ended with an incomplete multibyte character
  10738. while (this.charLength) {
  10739. // determine how many remaining bytes this buffer has to offer for this char
  10740. var available = (buffer.length >= this.charLength - this.charReceived) ?
  10741. this.charLength - this.charReceived :
  10742. buffer.length;
  10743. // add the new bytes to the char buffer
  10744. buffer.copy(this.charBuffer, this.charReceived, 0, available);
  10745. this.charReceived += available;
  10746. if (this.charReceived < this.charLength) {
  10747. // still not enough chars in this buffer? wait for more ...
  10748. return '';
  10749. }
  10750. // remove bytes belonging to the current character from the buffer
  10751. buffer = buffer.slice(available, buffer.length);
  10752. // get the character that was split
  10753. charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding);
  10754. // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
  10755. var charCode = charStr.charCodeAt(charStr.length - 1);
  10756. if (charCode >= 0xD800 && charCode <= 0xDBFF) {
  10757. this.charLength += this.surrogateSize;
  10758. charStr = '';
  10759. continue;
  10760. }
  10761. this.charReceived = this.charLength = 0;
  10762. // if there are no more bytes in this buffer, just emit our char
  10763. if (buffer.length === 0) {
  10764. return charStr;
  10765. }
  10766. break;
  10767. }
  10768. // determine and set charLength / charReceived
  10769. this.detectIncompleteChar(buffer);
  10770. var end = buffer.length;
  10771. if (this.charLength) {
  10772. // buffer the incomplete character bytes we got
  10773. buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end);
  10774. end -= this.charReceived;
  10775. }
  10776. charStr += buffer.toString(this.encoding, 0, end);
  10777. var end = charStr.length - 1;
  10778. var charCode = charStr.charCodeAt(end);
  10779. // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
  10780. if (charCode >= 0xD800 && charCode <= 0xDBFF) {
  10781. var size = this.surrogateSize;
  10782. this.charLength += size;
  10783. this.charReceived += size;
  10784. this.charBuffer.copy(this.charBuffer, size, 0, size);
  10785. buffer.copy(this.charBuffer, 0, 0, size);
  10786. return charStr.substring(0, end);
  10787. }
  10788. // or just emit the charStr
  10789. return charStr;
  10790. };
  10791. // detectIncompleteChar determines if there is an incomplete UTF-8 character at
  10792. // the end of the given buffer. If so, it sets this.charLength to the byte
  10793. // length that character, and sets this.charReceived to the number of bytes
  10794. // that are available for this character.
  10795. StringDecoder.prototype.detectIncompleteChar = function(buffer) {
  10796. // determine how many bytes we have to check at the end of this buffer
  10797. var i = (buffer.length >= 3) ? 3 : buffer.length;
  10798. // Figure out if one of the last i bytes of our buffer announces an
  10799. // incomplete char.
  10800. for (; i > 0; i--) {
  10801. var c = buffer[buffer.length - i];
  10802. // See http://en.wikipedia.org/wiki/UTF-8#Description
  10803. // 110XXXXX
  10804. if (i == 1 && c >> 5 == 0x06) {
  10805. this.charLength = 2;
  10806. break;
  10807. }
  10808. // 1110XXXX
  10809. if (i <= 2 && c >> 4 == 0x0E) {
  10810. this.charLength = 3;
  10811. break;
  10812. }
  10813. // 11110XXX
  10814. if (i <= 3 && c >> 3 == 0x1E) {
  10815. this.charLength = 4;
  10816. break;
  10817. }
  10818. }
  10819. this.charReceived = i;
  10820. };
  10821. StringDecoder.prototype.end = function(buffer) {
  10822. var res = '';
  10823. if (buffer && buffer.length)
  10824. res = this.write(buffer);
  10825. if (this.charReceived) {
  10826. var cr = this.charReceived;
  10827. var buf = this.charBuffer;
  10828. var enc = this.encoding;
  10829. res += buf.slice(0, cr).toString(enc);
  10830. }
  10831. return res;
  10832. };
  10833. function passThroughWrite(buffer) {
  10834. return buffer.toString(this.encoding);
  10835. }
  10836. function utf16DetectIncompleteChar(buffer) {
  10837. this.charReceived = buffer.length % 2;
  10838. this.charLength = this.charReceived ? 2 : 0;
  10839. }
  10840. function base64DetectIncompleteChar(buffer) {
  10841. this.charReceived = buffer.length % 3;
  10842. this.charLength = this.charReceived ? 3 : 0;
  10843. }
  10844. /***/ }),
  10845. /* 70 */
  10846. /***/ (function(module, exports) {
  10847. // Generated by CoffeeScript 1.12.7
  10848. (function() {
  10849. "use strict";
  10850. exports.stripBOM = function(str) {
  10851. if (str[0] === '\uFEFF') {
  10852. return str.substring(1);
  10853. } else {
  10854. return str;
  10855. }
  10856. };
  10857. }).call(this);
  10858. /***/ }),
  10859. /* 71 */
  10860. /***/ (function(module, exports) {
  10861. // Generated by CoffeeScript 1.12.7
  10862. (function() {
  10863. "use strict";
  10864. var prefixMatch;
  10865. prefixMatch = new RegExp(/(?!xmlns)^.*:/);
  10866. exports.normalize = function(str) {
  10867. return str.toLowerCase();
  10868. };
  10869. exports.firstCharLowerCase = function(str) {
  10870. return str.charAt(0).toLowerCase() + str.slice(1);
  10871. };
  10872. exports.stripPrefix = function(str) {
  10873. return str.replace(prefixMatch, '');
  10874. };
  10875. exports.parseNumbers = function(str) {
  10876. if (!isNaN(str)) {
  10877. str = str % 1 === 0 ? parseInt(str, 10) : parseFloat(str);
  10878. }
  10879. return str;
  10880. };
  10881. exports.parseBooleans = function(str) {
  10882. if (/^(?:true|false)$/i.test(str)) {
  10883. str = str.toLowerCase() === 'true';
  10884. }
  10885. return str;
  10886. };
  10887. }).call(this);
  10888. /***/ })
  10889. /******/ ]);