1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024 |
- (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.plist = f()}})(function(){var define,module,exports;return (function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}return e})()({1:[function(require,module,exports){
- /**
- * Parser functions.
- */
-
- var parserFunctions = require('./lib/parse');
- Object.keys(parserFunctions).forEach(function (k) { exports[k] = parserFunctions[k]; });
-
- /**
- * Builder functions.
- */
-
- var builderFunctions = require('./lib/build');
- Object.keys(builderFunctions).forEach(function (k) { exports[k] = builderFunctions[k]; });
-
- },{"./lib/build":2,"./lib/parse":3}],2:[function(require,module,exports){
- (function (Buffer){
- /**
- * Module dependencies.
- */
-
- var base64 = require('base64-js');
- var xmlbuilder = require('xmlbuilder');
-
- /**
- * Module exports.
- */
-
- exports.build = build;
-
- /**
- * Accepts a `Date` instance and returns an ISO date string.
- *
- * @param {Date} d - Date instance to serialize
- * @returns {String} ISO date string representation of `d`
- * @api private
- */
-
- function ISODateString(d){
- function pad(n){
- return n < 10 ? '0' + n : n;
- }
- return d.getUTCFullYear()+'-'
- + pad(d.getUTCMonth()+1)+'-'
- + pad(d.getUTCDate())+'T'
- + pad(d.getUTCHours())+':'
- + pad(d.getUTCMinutes())+':'
- + pad(d.getUTCSeconds())+'Z';
- }
-
- /**
- * Returns the internal "type" of `obj` via the
- * `Object.prototype.toString()` trick.
- *
- * @param {Mixed} obj - any value
- * @returns {String} the internal "type" name
- * @api private
- */
-
- var toString = Object.prototype.toString;
- function type (obj) {
- var m = toString.call(obj).match(/\[object (.*)\]/);
- return m ? m[1] : m;
- }
-
- /**
- * Generate an XML plist string from the input object `obj`.
- *
- * @param {Object} obj - the object to convert
- * @param {Object} [opts] - optional options object
- * @returns {String} converted plist XML string
- * @api public
- */
-
- function build (obj, opts) {
- var XMLHDR = {
- version: '1.0',
- encoding: 'UTF-8'
- };
-
- var XMLDTD = {
- pubid: '-//Apple//DTD PLIST 1.0//EN',
- sysid: 'http://www.apple.com/DTDs/PropertyList-1.0.dtd'
- };
-
- var doc = xmlbuilder.create('plist');
-
- doc.dec(XMLHDR.version, XMLHDR.encoding, XMLHDR.standalone);
- doc.dtd(XMLDTD.pubid, XMLDTD.sysid);
- doc.att('version', '1.0');
-
- walk_obj(obj, doc);
-
- if (!opts) opts = {};
- // default `pretty` to `true`
- opts.pretty = opts.pretty !== false;
- return doc.end(opts);
- }
-
- /**
- * depth first, recursive traversal of a javascript object. when complete,
- * next_child contains a reference to the build XML object.
- *
- * @api private
- */
-
- function walk_obj(next, next_child) {
- var tag_type, i, prop;
- var name = type(next);
-
- if ('Undefined' == name) {
- return;
- } else if (Array.isArray(next)) {
- next_child = next_child.ele('array');
- for (i = 0; i < next.length; i++) {
- walk_obj(next[i], next_child);
- }
-
- } else if (Buffer.isBuffer(next)) {
- next_child.ele('data').raw(next.toString('base64'));
-
- } else if ('Object' == name) {
- next_child = next_child.ele('dict');
- for (prop in next) {
- if (next.hasOwnProperty(prop)) {
- next_child.ele('key').txt(prop);
- walk_obj(next[prop], next_child);
- }
- }
-
- } else if ('Number' == name) {
- // detect if this is an integer or real
- // TODO: add an ability to force one way or another via a "cast"
- tag_type = (next % 1 === 0) ? 'integer' : 'real';
- next_child.ele(tag_type).txt(next.toString());
-
- } else if ('Date' == name) {
- next_child.ele('date').txt(ISODateString(new Date(next)));
-
- } else if ('Boolean' == name) {
- next_child.ele(next ? 'true' : 'false');
-
- } else if ('String' == name) {
- next_child.ele('string').txt(next);
-
- } else if ('ArrayBuffer' == name) {
- next_child.ele('data').raw(base64.fromByteArray(next));
-
- } else if (next && next.buffer && 'ArrayBuffer' == type(next.buffer)) {
- // a typed array
- next_child.ele('data').raw(base64.fromByteArray(new Uint8Array(next.buffer), next_child));
-
- }
- }
-
- }).call(this,{"isBuffer":require("../node_modules/is-buffer/index.js")})
- },{"../node_modules/is-buffer/index.js":7,"base64-js":4,"xmlbuilder":29}],3:[function(require,module,exports){
- (function (Buffer){
- /**
- * Module dependencies.
- */
-
- var DOMParser = require('xmldom').DOMParser;
-
- /**
- * Module exports.
- */
-
- exports.parse = parse;
-
- var TEXT_NODE = 3;
- var CDATA_NODE = 4;
- var COMMENT_NODE = 8;
-
-
- /**
- * We ignore raw text (usually whitespace), <!-- xml comments -->,
- * and raw CDATA nodes.
- *
- * @param {Element} node
- * @returns {Boolean}
- * @api private
- */
-
- function shouldIgnoreNode (node) {
- return node.nodeType === TEXT_NODE
- || node.nodeType === COMMENT_NODE
- || node.nodeType === CDATA_NODE;
- }
-
- /**
- * Check if the node is empty. Some plist file has such node:
- * <key />
- * this node shoud be ignored.
- *
- * @see https://github.com/TooTallNate/plist.js/issues/66
- * @param {Element} node
- * @returns {Boolean}
- * @api private
- */
- function isEmptyNode(node){
- if(!node.childNodes || node.childNodes.length === 0) {
- return true;
- } else {
- return false;
- }
- }
-
- function invariant(test, message) {
- if (!test) {
- throw new Error(message);
- }
- }
-
- /**
- * Parses a Plist XML string. Returns an Object.
- *
- * @param {String} xml - the XML String to decode
- * @returns {Mixed} the decoded value from the Plist XML
- * @api public
- */
-
- function parse (xml) {
- var doc = new DOMParser().parseFromString(xml);
- invariant(
- doc.documentElement.nodeName === 'plist',
- 'malformed document. First element should be <plist>'
- );
- var plist = parsePlistXML(doc.documentElement);
-
- // the root <plist> node gets interpreted as an Array,
- // so pull out the inner data first
- if (plist.length == 1) plist = plist[0];
-
- return plist;
- }
-
- /**
- * Convert an XML based plist document into a JSON representation.
- *
- * @param {Object} xml_node - current XML node in the plist
- * @returns {Mixed} built up JSON object
- * @api private
- */
-
- function parsePlistXML (node) {
- var i, new_obj, key, val, new_arr, res, counter, type;
-
- if (!node)
- return null;
-
- if (node.nodeName === 'plist') {
- new_arr = [];
- if (isEmptyNode(node)) {
- return new_arr;
- }
- for (i=0; i < node.childNodes.length; i++) {
- if (!shouldIgnoreNode(node.childNodes[i])) {
- new_arr.push( parsePlistXML(node.childNodes[i]));
- }
- }
- return new_arr;
- } else if (node.nodeName === 'dict') {
- new_obj = {};
- key = null;
- counter = 0;
- if (isEmptyNode(node)) {
- return new_obj;
- }
- for (i=0; i < node.childNodes.length; i++) {
- if (shouldIgnoreNode(node.childNodes[i])) continue;
- if (counter % 2 === 0) {
- invariant(
- node.childNodes[i].nodeName === 'key',
- 'Missing key while parsing <dict/>.'
- );
- key = parsePlistXML(node.childNodes[i]);
- } else {
- invariant(
- node.childNodes[i].nodeName !== 'key',
- 'Unexpected key "'
- + parsePlistXML(node.childNodes[i])
- + '" while parsing <dict/>.'
- );
- new_obj[key] = parsePlistXML(node.childNodes[i]);
- }
- counter += 1;
- }
- if (counter % 2 === 1) {
- throw new Error('Missing value for "' + key + '" while parsing <dict/>');
- }
- return new_obj;
-
- } else if (node.nodeName === 'array') {
- new_arr = [];
- if (isEmptyNode(node)) {
- return new_arr;
- }
- for (i=0; i < node.childNodes.length; i++) {
- if (!shouldIgnoreNode(node.childNodes[i])) {
- res = parsePlistXML(node.childNodes[i]);
- if (null != res) new_arr.push(res);
- }
- }
- return new_arr;
-
- } else if (node.nodeName === '#text') {
- // TODO: what should we do with text types? (CDATA sections)
-
- } else if (node.nodeName === 'key') {
- if (isEmptyNode(node)) {
- return '';
- }
- return node.childNodes[0].nodeValue;
- } else if (node.nodeName === 'string') {
- res = '';
- if (isEmptyNode(node)) {
- return res;
- }
- for (i=0; i < node.childNodes.length; i++) {
- var type = node.childNodes[i].nodeType;
- if (type === TEXT_NODE || type === CDATA_NODE) {
- res += node.childNodes[i].nodeValue;
- }
- }
- return res;
-
- } else if (node.nodeName === 'integer') {
- invariant(
- !isEmptyNode(node),
- 'Cannot parse "" as integer.'
- );
- return parseInt(node.childNodes[0].nodeValue, 10);
-
- } else if (node.nodeName === 'real') {
- invariant(
- !isEmptyNode(node),
- 'Cannot parse "" as real.'
- );
- res = '';
- for (i=0; i < node.childNodes.length; i++) {
- if (node.childNodes[i].nodeType === TEXT_NODE) {
- res += node.childNodes[i].nodeValue;
- }
- }
- return parseFloat(res);
-
- } else if (node.nodeName === 'data') {
- res = '';
- if (isEmptyNode(node)) {
- return Buffer.from(res, 'base64');
- }
- for (i=0; i < node.childNodes.length; i++) {
- if (node.childNodes[i].nodeType === TEXT_NODE) {
- res += node.childNodes[i].nodeValue.replace(/\s+/g, '');
- }
- }
- return Buffer.from(res, 'base64');
-
- } else if (node.nodeName === 'date') {
- invariant(
- !isEmptyNode(node),
- 'Cannot parse "" as Date.'
- )
- return new Date(node.childNodes[0].nodeValue);
-
- } else if (node.nodeName === 'true') {
- return true;
-
- } else if (node.nodeName === 'false') {
- return false;
- }
- }
-
- }).call(this,require("buffer").Buffer)
- },{"buffer":5,"xmldom":30}],4:[function(require,module,exports){
- 'use strict'
-
- exports.byteLength = byteLength
- exports.toByteArray = toByteArray
- exports.fromByteArray = fromByteArray
-
- var lookup = []
- var revLookup = []
- var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
-
- var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
- for (var i = 0, len = code.length; i < len; ++i) {
- lookup[i] = code[i]
- revLookup[code.charCodeAt(i)] = i
- }
-
- // Support decoding URL-safe base64 strings, as Node.js does.
- // See: https://en.wikipedia.org/wiki/Base64#URL_applications
- revLookup['-'.charCodeAt(0)] = 62
- revLookup['_'.charCodeAt(0)] = 63
-
- function placeHoldersCount (b64) {
- var len = b64.length
- if (len % 4 > 0) {
- throw new Error('Invalid string. Length must be a multiple of 4')
- }
-
- // the number of equal signs (place holders)
- // if there are two placeholders, than the two characters before it
- // represent one byte
- // if there is only one, then the three characters before it represent 2 bytes
- // this is just a cheap hack to not do indexOf twice
- return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0
- }
-
- function byteLength (b64) {
- // base64 is 4/3 + up to two characters of the original data
- return (b64.length * 3 / 4) - placeHoldersCount(b64)
- }
-
- function toByteArray (b64) {
- var i, l, tmp, placeHolders, arr
- var len = b64.length
- placeHolders = placeHoldersCount(b64)
-
- arr = new Arr((len * 3 / 4) - placeHolders)
-
- // if there are placeholders, only get up to the last complete 4 chars
- l = placeHolders > 0 ? len - 4 : len
-
- var L = 0
-
- for (i = 0; i < l; i += 4) {
- tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]
- arr[L++] = (tmp >> 16) & 0xFF
- arr[L++] = (tmp >> 8) & 0xFF
- arr[L++] = tmp & 0xFF
- }
-
- if (placeHolders === 2) {
- tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4)
- arr[L++] = tmp & 0xFF
- } else if (placeHolders === 1) {
- tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2)
- arr[L++] = (tmp >> 8) & 0xFF
- arr[L++] = tmp & 0xFF
- }
-
- return arr
- }
-
- function tripletToBase64 (num) {
- return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
- }
-
- function encodeChunk (uint8, start, end) {
- var tmp
- var output = []
- for (var i = start; i < end; i += 3) {
- tmp = ((uint8[i] << 16) & 0xFF0000) + ((uint8[i + 1] << 8) & 0xFF00) + (uint8[i + 2] & 0xFF)
- output.push(tripletToBase64(tmp))
- }
- return output.join('')
- }
-
- function fromByteArray (uint8) {
- var tmp
- var len = uint8.length
- var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
- var output = ''
- var parts = []
- var maxChunkLength = 16383 // must be multiple of 3
-
- // go through the array every three bytes, we'll deal with trailing stuff later
- for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
- parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
- }
-
- // pad the end with zeros, but make sure to not forget the extra bytes
- if (extraBytes === 1) {
- tmp = uint8[len - 1]
- output += lookup[tmp >> 2]
- output += lookup[(tmp << 4) & 0x3F]
- output += '=='
- } else if (extraBytes === 2) {
- tmp = (uint8[len - 2] << 8) + (uint8[len - 1])
- output += lookup[tmp >> 10]
- output += lookup[(tmp >> 4) & 0x3F]
- output += lookup[(tmp << 2) & 0x3F]
- output += '='
- }
-
- parts.push(output)
-
- return parts.join('')
- }
-
- },{}],5:[function(require,module,exports){
- /*!
- * The buffer module from node.js, for the browser.
- *
- * @author Feross Aboukhadijeh <https://feross.org>
- * @license MIT
- */
- /* eslint-disable no-proto */
-
- 'use strict'
-
- var base64 = require('base64-js')
- var ieee754 = require('ieee754')
-
- exports.Buffer = Buffer
- exports.SlowBuffer = SlowBuffer
- exports.INSPECT_MAX_BYTES = 50
-
- var K_MAX_LENGTH = 0x7fffffff
- exports.kMaxLength = K_MAX_LENGTH
-
- /**
- * If `Buffer.TYPED_ARRAY_SUPPORT`:
- * === true Use Uint8Array implementation (fastest)
- * === false Print warning and recommend using `buffer` v4.x which has an Object
- * implementation (most compatible, even IE6)
- *
- * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
- * Opera 11.6+, iOS 4.2+.
- *
- * We report that the browser does not support typed arrays if the are not subclassable
- * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
- * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
- * for __proto__ and has a buggy typed array implementation.
- */
- Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
-
- if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
- typeof console.error === 'function') {
- console.error(
- 'This browser lacks typed array (Uint8Array) support which is required by ' +
- '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
- )
- }
-
- function typedArraySupport () {
- // Can typed array instances can be augmented?
- try {
- var arr = new Uint8Array(1)
- arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
- return arr.foo() === 42
- } catch (e) {
- return false
- }
- }
-
- Object.defineProperty(Buffer.prototype, 'parent', {
- get: function () {
- if (!(this instanceof Buffer)) {
- return undefined
- }
- return this.buffer
- }
- })
-
- Object.defineProperty(Buffer.prototype, 'offset', {
- get: function () {
- if (!(this instanceof Buffer)) {
- return undefined
- }
- return this.byteOffset
- }
- })
-
- function createBuffer (length) {
- if (length > K_MAX_LENGTH) {
- throw new RangeError('Invalid typed array length')
- }
- // Return an augmented `Uint8Array` instance
- var buf = new Uint8Array(length)
- buf.__proto__ = Buffer.prototype
- return buf
- }
-
- /**
- * The Buffer constructor returns instances of `Uint8Array` that have their
- * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
- * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
- * and the `Uint8Array` methods. Square bracket notation works as expected -- it
- * returns a single octet.
- *
- * The `Uint8Array` prototype remains unmodified.
- */
-
- function Buffer (arg, encodingOrOffset, length) {
- // Common case.
- if (typeof arg === 'number') {
- if (typeof encodingOrOffset === 'string') {
- throw new Error(
- 'If encoding is specified then the first argument must be a string'
- )
- }
- return allocUnsafe(arg)
- }
- return from(arg, encodingOrOffset, length)
- }
-
- // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
- if (typeof Symbol !== 'undefined' && Symbol.species &&
- Buffer[Symbol.species] === Buffer) {
- Object.defineProperty(Buffer, Symbol.species, {
- value: null,
- configurable: true,
- enumerable: false,
- writable: false
- })
- }
-
- Buffer.poolSize = 8192 // not used by this implementation
-
- function from (value, encodingOrOffset, length) {
- if (typeof value === 'number') {
- throw new TypeError('"value" argument must not be a number')
- }
-
- if (isArrayBuffer(value) || (value && isArrayBuffer(value.buffer))) {
- return fromArrayBuffer(value, encodingOrOffset, length)
- }
-
- if (typeof value === 'string') {
- return fromString(value, encodingOrOffset)
- }
-
- return fromObject(value)
- }
-
- /**
- * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
- * if value is a number.
- * Buffer.from(str[, encoding])
- * Buffer.from(array)
- * Buffer.from(buffer)
- * Buffer.from(arrayBuffer[, byteOffset[, length]])
- **/
- Buffer.from = function (value, encodingOrOffset, length) {
- return from(value, encodingOrOffset, length)
- }
-
- // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
- // https://github.com/feross/buffer/pull/148
- Buffer.prototype.__proto__ = Uint8Array.prototype
- Buffer.__proto__ = Uint8Array
-
- function assertSize (size) {
- if (typeof size !== 'number') {
- throw new TypeError('"size" argument must be of type number')
- } else if (size < 0) {
- throw new RangeError('"size" argument must not be negative')
- }
- }
-
- function alloc (size, fill, encoding) {
- assertSize(size)
- if (size <= 0) {
- return createBuffer(size)
- }
- if (fill !== undefined) {
- // Only pay attention to encoding if it's a string. This
- // prevents accidentally sending in a number that would
- // be interpretted as a start offset.
- return typeof encoding === 'string'
- ? createBuffer(size).fill(fill, encoding)
- : createBuffer(size).fill(fill)
- }
- return createBuffer(size)
- }
-
- /**
- * Creates a new filled Buffer instance.
- * alloc(size[, fill[, encoding]])
- **/
- Buffer.alloc = function (size, fill, encoding) {
- return alloc(size, fill, encoding)
- }
-
- function allocUnsafe (size) {
- assertSize(size)
- return createBuffer(size < 0 ? 0 : checked(size) | 0)
- }
-
- /**
- * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
- * */
- Buffer.allocUnsafe = function (size) {
- return allocUnsafe(size)
- }
- /**
- * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
- */
- Buffer.allocUnsafeSlow = function (size) {
- return allocUnsafe(size)
- }
-
- function fromString (string, encoding) {
- if (typeof encoding !== 'string' || encoding === '') {
- encoding = 'utf8'
- }
-
- if (!Buffer.isEncoding(encoding)) {
- throw new TypeError('Unknown encoding: ' + encoding)
- }
-
- var length = byteLength(string, encoding) | 0
- var buf = createBuffer(length)
-
- var actual = buf.write(string, encoding)
-
- if (actual !== length) {
- // Writing a hex string, for example, that contains invalid characters will
- // cause everything after the first invalid character to be ignored. (e.g.
- // 'abxxcd' will be treated as 'ab')
- buf = buf.slice(0, actual)
- }
-
- return buf
- }
-
- function fromArrayLike (array) {
- var length = array.length < 0 ? 0 : checked(array.length) | 0
- var buf = createBuffer(length)
- for (var i = 0; i < length; i += 1) {
- buf[i] = array[i] & 255
- }
- return buf
- }
-
- function fromArrayBuffer (array, byteOffset, length) {
- if (byteOffset < 0 || array.byteLength < byteOffset) {
- throw new RangeError('"offset" is outside of buffer bounds')
- }
-
- if (array.byteLength < byteOffset + (length || 0)) {
- throw new RangeError('"length" is outside of buffer bounds')
- }
-
- var buf
- if (byteOffset === undefined && length === undefined) {
- buf = new Uint8Array(array)
- } else if (length === undefined) {
- buf = new Uint8Array(array, byteOffset)
- } else {
- buf = new Uint8Array(array, byteOffset, length)
- }
-
- // Return an augmented `Uint8Array` instance
- buf.__proto__ = Buffer.prototype
- return buf
- }
-
- function fromObject (obj) {
- if (Buffer.isBuffer(obj)) {
- var len = checked(obj.length) | 0
- var buf = createBuffer(len)
-
- if (buf.length === 0) {
- return buf
- }
-
- obj.copy(buf, 0, 0, len)
- return buf
- }
-
- if (obj) {
- if (ArrayBuffer.isView(obj) || 'length' in obj) {
- if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
- return createBuffer(0)
- }
- return fromArrayLike(obj)
- }
-
- if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
- return fromArrayLike(obj.data)
- }
- }
-
- throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.')
- }
-
- function checked (length) {
- // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
- // length is NaN (which is otherwise coerced to zero.)
- if (length >= K_MAX_LENGTH) {
- throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
- 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
- }
- return length | 0
- }
-
- function SlowBuffer (length) {
- if (+length != length) { // eslint-disable-line eqeqeq
- length = 0
- }
- return Buffer.alloc(+length)
- }
-
- Buffer.isBuffer = function isBuffer (b) {
- return b != null && b._isBuffer === true
- }
-
- Buffer.compare = function compare (a, b) {
- if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
- throw new TypeError('Arguments must be Buffers')
- }
-
- if (a === b) return 0
-
- var x = a.length
- var y = b.length
-
- for (var i = 0, len = Math.min(x, y); i < len; ++i) {
- if (a[i] !== b[i]) {
- x = a[i]
- y = b[i]
- break
- }
- }
-
- if (x < y) return -1
- if (y < x) return 1
- return 0
- }
-
- Buffer.isEncoding = function isEncoding (encoding) {
- switch (String(encoding).toLowerCase()) {
- case 'hex':
- case 'utf8':
- case 'utf-8':
- case 'ascii':
- case 'latin1':
- case 'binary':
- case 'base64':
- case 'ucs2':
- case 'ucs-2':
- case 'utf16le':
- case 'utf-16le':
- return true
- default:
- return false
- }
- }
-
- Buffer.concat = function concat (list, length) {
- if (!Array.isArray(list)) {
- throw new TypeError('"list" argument must be an Array of Buffers')
- }
-
- if (list.length === 0) {
- return Buffer.alloc(0)
- }
-
- var i
- if (length === undefined) {
- length = 0
- for (i = 0; i < list.length; ++i) {
- length += list[i].length
- }
- }
-
- var buffer = Buffer.allocUnsafe(length)
- var pos = 0
- for (i = 0; i < list.length; ++i) {
- var buf = list[i]
- if (ArrayBuffer.isView(buf)) {
- buf = Buffer.from(buf)
- }
- if (!Buffer.isBuffer(buf)) {
- throw new TypeError('"list" argument must be an Array of Buffers')
- }
- buf.copy(buffer, pos)
- pos += buf.length
- }
- return buffer
- }
-
- function byteLength (string, encoding) {
- if (Buffer.isBuffer(string)) {
- return string.length
- }
- if (ArrayBuffer.isView(string) || isArrayBuffer(string)) {
- return string.byteLength
- }
- if (typeof string !== 'string') {
- string = '' + string
- }
-
- var len = string.length
- if (len === 0) return 0
-
- // Use a for loop to avoid recursion
- var loweredCase = false
- for (;;) {
- switch (encoding) {
- case 'ascii':
- case 'latin1':
- case 'binary':
- return len
- case 'utf8':
- case 'utf-8':
- case undefined:
- return utf8ToBytes(string).length
- case 'ucs2':
- case 'ucs-2':
- case 'utf16le':
- case 'utf-16le':
- return len * 2
- case 'hex':
- return len >>> 1
- case 'base64':
- return base64ToBytes(string).length
- default:
- if (loweredCase) return utf8ToBytes(string).length // assume utf8
- encoding = ('' + encoding).toLowerCase()
- loweredCase = true
- }
- }
- }
- Buffer.byteLength = byteLength
-
- function slowToString (encoding, start, end) {
- var loweredCase = false
-
- // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
- // property of a typed array.
-
- // This behaves neither like String nor Uint8Array in that we set start/end
- // to their upper/lower bounds if the value passed is out of range.
- // undefined is handled specially as per ECMA-262 6th Edition,
- // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
- if (start === undefined || start < 0) {
- start = 0
- }
- // Return early if start > this.length. Done here to prevent potential uint32
- // coercion fail below.
- if (start > this.length) {
- return ''
- }
-
- if (end === undefined || end > this.length) {
- end = this.length
- }
-
- if (end <= 0) {
- return ''
- }
-
- // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
- end >>>= 0
- start >>>= 0
-
- if (end <= start) {
- return ''
- }
-
- if (!encoding) encoding = 'utf8'
-
- while (true) {
- switch (encoding) {
- case 'hex':
- return hexSlice(this, start, end)
-
- case 'utf8':
- case 'utf-8':
- return utf8Slice(this, start, end)
-
- case 'ascii':
- return asciiSlice(this, start, end)
-
- case 'latin1':
- case 'binary':
- return latin1Slice(this, start, end)
-
- case 'base64':
- return base64Slice(this, start, end)
-
- case 'ucs2':
- case 'ucs-2':
- case 'utf16le':
- case 'utf-16le':
- return utf16leSlice(this, start, end)
-
- default:
- if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
- encoding = (encoding + '').toLowerCase()
- loweredCase = true
- }
- }
- }
-
- // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
- // to detect a Buffer instance. It's not possible to use `instanceof Buffer`
- // reliably in a browserify context because there could be multiple different
- // copies of the 'buffer' package in use. This method works even for Buffer
- // instances that were created from another copy of the `buffer` package.
- // See: https://github.com/feross/buffer/issues/154
- Buffer.prototype._isBuffer = true
-
- function swap (b, n, m) {
- var i = b[n]
- b[n] = b[m]
- b[m] = i
- }
-
- Buffer.prototype.swap16 = function swap16 () {
- var len = this.length
- if (len % 2 !== 0) {
- throw new RangeError('Buffer size must be a multiple of 16-bits')
- }
- for (var i = 0; i < len; i += 2) {
- swap(this, i, i + 1)
- }
- return this
- }
-
- Buffer.prototype.swap32 = function swap32 () {
- var len = this.length
- if (len % 4 !== 0) {
- throw new RangeError('Buffer size must be a multiple of 32-bits')
- }
- for (var i = 0; i < len; i += 4) {
- swap(this, i, i + 3)
- swap(this, i + 1, i + 2)
- }
- return this
- }
-
- Buffer.prototype.swap64 = function swap64 () {
- var len = this.length
- if (len % 8 !== 0) {
- throw new RangeError('Buffer size must be a multiple of 64-bits')
- }
- for (var i = 0; i < len; i += 8) {
- swap(this, i, i + 7)
- swap(this, i + 1, i + 6)
- swap(this, i + 2, i + 5)
- swap(this, i + 3, i + 4)
- }
- return this
- }
-
- Buffer.prototype.toString = function toString () {
- var length = this.length
- if (length === 0) return ''
- if (arguments.length === 0) return utf8Slice(this, 0, length)
- return slowToString.apply(this, arguments)
- }
-
- Buffer.prototype.toLocaleString = Buffer.prototype.toString
-
- Buffer.prototype.equals = function equals (b) {
- if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
- if (this === b) return true
- return Buffer.compare(this, b) === 0
- }
-
- Buffer.prototype.inspect = function inspect () {
- var str = ''
- var max = exports.INSPECT_MAX_BYTES
- if (this.length > 0) {
- str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
- if (this.length > max) str += ' ... '
- }
- return '<Buffer ' + str + '>'
- }
-
- Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
- if (!Buffer.isBuffer(target)) {
- throw new TypeError('Argument must be a Buffer')
- }
-
- if (start === undefined) {
- start = 0
- }
- if (end === undefined) {
- end = target ? target.length : 0
- }
- if (thisStart === undefined) {
- thisStart = 0
- }
- if (thisEnd === undefined) {
- thisEnd = this.length
- }
-
- if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
- throw new RangeError('out of range index')
- }
-
- if (thisStart >= thisEnd && start >= end) {
- return 0
- }
- if (thisStart >= thisEnd) {
- return -1
- }
- if (start >= end) {
- return 1
- }
-
- start >>>= 0
- end >>>= 0
- thisStart >>>= 0
- thisEnd >>>= 0
-
- if (this === target) return 0
-
- var x = thisEnd - thisStart
- var y = end - start
- var len = Math.min(x, y)
-
- var thisCopy = this.slice(thisStart, thisEnd)
- var targetCopy = target.slice(start, end)
-
- for (var i = 0; i < len; ++i) {
- if (thisCopy[i] !== targetCopy[i]) {
- x = thisCopy[i]
- y = targetCopy[i]
- break
- }
- }
-
- if (x < y) return -1
- if (y < x) return 1
- return 0
- }
-
- // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
- // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
- //
- // Arguments:
- // - buffer - a Buffer to search
- // - val - a string, Buffer, or number
- // - byteOffset - an index into `buffer`; will be clamped to an int32
- // - encoding - an optional encoding, relevant is val is a string
- // - dir - true for indexOf, false for lastIndexOf
- function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
- // Empty buffer means no match
- if (buffer.length === 0) return -1
-
- // Normalize byteOffset
- if (typeof byteOffset === 'string') {
- encoding = byteOffset
- byteOffset = 0
- } else if (byteOffset > 0x7fffffff) {
- byteOffset = 0x7fffffff
- } else if (byteOffset < -0x80000000) {
- byteOffset = -0x80000000
- }
- byteOffset = +byteOffset // Coerce to Number.
- if (numberIsNaN(byteOffset)) {
- // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
- byteOffset = dir ? 0 : (buffer.length - 1)
- }
-
- // Normalize byteOffset: negative offsets start from the end of the buffer
- if (byteOffset < 0) byteOffset = buffer.length + byteOffset
- if (byteOffset >= buffer.length) {
- if (dir) return -1
- else byteOffset = buffer.length - 1
- } else if (byteOffset < 0) {
- if (dir) byteOffset = 0
- else return -1
- }
-
- // Normalize val
- if (typeof val === 'string') {
- val = Buffer.from(val, encoding)
- }
-
- // Finally, search either indexOf (if dir is true) or lastIndexOf
- if (Buffer.isBuffer(val)) {
- // Special case: looking for empty string/buffer always fails
- if (val.length === 0) {
- return -1
- }
- return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
- } else if (typeof val === 'number') {
- val = val & 0xFF // Search for a byte value [0-255]
- if (typeof Uint8Array.prototype.indexOf === 'function') {
- if (dir) {
- return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
- } else {
- return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
- }
- }
- return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
- }
-
- throw new TypeError('val must be string, number or Buffer')
- }
-
- function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
- var indexSize = 1
- var arrLength = arr.length
- var valLength = val.length
-
- if (encoding !== undefined) {
- encoding = String(encoding).toLowerCase()
- if (encoding === 'ucs2' || encoding === 'ucs-2' ||
- encoding === 'utf16le' || encoding === 'utf-16le') {
- if (arr.length < 2 || val.length < 2) {
- return -1
- }
- indexSize = 2
- arrLength /= 2
- valLength /= 2
- byteOffset /= 2
- }
- }
-
- function read (buf, i) {
- if (indexSize === 1) {
- return buf[i]
- } else {
- return buf.readUInt16BE(i * indexSize)
- }
- }
-
- var i
- if (dir) {
- var foundIndex = -1
- for (i = byteOffset; i < arrLength; i++) {
- if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
- if (foundIndex === -1) foundIndex = i
- if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
- } else {
- if (foundIndex !== -1) i -= i - foundIndex
- foundIndex = -1
- }
- }
- } else {
- if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
- for (i = byteOffset; i >= 0; i--) {
- var found = true
- for (var j = 0; j < valLength; j++) {
- if (read(arr, i + j) !== read(val, j)) {
- found = false
- break
- }
- }
- if (found) return i
- }
- }
-
- return -1
- }
-
- Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
- return this.indexOf(val, byteOffset, encoding) !== -1
- }
-
- Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
- return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
- }
-
- Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
- return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
- }
-
- function hexWrite (buf, string, offset, length) {
- offset = Number(offset) || 0
- var remaining = buf.length - offset
- if (!length) {
- length = remaining
- } else {
- length = Number(length)
- if (length > remaining) {
- length = remaining
- }
- }
-
- var strLen = string.length
-
- if (length > strLen / 2) {
- length = strLen / 2
- }
- for (var i = 0; i < length; ++i) {
- var parsed = parseInt(string.substr(i * 2, 2), 16)
- if (numberIsNaN(parsed)) return i
- buf[offset + i] = parsed
- }
- return i
- }
-
- function utf8Write (buf, string, offset, length) {
- return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
- }
-
- function asciiWrite (buf, string, offset, length) {
- return blitBuffer(asciiToBytes(string), buf, offset, length)
- }
-
- function latin1Write (buf, string, offset, length) {
- return asciiWrite(buf, string, offset, length)
- }
-
- function base64Write (buf, string, offset, length) {
- return blitBuffer(base64ToBytes(string), buf, offset, length)
- }
-
- function ucs2Write (buf, string, offset, length) {
- return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
- }
-
- Buffer.prototype.write = function write (string, offset, length, encoding) {
- // Buffer#write(string)
- if (offset === undefined) {
- encoding = 'utf8'
- length = this.length
- offset = 0
- // Buffer#write(string, encoding)
- } else if (length === undefined && typeof offset === 'string') {
- encoding = offset
- length = this.length
- offset = 0
- // Buffer#write(string, offset[, length][, encoding])
- } else if (isFinite(offset)) {
- offset = offset >>> 0
- if (isFinite(length)) {
- length = length >>> 0
- if (encoding === undefined) encoding = 'utf8'
- } else {
- encoding = length
- length = undefined
- }
- } else {
- throw new Error(
- 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
- )
- }
-
- var remaining = this.length - offset
- if (length === undefined || length > remaining) length = remaining
-
- if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
- throw new RangeError('Attempt to write outside buffer bounds')
- }
-
- if (!encoding) encoding = 'utf8'
-
- var loweredCase = false
- for (;;) {
- switch (encoding) {
- case 'hex':
- return hexWrite(this, string, offset, length)
-
- case 'utf8':
- case 'utf-8':
- return utf8Write(this, string, offset, length)
-
- case 'ascii':
- return asciiWrite(this, string, offset, length)
-
- case 'latin1':
- case 'binary':
- return latin1Write(this, string, offset, length)
-
- case 'base64':
- // Warning: maxLength not taken into account in base64Write
- return base64Write(this, string, offset, length)
-
- case 'ucs2':
- case 'ucs-2':
- case 'utf16le':
- case 'utf-16le':
- return ucs2Write(this, string, offset, length)
-
- default:
- if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
- encoding = ('' + encoding).toLowerCase()
- loweredCase = true
- }
- }
- }
-
- Buffer.prototype.toJSON = function toJSON () {
- return {
- type: 'Buffer',
- data: Array.prototype.slice.call(this._arr || this, 0)
- }
- }
-
- function base64Slice (buf, start, end) {
- if (start === 0 && end === buf.length) {
- return base64.fromByteArray(buf)
- } else {
- return base64.fromByteArray(buf.slice(start, end))
- }
- }
-
- function utf8Slice (buf, start, end) {
- end = Math.min(buf.length, end)
- var res = []
-
- var i = start
- while (i < end) {
- var firstByte = buf[i]
- var codePoint = null
- var bytesPerSequence = (firstByte > 0xEF) ? 4
- : (firstByte > 0xDF) ? 3
- : (firstByte > 0xBF) ? 2
- : 1
-
- if (i + bytesPerSequence <= end) {
- var secondByte, thirdByte, fourthByte, tempCodePoint
-
- switch (bytesPerSequence) {
- case 1:
- if (firstByte < 0x80) {
- codePoint = firstByte
- }
- break
- case 2:
- secondByte = buf[i + 1]
- if ((secondByte & 0xC0) === 0x80) {
- tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
- if (tempCodePoint > 0x7F) {
- codePoint = tempCodePoint
- }
- }
- break
- case 3:
- secondByte = buf[i + 1]
- thirdByte = buf[i + 2]
- if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
- tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
- if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
- codePoint = tempCodePoint
- }
- }
- break
- case 4:
- secondByte = buf[i + 1]
- thirdByte = buf[i + 2]
- fourthByte = buf[i + 3]
- if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
- tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
- if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
- codePoint = tempCodePoint
- }
- }
- }
- }
-
- if (codePoint === null) {
- // we did not generate a valid codePoint so insert a
- // replacement char (U+FFFD) and advance only 1 byte
- codePoint = 0xFFFD
- bytesPerSequence = 1
- } else if (codePoint > 0xFFFF) {
- // encode to utf16 (surrogate pair dance)
- codePoint -= 0x10000
- res.push(codePoint >>> 10 & 0x3FF | 0xD800)
- codePoint = 0xDC00 | codePoint & 0x3FF
- }
-
- res.push(codePoint)
- i += bytesPerSequence
- }
-
- return decodeCodePointsArray(res)
- }
-
- // Based on http://stackoverflow.com/a/22747272/680742, the browser with
- // the lowest limit is Chrome, with 0x10000 args.
- // We go 1 magnitude less, for safety
- var MAX_ARGUMENTS_LENGTH = 0x1000
-
- function decodeCodePointsArray (codePoints) {
- var len = codePoints.length
- if (len <= MAX_ARGUMENTS_LENGTH) {
- return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
- }
-
- // Decode in chunks to avoid "call stack size exceeded".
- var res = ''
- var i = 0
- while (i < len) {
- res += String.fromCharCode.apply(
- String,
- codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
- )
- }
- return res
- }
-
- function asciiSlice (buf, start, end) {
- var ret = ''
- end = Math.min(buf.length, end)
-
- for (var i = start; i < end; ++i) {
- ret += String.fromCharCode(buf[i] & 0x7F)
- }
- return ret
- }
-
- function latin1Slice (buf, start, end) {
- var ret = ''
- end = Math.min(buf.length, end)
-
- for (var i = start; i < end; ++i) {
- ret += String.fromCharCode(buf[i])
- }
- return ret
- }
-
- function hexSlice (buf, start, end) {
- var len = buf.length
-
- if (!start || start < 0) start = 0
- if (!end || end < 0 || end > len) end = len
-
- var out = ''
- for (var i = start; i < end; ++i) {
- out += toHex(buf[i])
- }
- return out
- }
-
- function utf16leSlice (buf, start, end) {
- var bytes = buf.slice(start, end)
- var res = ''
- for (var i = 0; i < bytes.length; i += 2) {
- res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
- }
- return res
- }
-
- Buffer.prototype.slice = function slice (start, end) {
- var len = this.length
- start = ~~start
- end = end === undefined ? len : ~~end
-
- if (start < 0) {
- start += len
- if (start < 0) start = 0
- } else if (start > len) {
- start = len
- }
-
- if (end < 0) {
- end += len
- if (end < 0) end = 0
- } else if (end > len) {
- end = len
- }
-
- if (end < start) end = start
-
- var newBuf = this.subarray(start, end)
- // Return an augmented `Uint8Array` instance
- newBuf.__proto__ = Buffer.prototype
- return newBuf
- }
-
- /*
- * Need to make sure that buffer isn't trying to write out of bounds.
- */
- function checkOffset (offset, ext, length) {
- if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
- if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
- }
-
- Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
- offset = offset >>> 0
- byteLength = byteLength >>> 0
- if (!noAssert) checkOffset(offset, byteLength, this.length)
-
- var val = this[offset]
- var mul = 1
- var i = 0
- while (++i < byteLength && (mul *= 0x100)) {
- val += this[offset + i] * mul
- }
-
- return val
- }
-
- Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
- offset = offset >>> 0
- byteLength = byteLength >>> 0
- if (!noAssert) {
- checkOffset(offset, byteLength, this.length)
- }
-
- var val = this[offset + --byteLength]
- var mul = 1
- while (byteLength > 0 && (mul *= 0x100)) {
- val += this[offset + --byteLength] * mul
- }
-
- return val
- }
-
- Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 1, this.length)
- return this[offset]
- }
-
- Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 2, this.length)
- return this[offset] | (this[offset + 1] << 8)
- }
-
- Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 2, this.length)
- return (this[offset] << 8) | this[offset + 1]
- }
-
- Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 4, this.length)
-
- return ((this[offset]) |
- (this[offset + 1] << 8) |
- (this[offset + 2] << 16)) +
- (this[offset + 3] * 0x1000000)
- }
-
- Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 4, this.length)
-
- return (this[offset] * 0x1000000) +
- ((this[offset + 1] << 16) |
- (this[offset + 2] << 8) |
- this[offset + 3])
- }
-
- Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
- offset = offset >>> 0
- byteLength = byteLength >>> 0
- if (!noAssert) checkOffset(offset, byteLength, this.length)
-
- var val = this[offset]
- var mul = 1
- var i = 0
- while (++i < byteLength && (mul *= 0x100)) {
- val += this[offset + i] * mul
- }
- mul *= 0x80
-
- if (val >= mul) val -= Math.pow(2, 8 * byteLength)
-
- return val
- }
-
- Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
- offset = offset >>> 0
- byteLength = byteLength >>> 0
- if (!noAssert) checkOffset(offset, byteLength, this.length)
-
- var i = byteLength
- var mul = 1
- var val = this[offset + --i]
- while (i > 0 && (mul *= 0x100)) {
- val += this[offset + --i] * mul
- }
- mul *= 0x80
-
- if (val >= mul) val -= Math.pow(2, 8 * byteLength)
-
- return val
- }
-
- Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 1, this.length)
- if (!(this[offset] & 0x80)) return (this[offset])
- return ((0xff - this[offset] + 1) * -1)
- }
-
- Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 2, this.length)
- var val = this[offset] | (this[offset + 1] << 8)
- return (val & 0x8000) ? val | 0xFFFF0000 : val
- }
-
- Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 2, this.length)
- var val = this[offset + 1] | (this[offset] << 8)
- return (val & 0x8000) ? val | 0xFFFF0000 : val
- }
-
- Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 4, this.length)
-
- return (this[offset]) |
- (this[offset + 1] << 8) |
- (this[offset + 2] << 16) |
- (this[offset + 3] << 24)
- }
-
- Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 4, this.length)
-
- return (this[offset] << 24) |
- (this[offset + 1] << 16) |
- (this[offset + 2] << 8) |
- (this[offset + 3])
- }
-
- Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 4, this.length)
- return ieee754.read(this, offset, true, 23, 4)
- }
-
- Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 4, this.length)
- return ieee754.read(this, offset, false, 23, 4)
- }
-
- Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 8, this.length)
- return ieee754.read(this, offset, true, 52, 8)
- }
-
- Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
- offset = offset >>> 0
- if (!noAssert) checkOffset(offset, 8, this.length)
- return ieee754.read(this, offset, false, 52, 8)
- }
-
- function checkInt (buf, value, offset, ext, max, min) {
- if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
- if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
- if (offset + ext > buf.length) throw new RangeError('Index out of range')
- }
-
- Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
- value = +value
- offset = offset >>> 0
- byteLength = byteLength >>> 0
- if (!noAssert) {
- var maxBytes = Math.pow(2, 8 * byteLength) - 1
- checkInt(this, value, offset, byteLength, maxBytes, 0)
- }
-
- var mul = 1
- var i = 0
- this[offset] = value & 0xFF
- while (++i < byteLength && (mul *= 0x100)) {
- this[offset + i] = (value / mul) & 0xFF
- }
-
- return offset + byteLength
- }
-
- Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
- value = +value
- offset = offset >>> 0
- byteLength = byteLength >>> 0
- if (!noAssert) {
- var maxBytes = Math.pow(2, 8 * byteLength) - 1
- checkInt(this, value, offset, byteLength, maxBytes, 0)
- }
-
- var i = byteLength - 1
- var mul = 1
- this[offset + i] = value & 0xFF
- while (--i >= 0 && (mul *= 0x100)) {
- this[offset + i] = (value / mul) & 0xFF
- }
-
- return offset + byteLength
- }
-
- Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
- this[offset] = (value & 0xff)
- return offset + 1
- }
-
- Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
- this[offset] = (value & 0xff)
- this[offset + 1] = (value >>> 8)
- return offset + 2
- }
-
- Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
- this[offset] = (value >>> 8)
- this[offset + 1] = (value & 0xff)
- return offset + 2
- }
-
- Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
- this[offset + 3] = (value >>> 24)
- this[offset + 2] = (value >>> 16)
- this[offset + 1] = (value >>> 8)
- this[offset] = (value & 0xff)
- return offset + 4
- }
-
- Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
- this[offset] = (value >>> 24)
- this[offset + 1] = (value >>> 16)
- this[offset + 2] = (value >>> 8)
- this[offset + 3] = (value & 0xff)
- return offset + 4
- }
-
- Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) {
- var limit = Math.pow(2, (8 * byteLength) - 1)
-
- checkInt(this, value, offset, byteLength, limit - 1, -limit)
- }
-
- var i = 0
- var mul = 1
- var sub = 0
- this[offset] = value & 0xFF
- while (++i < byteLength && (mul *= 0x100)) {
- if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
- sub = 1
- }
- this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
- }
-
- return offset + byteLength
- }
-
- Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) {
- var limit = Math.pow(2, (8 * byteLength) - 1)
-
- checkInt(this, value, offset, byteLength, limit - 1, -limit)
- }
-
- var i = byteLength - 1
- var mul = 1
- var sub = 0
- this[offset + i] = value & 0xFF
- while (--i >= 0 && (mul *= 0x100)) {
- if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
- sub = 1
- }
- this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
- }
-
- return offset + byteLength
- }
-
- Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
- if (value < 0) value = 0xff + value + 1
- this[offset] = (value & 0xff)
- return offset + 1
- }
-
- Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
- this[offset] = (value & 0xff)
- this[offset + 1] = (value >>> 8)
- return offset + 2
- }
-
- Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
- this[offset] = (value >>> 8)
- this[offset + 1] = (value & 0xff)
- return offset + 2
- }
-
- Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
- this[offset] = (value & 0xff)
- this[offset + 1] = (value >>> 8)
- this[offset + 2] = (value >>> 16)
- this[offset + 3] = (value >>> 24)
- return offset + 4
- }
-
- Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
- if (value < 0) value = 0xffffffff + value + 1
- this[offset] = (value >>> 24)
- this[offset + 1] = (value >>> 16)
- this[offset + 2] = (value >>> 8)
- this[offset + 3] = (value & 0xff)
- return offset + 4
- }
-
- function checkIEEE754 (buf, value, offset, ext, max, min) {
- if (offset + ext > buf.length) throw new RangeError('Index out of range')
- if (offset < 0) throw new RangeError('Index out of range')
- }
-
- function writeFloat (buf, value, offset, littleEndian, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) {
- checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
- }
- ieee754.write(buf, value, offset, littleEndian, 23, 4)
- return offset + 4
- }
-
- Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
- return writeFloat(this, value, offset, true, noAssert)
- }
-
- Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
- return writeFloat(this, value, offset, false, noAssert)
- }
-
- function writeDouble (buf, value, offset, littleEndian, noAssert) {
- value = +value
- offset = offset >>> 0
- if (!noAssert) {
- checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
- }
- ieee754.write(buf, value, offset, littleEndian, 52, 8)
- return offset + 8
- }
-
- Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
- return writeDouble(this, value, offset, true, noAssert)
- }
-
- Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
- return writeDouble(this, value, offset, false, noAssert)
- }
-
- // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
- Buffer.prototype.copy = function copy (target, targetStart, start, end) {
- if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
- if (!start) start = 0
- if (!end && end !== 0) end = this.length
- if (targetStart >= target.length) targetStart = target.length
- if (!targetStart) targetStart = 0
- if (end > 0 && end < start) end = start
-
- // Copy 0 bytes; we're done
- if (end === start) return 0
- if (target.length === 0 || this.length === 0) return 0
-
- // Fatal error conditions
- if (targetStart < 0) {
- throw new RangeError('targetStart out of bounds')
- }
- if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
- if (end < 0) throw new RangeError('sourceEnd out of bounds')
-
- // Are we oob?
- if (end > this.length) end = this.length
- if (target.length - targetStart < end - start) {
- end = target.length - targetStart + start
- }
-
- var len = end - start
-
- if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
- // Use built-in when available, missing from IE11
- this.copyWithin(targetStart, start, end)
- } else if (this === target && start < targetStart && targetStart < end) {
- // descending copy from end
- for (var i = len - 1; i >= 0; --i) {
- target[i + targetStart] = this[i + start]
- }
- } else {
- Uint8Array.prototype.set.call(
- target,
- this.subarray(start, end),
- targetStart
- )
- }
-
- return len
- }
-
- // Usage:
- // buffer.fill(number[, offset[, end]])
- // buffer.fill(buffer[, offset[, end]])
- // buffer.fill(string[, offset[, end]][, encoding])
- Buffer.prototype.fill = function fill (val, start, end, encoding) {
- // Handle string cases:
- if (typeof val === 'string') {
- if (typeof start === 'string') {
- encoding = start
- start = 0
- end = this.length
- } else if (typeof end === 'string') {
- encoding = end
- end = this.length
- }
- if (encoding !== undefined && typeof encoding !== 'string') {
- throw new TypeError('encoding must be a string')
- }
- if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
- throw new TypeError('Unknown encoding: ' + encoding)
- }
- if (val.length === 1) {
- var code = val.charCodeAt(0)
- if ((encoding === 'utf8' && code < 128) ||
- encoding === 'latin1') {
- // Fast path: If `val` fits into a single byte, use that numeric value.
- val = code
- }
- }
- } else if (typeof val === 'number') {
- val = val & 255
- }
-
- // Invalid ranges are not set to a default, so can range check early.
- if (start < 0 || this.length < start || this.length < end) {
- throw new RangeError('Out of range index')
- }
-
- if (end <= start) {
- return this
- }
-
- start = start >>> 0
- end = end === undefined ? this.length : end >>> 0
-
- if (!val) val = 0
-
- var i
- if (typeof val === 'number') {
- for (i = start; i < end; ++i) {
- this[i] = val
- }
- } else {
- var bytes = Buffer.isBuffer(val)
- ? val
- : new Buffer(val, encoding)
- var len = bytes.length
- if (len === 0) {
- throw new TypeError('The value "' + val +
- '" is invalid for argument "value"')
- }
- for (i = 0; i < end - start; ++i) {
- this[i + start] = bytes[i % len]
- }
- }
-
- return this
- }
-
- // HELPER FUNCTIONS
- // ================
-
- var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
-
- function base64clean (str) {
- // Node takes equal signs as end of the Base64 encoding
- str = str.split('=')[0]
- // Node strips out invalid characters like \n and \t from the string, base64-js does not
- str = str.trim().replace(INVALID_BASE64_RE, '')
- // Node converts strings with length < 2 to ''
- if (str.length < 2) return ''
- // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
- while (str.length % 4 !== 0) {
- str = str + '='
- }
- return str
- }
-
- function toHex (n) {
- if (n < 16) return '0' + n.toString(16)
- return n.toString(16)
- }
-
- function utf8ToBytes (string, units) {
- units = units || Infinity
- var codePoint
- var length = string.length
- var leadSurrogate = null
- var bytes = []
-
- for (var i = 0; i < length; ++i) {
- codePoint = string.charCodeAt(i)
-
- // is surrogate component
- if (codePoint > 0xD7FF && codePoint < 0xE000) {
- // last char was a lead
- if (!leadSurrogate) {
- // no lead yet
- if (codePoint > 0xDBFF) {
- // unexpected trail
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
- continue
- } else if (i + 1 === length) {
- // unpaired lead
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
- continue
- }
-
- // valid lead
- leadSurrogate = codePoint
-
- continue
- }
-
- // 2 leads in a row
- if (codePoint < 0xDC00) {
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
- leadSurrogate = codePoint
- continue
- }
-
- // valid surrogate pair
- codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
- } else if (leadSurrogate) {
- // valid bmp char, but last char was a lead
- if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
- }
-
- leadSurrogate = null
-
- // encode utf8
- if (codePoint < 0x80) {
- if ((units -= 1) < 0) break
- bytes.push(codePoint)
- } else if (codePoint < 0x800) {
- if ((units -= 2) < 0) break
- bytes.push(
- codePoint >> 0x6 | 0xC0,
- codePoint & 0x3F | 0x80
- )
- } else if (codePoint < 0x10000) {
- if ((units -= 3) < 0) break
- bytes.push(
- codePoint >> 0xC | 0xE0,
- codePoint >> 0x6 & 0x3F | 0x80,
- codePoint & 0x3F | 0x80
- )
- } else if (codePoint < 0x110000) {
- if ((units -= 4) < 0) break
- bytes.push(
- codePoint >> 0x12 | 0xF0,
- codePoint >> 0xC & 0x3F | 0x80,
- codePoint >> 0x6 & 0x3F | 0x80,
- codePoint & 0x3F | 0x80
- )
- } else {
- throw new Error('Invalid code point')
- }
- }
-
- return bytes
- }
-
- function asciiToBytes (str) {
- var byteArray = []
- for (var i = 0; i < str.length; ++i) {
- // Node's code seems to be doing this and not & 0x7F..
- byteArray.push(str.charCodeAt(i) & 0xFF)
- }
- return byteArray
- }
-
- function utf16leToBytes (str, units) {
- var c, hi, lo
- var byteArray = []
- for (var i = 0; i < str.length; ++i) {
- if ((units -= 2) < 0) break
-
- c = str.charCodeAt(i)
- hi = c >> 8
- lo = c % 256
- byteArray.push(lo)
- byteArray.push(hi)
- }
-
- return byteArray
- }
-
- function base64ToBytes (str) {
- return base64.toByteArray(base64clean(str))
- }
-
- function blitBuffer (src, dst, offset, length) {
- for (var i = 0; i < length; ++i) {
- if ((i + offset >= dst.length) || (i >= src.length)) break
- dst[i + offset] = src[i]
- }
- return i
- }
-
- // ArrayBuffers from another context (i.e. an iframe) do not pass the `instanceof` check
- // but they should be treated as valid. See: https://github.com/feross/buffer/issues/166
- function isArrayBuffer (obj) {
- return obj instanceof ArrayBuffer ||
- (obj != null && obj.constructor != null && obj.constructor.name === 'ArrayBuffer' &&
- typeof obj.byteLength === 'number')
- }
-
- function numberIsNaN (obj) {
- return obj !== obj // eslint-disable-line no-self-compare
- }
-
- },{"base64-js":4,"ieee754":6}],6:[function(require,module,exports){
- exports.read = function (buffer, offset, isLE, mLen, nBytes) {
- var e, m
- var eLen = (nBytes * 8) - mLen - 1
- var eMax = (1 << eLen) - 1
- var eBias = eMax >> 1
- var nBits = -7
- var i = isLE ? (nBytes - 1) : 0
- var d = isLE ? -1 : 1
- var s = buffer[offset + i]
-
- i += d
-
- e = s & ((1 << (-nBits)) - 1)
- s >>= (-nBits)
- nBits += eLen
- for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
-
- m = e & ((1 << (-nBits)) - 1)
- e >>= (-nBits)
- nBits += mLen
- for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
-
- if (e === 0) {
- e = 1 - eBias
- } else if (e === eMax) {
- return m ? NaN : ((s ? -1 : 1) * Infinity)
- } else {
- m = m + Math.pow(2, mLen)
- e = e - eBias
- }
- return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
- }
-
- exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
- var e, m, c
- var eLen = (nBytes * 8) - mLen - 1
- var eMax = (1 << eLen) - 1
- var eBias = eMax >> 1
- var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
- var i = isLE ? 0 : (nBytes - 1)
- var d = isLE ? 1 : -1
- var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
-
- value = Math.abs(value)
-
- if (isNaN(value) || value === Infinity) {
- m = isNaN(value) ? 1 : 0
- e = eMax
- } else {
- e = Math.floor(Math.log(value) / Math.LN2)
- if (value * (c = Math.pow(2, -e)) < 1) {
- e--
- c *= 2
- }
- if (e + eBias >= 1) {
- value += rt / c
- } else {
- value += rt * Math.pow(2, 1 - eBias)
- }
- if (value * c >= 2) {
- e++
- c /= 2
- }
-
- if (e + eBias >= eMax) {
- m = 0
- e = eMax
- } else if (e + eBias >= 1) {
- m = ((value * c) - 1) * Math.pow(2, mLen)
- e = e + eBias
- } else {
- m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
- e = 0
- }
- }
-
- for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
-
- e = (e << mLen) | m
- eLen += mLen
- for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
-
- buffer[offset + i - d] |= s * 128
- }
-
- },{}],7:[function(require,module,exports){
- /*!
- * Determine if an object is a Buffer
- *
- * @author Feross Aboukhadijeh <https://feross.org>
- * @license MIT
- */
-
- // The _isBuffer check is for Safari 5-7 support, because it's missing
- // Object.prototype.constructor. Remove this eventually
- module.exports = function (obj) {
- return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
- }
-
- function isBuffer (obj) {
- return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
- }
-
- // For Node v0.10 support. Remove this eventually.
- function isSlowBuffer (obj) {
- return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
- }
-
- },{}],8:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var assign, isArray, isEmpty, isFunction, isObject, isPlainObject,
- slice = [].slice,
- hasProp = {}.hasOwnProperty;
-
- assign = function() {
- var i, key, len, source, sources, target;
- target = arguments[0], sources = 2 <= arguments.length ? slice.call(arguments, 1) : [];
- if (isFunction(Object.assign)) {
- Object.assign.apply(null, arguments);
- } else {
- for (i = 0, len = sources.length; i < len; i++) {
- source = sources[i];
- if (source != null) {
- for (key in source) {
- if (!hasProp.call(source, key)) continue;
- target[key] = source[key];
- }
- }
- }
- }
- return target;
- };
-
- isFunction = function(val) {
- return !!val && Object.prototype.toString.call(val) === '[object Function]';
- };
-
- isObject = function(val) {
- var ref;
- return !!val && ((ref = typeof val) === 'function' || ref === 'object');
- };
-
- isArray = function(val) {
- if (isFunction(Array.isArray)) {
- return Array.isArray(val);
- } else {
- return Object.prototype.toString.call(val) === '[object Array]';
- }
- };
-
- isEmpty = function(val) {
- var key;
- if (isArray(val)) {
- return !val.length;
- } else {
- for (key in val) {
- if (!hasProp.call(val, key)) continue;
- return false;
- }
- return true;
- }
- };
-
- isPlainObject = function(val) {
- var ctor, proto;
- 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));
- };
-
- module.exports.assign = assign;
-
- module.exports.isFunction = isFunction;
-
- module.exports.isObject = isObject;
-
- module.exports.isArray = isArray;
-
- module.exports.isEmpty = isEmpty;
-
- module.exports.isPlainObject = isPlainObject;
-
- }).call(this);
-
- },{}],9:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLAttribute;
-
- module.exports = XMLAttribute = (function() {
- function XMLAttribute(parent, name, value) {
- this.options = parent.options;
- this.stringify = parent.stringify;
- if (name == null) {
- throw new Error("Missing attribute name of element " + parent.name);
- }
- if (value == null) {
- throw new Error("Missing attribute value for attribute " + name + " of element " + parent.name);
- }
- this.name = this.stringify.attName(name);
- this.value = this.stringify.attValue(value);
- }
-
- XMLAttribute.prototype.clone = function() {
- return Object.create(this);
- };
-
- XMLAttribute.prototype.toString = function(options) {
- return this.options.writer.set(options).attribute(this);
- };
-
- return XMLAttribute;
-
- })();
-
- }).call(this);
-
- },{}],10:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLCData, XMLNode,
- 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; },
- hasProp = {}.hasOwnProperty;
-
- XMLNode = require('./XMLNode');
-
- module.exports = XMLCData = (function(superClass) {
- extend(XMLCData, superClass);
-
- function XMLCData(parent, text) {
- XMLCData.__super__.constructor.call(this, parent);
- if (text == null) {
- throw new Error("Missing CDATA text");
- }
- this.text = this.stringify.cdata(text);
- }
-
- XMLCData.prototype.clone = function() {
- return Object.create(this);
- };
-
- XMLCData.prototype.toString = function(options) {
- return this.options.writer.set(options).cdata(this);
- };
-
- return XMLCData;
-
- })(XMLNode);
-
- }).call(this);
-
- },{"./XMLNode":21}],11:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLComment, XMLNode,
- 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; },
- hasProp = {}.hasOwnProperty;
-
- XMLNode = require('./XMLNode');
-
- module.exports = XMLComment = (function(superClass) {
- extend(XMLComment, superClass);
-
- function XMLComment(parent, text) {
- XMLComment.__super__.constructor.call(this, parent);
- if (text == null) {
- throw new Error("Missing comment text");
- }
- this.text = this.stringify.comment(text);
- }
-
- XMLComment.prototype.clone = function() {
- return Object.create(this);
- };
-
- XMLComment.prototype.toString = function(options) {
- return this.options.writer.set(options).comment(this);
- };
-
- return XMLComment;
-
- })(XMLNode);
-
- }).call(this);
-
- },{"./XMLNode":21}],12:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLDTDAttList, XMLNode,
- 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; },
- hasProp = {}.hasOwnProperty;
-
- XMLNode = require('./XMLNode');
-
- module.exports = XMLDTDAttList = (function(superClass) {
- extend(XMLDTDAttList, superClass);
-
- function XMLDTDAttList(parent, elementName, attributeName, attributeType, defaultValueType, defaultValue) {
- XMLDTDAttList.__super__.constructor.call(this, parent);
- if (elementName == null) {
- throw new Error("Missing DTD element name");
- }
- if (attributeName == null) {
- throw new Error("Missing DTD attribute name");
- }
- if (!attributeType) {
- throw new Error("Missing DTD attribute type");
- }
- if (!defaultValueType) {
- throw new Error("Missing DTD attribute default");
- }
- if (defaultValueType.indexOf('#') !== 0) {
- defaultValueType = '#' + defaultValueType;
- }
- if (!defaultValueType.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/)) {
- throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT");
- }
- if (defaultValue && !defaultValueType.match(/^(#FIXED|#DEFAULT)$/)) {
- throw new Error("Default value only applies to #FIXED or #DEFAULT");
- }
- this.elementName = this.stringify.eleName(elementName);
- this.attributeName = this.stringify.attName(attributeName);
- this.attributeType = this.stringify.dtdAttType(attributeType);
- this.defaultValue = this.stringify.dtdAttDefault(defaultValue);
- this.defaultValueType = defaultValueType;
- }
-
- XMLDTDAttList.prototype.toString = function(options) {
- return this.options.writer.set(options).dtdAttList(this);
- };
-
- return XMLDTDAttList;
-
- })(XMLNode);
-
- }).call(this);
-
- },{"./XMLNode":21}],13:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLDTDElement, XMLNode,
- 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; },
- hasProp = {}.hasOwnProperty;
-
- XMLNode = require('./XMLNode');
-
- module.exports = XMLDTDElement = (function(superClass) {
- extend(XMLDTDElement, superClass);
-
- function XMLDTDElement(parent, name, value) {
- XMLDTDElement.__super__.constructor.call(this, parent);
- if (name == null) {
- throw new Error("Missing DTD element name");
- }
- if (!value) {
- value = '(#PCDATA)';
- }
- if (Array.isArray(value)) {
- value = '(' + value.join(',') + ')';
- }
- this.name = this.stringify.eleName(name);
- this.value = this.stringify.dtdElementValue(value);
- }
-
- XMLDTDElement.prototype.toString = function(options) {
- return this.options.writer.set(options).dtdElement(this);
- };
-
- return XMLDTDElement;
-
- })(XMLNode);
-
- }).call(this);
-
- },{"./XMLNode":21}],14:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLDTDEntity, XMLNode, isObject,
- 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; },
- hasProp = {}.hasOwnProperty;
-
- isObject = require('./Utility').isObject;
-
- XMLNode = require('./XMLNode');
-
- module.exports = XMLDTDEntity = (function(superClass) {
- extend(XMLDTDEntity, superClass);
-
- function XMLDTDEntity(parent, pe, name, value) {
- XMLDTDEntity.__super__.constructor.call(this, parent);
- if (name == null) {
- throw new Error("Missing entity name");
- }
- if (value == null) {
- throw new Error("Missing entity value");
- }
- this.pe = !!pe;
- this.name = this.stringify.eleName(name);
- if (!isObject(value)) {
- this.value = this.stringify.dtdEntityValue(value);
- } else {
- if (!value.pubID && !value.sysID) {
- throw new Error("Public and/or system identifiers are required for an external entity");
- }
- if (value.pubID && !value.sysID) {
- throw new Error("System identifier is required for a public external entity");
- }
- if (value.pubID != null) {
- this.pubID = this.stringify.dtdPubID(value.pubID);
- }
- if (value.sysID != null) {
- this.sysID = this.stringify.dtdSysID(value.sysID);
- }
- if (value.nData != null) {
- this.nData = this.stringify.dtdNData(value.nData);
- }
- if (this.pe && this.nData) {
- throw new Error("Notation declaration is not allowed in a parameter entity");
- }
- }
- }
-
- XMLDTDEntity.prototype.toString = function(options) {
- return this.options.writer.set(options).dtdEntity(this);
- };
-
- return XMLDTDEntity;
-
- })(XMLNode);
-
- }).call(this);
-
- },{"./Utility":8,"./XMLNode":21}],15:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLDTDNotation, XMLNode,
- 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; },
- hasProp = {}.hasOwnProperty;
-
- XMLNode = require('./XMLNode');
-
- module.exports = XMLDTDNotation = (function(superClass) {
- extend(XMLDTDNotation, superClass);
-
- function XMLDTDNotation(parent, name, value) {
- XMLDTDNotation.__super__.constructor.call(this, parent);
- if (name == null) {
- throw new Error("Missing notation name");
- }
- if (!value.pubID && !value.sysID) {
- throw new Error("Public or system identifiers are required for an external entity");
- }
- this.name = this.stringify.eleName(name);
- if (value.pubID != null) {
- this.pubID = this.stringify.dtdPubID(value.pubID);
- }
- if (value.sysID != null) {
- this.sysID = this.stringify.dtdSysID(value.sysID);
- }
- }
-
- XMLDTDNotation.prototype.toString = function(options) {
- return this.options.writer.set(options).dtdNotation(this);
- };
-
- return XMLDTDNotation;
-
- })(XMLNode);
-
- }).call(this);
-
- },{"./XMLNode":21}],16:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLDeclaration, XMLNode, isObject,
- 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; },
- hasProp = {}.hasOwnProperty;
-
- isObject = require('./Utility').isObject;
-
- XMLNode = require('./XMLNode');
-
- module.exports = XMLDeclaration = (function(superClass) {
- extend(XMLDeclaration, superClass);
-
- function XMLDeclaration(parent, version, encoding, standalone) {
- var ref;
- XMLDeclaration.__super__.constructor.call(this, parent);
- if (isObject(version)) {
- ref = version, version = ref.version, encoding = ref.encoding, standalone = ref.standalone;
- }
- if (!version) {
- version = '1.0';
- }
- this.version = this.stringify.xmlVersion(version);
- if (encoding != null) {
- this.encoding = this.stringify.xmlEncoding(encoding);
- }
- if (standalone != null) {
- this.standalone = this.stringify.xmlStandalone(standalone);
- }
- }
-
- XMLDeclaration.prototype.toString = function(options) {
- return this.options.writer.set(options).declaration(this);
- };
-
- return XMLDeclaration;
-
- })(XMLNode);
-
- }).call(this);
-
- },{"./Utility":8,"./XMLNode":21}],17:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDocType, XMLNode, isObject,
- 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; },
- hasProp = {}.hasOwnProperty;
-
- isObject = require('./Utility').isObject;
-
- XMLNode = require('./XMLNode');
-
- XMLDTDAttList = require('./XMLDTDAttList');
-
- XMLDTDEntity = require('./XMLDTDEntity');
-
- XMLDTDElement = require('./XMLDTDElement');
-
- XMLDTDNotation = require('./XMLDTDNotation');
-
- module.exports = XMLDocType = (function(superClass) {
- extend(XMLDocType, superClass);
-
- function XMLDocType(parent, pubID, sysID) {
- var ref, ref1;
- XMLDocType.__super__.constructor.call(this, parent);
- this.documentObject = parent;
- if (isObject(pubID)) {
- ref = pubID, pubID = ref.pubID, sysID = ref.sysID;
- }
- if (sysID == null) {
- ref1 = [pubID, sysID], sysID = ref1[0], pubID = ref1[1];
- }
- if (pubID != null) {
- this.pubID = this.stringify.dtdPubID(pubID);
- }
- if (sysID != null) {
- this.sysID = this.stringify.dtdSysID(sysID);
- }
- }
-
- XMLDocType.prototype.element = function(name, value) {
- var child;
- child = new XMLDTDElement(this, name, value);
- this.children.push(child);
- return this;
- };
-
- XMLDocType.prototype.attList = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
- var child;
- child = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
- this.children.push(child);
- return this;
- };
-
- XMLDocType.prototype.entity = function(name, value) {
- var child;
- child = new XMLDTDEntity(this, false, name, value);
- this.children.push(child);
- return this;
- };
-
- XMLDocType.prototype.pEntity = function(name, value) {
- var child;
- child = new XMLDTDEntity(this, true, name, value);
- this.children.push(child);
- return this;
- };
-
- XMLDocType.prototype.notation = function(name, value) {
- var child;
- child = new XMLDTDNotation(this, name, value);
- this.children.push(child);
- return this;
- };
-
- XMLDocType.prototype.toString = function(options) {
- return this.options.writer.set(options).docType(this);
- };
-
- XMLDocType.prototype.ele = function(name, value) {
- return this.element(name, value);
- };
-
- XMLDocType.prototype.att = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
- return this.attList(elementName, attributeName, attributeType, defaultValueType, defaultValue);
- };
-
- XMLDocType.prototype.ent = function(name, value) {
- return this.entity(name, value);
- };
-
- XMLDocType.prototype.pent = function(name, value) {
- return this.pEntity(name, value);
- };
-
- XMLDocType.prototype.not = function(name, value) {
- return this.notation(name, value);
- };
-
- XMLDocType.prototype.up = function() {
- return this.root() || this.documentObject;
- };
-
- return XMLDocType;
-
- })(XMLNode);
-
- }).call(this);
-
- },{"./Utility":8,"./XMLDTDAttList":12,"./XMLDTDElement":13,"./XMLDTDEntity":14,"./XMLDTDNotation":15,"./XMLNode":21}],18:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLDocument, XMLNode, XMLStringWriter, XMLStringifier, isPlainObject,
- 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; },
- hasProp = {}.hasOwnProperty;
-
- isPlainObject = require('./Utility').isPlainObject;
-
- XMLNode = require('./XMLNode');
-
- XMLStringifier = require('./XMLStringifier');
-
- XMLStringWriter = require('./XMLStringWriter');
-
- module.exports = XMLDocument = (function(superClass) {
- extend(XMLDocument, superClass);
-
- function XMLDocument(options) {
- XMLDocument.__super__.constructor.call(this, null);
- options || (options = {});
- if (!options.writer) {
- options.writer = new XMLStringWriter();
- }
- this.options = options;
- this.stringify = new XMLStringifier(options);
- this.isDocument = true;
- }
-
- XMLDocument.prototype.end = function(writer) {
- var writerOptions;
- if (!writer) {
- writer = this.options.writer;
- } else if (isPlainObject(writer)) {
- writerOptions = writer;
- writer = this.options.writer.set(writerOptions);
- }
- return writer.document(this);
- };
-
- XMLDocument.prototype.toString = function(options) {
- return this.options.writer.set(options).document(this);
- };
-
- return XMLDocument;
-
- })(XMLNode);
-
- }).call(this);
-
- },{"./Utility":8,"./XMLNode":21,"./XMLStringWriter":25,"./XMLStringifier":26}],19:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLAttribute, XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLDocumentCB, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStringWriter, XMLStringifier, XMLText, isFunction, isObject, isPlainObject, ref,
- hasProp = {}.hasOwnProperty;
-
- ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction, isPlainObject = ref.isPlainObject;
-
- XMLElement = require('./XMLElement');
-
- XMLCData = require('./XMLCData');
-
- XMLComment = require('./XMLComment');
-
- XMLRaw = require('./XMLRaw');
-
- XMLText = require('./XMLText');
-
- XMLProcessingInstruction = require('./XMLProcessingInstruction');
-
- XMLDeclaration = require('./XMLDeclaration');
-
- XMLDocType = require('./XMLDocType');
-
- XMLDTDAttList = require('./XMLDTDAttList');
-
- XMLDTDEntity = require('./XMLDTDEntity');
-
- XMLDTDElement = require('./XMLDTDElement');
-
- XMLDTDNotation = require('./XMLDTDNotation');
-
- XMLAttribute = require('./XMLAttribute');
-
- XMLStringifier = require('./XMLStringifier');
-
- XMLStringWriter = require('./XMLStringWriter');
-
- module.exports = XMLDocumentCB = (function() {
- function XMLDocumentCB(options, onData, onEnd) {
- var writerOptions;
- options || (options = {});
- if (!options.writer) {
- options.writer = new XMLStringWriter(options);
- } else if (isPlainObject(options.writer)) {
- writerOptions = options.writer;
- options.writer = new XMLStringWriter(writerOptions);
- }
- this.options = options;
- this.writer = options.writer;
- this.stringify = new XMLStringifier(options);
- this.onDataCallback = onData || function() {};
- this.onEndCallback = onEnd || function() {};
- this.currentNode = null;
- this.currentLevel = -1;
- this.openTags = {};
- this.documentStarted = false;
- this.documentCompleted = false;
- this.root = null;
- }
-
- XMLDocumentCB.prototype.node = function(name, attributes, text) {
- var ref1;
- if (name == null) {
- throw new Error("Missing node name");
- }
- if (this.root && this.currentLevel === -1) {
- throw new Error("Document can only have one root node");
- }
- this.openCurrent();
- name = name.valueOf();
- if (attributes == null) {
- attributes = {};
- }
- attributes = attributes.valueOf();
- if (!isObject(attributes)) {
- ref1 = [attributes, text], text = ref1[0], attributes = ref1[1];
- }
- this.currentNode = new XMLElement(this, name, attributes);
- this.currentNode.children = false;
- this.currentLevel++;
- this.openTags[this.currentLevel] = this.currentNode;
- if (text != null) {
- this.text(text);
- }
- return this;
- };
-
- XMLDocumentCB.prototype.element = function(name, attributes, text) {
- if (this.currentNode && this.currentNode instanceof XMLDocType) {
- return this.dtdElement.apply(this, arguments);
- } else {
- return this.node(name, attributes, text);
- }
- };
-
- XMLDocumentCB.prototype.attribute = function(name, value) {
- var attName, attValue;
- if (!this.currentNode || this.currentNode.children) {
- throw new Error("att() can only be used immediately after an ele() call in callback mode");
- }
- if (name != null) {
- name = name.valueOf();
- }
- if (isObject(name)) {
- for (attName in name) {
- if (!hasProp.call(name, attName)) continue;
- attValue = name[attName];
- this.attribute(attName, attValue);
- }
- } else {
- if (isFunction(value)) {
- value = value.apply();
- }
- if (!this.options.skipNullAttributes || (value != null)) {
- this.currentNode.attributes[name] = new XMLAttribute(this, name, value);
- }
- }
- return this;
- };
-
- XMLDocumentCB.prototype.text = function(value) {
- var node;
- this.openCurrent();
- node = new XMLText(this, value);
- this.onData(this.writer.text(node, this.currentLevel + 1));
- return this;
- };
-
- XMLDocumentCB.prototype.cdata = function(value) {
- var node;
- this.openCurrent();
- node = new XMLCData(this, value);
- this.onData(this.writer.cdata(node, this.currentLevel + 1));
- return this;
- };
-
- XMLDocumentCB.prototype.comment = function(value) {
- var node;
- this.openCurrent();
- node = new XMLComment(this, value);
- this.onData(this.writer.comment(node, this.currentLevel + 1));
- return this;
- };
-
- XMLDocumentCB.prototype.raw = function(value) {
- var node;
- this.openCurrent();
- node = new XMLRaw(this, value);
- this.onData(this.writer.raw(node, this.currentLevel + 1));
- return this;
- };
-
- XMLDocumentCB.prototype.instruction = function(target, value) {
- var i, insTarget, insValue, len, node;
- this.openCurrent();
- if (target != null) {
- target = target.valueOf();
- }
- if (value != null) {
- value = value.valueOf();
- }
- if (Array.isArray(target)) {
- for (i = 0, len = target.length; i < len; i++) {
- insTarget = target[i];
- this.instruction(insTarget);
- }
- } else if (isObject(target)) {
- for (insTarget in target) {
- if (!hasProp.call(target, insTarget)) continue;
- insValue = target[insTarget];
- this.instruction(insTarget, insValue);
- }
- } else {
- if (isFunction(value)) {
- value = value.apply();
- }
- node = new XMLProcessingInstruction(this, target, value);
- this.onData(this.writer.processingInstruction(node, this.currentLevel + 1));
- }
- return this;
- };
-
- XMLDocumentCB.prototype.declaration = function(version, encoding, standalone) {
- var node;
- this.openCurrent();
- if (this.documentStarted) {
- throw new Error("declaration() must be the first node");
- }
- node = new XMLDeclaration(this, version, encoding, standalone);
- this.onData(this.writer.declaration(node, this.currentLevel + 1));
- return this;
- };
-
- XMLDocumentCB.prototype.doctype = function(root, pubID, sysID) {
- this.openCurrent();
- if (root == null) {
- throw new Error("Missing root node name");
- }
- if (this.root) {
- throw new Error("dtd() must come before the root node");
- }
- this.currentNode = new XMLDocType(this, pubID, sysID);
- this.currentNode.rootNodeName = root;
- this.currentNode.children = false;
- this.currentLevel++;
- this.openTags[this.currentLevel] = this.currentNode;
- return this;
- };
-
- XMLDocumentCB.prototype.dtdElement = function(name, value) {
- var node;
- this.openCurrent();
- node = new XMLDTDElement(this, name, value);
- this.onData(this.writer.dtdElement(node, this.currentLevel + 1));
- return this;
- };
-
- XMLDocumentCB.prototype.attList = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
- var node;
- this.openCurrent();
- node = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
- this.onData(this.writer.dtdAttList(node, this.currentLevel + 1));
- return this;
- };
-
- XMLDocumentCB.prototype.entity = function(name, value) {
- var node;
- this.openCurrent();
- node = new XMLDTDEntity(this, false, name, value);
- this.onData(this.writer.dtdEntity(node, this.currentLevel + 1));
- return this;
- };
-
- XMLDocumentCB.prototype.pEntity = function(name, value) {
- var node;
- this.openCurrent();
- node = new XMLDTDEntity(this, true, name, value);
- this.onData(this.writer.dtdEntity(node, this.currentLevel + 1));
- return this;
- };
-
- XMLDocumentCB.prototype.notation = function(name, value) {
- var node;
- this.openCurrent();
- node = new XMLDTDNotation(this, name, value);
- this.onData(this.writer.dtdNotation(node, this.currentLevel + 1));
- return this;
- };
-
- XMLDocumentCB.prototype.up = function() {
- if (this.currentLevel < 0) {
- throw new Error("The document node has no parent");
- }
- if (this.currentNode) {
- if (this.currentNode.children) {
- this.closeNode(this.currentNode);
- } else {
- this.openNode(this.currentNode);
- }
- this.currentNode = null;
- } else {
- this.closeNode(this.openTags[this.currentLevel]);
- }
- delete this.openTags[this.currentLevel];
- this.currentLevel--;
- return this;
- };
-
- XMLDocumentCB.prototype.end = function() {
- while (this.currentLevel >= 0) {
- this.up();
- }
- return this.onEnd();
- };
-
- XMLDocumentCB.prototype.openCurrent = function() {
- if (this.currentNode) {
- this.currentNode.children = true;
- return this.openNode(this.currentNode);
- }
- };
-
- XMLDocumentCB.prototype.openNode = function(node) {
- if (!node.isOpen) {
- if (!this.root && this.currentLevel === 0 && node instanceof XMLElement) {
- this.root = node;
- }
- this.onData(this.writer.openNode(node, this.currentLevel));
- return node.isOpen = true;
- }
- };
-
- XMLDocumentCB.prototype.closeNode = function(node) {
- if (!node.isClosed) {
- this.onData(this.writer.closeNode(node, this.currentLevel));
- return node.isClosed = true;
- }
- };
-
- XMLDocumentCB.prototype.onData = function(chunk) {
- this.documentStarted = true;
- return this.onDataCallback(chunk);
- };
-
- XMLDocumentCB.prototype.onEnd = function() {
- this.documentCompleted = true;
- return this.onEndCallback();
- };
-
- XMLDocumentCB.prototype.ele = function() {
- return this.element.apply(this, arguments);
- };
-
- XMLDocumentCB.prototype.nod = function(name, attributes, text) {
- return this.node(name, attributes, text);
- };
-
- XMLDocumentCB.prototype.txt = function(value) {
- return this.text(value);
- };
-
- XMLDocumentCB.prototype.dat = function(value) {
- return this.cdata(value);
- };
-
- XMLDocumentCB.prototype.com = function(value) {
- return this.comment(value);
- };
-
- XMLDocumentCB.prototype.ins = function(target, value) {
- return this.instruction(target, value);
- };
-
- XMLDocumentCB.prototype.dec = function(version, encoding, standalone) {
- return this.declaration(version, encoding, standalone);
- };
-
- XMLDocumentCB.prototype.dtd = function(root, pubID, sysID) {
- return this.doctype(root, pubID, sysID);
- };
-
- XMLDocumentCB.prototype.e = function(name, attributes, text) {
- return this.element(name, attributes, text);
- };
-
- XMLDocumentCB.prototype.n = function(name, attributes, text) {
- return this.node(name, attributes, text);
- };
-
- XMLDocumentCB.prototype.t = function(value) {
- return this.text(value);
- };
-
- XMLDocumentCB.prototype.d = function(value) {
- return this.cdata(value);
- };
-
- XMLDocumentCB.prototype.c = function(value) {
- return this.comment(value);
- };
-
- XMLDocumentCB.prototype.r = function(value) {
- return this.raw(value);
- };
-
- XMLDocumentCB.prototype.i = function(target, value) {
- return this.instruction(target, value);
- };
-
- XMLDocumentCB.prototype.att = function() {
- if (this.currentNode && this.currentNode instanceof XMLDocType) {
- return this.attList.apply(this, arguments);
- } else {
- return this.attribute.apply(this, arguments);
- }
- };
-
- XMLDocumentCB.prototype.a = function() {
- if (this.currentNode && this.currentNode instanceof XMLDocType) {
- return this.attList.apply(this, arguments);
- } else {
- return this.attribute.apply(this, arguments);
- }
- };
-
- XMLDocumentCB.prototype.ent = function(name, value) {
- return this.entity(name, value);
- };
-
- XMLDocumentCB.prototype.pent = function(name, value) {
- return this.pEntity(name, value);
- };
-
- XMLDocumentCB.prototype.not = function(name, value) {
- return this.notation(name, value);
- };
-
- return XMLDocumentCB;
-
- })();
-
- }).call(this);
-
- },{"./Utility":8,"./XMLAttribute":9,"./XMLCData":10,"./XMLComment":11,"./XMLDTDAttList":12,"./XMLDTDElement":13,"./XMLDTDEntity":14,"./XMLDTDNotation":15,"./XMLDeclaration":16,"./XMLDocType":17,"./XMLElement":20,"./XMLProcessingInstruction":22,"./XMLRaw":23,"./XMLStringWriter":25,"./XMLStringifier":26,"./XMLText":27}],20:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLAttribute, XMLElement, XMLNode, isFunction, isObject, ref,
- 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; },
- hasProp = {}.hasOwnProperty;
-
- ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction;
-
- XMLNode = require('./XMLNode');
-
- XMLAttribute = require('./XMLAttribute');
-
- module.exports = XMLElement = (function(superClass) {
- extend(XMLElement, superClass);
-
- function XMLElement(parent, name, attributes) {
- XMLElement.__super__.constructor.call(this, parent);
- if (name == null) {
- throw new Error("Missing element name");
- }
- this.name = this.stringify.eleName(name);
- this.attributes = {};
- if (attributes != null) {
- this.attribute(attributes);
- }
- if (parent.isDocument) {
- this.isRoot = true;
- this.documentObject = parent;
- parent.rootObject = this;
- }
- }
-
- XMLElement.prototype.clone = function() {
- var att, attName, clonedSelf, ref1;
- clonedSelf = Object.create(this);
- if (clonedSelf.isRoot) {
- clonedSelf.documentObject = null;
- }
- clonedSelf.attributes = {};
- ref1 = this.attributes;
- for (attName in ref1) {
- if (!hasProp.call(ref1, attName)) continue;
- att = ref1[attName];
- clonedSelf.attributes[attName] = att.clone();
- }
- clonedSelf.children = [];
- this.children.forEach(function(child) {
- var clonedChild;
- clonedChild = child.clone();
- clonedChild.parent = clonedSelf;
- return clonedSelf.children.push(clonedChild);
- });
- return clonedSelf;
- };
-
- XMLElement.prototype.attribute = function(name, value) {
- var attName, attValue;
- if (name != null) {
- name = name.valueOf();
- }
- if (isObject(name)) {
- for (attName in name) {
- if (!hasProp.call(name, attName)) continue;
- attValue = name[attName];
- this.attribute(attName, attValue);
- }
- } else {
- if (isFunction(value)) {
- value = value.apply();
- }
- if (!this.options.skipNullAttributes || (value != null)) {
- this.attributes[name] = new XMLAttribute(this, name, value);
- }
- }
- return this;
- };
-
- XMLElement.prototype.removeAttribute = function(name) {
- var attName, i, len;
- if (name == null) {
- throw new Error("Missing attribute name");
- }
- name = name.valueOf();
- if (Array.isArray(name)) {
- for (i = 0, len = name.length; i < len; i++) {
- attName = name[i];
- delete this.attributes[attName];
- }
- } else {
- delete this.attributes[name];
- }
- return this;
- };
-
- XMLElement.prototype.toString = function(options) {
- return this.options.writer.set(options).element(this);
- };
-
- XMLElement.prototype.att = function(name, value) {
- return this.attribute(name, value);
- };
-
- XMLElement.prototype.a = function(name, value) {
- return this.attribute(name, value);
- };
-
- return XMLElement;
-
- })(XMLNode);
-
- }).call(this);
-
- },{"./Utility":8,"./XMLAttribute":9,"./XMLNode":21}],21:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLCData, XMLComment, XMLDeclaration, XMLDocType, XMLElement, XMLNode, XMLProcessingInstruction, XMLRaw, XMLText, isEmpty, isFunction, isObject, ref,
- hasProp = {}.hasOwnProperty;
-
- ref = require('./Utility'), isObject = ref.isObject, isFunction = ref.isFunction, isEmpty = ref.isEmpty;
-
- XMLElement = null;
-
- XMLCData = null;
-
- XMLComment = null;
-
- XMLDeclaration = null;
-
- XMLDocType = null;
-
- XMLRaw = null;
-
- XMLText = null;
-
- XMLProcessingInstruction = null;
-
- module.exports = XMLNode = (function() {
- function XMLNode(parent) {
- this.parent = parent;
- if (this.parent) {
- this.options = this.parent.options;
- this.stringify = this.parent.stringify;
- }
- this.children = [];
- if (!XMLElement) {
- XMLElement = require('./XMLElement');
- XMLCData = require('./XMLCData');
- XMLComment = require('./XMLComment');
- XMLDeclaration = require('./XMLDeclaration');
- XMLDocType = require('./XMLDocType');
- XMLRaw = require('./XMLRaw');
- XMLText = require('./XMLText');
- XMLProcessingInstruction = require('./XMLProcessingInstruction');
- }
- }
-
- XMLNode.prototype.element = function(name, attributes, text) {
- var childNode, item, j, k, key, lastChild, len, len1, ref1, val;
- lastChild = null;
- if (attributes == null) {
- attributes = {};
- }
- attributes = attributes.valueOf();
- if (!isObject(attributes)) {
- ref1 = [attributes, text], text = ref1[0], attributes = ref1[1];
- }
- if (name != null) {
- name = name.valueOf();
- }
- if (Array.isArray(name)) {
- for (j = 0, len = name.length; j < len; j++) {
- item = name[j];
- lastChild = this.element(item);
- }
- } else if (isFunction(name)) {
- lastChild = this.element(name.apply());
- } else if (isObject(name)) {
- for (key in name) {
- if (!hasProp.call(name, key)) continue;
- val = name[key];
- if (isFunction(val)) {
- val = val.apply();
- }
- if ((isObject(val)) && (isEmpty(val))) {
- val = null;
- }
- if (!this.options.ignoreDecorators && this.stringify.convertAttKey && key.indexOf(this.stringify.convertAttKey) === 0) {
- lastChild = this.attribute(key.substr(this.stringify.convertAttKey.length), val);
- } else if (!this.options.separateArrayItems && Array.isArray(val)) {
- for (k = 0, len1 = val.length; k < len1; k++) {
- item = val[k];
- childNode = {};
- childNode[key] = item;
- lastChild = this.element(childNode);
- }
- } else if (isObject(val)) {
- lastChild = this.element(key);
- lastChild.element(val);
- } else {
- lastChild = this.element(key, val);
- }
- }
- } else {
- if (!this.options.ignoreDecorators && this.stringify.convertTextKey && name.indexOf(this.stringify.convertTextKey) === 0) {
- lastChild = this.text(text);
- } else if (!this.options.ignoreDecorators && this.stringify.convertCDataKey && name.indexOf(this.stringify.convertCDataKey) === 0) {
- lastChild = this.cdata(text);
- } else if (!this.options.ignoreDecorators && this.stringify.convertCommentKey && name.indexOf(this.stringify.convertCommentKey) === 0) {
- lastChild = this.comment(text);
- } else if (!this.options.ignoreDecorators && this.stringify.convertRawKey && name.indexOf(this.stringify.convertRawKey) === 0) {
- lastChild = this.raw(text);
- } else if (!this.options.ignoreDecorators && this.stringify.convertPIKey && name.indexOf(this.stringify.convertPIKey) === 0) {
- lastChild = this.instruction(name.substr(this.stringify.convertPIKey.length), text);
- } else {
- lastChild = this.node(name, attributes, text);
- }
- }
- if (lastChild == null) {
- throw new Error("Could not create any elements with: " + name);
- }
- return lastChild;
- };
-
- XMLNode.prototype.insertBefore = function(name, attributes, text) {
- var child, i, removed;
- if (this.isRoot) {
- throw new Error("Cannot insert elements at root level");
- }
- i = this.parent.children.indexOf(this);
- removed = this.parent.children.splice(i);
- child = this.parent.element(name, attributes, text);
- Array.prototype.push.apply(this.parent.children, removed);
- return child;
- };
-
- XMLNode.prototype.insertAfter = function(name, attributes, text) {
- var child, i, removed;
- if (this.isRoot) {
- throw new Error("Cannot insert elements at root level");
- }
- i = this.parent.children.indexOf(this);
- removed = this.parent.children.splice(i + 1);
- child = this.parent.element(name, attributes, text);
- Array.prototype.push.apply(this.parent.children, removed);
- return child;
- };
-
- XMLNode.prototype.remove = function() {
- var i, ref1;
- if (this.isRoot) {
- throw new Error("Cannot remove the root element");
- }
- i = this.parent.children.indexOf(this);
- [].splice.apply(this.parent.children, [i, i - i + 1].concat(ref1 = [])), ref1;
- return this.parent;
- };
-
- XMLNode.prototype.node = function(name, attributes, text) {
- var child, ref1;
- if (name != null) {
- name = name.valueOf();
- }
- attributes || (attributes = {});
- attributes = attributes.valueOf();
- if (!isObject(attributes)) {
- ref1 = [attributes, text], text = ref1[0], attributes = ref1[1];
- }
- child = new XMLElement(this, name, attributes);
- if (text != null) {
- child.text(text);
- }
- this.children.push(child);
- return child;
- };
-
- XMLNode.prototype.text = function(value) {
- var child;
- child = new XMLText(this, value);
- this.children.push(child);
- return this;
- };
-
- XMLNode.prototype.cdata = function(value) {
- var child;
- child = new XMLCData(this, value);
- this.children.push(child);
- return this;
- };
-
- XMLNode.prototype.comment = function(value) {
- var child;
- child = new XMLComment(this, value);
- this.children.push(child);
- return this;
- };
-
- XMLNode.prototype.commentBefore = function(value) {
- var child, i, removed;
- i = this.parent.children.indexOf(this);
- removed = this.parent.children.splice(i);
- child = this.parent.comment(value);
- Array.prototype.push.apply(this.parent.children, removed);
- return this;
- };
-
- XMLNode.prototype.commentAfter = function(value) {
- var child, i, removed;
- i = this.parent.children.indexOf(this);
- removed = this.parent.children.splice(i + 1);
- child = this.parent.comment(value);
- Array.prototype.push.apply(this.parent.children, removed);
- return this;
- };
-
- XMLNode.prototype.raw = function(value) {
- var child;
- child = new XMLRaw(this, value);
- this.children.push(child);
- return this;
- };
-
- XMLNode.prototype.instruction = function(target, value) {
- var insTarget, insValue, instruction, j, len;
- if (target != null) {
- target = target.valueOf();
- }
- if (value != null) {
- value = value.valueOf();
- }
- if (Array.isArray(target)) {
- for (j = 0, len = target.length; j < len; j++) {
- insTarget = target[j];
- this.instruction(insTarget);
- }
- } else if (isObject(target)) {
- for (insTarget in target) {
- if (!hasProp.call(target, insTarget)) continue;
- insValue = target[insTarget];
- this.instruction(insTarget, insValue);
- }
- } else {
- if (isFunction(value)) {
- value = value.apply();
- }
- instruction = new XMLProcessingInstruction(this, target, value);
- this.children.push(instruction);
- }
- return this;
- };
-
- XMLNode.prototype.instructionBefore = function(target, value) {
- var child, i, removed;
- i = this.parent.children.indexOf(this);
- removed = this.parent.children.splice(i);
- child = this.parent.instruction(target, value);
- Array.prototype.push.apply(this.parent.children, removed);
- return this;
- };
-
- XMLNode.prototype.instructionAfter = function(target, value) {
- var child, i, removed;
- i = this.parent.children.indexOf(this);
- removed = this.parent.children.splice(i + 1);
- child = this.parent.instruction(target, value);
- Array.prototype.push.apply(this.parent.children, removed);
- return this;
- };
-
- XMLNode.prototype.declaration = function(version, encoding, standalone) {
- var doc, xmldec;
- doc = this.document();
- xmldec = new XMLDeclaration(doc, version, encoding, standalone);
- if (doc.children[0] instanceof XMLDeclaration) {
- doc.children[0] = xmldec;
- } else {
- doc.children.unshift(xmldec);
- }
- return doc.root() || doc;
- };
-
- XMLNode.prototype.doctype = function(pubID, sysID) {
- var child, doc, doctype, i, j, k, len, len1, ref1, ref2;
- doc = this.document();
- doctype = new XMLDocType(doc, pubID, sysID);
- ref1 = doc.children;
- for (i = j = 0, len = ref1.length; j < len; i = ++j) {
- child = ref1[i];
- if (child instanceof XMLDocType) {
- doc.children[i] = doctype;
- return doctype;
- }
- }
- ref2 = doc.children;
- for (i = k = 0, len1 = ref2.length; k < len1; i = ++k) {
- child = ref2[i];
- if (child.isRoot) {
- doc.children.splice(i, 0, doctype);
- return doctype;
- }
- }
- doc.children.push(doctype);
- return doctype;
- };
-
- XMLNode.prototype.up = function() {
- if (this.isRoot) {
- throw new Error("The root node has no parent. Use doc() if you need to get the document object.");
- }
- return this.parent;
- };
-
- XMLNode.prototype.root = function() {
- var node;
- node = this;
- while (node) {
- if (node.isDocument) {
- return node.rootObject;
- } else if (node.isRoot) {
- return node;
- } else {
- node = node.parent;
- }
- }
- };
-
- XMLNode.prototype.document = function() {
- var node;
- node = this;
- while (node) {
- if (node.isDocument) {
- return node;
- } else {
- node = node.parent;
- }
- }
- };
-
- XMLNode.prototype.end = function(options) {
- return this.document().end(options);
- };
-
- XMLNode.prototype.prev = function() {
- var i;
- i = this.parent.children.indexOf(this);
- if (i < 1) {
- throw new Error("Already at the first node");
- }
- return this.parent.children[i - 1];
- };
-
- XMLNode.prototype.next = function() {
- var i;
- i = this.parent.children.indexOf(this);
- if (i === -1 || i === this.parent.children.length - 1) {
- throw new Error("Already at the last node");
- }
- return this.parent.children[i + 1];
- };
-
- XMLNode.prototype.importDocument = function(doc) {
- var clonedRoot;
- clonedRoot = doc.root().clone();
- clonedRoot.parent = this;
- clonedRoot.isRoot = false;
- this.children.push(clonedRoot);
- return this;
- };
-
- XMLNode.prototype.ele = function(name, attributes, text) {
- return this.element(name, attributes, text);
- };
-
- XMLNode.prototype.nod = function(name, attributes, text) {
- return this.node(name, attributes, text);
- };
-
- XMLNode.prototype.txt = function(value) {
- return this.text(value);
- };
-
- XMLNode.prototype.dat = function(value) {
- return this.cdata(value);
- };
-
- XMLNode.prototype.com = function(value) {
- return this.comment(value);
- };
-
- XMLNode.prototype.ins = function(target, value) {
- return this.instruction(target, value);
- };
-
- XMLNode.prototype.doc = function() {
- return this.document();
- };
-
- XMLNode.prototype.dec = function(version, encoding, standalone) {
- return this.declaration(version, encoding, standalone);
- };
-
- XMLNode.prototype.dtd = function(pubID, sysID) {
- return this.doctype(pubID, sysID);
- };
-
- XMLNode.prototype.e = function(name, attributes, text) {
- return this.element(name, attributes, text);
- };
-
- XMLNode.prototype.n = function(name, attributes, text) {
- return this.node(name, attributes, text);
- };
-
- XMLNode.prototype.t = function(value) {
- return this.text(value);
- };
-
- XMLNode.prototype.d = function(value) {
- return this.cdata(value);
- };
-
- XMLNode.prototype.c = function(value) {
- return this.comment(value);
- };
-
- XMLNode.prototype.r = function(value) {
- return this.raw(value);
- };
-
- XMLNode.prototype.i = function(target, value) {
- return this.instruction(target, value);
- };
-
- XMLNode.prototype.u = function() {
- return this.up();
- };
-
- XMLNode.prototype.importXMLBuilder = function(doc) {
- return this.importDocument(doc);
- };
-
- return XMLNode;
-
- })();
-
- }).call(this);
-
- },{"./Utility":8,"./XMLCData":10,"./XMLComment":11,"./XMLDeclaration":16,"./XMLDocType":17,"./XMLElement":20,"./XMLProcessingInstruction":22,"./XMLRaw":23,"./XMLText":27}],22:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLNode, XMLProcessingInstruction,
- 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; },
- hasProp = {}.hasOwnProperty;
-
- XMLNode = require('./XMLNode');
-
- module.exports = XMLProcessingInstruction = (function(superClass) {
- extend(XMLProcessingInstruction, superClass);
-
- function XMLProcessingInstruction(parent, target, value) {
- XMLProcessingInstruction.__super__.constructor.call(this, parent);
- if (target == null) {
- throw new Error("Missing instruction target");
- }
- this.target = this.stringify.insTarget(target);
- if (value) {
- this.value = this.stringify.insValue(value);
- }
- }
-
- XMLProcessingInstruction.prototype.clone = function() {
- return Object.create(this);
- };
-
- XMLProcessingInstruction.prototype.toString = function(options) {
- return this.options.writer.set(options).processingInstruction(this);
- };
-
- return XMLProcessingInstruction;
-
- })(XMLNode);
-
- }).call(this);
-
- },{"./XMLNode":21}],23:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLNode, XMLRaw,
- 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; },
- hasProp = {}.hasOwnProperty;
-
- XMLNode = require('./XMLNode');
-
- module.exports = XMLRaw = (function(superClass) {
- extend(XMLRaw, superClass);
-
- function XMLRaw(parent, text) {
- XMLRaw.__super__.constructor.call(this, parent);
- if (text == null) {
- throw new Error("Missing raw text");
- }
- this.value = this.stringify.raw(text);
- }
-
- XMLRaw.prototype.clone = function() {
- return Object.create(this);
- };
-
- XMLRaw.prototype.toString = function(options) {
- return this.options.writer.set(options).raw(this);
- };
-
- return XMLRaw;
-
- })(XMLNode);
-
- }).call(this);
-
- },{"./XMLNode":21}],24:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStreamWriter, XMLText, XMLWriterBase,
- 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; },
- hasProp = {}.hasOwnProperty;
-
- XMLDeclaration = require('./XMLDeclaration');
-
- XMLDocType = require('./XMLDocType');
-
- XMLCData = require('./XMLCData');
-
- XMLComment = require('./XMLComment');
-
- XMLElement = require('./XMLElement');
-
- XMLRaw = require('./XMLRaw');
-
- XMLText = require('./XMLText');
-
- XMLProcessingInstruction = require('./XMLProcessingInstruction');
-
- XMLDTDAttList = require('./XMLDTDAttList');
-
- XMLDTDElement = require('./XMLDTDElement');
-
- XMLDTDEntity = require('./XMLDTDEntity');
-
- XMLDTDNotation = require('./XMLDTDNotation');
-
- XMLWriterBase = require('./XMLWriterBase');
-
- module.exports = XMLStreamWriter = (function(superClass) {
- extend(XMLStreamWriter, superClass);
-
- function XMLStreamWriter(stream, options) {
- XMLStreamWriter.__super__.constructor.call(this, options);
- this.stream = stream;
- }
-
- XMLStreamWriter.prototype.document = function(doc) {
- var child, i, j, len, len1, ref, ref1, results;
- ref = doc.children;
- for (i = 0, len = ref.length; i < len; i++) {
- child = ref[i];
- child.isLastRootNode = false;
- }
- doc.children[doc.children.length - 1].isLastRootNode = true;
- ref1 = doc.children;
- results = [];
- for (j = 0, len1 = ref1.length; j < len1; j++) {
- child = ref1[j];
- switch (false) {
- case !(child instanceof XMLDeclaration):
- results.push(this.declaration(child));
- break;
- case !(child instanceof XMLDocType):
- results.push(this.docType(child));
- break;
- case !(child instanceof XMLComment):
- results.push(this.comment(child));
- break;
- case !(child instanceof XMLProcessingInstruction):
- results.push(this.processingInstruction(child));
- break;
- default:
- results.push(this.element(child));
- }
- }
- return results;
- };
-
- XMLStreamWriter.prototype.attribute = function(att) {
- return this.stream.write(' ' + att.name + '="' + att.value + '"');
- };
-
- XMLStreamWriter.prototype.cdata = function(node, level) {
- return this.stream.write(this.space(level) + '<![CDATA[' + node.text + ']]>' + this.endline(node));
- };
-
- XMLStreamWriter.prototype.comment = function(node, level) {
- return this.stream.write(this.space(level) + '<!-- ' + node.text + ' -->' + this.endline(node));
- };
-
- XMLStreamWriter.prototype.declaration = function(node, level) {
- this.stream.write(this.space(level));
- this.stream.write('<?xml version="' + node.version + '"');
- if (node.encoding != null) {
- this.stream.write(' encoding="' + node.encoding + '"');
- }
- if (node.standalone != null) {
- this.stream.write(' standalone="' + node.standalone + '"');
- }
- this.stream.write(this.spacebeforeslash + '?>');
- return this.stream.write(this.endline(node));
- };
-
- XMLStreamWriter.prototype.docType = function(node, level) {
- var child, i, len, ref;
- level || (level = 0);
- this.stream.write(this.space(level));
- this.stream.write('<!DOCTYPE ' + node.root().name);
- if (node.pubID && node.sysID) {
- this.stream.write(' PUBLIC "' + node.pubID + '" "' + node.sysID + '"');
- } else if (node.sysID) {
- this.stream.write(' SYSTEM "' + node.sysID + '"');
- }
- if (node.children.length > 0) {
- this.stream.write(' [');
- this.stream.write(this.endline(node));
- ref = node.children;
- for (i = 0, len = ref.length; i < len; i++) {
- child = ref[i];
- switch (false) {
- case !(child instanceof XMLDTDAttList):
- this.dtdAttList(child, level + 1);
- break;
- case !(child instanceof XMLDTDElement):
- this.dtdElement(child, level + 1);
- break;
- case !(child instanceof XMLDTDEntity):
- this.dtdEntity(child, level + 1);
- break;
- case !(child instanceof XMLDTDNotation):
- this.dtdNotation(child, level + 1);
- break;
- case !(child instanceof XMLCData):
- this.cdata(child, level + 1);
- break;
- case !(child instanceof XMLComment):
- this.comment(child, level + 1);
- break;
- case !(child instanceof XMLProcessingInstruction):
- this.processingInstruction(child, level + 1);
- break;
- default:
- throw new Error("Unknown DTD node type: " + child.constructor.name);
- }
- }
- this.stream.write(']');
- }
- this.stream.write(this.spacebeforeslash + '>');
- return this.stream.write(this.endline(node));
- };
-
- XMLStreamWriter.prototype.element = function(node, level) {
- var att, child, i, len, name, ref, ref1, space;
- level || (level = 0);
- space = this.space(level);
- this.stream.write(space + '<' + node.name);
- ref = node.attributes;
- for (name in ref) {
- if (!hasProp.call(ref, name)) continue;
- att = ref[name];
- this.attribute(att);
- }
- if (node.children.length === 0 || node.children.every(function(e) {
- return e.value === '';
- })) {
- if (this.allowEmpty) {
- this.stream.write('></' + node.name + '>');
- } else {
- this.stream.write(this.spacebeforeslash + '/>');
- }
- } else if (this.pretty && node.children.length === 1 && (node.children[0].value != null)) {
- this.stream.write('>');
- this.stream.write(node.children[0].value);
- this.stream.write('</' + node.name + '>');
- } else {
- this.stream.write('>' + this.newline);
- ref1 = node.children;
- for (i = 0, len = ref1.length; i < len; i++) {
- child = ref1[i];
- switch (false) {
- case !(child instanceof XMLCData):
- this.cdata(child, level + 1);
- break;
- case !(child instanceof XMLComment):
- this.comment(child, level + 1);
- break;
- case !(child instanceof XMLElement):
- this.element(child, level + 1);
- break;
- case !(child instanceof XMLRaw):
- this.raw(child, level + 1);
- break;
- case !(child instanceof XMLText):
- this.text(child, level + 1);
- break;
- case !(child instanceof XMLProcessingInstruction):
- this.processingInstruction(child, level + 1);
- break;
- default:
- throw new Error("Unknown XML node type: " + child.constructor.name);
- }
- }
- this.stream.write(space + '</' + node.name + '>');
- }
- return this.stream.write(this.endline(node));
- };
-
- XMLStreamWriter.prototype.processingInstruction = function(node, level) {
- this.stream.write(this.space(level) + '<?' + node.target);
- if (node.value) {
- this.stream.write(' ' + node.value);
- }
- return this.stream.write(this.spacebeforeslash + '?>' + this.endline(node));
- };
-
- XMLStreamWriter.prototype.raw = function(node, level) {
- return this.stream.write(this.space(level) + node.value + this.endline(node));
- };
-
- XMLStreamWriter.prototype.text = function(node, level) {
- return this.stream.write(this.space(level) + node.value + this.endline(node));
- };
-
- XMLStreamWriter.prototype.dtdAttList = function(node, level) {
- this.stream.write(this.space(level) + '<!ATTLIST ' + node.elementName + ' ' + node.attributeName + ' ' + node.attributeType);
- if (node.defaultValueType !== '#DEFAULT') {
- this.stream.write(' ' + node.defaultValueType);
- }
- if (node.defaultValue) {
- this.stream.write(' "' + node.defaultValue + '"');
- }
- return this.stream.write(this.spacebeforeslash + '>' + this.endline(node));
- };
-
- XMLStreamWriter.prototype.dtdElement = function(node, level) {
- this.stream.write(this.space(level) + '<!ELEMENT ' + node.name + ' ' + node.value);
- return this.stream.write(this.spacebeforeslash + '>' + this.endline(node));
- };
-
- XMLStreamWriter.prototype.dtdEntity = function(node, level) {
- this.stream.write(this.space(level) + '<!ENTITY');
- if (node.pe) {
- this.stream.write(' %');
- }
- this.stream.write(' ' + node.name);
- if (node.value) {
- this.stream.write(' "' + node.value + '"');
- } else {
- if (node.pubID && node.sysID) {
- this.stream.write(' PUBLIC "' + node.pubID + '" "' + node.sysID + '"');
- } else if (node.sysID) {
- this.stream.write(' SYSTEM "' + node.sysID + '"');
- }
- if (node.nData) {
- this.stream.write(' NDATA ' + node.nData);
- }
- }
- return this.stream.write(this.spacebeforeslash + '>' + this.endline(node));
- };
-
- XMLStreamWriter.prototype.dtdNotation = function(node, level) {
- this.stream.write(this.space(level) + '<!NOTATION ' + node.name);
- if (node.pubID && node.sysID) {
- this.stream.write(' PUBLIC "' + node.pubID + '" "' + node.sysID + '"');
- } else if (node.pubID) {
- this.stream.write(' PUBLIC "' + node.pubID + '"');
- } else if (node.sysID) {
- this.stream.write(' SYSTEM "' + node.sysID + '"');
- }
- return this.stream.write(this.spacebeforeslash + '>' + this.endline(node));
- };
-
- XMLStreamWriter.prototype.endline = function(node) {
- if (!node.isLastRootNode) {
- return this.newline;
- } else {
- return '';
- }
- };
-
- return XMLStreamWriter;
-
- })(XMLWriterBase);
-
- }).call(this);
-
- },{"./XMLCData":10,"./XMLComment":11,"./XMLDTDAttList":12,"./XMLDTDElement":13,"./XMLDTDEntity":14,"./XMLDTDNotation":15,"./XMLDeclaration":16,"./XMLDocType":17,"./XMLElement":20,"./XMLProcessingInstruction":22,"./XMLRaw":23,"./XMLText":27,"./XMLWriterBase":28}],25:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStringWriter, XMLText, XMLWriterBase,
- 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; },
- hasProp = {}.hasOwnProperty;
-
- XMLDeclaration = require('./XMLDeclaration');
-
- XMLDocType = require('./XMLDocType');
-
- XMLCData = require('./XMLCData');
-
- XMLComment = require('./XMLComment');
-
- XMLElement = require('./XMLElement');
-
- XMLRaw = require('./XMLRaw');
-
- XMLText = require('./XMLText');
-
- XMLProcessingInstruction = require('./XMLProcessingInstruction');
-
- XMLDTDAttList = require('./XMLDTDAttList');
-
- XMLDTDElement = require('./XMLDTDElement');
-
- XMLDTDEntity = require('./XMLDTDEntity');
-
- XMLDTDNotation = require('./XMLDTDNotation');
-
- XMLWriterBase = require('./XMLWriterBase');
-
- module.exports = XMLStringWriter = (function(superClass) {
- extend(XMLStringWriter, superClass);
-
- function XMLStringWriter(options) {
- XMLStringWriter.__super__.constructor.call(this, options);
- }
-
- XMLStringWriter.prototype.document = function(doc) {
- var child, i, len, r, ref;
- this.textispresent = false;
- r = '';
- ref = doc.children;
- for (i = 0, len = ref.length; i < len; i++) {
- child = ref[i];
- r += (function() {
- switch (false) {
- case !(child instanceof XMLDeclaration):
- return this.declaration(child);
- case !(child instanceof XMLDocType):
- return this.docType(child);
- case !(child instanceof XMLComment):
- return this.comment(child);
- case !(child instanceof XMLProcessingInstruction):
- return this.processingInstruction(child);
- default:
- return this.element(child, 0);
- }
- }).call(this);
- }
- if (this.pretty && r.slice(-this.newline.length) === this.newline) {
- r = r.slice(0, -this.newline.length);
- }
- return r;
- };
-
- XMLStringWriter.prototype.attribute = function(att) {
- return ' ' + att.name + '="' + att.value + '"';
- };
-
- XMLStringWriter.prototype.cdata = function(node, level) {
- return this.space(level) + '<![CDATA[' + node.text + ']]>' + this.newline;
- };
-
- XMLStringWriter.prototype.comment = function(node, level) {
- return this.space(level) + '<!-- ' + node.text + ' -->' + this.newline;
- };
-
- XMLStringWriter.prototype.declaration = function(node, level) {
- var r;
- r = this.space(level);
- r += '<?xml version="' + node.version + '"';
- if (node.encoding != null) {
- r += ' encoding="' + node.encoding + '"';
- }
- if (node.standalone != null) {
- r += ' standalone="' + node.standalone + '"';
- }
- r += this.spacebeforeslash + '?>';
- r += this.newline;
- return r;
- };
-
- XMLStringWriter.prototype.docType = function(node, level) {
- var child, i, len, r, ref;
- level || (level = 0);
- r = this.space(level);
- r += '<!DOCTYPE ' + node.root().name;
- if (node.pubID && node.sysID) {
- r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
- } else if (node.sysID) {
- r += ' SYSTEM "' + node.sysID + '"';
- }
- if (node.children.length > 0) {
- r += ' [';
- r += this.newline;
- ref = node.children;
- for (i = 0, len = ref.length; i < len; i++) {
- child = ref[i];
- r += (function() {
- switch (false) {
- case !(child instanceof XMLDTDAttList):
- return this.dtdAttList(child, level + 1);
- case !(child instanceof XMLDTDElement):
- return this.dtdElement(child, level + 1);
- case !(child instanceof XMLDTDEntity):
- return this.dtdEntity(child, level + 1);
- case !(child instanceof XMLDTDNotation):
- return this.dtdNotation(child, level + 1);
- case !(child instanceof XMLCData):
- return this.cdata(child, level + 1);
- case !(child instanceof XMLComment):
- return this.comment(child, level + 1);
- case !(child instanceof XMLProcessingInstruction):
- return this.processingInstruction(child, level + 1);
- default:
- throw new Error("Unknown DTD node type: " + child.constructor.name);
- }
- }).call(this);
- }
- r += ']';
- }
- r += this.spacebeforeslash + '>';
- r += this.newline;
- return r;
- };
-
- XMLStringWriter.prototype.element = function(node, level) {
- var att, child, i, j, len, len1, name, r, ref, ref1, ref2, space, textispresentwasset;
- level || (level = 0);
- textispresentwasset = false;
- if (this.textispresent) {
- this.newline = '';
- this.pretty = false;
- } else {
- this.newline = this.newlinedefault;
- this.pretty = this.prettydefault;
- }
- space = this.space(level);
- r = '';
- r += space + '<' + node.name;
- ref = node.attributes;
- for (name in ref) {
- if (!hasProp.call(ref, name)) continue;
- att = ref[name];
- r += this.attribute(att);
- }
- if (node.children.length === 0 || node.children.every(function(e) {
- return e.value === '';
- })) {
- if (this.allowEmpty) {
- r += '></' + node.name + '>' + this.newline;
- } else {
- r += this.spacebeforeslash + '/>' + this.newline;
- }
- } else if (this.pretty && node.children.length === 1 && (node.children[0].value != null)) {
- r += '>';
- r += node.children[0].value;
- r += '</' + node.name + '>' + this.newline;
- } else {
- if (this.dontprettytextnodes) {
- ref1 = node.children;
- for (i = 0, len = ref1.length; i < len; i++) {
- child = ref1[i];
- if (child.value != null) {
- this.textispresent++;
- textispresentwasset = true;
- break;
- }
- }
- }
- if (this.textispresent) {
- this.newline = '';
- this.pretty = false;
- space = this.space(level);
- }
- r += '>' + this.newline;
- ref2 = node.children;
- for (j = 0, len1 = ref2.length; j < len1; j++) {
- child = ref2[j];
- r += (function() {
- switch (false) {
- case !(child instanceof XMLCData):
- return this.cdata(child, level + 1);
- case !(child instanceof XMLComment):
- return this.comment(child, level + 1);
- case !(child instanceof XMLElement):
- return this.element(child, level + 1);
- case !(child instanceof XMLRaw):
- return this.raw(child, level + 1);
- case !(child instanceof XMLText):
- return this.text(child, level + 1);
- case !(child instanceof XMLProcessingInstruction):
- return this.processingInstruction(child, level + 1);
- default:
- throw new Error("Unknown XML node type: " + child.constructor.name);
- }
- }).call(this);
- }
- if (textispresentwasset) {
- this.textispresent--;
- }
- if (!this.textispresent) {
- this.newline = this.newlinedefault;
- this.pretty = this.prettydefault;
- }
- r += space + '</' + node.name + '>' + this.newline;
- }
- return r;
- };
-
- XMLStringWriter.prototype.processingInstruction = function(node, level) {
- var r;
- r = this.space(level) + '<?' + node.target;
- if (node.value) {
- r += ' ' + node.value;
- }
- r += this.spacebeforeslash + '?>' + this.newline;
- return r;
- };
-
- XMLStringWriter.prototype.raw = function(node, level) {
- return this.space(level) + node.value + this.newline;
- };
-
- XMLStringWriter.prototype.text = function(node, level) {
- return this.space(level) + node.value + this.newline;
- };
-
- XMLStringWriter.prototype.dtdAttList = function(node, level) {
- var r;
- r = this.space(level) + '<!ATTLIST ' + node.elementName + ' ' + node.attributeName + ' ' + node.attributeType;
- if (node.defaultValueType !== '#DEFAULT') {
- r += ' ' + node.defaultValueType;
- }
- if (node.defaultValue) {
- r += ' "' + node.defaultValue + '"';
- }
- r += this.spacebeforeslash + '>' + this.newline;
- return r;
- };
-
- XMLStringWriter.prototype.dtdElement = function(node, level) {
- return this.space(level) + '<!ELEMENT ' + node.name + ' ' + node.value + this.spacebeforeslash + '>' + this.newline;
- };
-
- XMLStringWriter.prototype.dtdEntity = function(node, level) {
- var r;
- r = this.space(level) + '<!ENTITY';
- if (node.pe) {
- r += ' %';
- }
- r += ' ' + node.name;
- if (node.value) {
- r += ' "' + node.value + '"';
- } else {
- if (node.pubID && node.sysID) {
- r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
- } else if (node.sysID) {
- r += ' SYSTEM "' + node.sysID + '"';
- }
- if (node.nData) {
- r += ' NDATA ' + node.nData;
- }
- }
- r += this.spacebeforeslash + '>' + this.newline;
- return r;
- };
-
- XMLStringWriter.prototype.dtdNotation = function(node, level) {
- var r;
- r = this.space(level) + '<!NOTATION ' + node.name;
- if (node.pubID && node.sysID) {
- r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
- } else if (node.pubID) {
- r += ' PUBLIC "' + node.pubID + '"';
- } else if (node.sysID) {
- r += ' SYSTEM "' + node.sysID + '"';
- }
- r += this.spacebeforeslash + '>' + this.newline;
- return r;
- };
-
- XMLStringWriter.prototype.openNode = function(node, level) {
- var att, name, r, ref;
- level || (level = 0);
- if (node instanceof XMLElement) {
- r = this.space(level) + '<' + node.name;
- ref = node.attributes;
- for (name in ref) {
- if (!hasProp.call(ref, name)) continue;
- att = ref[name];
- r += this.attribute(att);
- }
- r += (node.children ? '>' : '/>') + this.newline;
- return r;
- } else {
- r = this.space(level) + '<!DOCTYPE ' + node.rootNodeName;
- if (node.pubID && node.sysID) {
- r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
- } else if (node.sysID) {
- r += ' SYSTEM "' + node.sysID + '"';
- }
- r += (node.children ? ' [' : '>') + this.newline;
- return r;
- }
- };
-
- XMLStringWriter.prototype.closeNode = function(node, level) {
- level || (level = 0);
- switch (false) {
- case !(node instanceof XMLElement):
- return this.space(level) + '</' + node.name + '>' + this.newline;
- case !(node instanceof XMLDocType):
- return this.space(level) + ']>' + this.newline;
- }
- };
-
- return XMLStringWriter;
-
- })(XMLWriterBase);
-
- }).call(this);
-
- },{"./XMLCData":10,"./XMLComment":11,"./XMLDTDAttList":12,"./XMLDTDElement":13,"./XMLDTDEntity":14,"./XMLDTDNotation":15,"./XMLDeclaration":16,"./XMLDocType":17,"./XMLElement":20,"./XMLProcessingInstruction":22,"./XMLRaw":23,"./XMLText":27,"./XMLWriterBase":28}],26:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLStringifier,
- bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
- hasProp = {}.hasOwnProperty;
-
- module.exports = XMLStringifier = (function() {
- function XMLStringifier(options) {
- this.assertLegalChar = bind(this.assertLegalChar, this);
- var key, ref, value;
- options || (options = {});
- this.noDoubleEncoding = options.noDoubleEncoding;
- ref = options.stringify || {};
- for (key in ref) {
- if (!hasProp.call(ref, key)) continue;
- value = ref[key];
- this[key] = value;
- }
- }
-
- XMLStringifier.prototype.eleName = function(val) {
- val = '' + val || '';
- return this.assertLegalChar(val);
- };
-
- XMLStringifier.prototype.eleText = function(val) {
- val = '' + val || '';
- return this.assertLegalChar(this.elEscape(val));
- };
-
- XMLStringifier.prototype.cdata = function(val) {
- val = '' + val || '';
- val = val.replace(']]>', ']]]]><![CDATA[>');
- return this.assertLegalChar(val);
- };
-
- XMLStringifier.prototype.comment = function(val) {
- val = '' + val || '';
- if (val.match(/--/)) {
- throw new Error("Comment text cannot contain double-hypen: " + val);
- }
- return this.assertLegalChar(val);
- };
-
- XMLStringifier.prototype.raw = function(val) {
- return '' + val || '';
- };
-
- XMLStringifier.prototype.attName = function(val) {
- return val = '' + val || '';
- };
-
- XMLStringifier.prototype.attValue = function(val) {
- val = '' + val || '';
- return this.attEscape(val);
- };
-
- XMLStringifier.prototype.insTarget = function(val) {
- return '' + val || '';
- };
-
- XMLStringifier.prototype.insValue = function(val) {
- val = '' + val || '';
- if (val.match(/\?>/)) {
- throw new Error("Invalid processing instruction value: " + val);
- }
- return val;
- };
-
- XMLStringifier.prototype.xmlVersion = function(val) {
- val = '' + val || '';
- if (!val.match(/1\.[0-9]+/)) {
- throw new Error("Invalid version number: " + val);
- }
- return val;
- };
-
- XMLStringifier.prototype.xmlEncoding = function(val) {
- val = '' + val || '';
- if (!val.match(/^[A-Za-z](?:[A-Za-z0-9._-])*$/)) {
- throw new Error("Invalid encoding: " + val);
- }
- return val;
- };
-
- XMLStringifier.prototype.xmlStandalone = function(val) {
- if (val) {
- return "yes";
- } else {
- return "no";
- }
- };
-
- XMLStringifier.prototype.dtdPubID = function(val) {
- return '' + val || '';
- };
-
- XMLStringifier.prototype.dtdSysID = function(val) {
- return '' + val || '';
- };
-
- XMLStringifier.prototype.dtdElementValue = function(val) {
- return '' + val || '';
- };
-
- XMLStringifier.prototype.dtdAttType = function(val) {
- return '' + val || '';
- };
-
- XMLStringifier.prototype.dtdAttDefault = function(val) {
- if (val != null) {
- return '' + val || '';
- } else {
- return val;
- }
- };
-
- XMLStringifier.prototype.dtdEntityValue = function(val) {
- return '' + val || '';
- };
-
- XMLStringifier.prototype.dtdNData = function(val) {
- return '' + val || '';
- };
-
- XMLStringifier.prototype.convertAttKey = '@';
-
- XMLStringifier.prototype.convertPIKey = '?';
-
- XMLStringifier.prototype.convertTextKey = '#text';
-
- XMLStringifier.prototype.convertCDataKey = '#cdata';
-
- XMLStringifier.prototype.convertCommentKey = '#comment';
-
- XMLStringifier.prototype.convertRawKey = '#raw';
-
- XMLStringifier.prototype.assertLegalChar = function(str) {
- var res;
- res = str.match(/[\0\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/);
- if (res) {
- throw new Error("Invalid character in string: " + str + " at index " + res.index);
- }
- return str;
- };
-
- XMLStringifier.prototype.elEscape = function(str) {
- var ampregex;
- ampregex = this.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g;
- return str.replace(ampregex, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\r/g, '
');
- };
-
- XMLStringifier.prototype.attEscape = function(str) {
- var ampregex;
- ampregex = this.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g;
- return str.replace(ampregex, '&').replace(/</g, '<').replace(/"/g, '"').replace(/\t/g, '	').replace(/\n/g, '
').replace(/\r/g, '
');
- };
-
- return XMLStringifier;
-
- })();
-
- }).call(this);
-
- },{}],27:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLNode, XMLText,
- 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; },
- hasProp = {}.hasOwnProperty;
-
- XMLNode = require('./XMLNode');
-
- module.exports = XMLText = (function(superClass) {
- extend(XMLText, superClass);
-
- function XMLText(parent, text) {
- XMLText.__super__.constructor.call(this, parent);
- if (text == null) {
- throw new Error("Missing element text");
- }
- this.value = this.stringify.eleText(text);
- }
-
- XMLText.prototype.clone = function() {
- return Object.create(this);
- };
-
- XMLText.prototype.toString = function(options) {
- return this.options.writer.set(options).text(this);
- };
-
- return XMLText;
-
- })(XMLNode);
-
- }).call(this);
-
- },{"./XMLNode":21}],28:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLWriterBase,
- hasProp = {}.hasOwnProperty;
-
- module.exports = XMLWriterBase = (function() {
- function XMLWriterBase(options) {
- var key, ref, ref1, ref2, ref3, ref4, ref5, ref6, value;
- options || (options = {});
- this.pretty = options.pretty || false;
- this.allowEmpty = (ref = options.allowEmpty) != null ? ref : false;
- if (this.pretty) {
- this.indent = (ref1 = options.indent) != null ? ref1 : ' ';
- this.newline = (ref2 = options.newline) != null ? ref2 : '\n';
- this.offset = (ref3 = options.offset) != null ? ref3 : 0;
- this.dontprettytextnodes = (ref4 = options.dontprettytextnodes) != null ? ref4 : 0;
- } else {
- this.indent = '';
- this.newline = '';
- this.offset = 0;
- this.dontprettytextnodes = 0;
- }
- this.spacebeforeslash = (ref5 = options.spacebeforeslash) != null ? ref5 : '';
- if (this.spacebeforeslash === true) {
- this.spacebeforeslash = ' ';
- }
- this.newlinedefault = this.newline;
- this.prettydefault = this.pretty;
- ref6 = options.writer || {};
- for (key in ref6) {
- if (!hasProp.call(ref6, key)) continue;
- value = ref6[key];
- this[key] = value;
- }
- }
-
- XMLWriterBase.prototype.set = function(options) {
- var key, ref, value;
- options || (options = {});
- if ("pretty" in options) {
- this.pretty = options.pretty;
- }
- if ("allowEmpty" in options) {
- this.allowEmpty = options.allowEmpty;
- }
- if (this.pretty) {
- this.indent = "indent" in options ? options.indent : ' ';
- this.newline = "newline" in options ? options.newline : '\n';
- this.offset = "offset" in options ? options.offset : 0;
- this.dontprettytextnodes = "dontprettytextnodes" in options ? options.dontprettytextnodes : 0;
- } else {
- this.indent = '';
- this.newline = '';
- this.offset = 0;
- this.dontprettytextnodes = 0;
- }
- this.spacebeforeslash = "spacebeforeslash" in options ? options.spacebeforeslash : '';
- if (this.spacebeforeslash === true) {
- this.spacebeforeslash = ' ';
- }
- this.newlinedefault = this.newline;
- this.prettydefault = this.pretty;
- ref = options.writer || {};
- for (key in ref) {
- if (!hasProp.call(ref, key)) continue;
- value = ref[key];
- this[key] = value;
- }
- return this;
- };
-
- XMLWriterBase.prototype.space = function(level) {
- var indent;
- if (this.pretty) {
- indent = (level || 0) + this.offset + 1;
- if (indent > 0) {
- return new Array(indent).join(this.indent);
- } else {
- return '';
- }
- } else {
- return '';
- }
- };
-
- return XMLWriterBase;
-
- })();
-
- }).call(this);
-
- },{}],29:[function(require,module,exports){
- // Generated by CoffeeScript 1.12.7
- (function() {
- var XMLDocument, XMLDocumentCB, XMLStreamWriter, XMLStringWriter, assign, isFunction, ref;
-
- ref = require('./Utility'), assign = ref.assign, isFunction = ref.isFunction;
-
- XMLDocument = require('./XMLDocument');
-
- XMLDocumentCB = require('./XMLDocumentCB');
-
- XMLStringWriter = require('./XMLStringWriter');
-
- XMLStreamWriter = require('./XMLStreamWriter');
-
- module.exports.create = function(name, xmldec, doctype, options) {
- var doc, root;
- if (name == null) {
- throw new Error("Root element needs a name");
- }
- options = assign({}, xmldec, doctype, options);
- doc = new XMLDocument(options);
- root = doc.element(name);
- if (!options.headless) {
- doc.declaration(options);
- if ((options.pubID != null) || (options.sysID != null)) {
- doc.doctype(options);
- }
- }
- return root;
- };
-
- module.exports.begin = function(options, onData, onEnd) {
- var ref1;
- if (isFunction(options)) {
- ref1 = [options, onData], onData = ref1[0], onEnd = ref1[1];
- options = {};
- }
- if (onData) {
- return new XMLDocumentCB(options, onData, onEnd);
- } else {
- return new XMLDocument(options);
- }
- };
-
- module.exports.stringWriter = function(options) {
- return new XMLStringWriter(options);
- };
-
- module.exports.streamWriter = function(stream, options) {
- return new XMLStreamWriter(stream, options);
- };
-
- }).call(this);
-
- },{"./Utility":8,"./XMLDocument":18,"./XMLDocumentCB":19,"./XMLStreamWriter":24,"./XMLStringWriter":25}],30:[function(require,module,exports){
- function DOMParser(options){
- this.options = options ||{locator:{}};
-
- }
- DOMParser.prototype.parseFromString = function(source,mimeType){
- var options = this.options;
- var sax = new XMLReader();
- var domBuilder = options.domBuilder || new DOMHandler();//contentHandler and LexicalHandler
- var errorHandler = options.errorHandler;
- var locator = options.locator;
- var defaultNSMap = options.xmlns||{};
- var entityMap = {'lt':'<','gt':'>','amp':'&','quot':'"','apos':"'"}
- if(locator){
- domBuilder.setDocumentLocator(locator)
- }
-
- sax.errorHandler = buildErrorHandler(errorHandler,domBuilder,locator);
- sax.domBuilder = options.domBuilder || domBuilder;
- if(/\/x?html?$/.test(mimeType)){
- entityMap.nbsp = '\xa0';
- entityMap.copy = '\xa9';
- defaultNSMap['']= 'http://www.w3.org/1999/xhtml';
- }
- defaultNSMap.xml = defaultNSMap.xml || 'http://www.w3.org/XML/1998/namespace';
- if(source){
- sax.parse(source,defaultNSMap,entityMap);
- }else{
- sax.errorHandler.error("invalid doc source");
- }
- return domBuilder.doc;
- }
- function buildErrorHandler(errorImpl,domBuilder,locator){
- if(!errorImpl){
- if(domBuilder instanceof DOMHandler){
- return domBuilder;
- }
- errorImpl = domBuilder ;
- }
- var errorHandler = {}
- var isCallback = errorImpl instanceof Function;
- locator = locator||{}
- function build(key){
- var fn = errorImpl[key];
- if(!fn && isCallback){
- fn = errorImpl.length == 2?function(msg){errorImpl(key,msg)}:errorImpl;
- }
- errorHandler[key] = fn && function(msg){
- fn('[xmldom '+key+']\t'+msg+_locator(locator));
- }||function(){};
- }
- build('warning');
- build('error');
- build('fatalError');
- return errorHandler;
- }
-
- //console.log('#\n\n\n\n\n\n\n####')
- /**
- * +ContentHandler+ErrorHandler
- * +LexicalHandler+EntityResolver2
- * -DeclHandler-DTDHandler
- *
- * DefaultHandler:EntityResolver, DTDHandler, ContentHandler, ErrorHandler
- * DefaultHandler2:DefaultHandler,LexicalHandler, DeclHandler, EntityResolver2
- * @link http://www.saxproject.org/apidoc/org/xml/sax/helpers/DefaultHandler.html
- */
- function DOMHandler() {
- this.cdata = false;
- }
- function position(locator,node){
- node.lineNumber = locator.lineNumber;
- node.columnNumber = locator.columnNumber;
- }
- /**
- * @see org.xml.sax.ContentHandler#startDocument
- * @link http://www.saxproject.org/apidoc/org/xml/sax/ContentHandler.html
- */
- DOMHandler.prototype = {
- startDocument : function() {
- this.doc = new DOMImplementation().createDocument(null, null, null);
- if (this.locator) {
- this.doc.documentURI = this.locator.systemId;
- }
- },
- startElement:function(namespaceURI, localName, qName, attrs) {
- var doc = this.doc;
- var el = doc.createElementNS(namespaceURI, qName||localName);
- var len = attrs.length;
- appendElement(this, el);
- this.currentElement = el;
-
- this.locator && position(this.locator,el)
- for (var i = 0 ; i < len; i++) {
- var namespaceURI = attrs.getURI(i);
- var value = attrs.getValue(i);
- var qName = attrs.getQName(i);
- var attr = doc.createAttributeNS(namespaceURI, qName);
- this.locator &&position(attrs.getLocator(i),attr);
- attr.value = attr.nodeValue = value;
- el.setAttributeNode(attr)
- }
- },
- endElement:function(namespaceURI, localName, qName) {
- var current = this.currentElement
- var tagName = current.tagName;
- this.currentElement = current.parentNode;
- },
- startPrefixMapping:function(prefix, uri) {
- },
- endPrefixMapping:function(prefix) {
- },
- processingInstruction:function(target, data) {
- var ins = this.doc.createProcessingInstruction(target, data);
- this.locator && position(this.locator,ins)
- appendElement(this, ins);
- },
- ignorableWhitespace:function(ch, start, length) {
- },
- characters:function(chars, start, length) {
- chars = _toString.apply(this,arguments)
- //console.log(chars)
- if(chars){
- if (this.cdata) {
- var charNode = this.doc.createCDATASection(chars);
- } else {
- var charNode = this.doc.createTextNode(chars);
- }
- if(this.currentElement){
- this.currentElement.appendChild(charNode);
- }else if(/^\s*$/.test(chars)){
- this.doc.appendChild(charNode);
- //process xml
- }
- this.locator && position(this.locator,charNode)
- }
- },
- skippedEntity:function(name) {
- },
- endDocument:function() {
- this.doc.normalize();
- },
- setDocumentLocator:function (locator) {
- if(this.locator = locator){// && !('lineNumber' in locator)){
- locator.lineNumber = 0;
- }
- },
- //LexicalHandler
- comment:function(chars, start, length) {
- chars = _toString.apply(this,arguments)
- var comm = this.doc.createComment(chars);
- this.locator && position(this.locator,comm)
- appendElement(this, comm);
- },
-
- startCDATA:function() {
- //used in characters() methods
- this.cdata = true;
- },
- endCDATA:function() {
- this.cdata = false;
- },
-
- startDTD:function(name, publicId, systemId) {
- var impl = this.doc.implementation;
- if (impl && impl.createDocumentType) {
- var dt = impl.createDocumentType(name, publicId, systemId);
- this.locator && position(this.locator,dt)
- appendElement(this, dt);
- }
- },
- /**
- * @see org.xml.sax.ErrorHandler
- * @link http://www.saxproject.org/apidoc/org/xml/sax/ErrorHandler.html
- */
- warning:function(error) {
- console.warn('[xmldom warning]\t'+error,_locator(this.locator));
- },
- error:function(error) {
- console.error('[xmldom error]\t'+error,_locator(this.locator));
- },
- fatalError:function(error) {
- console.error('[xmldom fatalError]\t'+error,_locator(this.locator));
- throw error;
- }
- }
- function _locator(l){
- if(l){
- return '\n@'+(l.systemId ||'')+'#[line:'+l.lineNumber+',col:'+l.columnNumber+']'
- }
- }
- function _toString(chars,start,length){
- if(typeof chars == 'string'){
- return chars.substr(start,length)
- }else{//java sax connect width xmldom on rhino(what about: "? && !(chars instanceof String)")
- if(chars.length >= start+length || start){
- return new java.lang.String(chars,start,length)+'';
- }
- return chars;
- }
- }
-
- /*
- * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/LexicalHandler.html
- * used method of org.xml.sax.ext.LexicalHandler:
- * #comment(chars, start, length)
- * #startCDATA()
- * #endCDATA()
- * #startDTD(name, publicId, systemId)
- *
- *
- * IGNORED method of org.xml.sax.ext.LexicalHandler:
- * #endDTD()
- * #startEntity(name)
- * #endEntity(name)
- *
- *
- * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/DeclHandler.html
- * IGNORED method of org.xml.sax.ext.DeclHandler
- * #attributeDecl(eName, aName, type, mode, value)
- * #elementDecl(name, model)
- * #externalEntityDecl(name, publicId, systemId)
- * #internalEntityDecl(name, value)
- * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/EntityResolver2.html
- * IGNORED method of org.xml.sax.EntityResolver2
- * #resolveEntity(String name,String publicId,String baseURI,String systemId)
- * #resolveEntity(publicId, systemId)
- * #getExternalSubset(name, baseURI)
- * @link http://www.saxproject.org/apidoc/org/xml/sax/DTDHandler.html
- * IGNORED method of org.xml.sax.DTDHandler
- * #notationDecl(name, publicId, systemId) {};
- * #unparsedEntityDecl(name, publicId, systemId, notationName) {};
- */
- "endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(key){
- DOMHandler.prototype[key] = function(){return null}
- })
-
- /* Private static helpers treated below as private instance methods, so don't need to add these to the public API; we might use a Relator to also get rid of non-standard public properties */
- function appendElement (hander,node) {
- if (!hander.currentElement) {
- hander.doc.appendChild(node);
- } else {
- hander.currentElement.appendChild(node);
- }
- }//appendChild and setAttributeNS are preformance key
-
- //if(typeof require == 'function'){
- var XMLReader = require('./sax').XMLReader;
- var DOMImplementation = exports.DOMImplementation = require('./dom').DOMImplementation;
- exports.XMLSerializer = require('./dom').XMLSerializer ;
- exports.DOMParser = DOMParser;
- //}
-
- },{"./dom":31,"./sax":32}],31:[function(require,module,exports){
- /*
- * DOM Level 2
- * Object DOMException
- * @see http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html
- * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html
- */
-
- function copy(src,dest){
- for(var p in src){
- dest[p] = src[p];
- }
- }
- /**
- ^\w+\.prototype\.([_\w]+)\s*=\s*((?:.*\{\s*?[\r\n][\s\S]*?^})|\S.*?(?=[;\r\n]));?
- ^\w+\.prototype\.([_\w]+)\s*=\s*(\S.*?(?=[;\r\n]));?
- */
- function _extends(Class,Super){
- var pt = Class.prototype;
- if(Object.create){
- var ppt = Object.create(Super.prototype)
- pt.__proto__ = ppt;
- }
- if(!(pt instanceof Super)){
- function t(){};
- t.prototype = Super.prototype;
- t = new t();
- copy(pt,t);
- Class.prototype = pt = t;
- }
- if(pt.constructor != Class){
- if(typeof Class != 'function'){
- console.error("unknow Class:"+Class)
- }
- pt.constructor = Class
- }
- }
- var htmlns = 'http://www.w3.org/1999/xhtml' ;
- // Node Types
- var NodeType = {}
- var ELEMENT_NODE = NodeType.ELEMENT_NODE = 1;
- var ATTRIBUTE_NODE = NodeType.ATTRIBUTE_NODE = 2;
- var TEXT_NODE = NodeType.TEXT_NODE = 3;
- var CDATA_SECTION_NODE = NodeType.CDATA_SECTION_NODE = 4;
- var ENTITY_REFERENCE_NODE = NodeType.ENTITY_REFERENCE_NODE = 5;
- var ENTITY_NODE = NodeType.ENTITY_NODE = 6;
- var PROCESSING_INSTRUCTION_NODE = NodeType.PROCESSING_INSTRUCTION_NODE = 7;
- var COMMENT_NODE = NodeType.COMMENT_NODE = 8;
- var DOCUMENT_NODE = NodeType.DOCUMENT_NODE = 9;
- var DOCUMENT_TYPE_NODE = NodeType.DOCUMENT_TYPE_NODE = 10;
- var DOCUMENT_FRAGMENT_NODE = NodeType.DOCUMENT_FRAGMENT_NODE = 11;
- var NOTATION_NODE = NodeType.NOTATION_NODE = 12;
-
- // ExceptionCode
- var ExceptionCode = {}
- var ExceptionMessage = {};
- var INDEX_SIZE_ERR = ExceptionCode.INDEX_SIZE_ERR = ((ExceptionMessage[1]="Index size error"),1);
- var DOMSTRING_SIZE_ERR = ExceptionCode.DOMSTRING_SIZE_ERR = ((ExceptionMessage[2]="DOMString size error"),2);
- var HIERARCHY_REQUEST_ERR = ExceptionCode.HIERARCHY_REQUEST_ERR = ((ExceptionMessage[3]="Hierarchy request error"),3);
- var WRONG_DOCUMENT_ERR = ExceptionCode.WRONG_DOCUMENT_ERR = ((ExceptionMessage[4]="Wrong document"),4);
- var INVALID_CHARACTER_ERR = ExceptionCode.INVALID_CHARACTER_ERR = ((ExceptionMessage[5]="Invalid character"),5);
- var NO_DATA_ALLOWED_ERR = ExceptionCode.NO_DATA_ALLOWED_ERR = ((ExceptionMessage[6]="No data allowed"),6);
- var NO_MODIFICATION_ALLOWED_ERR = ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = ((ExceptionMessage[7]="No modification allowed"),7);
- var NOT_FOUND_ERR = ExceptionCode.NOT_FOUND_ERR = ((ExceptionMessage[8]="Not found"),8);
- var NOT_SUPPORTED_ERR = ExceptionCode.NOT_SUPPORTED_ERR = ((ExceptionMessage[9]="Not supported"),9);
- var INUSE_ATTRIBUTE_ERR = ExceptionCode.INUSE_ATTRIBUTE_ERR = ((ExceptionMessage[10]="Attribute in use"),10);
- //level2
- var INVALID_STATE_ERR = ExceptionCode.INVALID_STATE_ERR = ((ExceptionMessage[11]="Invalid state"),11);
- var SYNTAX_ERR = ExceptionCode.SYNTAX_ERR = ((ExceptionMessage[12]="Syntax error"),12);
- var INVALID_MODIFICATION_ERR = ExceptionCode.INVALID_MODIFICATION_ERR = ((ExceptionMessage[13]="Invalid modification"),13);
- var NAMESPACE_ERR = ExceptionCode.NAMESPACE_ERR = ((ExceptionMessage[14]="Invalid namespace"),14);
- var INVALID_ACCESS_ERR = ExceptionCode.INVALID_ACCESS_ERR = ((ExceptionMessage[15]="Invalid access"),15);
-
-
- function DOMException(code, message) {
- if(message instanceof Error){
- var error = message;
- }else{
- error = this;
- Error.call(this, ExceptionMessage[code]);
- this.message = ExceptionMessage[code];
- if(Error.captureStackTrace) Error.captureStackTrace(this, DOMException);
- }
- error.code = code;
- if(message) this.message = this.message + ": " + message;
- return error;
- };
- DOMException.prototype = Error.prototype;
- copy(ExceptionCode,DOMException)
- /**
- * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-536297177
- * The NodeList interface provides the abstraction of an ordered collection of nodes, without defining or constraining how this collection is implemented. NodeList objects in the DOM are live.
- * The items in the NodeList are accessible via an integral index, starting from 0.
- */
- function NodeList() {
- };
- NodeList.prototype = {
- /**
- * The number of nodes in the list. The range of valid child node indices is 0 to length-1 inclusive.
- * @standard level1
- */
- length:0,
- /**
- * Returns the indexth item in the collection. If index is greater than or equal to the number of nodes in the list, this returns null.
- * @standard level1
- * @param index unsigned long
- * Index into the collection.
- * @return Node
- * The node at the indexth position in the NodeList, or null if that is not a valid index.
- */
- item: function(index) {
- return this[index] || null;
- },
- toString:function(isHTML,nodeFilter){
- for(var buf = [], i = 0;i<this.length;i++){
- serializeToString(this[i],buf,isHTML,nodeFilter);
- }
- return buf.join('');
- }
- };
- function LiveNodeList(node,refresh){
- this._node = node;
- this._refresh = refresh
- _updateLiveList(this);
- }
- function _updateLiveList(list){
- var inc = list._node._inc || list._node.ownerDocument._inc;
- if(list._inc != inc){
- var ls = list._refresh(list._node);
- //console.log(ls.length)
- __set__(list,'length',ls.length);
- copy(ls,list);
- list._inc = inc;
- }
- }
- LiveNodeList.prototype.item = function(i){
- _updateLiveList(this);
- return this[i];
- }
-
- _extends(LiveNodeList,NodeList);
- /**
- *
- * Objects implementing the NamedNodeMap interface are used to represent collections of nodes that can be accessed by name. Note that NamedNodeMap does not inherit from NodeList; NamedNodeMaps are not maintained in any particular order. Objects contained in an object implementing NamedNodeMap may also be accessed by an ordinal index, but this is simply to allow convenient enumeration of the contents of a NamedNodeMap, and does not imply that the DOM specifies an order to these Nodes.
- * NamedNodeMap objects in the DOM are live.
- * used for attributes or DocumentType entities
- */
- function NamedNodeMap() {
- };
-
- function _findNodeIndex(list,node){
- var i = list.length;
- while(i--){
- if(list[i] === node){return i}
- }
- }
-
- function _addNamedNode(el,list,newAttr,oldAttr){
- if(oldAttr){
- list[_findNodeIndex(list,oldAttr)] = newAttr;
- }else{
- list[list.length++] = newAttr;
- }
- if(el){
- newAttr.ownerElement = el;
- var doc = el.ownerDocument;
- if(doc){
- oldAttr && _onRemoveAttribute(doc,el,oldAttr);
- _onAddAttribute(doc,el,newAttr);
- }
- }
- }
- function _removeNamedNode(el,list,attr){
- //console.log('remove attr:'+attr)
- var i = _findNodeIndex(list,attr);
- if(i>=0){
- var lastIndex = list.length-1
- while(i<lastIndex){
- list[i] = list[++i]
- }
- list.length = lastIndex;
- if(el){
- var doc = el.ownerDocument;
- if(doc){
- _onRemoveAttribute(doc,el,attr);
- attr.ownerElement = null;
- }
- }
- }else{
- throw DOMException(NOT_FOUND_ERR,new Error(el.tagName+'@'+attr))
- }
- }
- NamedNodeMap.prototype = {
- length:0,
- item:NodeList.prototype.item,
- getNamedItem: function(key) {
- // if(key.indexOf(':')>0 || key == 'xmlns'){
- // return null;
- // }
- //console.log()
- var i = this.length;
- while(i--){
- var attr = this[i];
- //console.log(attr.nodeName,key)
- if(attr.nodeName == key){
- return attr;
- }
- }
- },
- setNamedItem: function(attr) {
- var el = attr.ownerElement;
- if(el && el!=this._ownerElement){
- throw new DOMException(INUSE_ATTRIBUTE_ERR);
- }
- var oldAttr = this.getNamedItem(attr.nodeName);
- _addNamedNode(this._ownerElement,this,attr,oldAttr);
- return oldAttr;
- },
- /* returns Node */
- setNamedItemNS: function(attr) {// raises: WRONG_DOCUMENT_ERR,NO_MODIFICATION_ALLOWED_ERR,INUSE_ATTRIBUTE_ERR
- var el = attr.ownerElement, oldAttr;
- if(el && el!=this._ownerElement){
- throw new DOMException(INUSE_ATTRIBUTE_ERR);
- }
- oldAttr = this.getNamedItemNS(attr.namespaceURI,attr.localName);
- _addNamedNode(this._ownerElement,this,attr,oldAttr);
- return oldAttr;
- },
-
- /* returns Node */
- removeNamedItem: function(key) {
- var attr = this.getNamedItem(key);
- _removeNamedNode(this._ownerElement,this,attr);
- return attr;
-
-
- },// raises: NOT_FOUND_ERR,NO_MODIFICATION_ALLOWED_ERR
-
- //for level2
- removeNamedItemNS:function(namespaceURI,localName){
- var attr = this.getNamedItemNS(namespaceURI,localName);
- _removeNamedNode(this._ownerElement,this,attr);
- return attr;
- },
- getNamedItemNS: function(namespaceURI, localName) {
- var i = this.length;
- while(i--){
- var node = this[i];
- if(node.localName == localName && node.namespaceURI == namespaceURI){
- return node;
- }
- }
- return null;
- }
- };
- /**
- * @see http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490
- */
- function DOMImplementation(/* Object */ features) {
- this._features = {};
- if (features) {
- for (var feature in features) {
- this._features = features[feature];
- }
- }
- };
-
- DOMImplementation.prototype = {
- hasFeature: function(/* string */ feature, /* string */ version) {
- var versions = this._features[feature.toLowerCase()];
- if (versions && (!version || version in versions)) {
- return true;
- } else {
- return false;
- }
- },
- // Introduced in DOM Level 2:
- createDocument:function(namespaceURI, qualifiedName, doctype){// raises:INVALID_CHARACTER_ERR,NAMESPACE_ERR,WRONG_DOCUMENT_ERR
- var doc = new Document();
- doc.implementation = this;
- doc.childNodes = new NodeList();
- doc.doctype = doctype;
- if(doctype){
- doc.appendChild(doctype);
- }
- if(qualifiedName){
- var root = doc.createElementNS(namespaceURI,qualifiedName);
- doc.appendChild(root);
- }
- return doc;
- },
- // Introduced in DOM Level 2:
- createDocumentType:function(qualifiedName, publicId, systemId){// raises:INVALID_CHARACTER_ERR,NAMESPACE_ERR
- var node = new DocumentType();
- node.name = qualifiedName;
- node.nodeName = qualifiedName;
- node.publicId = publicId;
- node.systemId = systemId;
- // Introduced in DOM Level 2:
- //readonly attribute DOMString internalSubset;
-
- //TODO:..
- // readonly attribute NamedNodeMap entities;
- // readonly attribute NamedNodeMap notations;
- return node;
- }
- };
-
-
- /**
- * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247
- */
-
- function Node() {
- };
-
- Node.prototype = {
- firstChild : null,
- lastChild : null,
- previousSibling : null,
- nextSibling : null,
- attributes : null,
- parentNode : null,
- childNodes : null,
- ownerDocument : null,
- nodeValue : null,
- namespaceURI : null,
- prefix : null,
- localName : null,
- // Modified in DOM Level 2:
- insertBefore:function(newChild, refChild){//raises
- return _insertBefore(this,newChild,refChild);
- },
- replaceChild:function(newChild, oldChild){//raises
- this.insertBefore(newChild,oldChild);
- if(oldChild){
- this.removeChild(oldChild);
- }
- },
- removeChild:function(oldChild){
- return _removeChild(this,oldChild);
- },
- appendChild:function(newChild){
- return this.insertBefore(newChild,null);
- },
- hasChildNodes:function(){
- return this.firstChild != null;
- },
- cloneNode:function(deep){
- return cloneNode(this.ownerDocument||this,this,deep);
- },
- // Modified in DOM Level 2:
- normalize:function(){
- var child = this.firstChild;
- while(child){
- var next = child.nextSibling;
- if(next && next.nodeType == TEXT_NODE && child.nodeType == TEXT_NODE){
- this.removeChild(next);
- child.appendData(next.data);
- }else{
- child.normalize();
- child = next;
- }
- }
- },
- // Introduced in DOM Level 2:
- isSupported:function(feature, version){
- return this.ownerDocument.implementation.hasFeature(feature,version);
- },
- // Introduced in DOM Level 2:
- hasAttributes:function(){
- return this.attributes.length>0;
- },
- lookupPrefix:function(namespaceURI){
- var el = this;
- while(el){
- var map = el._nsMap;
- //console.dir(map)
- if(map){
- for(var n in map){
- if(map[n] == namespaceURI){
- return n;
- }
- }
- }
- el = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode;
- }
- return null;
- },
- // Introduced in DOM Level 3:
- lookupNamespaceURI:function(prefix){
- var el = this;
- while(el){
- var map = el._nsMap;
- //console.dir(map)
- if(map){
- if(prefix in map){
- return map[prefix] ;
- }
- }
- el = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode;
- }
- return null;
- },
- // Introduced in DOM Level 3:
- isDefaultNamespace:function(namespaceURI){
- var prefix = this.lookupPrefix(namespaceURI);
- return prefix == null;
- }
- };
-
-
- function _xmlEncoder(c){
- return c == '<' && '<' ||
- c == '>' && '>' ||
- c == '&' && '&' ||
- c == '"' && '"' ||
- '&#'+c.charCodeAt()+';'
- }
-
-
- copy(NodeType,Node);
- copy(NodeType,Node.prototype);
-
- /**
- * @param callback return true for continue,false for break
- * @return boolean true: break visit;
- */
- function _visitNode(node,callback){
- if(callback(node)){
- return true;
- }
- if(node = node.firstChild){
- do{
- if(_visitNode(node,callback)){return true}
- }while(node=node.nextSibling)
- }
- }
-
-
-
- function Document(){
- }
- function _onAddAttribute(doc,el,newAttr){
- doc && doc._inc++;
- var ns = newAttr.namespaceURI ;
- if(ns == 'http://www.w3.org/2000/xmlns/'){
- //update namespace
- el._nsMap[newAttr.prefix?newAttr.localName:''] = newAttr.value
- }
- }
- function _onRemoveAttribute(doc,el,newAttr,remove){
- doc && doc._inc++;
- var ns = newAttr.namespaceURI ;
- if(ns == 'http://www.w3.org/2000/xmlns/'){
- //update namespace
- delete el._nsMap[newAttr.prefix?newAttr.localName:'']
- }
- }
- function _onUpdateChild(doc,el,newChild){
- if(doc && doc._inc){
- doc._inc++;
- //update childNodes
- var cs = el.childNodes;
- if(newChild){
- cs[cs.length++] = newChild;
- }else{
- //console.log(1)
- var child = el.firstChild;
- var i = 0;
- while(child){
- cs[i++] = child;
- child =child.nextSibling;
- }
- cs.length = i;
- }
- }
- }
-
- /**
- * attributes;
- * children;
- *
- * writeable properties:
- * nodeValue,Attr:value,CharacterData:data
- * prefix
- */
- function _removeChild(parentNode,child){
- var previous = child.previousSibling;
- var next = child.nextSibling;
- if(previous){
- previous.nextSibling = next;
- }else{
- parentNode.firstChild = next
- }
- if(next){
- next.previousSibling = previous;
- }else{
- parentNode.lastChild = previous;
- }
- _onUpdateChild(parentNode.ownerDocument,parentNode);
- return child;
- }
- /**
- * preformance key(refChild == null)
- */
- function _insertBefore(parentNode,newChild,nextChild){
- var cp = newChild.parentNode;
- if(cp){
- cp.removeChild(newChild);//remove and update
- }
- if(newChild.nodeType === DOCUMENT_FRAGMENT_NODE){
- var newFirst = newChild.firstChild;
- if (newFirst == null) {
- return newChild;
- }
- var newLast = newChild.lastChild;
- }else{
- newFirst = newLast = newChild;
- }
- var pre = nextChild ? nextChild.previousSibling : parentNode.lastChild;
-
- newFirst.previousSibling = pre;
- newLast.nextSibling = nextChild;
-
-
- if(pre){
- pre.nextSibling = newFirst;
- }else{
- parentNode.firstChild = newFirst;
- }
- if(nextChild == null){
- parentNode.lastChild = newLast;
- }else{
- nextChild.previousSibling = newLast;
- }
- do{
- newFirst.parentNode = parentNode;
- }while(newFirst !== newLast && (newFirst= newFirst.nextSibling))
- _onUpdateChild(parentNode.ownerDocument||parentNode,parentNode);
- //console.log(parentNode.lastChild.nextSibling == null)
- if (newChild.nodeType == DOCUMENT_FRAGMENT_NODE) {
- newChild.firstChild = newChild.lastChild = null;
- }
- return newChild;
- }
- function _appendSingleChild(parentNode,newChild){
- var cp = newChild.parentNode;
- if(cp){
- var pre = parentNode.lastChild;
- cp.removeChild(newChild);//remove and update
- var pre = parentNode.lastChild;
- }
- var pre = parentNode.lastChild;
- newChild.parentNode = parentNode;
- newChild.previousSibling = pre;
- newChild.nextSibling = null;
- if(pre){
- pre.nextSibling = newChild;
- }else{
- parentNode.firstChild = newChild;
- }
- parentNode.lastChild = newChild;
- _onUpdateChild(parentNode.ownerDocument,parentNode,newChild);
- return newChild;
- //console.log("__aa",parentNode.lastChild.nextSibling == null)
- }
- Document.prototype = {
- //implementation : null,
- nodeName : '#document',
- nodeType : DOCUMENT_NODE,
- doctype : null,
- documentElement : null,
- _inc : 1,
-
- insertBefore : function(newChild, refChild){//raises
- if(newChild.nodeType == DOCUMENT_FRAGMENT_NODE){
- var child = newChild.firstChild;
- while(child){
- var next = child.nextSibling;
- this.insertBefore(child,refChild);
- child = next;
- }
- return newChild;
- }
- if(this.documentElement == null && newChild.nodeType == ELEMENT_NODE){
- this.documentElement = newChild;
- }
-
- return _insertBefore(this,newChild,refChild),(newChild.ownerDocument = this),newChild;
- },
- removeChild : function(oldChild){
- if(this.documentElement == oldChild){
- this.documentElement = null;
- }
- return _removeChild(this,oldChild);
- },
- // Introduced in DOM Level 2:
- importNode : function(importedNode,deep){
- return importNode(this,importedNode,deep);
- },
- // Introduced in DOM Level 2:
- getElementById : function(id){
- var rtv = null;
- _visitNode(this.documentElement,function(node){
- if(node.nodeType == ELEMENT_NODE){
- if(node.getAttribute('id') == id){
- rtv = node;
- return true;
- }
- }
- })
- return rtv;
- },
-
- //document factory method:
- createElement : function(tagName){
- var node = new Element();
- node.ownerDocument = this;
- node.nodeName = tagName;
- node.tagName = tagName;
- node.childNodes = new NodeList();
- var attrs = node.attributes = new NamedNodeMap();
- attrs._ownerElement = node;
- return node;
- },
- createDocumentFragment : function(){
- var node = new DocumentFragment();
- node.ownerDocument = this;
- node.childNodes = new NodeList();
- return node;
- },
- createTextNode : function(data){
- var node = new Text();
- node.ownerDocument = this;
- node.appendData(data)
- return node;
- },
- createComment : function(data){
- var node = new Comment();
- node.ownerDocument = this;
- node.appendData(data)
- return node;
- },
- createCDATASection : function(data){
- var node = new CDATASection();
- node.ownerDocument = this;
- node.appendData(data)
- return node;
- },
- createProcessingInstruction : function(target,data){
- var node = new ProcessingInstruction();
- node.ownerDocument = this;
- node.tagName = node.target = target;
- node.nodeValue= node.data = data;
- return node;
- },
- createAttribute : function(name){
- var node = new Attr();
- node.ownerDocument = this;
- node.name = name;
- node.nodeName = name;
- node.localName = name;
- node.specified = true;
- return node;
- },
- createEntityReference : function(name){
- var node = new EntityReference();
- node.ownerDocument = this;
- node.nodeName = name;
- return node;
- },
- // Introduced in DOM Level 2:
- createElementNS : function(namespaceURI,qualifiedName){
- var node = new Element();
- var pl = qualifiedName.split(':');
- var attrs = node.attributes = new NamedNodeMap();
- node.childNodes = new NodeList();
- node.ownerDocument = this;
- node.nodeName = qualifiedName;
- node.tagName = qualifiedName;
- node.namespaceURI = namespaceURI;
- if(pl.length == 2){
- node.prefix = pl[0];
- node.localName = pl[1];
- }else{
- //el.prefix = null;
- node.localName = qualifiedName;
- }
- attrs._ownerElement = node;
- return node;
- },
- // Introduced in DOM Level 2:
- createAttributeNS : function(namespaceURI,qualifiedName){
- var node = new Attr();
- var pl = qualifiedName.split(':');
- node.ownerDocument = this;
- node.nodeName = qualifiedName;
- node.name = qualifiedName;
- node.namespaceURI = namespaceURI;
- node.specified = true;
- if(pl.length == 2){
- node.prefix = pl[0];
- node.localName = pl[1];
- }else{
- //el.prefix = null;
- node.localName = qualifiedName;
- }
- return node;
- }
- };
- _extends(Document,Node);
-
-
- function Element() {
- this._nsMap = {};
- };
- Element.prototype = {
- nodeType : ELEMENT_NODE,
- hasAttribute : function(name){
- return this.getAttributeNode(name)!=null;
- },
- getAttribute : function(name){
- var attr = this.getAttributeNode(name);
- return attr && attr.value || '';
- },
- getAttributeNode : function(name){
- return this.attributes.getNamedItem(name);
- },
- setAttribute : function(name, value){
- var attr = this.ownerDocument.createAttribute(name);
- attr.value = attr.nodeValue = "" + value;
- this.setAttributeNode(attr)
- },
- removeAttribute : function(name){
- var attr = this.getAttributeNode(name)
- attr && this.removeAttributeNode(attr);
- },
-
- //four real opeartion method
- appendChild:function(newChild){
- if(newChild.nodeType === DOCUMENT_FRAGMENT_NODE){
- return this.insertBefore(newChild,null);
- }else{
- return _appendSingleChild(this,newChild);
- }
- },
- setAttributeNode : function(newAttr){
- return this.attributes.setNamedItem(newAttr);
- },
- setAttributeNodeNS : function(newAttr){
- return this.attributes.setNamedItemNS(newAttr);
- },
- removeAttributeNode : function(oldAttr){
- //console.log(this == oldAttr.ownerElement)
- return this.attributes.removeNamedItem(oldAttr.nodeName);
- },
- //get real attribute name,and remove it by removeAttributeNode
- removeAttributeNS : function(namespaceURI, localName){
- var old = this.getAttributeNodeNS(namespaceURI, localName);
- old && this.removeAttributeNode(old);
- },
-
- hasAttributeNS : function(namespaceURI, localName){
- return this.getAttributeNodeNS(namespaceURI, localName)!=null;
- },
- getAttributeNS : function(namespaceURI, localName){
- var attr = this.getAttributeNodeNS(namespaceURI, localName);
- return attr && attr.value || '';
- },
- setAttributeNS : function(namespaceURI, qualifiedName, value){
- var attr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName);
- attr.value = attr.nodeValue = "" + value;
- this.setAttributeNode(attr)
- },
- getAttributeNodeNS : function(namespaceURI, localName){
- return this.attributes.getNamedItemNS(namespaceURI, localName);
- },
-
- getElementsByTagName : function(tagName){
- return new LiveNodeList(this,function(base){
- var ls = [];
- _visitNode(base,function(node){
- if(node !== base && node.nodeType == ELEMENT_NODE && (tagName === '*' || node.tagName == tagName)){
- ls.push(node);
- }
- });
- return ls;
- });
- },
- getElementsByTagNameNS : function(namespaceURI, localName){
- return new LiveNodeList(this,function(base){
- var ls = [];
- _visitNode(base,function(node){
- if(node !== base && node.nodeType === ELEMENT_NODE && (namespaceURI === '*' || node.namespaceURI === namespaceURI) && (localName === '*' || node.localName == localName)){
- ls.push(node);
- }
- });
- return ls;
-
- });
- }
- };
- Document.prototype.getElementsByTagName = Element.prototype.getElementsByTagName;
- Document.prototype.getElementsByTagNameNS = Element.prototype.getElementsByTagNameNS;
-
-
- _extends(Element,Node);
- function Attr() {
- };
- Attr.prototype.nodeType = ATTRIBUTE_NODE;
- _extends(Attr,Node);
-
-
- function CharacterData() {
- };
- CharacterData.prototype = {
- data : '',
- substringData : function(offset, count) {
- return this.data.substring(offset, offset+count);
- },
- appendData: function(text) {
- text = this.data+text;
- this.nodeValue = this.data = text;
- this.length = text.length;
- },
- insertData: function(offset,text) {
- this.replaceData(offset,0,text);
-
- },
- appendChild:function(newChild){
- throw new Error(ExceptionMessage[HIERARCHY_REQUEST_ERR])
- },
- deleteData: function(offset, count) {
- this.replaceData(offset,count,"");
- },
- replaceData: function(offset, count, text) {
- var start = this.data.substring(0,offset);
- var end = this.data.substring(offset+count);
- text = start + text + end;
- this.nodeValue = this.data = text;
- this.length = text.length;
- }
- }
- _extends(CharacterData,Node);
- function Text() {
- };
- Text.prototype = {
- nodeName : "#text",
- nodeType : TEXT_NODE,
- splitText : function(offset) {
- var text = this.data;
- var newText = text.substring(offset);
- text = text.substring(0, offset);
- this.data = this.nodeValue = text;
- this.length = text.length;
- var newNode = this.ownerDocument.createTextNode(newText);
- if(this.parentNode){
- this.parentNode.insertBefore(newNode, this.nextSibling);
- }
- return newNode;
- }
- }
- _extends(Text,CharacterData);
- function Comment() {
- };
- Comment.prototype = {
- nodeName : "#comment",
- nodeType : COMMENT_NODE
- }
- _extends(Comment,CharacterData);
-
- function CDATASection() {
- };
- CDATASection.prototype = {
- nodeName : "#cdata-section",
- nodeType : CDATA_SECTION_NODE
- }
- _extends(CDATASection,CharacterData);
-
-
- function DocumentType() {
- };
- DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;
- _extends(DocumentType,Node);
-
- function Notation() {
- };
- Notation.prototype.nodeType = NOTATION_NODE;
- _extends(Notation,Node);
-
- function Entity() {
- };
- Entity.prototype.nodeType = ENTITY_NODE;
- _extends(Entity,Node);
-
- function EntityReference() {
- };
- EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE;
- _extends(EntityReference,Node);
-
- function DocumentFragment() {
- };
- DocumentFragment.prototype.nodeName = "#document-fragment";
- DocumentFragment.prototype.nodeType = DOCUMENT_FRAGMENT_NODE;
- _extends(DocumentFragment,Node);
-
-
- function ProcessingInstruction() {
- }
- ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;
- _extends(ProcessingInstruction,Node);
- function XMLSerializer(){}
- XMLSerializer.prototype.serializeToString = function(node,isHtml,nodeFilter){
- return nodeSerializeToString.call(node,isHtml,nodeFilter);
- }
- Node.prototype.toString = nodeSerializeToString;
- function nodeSerializeToString(isHtml,nodeFilter){
- var buf = [];
- var refNode = this.nodeType == 9?this.documentElement:this;
- var prefix = refNode.prefix;
- var uri = refNode.namespaceURI;
-
- if(uri && prefix == null){
- //console.log(prefix)
- var prefix = refNode.lookupPrefix(uri);
- if(prefix == null){
- //isHTML = true;
- var visibleNamespaces=[
- {namespace:uri,prefix:null}
- //{namespace:uri,prefix:''}
- ]
- }
- }
- serializeToString(this,buf,isHtml,nodeFilter,visibleNamespaces);
- //console.log('###',this.nodeType,uri,prefix,buf.join(''))
- return buf.join('');
- }
- function needNamespaceDefine(node,isHTML, visibleNamespaces) {
- var prefix = node.prefix||'';
- var uri = node.namespaceURI;
- if (!prefix && !uri){
- return false;
- }
- if (prefix === "xml" && uri === "http://www.w3.org/XML/1998/namespace"
- || uri == 'http://www.w3.org/2000/xmlns/'){
- return false;
- }
-
- var i = visibleNamespaces.length
- //console.log('@@@@',node.tagName,prefix,uri,visibleNamespaces)
- while (i--) {
- var ns = visibleNamespaces[i];
- // get namespace prefix
- //console.log(node.nodeType,node.tagName,ns.prefix,prefix)
- if (ns.prefix == prefix){
- return ns.namespace != uri;
- }
- }
- //console.log(isHTML,uri,prefix=='')
- //if(isHTML && prefix ==null && uri == 'http://www.w3.org/1999/xhtml'){
- // return false;
- //}
- //node.flag = '11111'
- //console.error(3,true,node.flag,node.prefix,node.namespaceURI)
- return true;
- }
- function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){
- if(nodeFilter){
- node = nodeFilter(node);
- if(node){
- if(typeof node == 'string'){
- buf.push(node);
- return;
- }
- }else{
- return;
- }
- //buf.sort.apply(attrs, attributeSorter);
- }
- switch(node.nodeType){
- case ELEMENT_NODE:
- if (!visibleNamespaces) visibleNamespaces = [];
- var startVisibleNamespaces = visibleNamespaces.length;
- var attrs = node.attributes;
- var len = attrs.length;
- var child = node.firstChild;
- var nodeName = node.tagName;
-
- isHTML = (htmlns === node.namespaceURI) ||isHTML
- buf.push('<',nodeName);
-
-
-
- for(var i=0;i<len;i++){
- // add namespaces for attributes
- var attr = attrs.item(i);
- if (attr.prefix == 'xmlns') {
- visibleNamespaces.push({ prefix: attr.localName, namespace: attr.value });
- }else if(attr.nodeName == 'xmlns'){
- visibleNamespaces.push({ prefix: '', namespace: attr.value });
- }
- }
- for(var i=0;i<len;i++){
- var attr = attrs.item(i);
- if (needNamespaceDefine(attr,isHTML, visibleNamespaces)) {
- var prefix = attr.prefix||'';
- var uri = attr.namespaceURI;
- var ns = prefix ? ' xmlns:' + prefix : " xmlns";
- buf.push(ns, '="' , uri , '"');
- visibleNamespaces.push({ prefix: prefix, namespace:uri });
- }
- serializeToString(attr,buf,isHTML,nodeFilter,visibleNamespaces);
- }
- // add namespace for current node
- if (needNamespaceDefine(node,isHTML, visibleNamespaces)) {
- var prefix = node.prefix||'';
- var uri = node.namespaceURI;
- var ns = prefix ? ' xmlns:' + prefix : " xmlns";
- buf.push(ns, '="' , uri , '"');
- visibleNamespaces.push({ prefix: prefix, namespace:uri });
- }
-
- if(child || isHTML && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)){
- buf.push('>');
- //if is cdata child node
- if(isHTML && /^script$/i.test(nodeName)){
- while(child){
- if(child.data){
- buf.push(child.data);
- }else{
- serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces);
- }
- child = child.nextSibling;
- }
- }else
- {
- while(child){
- serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces);
- child = child.nextSibling;
- }
- }
- buf.push('</',nodeName,'>');
- }else{
- buf.push('/>');
- }
- // remove added visible namespaces
- //visibleNamespaces.length = startVisibleNamespaces;
- return;
- case DOCUMENT_NODE:
- case DOCUMENT_FRAGMENT_NODE:
- var child = node.firstChild;
- while(child){
- serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces);
- child = child.nextSibling;
- }
- return;
- case ATTRIBUTE_NODE:
- return buf.push(' ',node.name,'="',node.value.replace(/[<&"]/g,_xmlEncoder),'"');
- case TEXT_NODE:
- return buf.push(node.data.replace(/[<&]/g,_xmlEncoder));
- case CDATA_SECTION_NODE:
- return buf.push( '<![CDATA[',node.data,']]>');
- case COMMENT_NODE:
- return buf.push( "<!--",node.data,"-->");
- case DOCUMENT_TYPE_NODE:
- var pubid = node.publicId;
- var sysid = node.systemId;
- buf.push('<!DOCTYPE ',node.name);
- if(pubid){
- buf.push(' PUBLIC "',pubid);
- if (sysid && sysid!='.') {
- buf.push( '" "',sysid);
- }
- buf.push('">');
- }else if(sysid && sysid!='.'){
- buf.push(' SYSTEM "',sysid,'">');
- }else{
- var sub = node.internalSubset;
- if(sub){
- buf.push(" [",sub,"]");
- }
- buf.push(">");
- }
- return;
- case PROCESSING_INSTRUCTION_NODE:
- return buf.push( "<?",node.target," ",node.data,"?>");
- case ENTITY_REFERENCE_NODE:
- return buf.push( '&',node.nodeName,';');
- //case ENTITY_NODE:
- //case NOTATION_NODE:
- default:
- buf.push('??',node.nodeName);
- }
- }
- function importNode(doc,node,deep){
- var node2;
- switch (node.nodeType) {
- case ELEMENT_NODE:
- node2 = node.cloneNode(false);
- node2.ownerDocument = doc;
- //var attrs = node2.attributes;
- //var len = attrs.length;
- //for(var i=0;i<len;i++){
- //node2.setAttributeNodeNS(importNode(doc,attrs.item(i),deep));
- //}
- case DOCUMENT_FRAGMENT_NODE:
- break;
- case ATTRIBUTE_NODE:
- deep = true;
- break;
- //case ENTITY_REFERENCE_NODE:
- //case PROCESSING_INSTRUCTION_NODE:
- ////case TEXT_NODE:
- //case CDATA_SECTION_NODE:
- //case COMMENT_NODE:
- // deep = false;
- // break;
- //case DOCUMENT_NODE:
- //case DOCUMENT_TYPE_NODE:
- //cannot be imported.
- //case ENTITY_NODE:
- //case NOTATION_NODE:
- //can not hit in level3
- //default:throw e;
- }
- if(!node2){
- node2 = node.cloneNode(false);//false
- }
- node2.ownerDocument = doc;
- node2.parentNode = null;
- if(deep){
- var child = node.firstChild;
- while(child){
- node2.appendChild(importNode(doc,child,deep));
- child = child.nextSibling;
- }
- }
- return node2;
- }
- //
- //var _relationMap = {firstChild:1,lastChild:1,previousSibling:1,nextSibling:1,
- // attributes:1,childNodes:1,parentNode:1,documentElement:1,doctype,};
- function cloneNode(doc,node,deep){
- var node2 = new node.constructor();
- for(var n in node){
- var v = node[n];
- if(typeof v != 'object' ){
- if(v != node2[n]){
- node2[n] = v;
- }
- }
- }
- if(node.childNodes){
- node2.childNodes = new NodeList();
- }
- node2.ownerDocument = doc;
- switch (node2.nodeType) {
- case ELEMENT_NODE:
- var attrs = node.attributes;
- var attrs2 = node2.attributes = new NamedNodeMap();
- var len = attrs.length
- attrs2._ownerElement = node2;
- for(var i=0;i<len;i++){
- node2.setAttributeNode(cloneNode(doc,attrs.item(i),true));
- }
- break;;
- case ATTRIBUTE_NODE:
- deep = true;
- }
- if(deep){
- var child = node.firstChild;
- while(child){
- node2.appendChild(cloneNode(doc,child,deep));
- child = child.nextSibling;
- }
- }
- return node2;
- }
-
- function __set__(object,key,value){
- object[key] = value
- }
- //do dynamic
- try{
- if(Object.defineProperty){
- Object.defineProperty(LiveNodeList.prototype,'length',{
- get:function(){
- _updateLiveList(this);
- return this.$$length;
- }
- });
- Object.defineProperty(Node.prototype,'textContent',{
- get:function(){
- return getTextContent(this);
- },
- set:function(data){
- switch(this.nodeType){
- case ELEMENT_NODE:
- case DOCUMENT_FRAGMENT_NODE:
- while(this.firstChild){
- this.removeChild(this.firstChild);
- }
- if(data || String(data)){
- this.appendChild(this.ownerDocument.createTextNode(data));
- }
- break;
- default:
- //TODO:
- this.data = data;
- this.value = data;
- this.nodeValue = data;
- }
- }
- })
-
- function getTextContent(node){
- switch(node.nodeType){
- case ELEMENT_NODE:
- case DOCUMENT_FRAGMENT_NODE:
- var buf = [];
- node = node.firstChild;
- while(node){
- if(node.nodeType!==7 && node.nodeType !==8){
- buf.push(getTextContent(node));
- }
- node = node.nextSibling;
- }
- return buf.join('');
- default:
- return node.nodeValue;
- }
- }
- __set__ = function(object,key,value){
- //console.log(value)
- object['$$'+key] = value
- }
- }
- }catch(e){//ie8
- }
-
- //if(typeof require == 'function'){
- exports.DOMImplementation = DOMImplementation;
- exports.XMLSerializer = XMLSerializer;
- //}
-
- },{}],32:[function(require,module,exports){
- //[4] NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
- //[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
- //[5] Name ::= NameStartChar (NameChar)*
- var nameStartChar = /[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]///\u10000-\uEFFFF
- var nameChar = new RegExp("[\\-\\.0-9"+nameStartChar.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]");
- var tagNamePattern = new RegExp('^'+nameStartChar.source+nameChar.source+'*(?:\:'+nameStartChar.source+nameChar.source+'*)?$');
- //var tagNamePattern = /^[a-zA-Z_][\w\-\.]*(?:\:[a-zA-Z_][\w\-\.]*)?$/
- //var handlers = 'resolveEntity,getExternalSubset,characters,endDocument,endElement,endPrefixMapping,ignorableWhitespace,processingInstruction,setDocumentLocator,skippedEntity,startDocument,startElement,startPrefixMapping,notationDecl,unparsedEntityDecl,error,fatalError,warning,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,comment,endCDATA,endDTD,endEntity,startCDATA,startDTD,startEntity'.split(',')
-
- //S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE
- //S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE
- var S_TAG = 0;//tag name offerring
- var S_ATTR = 1;//attr name offerring
- var S_ATTR_SPACE=2;//attr name end and space offer
- var S_EQ = 3;//=space?
- var S_ATTR_NOQUOT_VALUE = 4;//attr value(no quot value only)
- var S_ATTR_END = 5;//attr value end and no space(quot end)
- var S_TAG_SPACE = 6;//(attr value end || tag end ) && (space offer)
- var S_TAG_CLOSE = 7;//closed el<el />
-
- function XMLReader(){
-
- }
-
- XMLReader.prototype = {
- parse:function(source,defaultNSMap,entityMap){
- var domBuilder = this.domBuilder;
- domBuilder.startDocument();
- _copy(defaultNSMap ,defaultNSMap = {})
- parse(source,defaultNSMap,entityMap,
- domBuilder,this.errorHandler);
- domBuilder.endDocument();
- }
- }
- function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){
- function fixedFromCharCode(code) {
- // String.prototype.fromCharCode does not supports
- // > 2 bytes unicode chars directly
- if (code > 0xffff) {
- code -= 0x10000;
- var surrogate1 = 0xd800 + (code >> 10)
- , surrogate2 = 0xdc00 + (code & 0x3ff);
-
- return String.fromCharCode(surrogate1, surrogate2);
- } else {
- return String.fromCharCode(code);
- }
- }
- function entityReplacer(a){
- var k = a.slice(1,-1);
- if(k in entityMap){
- return entityMap[k];
- }else if(k.charAt(0) === '#'){
- return fixedFromCharCode(parseInt(k.substr(1).replace('x','0x')))
- }else{
- errorHandler.error('entity not found:'+a);
- return a;
- }
- }
- function appendText(end){//has some bugs
- if(end>start){
- var xt = source.substring(start,end).replace(/&#?\w+;/g,entityReplacer);
- locator&&position(start);
- domBuilder.characters(xt,0,end-start);
- start = end
- }
- }
- function position(p,m){
- while(p>=lineEnd && (m = linePattern.exec(source))){
- lineStart = m.index;
- lineEnd = lineStart + m[0].length;
- locator.lineNumber++;
- //console.log('line++:',locator,startPos,endPos)
- }
- locator.columnNumber = p-lineStart+1;
- }
- var lineStart = 0;
- var lineEnd = 0;
- var linePattern = /.*(?:\r\n?|\n)|.*$/g
- var locator = domBuilder.locator;
-
- var parseStack = [{currentNSMap:defaultNSMapCopy}]
- var closeMap = {};
- var start = 0;
- while(true){
- try{
- var tagStart = source.indexOf('<',start);
- if(tagStart<0){
- if(!source.substr(start).match(/^\s*$/)){
- var doc = domBuilder.doc;
- var text = doc.createTextNode(source.substr(start));
- doc.appendChild(text);
- domBuilder.currentElement = text;
- }
- return;
- }
- if(tagStart>start){
- appendText(tagStart);
- }
- switch(source.charAt(tagStart+1)){
- case '/':
- var end = source.indexOf('>',tagStart+3);
- var tagName = source.substring(tagStart+2,end);
- var config = parseStack.pop();
- if(end<0){
-
- tagName = source.substring(tagStart+2).replace(/[\s<].*/,'');
- //console.error('#@@@@@@'+tagName)
- errorHandler.error("end tag name: "+tagName+' is not complete:'+config.tagName);
- end = tagStart+1+tagName.length;
- }else if(tagName.match(/\s</)){
- tagName = tagName.replace(/[\s<].*/,'');
- errorHandler.error("end tag name: "+tagName+' maybe not complete');
- end = tagStart+1+tagName.length;
- }
- //console.error(parseStack.length,parseStack)
- //console.error(config);
- var localNSMap = config.localNSMap;
- var endMatch = config.tagName == tagName;
- var endIgnoreCaseMach = endMatch || config.tagName&&config.tagName.toLowerCase() == tagName.toLowerCase()
- if(endIgnoreCaseMach){
- domBuilder.endElement(config.uri,config.localName,tagName);
- if(localNSMap){
- for(var prefix in localNSMap){
- domBuilder.endPrefixMapping(prefix) ;
- }
- }
- if(!endMatch){
- errorHandler.fatalError("end tag name: "+tagName+' is not match the current start tagName:'+config.tagName );
- }
- }else{
- parseStack.push(config)
- }
-
- end++;
- break;
- // end elment
- case '?':// <?...?>
- locator&&position(tagStart);
- end = parseInstruction(source,tagStart,domBuilder);
- break;
- case '!':// <!doctype,<![CDATA,<!--
- locator&&position(tagStart);
- end = parseDCC(source,tagStart,domBuilder,errorHandler);
- break;
- default:
- locator&&position(tagStart);
- var el = new ElementAttributes();
- var currentNSMap = parseStack[parseStack.length-1].currentNSMap;
- //elStartEnd
- var end = parseElementStartPart(source,tagStart,el,currentNSMap,entityReplacer,errorHandler);
- var len = el.length;
-
-
- if(!el.closed && fixSelfClosed(source,end,el.tagName,closeMap)){
- el.closed = true;
- if(!entityMap.nbsp){
- errorHandler.warning('unclosed xml attribute');
- }
- }
- if(locator && len){
- var locator2 = copyLocator(locator,{});
- //try{//attribute position fixed
- for(var i = 0;i<len;i++){
- var a = el[i];
- position(a.offset);
- a.locator = copyLocator(locator,{});
- }
- //}catch(e){console.error('@@@@@'+e)}
- domBuilder.locator = locator2
- if(appendElement(el,domBuilder,currentNSMap)){
- parseStack.push(el)
- }
- domBuilder.locator = locator;
- }else{
- if(appendElement(el,domBuilder,currentNSMap)){
- parseStack.push(el)
- }
- }
-
-
-
- if(el.uri === 'http://www.w3.org/1999/xhtml' && !el.closed){
- end = parseHtmlSpecialContent(source,end,el.tagName,entityReplacer,domBuilder)
- }else{
- end++;
- }
- }
- }catch(e){
- errorHandler.error('element parse error: '+e)
- //errorHandler.error('element parse error: '+e);
- end = -1;
- //throw e;
- }
- if(end>start){
- start = end;
- }else{
- //TODO: 这里有可能sax回退,有位置错误风险
- appendText(Math.max(tagStart,start)+1);
- }
- }
- }
- function copyLocator(f,t){
- t.lineNumber = f.lineNumber;
- t.columnNumber = f.columnNumber;
- return t;
- }
-
- /**
- * @see #appendElement(source,elStartEnd,el,selfClosed,entityReplacer,domBuilder,parseStack);
- * @return end of the elementStartPart(end of elementEndPart for selfClosed el)
- */
- function parseElementStartPart(source,start,el,currentNSMap,entityReplacer,errorHandler){
- var attrName;
- var value;
- var p = ++start;
- var s = S_TAG;//status
- while(true){
- var c = source.charAt(p);
- switch(c){
- case '=':
- if(s === S_ATTR){//attrName
- attrName = source.slice(start,p);
- s = S_EQ;
- }else if(s === S_ATTR_SPACE){
- s = S_EQ;
- }else{
- //fatalError: equal must after attrName or space after attrName
- throw new Error('attribute equal must after attrName');
- }
- break;
- case '\'':
- case '"':
- if(s === S_EQ || s === S_ATTR //|| s == S_ATTR_SPACE
- ){//equal
- if(s === S_ATTR){
- errorHandler.warning('attribute value must after "="')
- attrName = source.slice(start,p)
- }
- start = p+1;
- p = source.indexOf(c,start)
- if(p>0){
- value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);
- el.add(attrName,value,start-1);
- s = S_ATTR_END;
- }else{
- //fatalError: no end quot match
- throw new Error('attribute value no end \''+c+'\' match');
- }
- }else if(s == S_ATTR_NOQUOT_VALUE){
- value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);
- //console.log(attrName,value,start,p)
- el.add(attrName,value,start);
- //console.dir(el)
- errorHandler.warning('attribute "'+attrName+'" missed start quot('+c+')!!');
- start = p+1;
- s = S_ATTR_END
- }else{
- //fatalError: no equal before
- throw new Error('attribute value must after "="');
- }
- break;
- case '/':
- switch(s){
- case S_TAG:
- el.setTagName(source.slice(start,p));
- case S_ATTR_END:
- case S_TAG_SPACE:
- case S_TAG_CLOSE:
- s =S_TAG_CLOSE;
- el.closed = true;
- case S_ATTR_NOQUOT_VALUE:
- case S_ATTR:
- case S_ATTR_SPACE:
- break;
- //case S_EQ:
- default:
- throw new Error("attribute invalid close char('/')")
- }
- break;
- case ''://end document
- //throw new Error('unexpected end of input')
- errorHandler.error('unexpected end of input');
- if(s == S_TAG){
- el.setTagName(source.slice(start,p));
- }
- return p;
- case '>':
- switch(s){
- case S_TAG:
- el.setTagName(source.slice(start,p));
- case S_ATTR_END:
- case S_TAG_SPACE:
- case S_TAG_CLOSE:
- break;//normal
- case S_ATTR_NOQUOT_VALUE://Compatible state
- case S_ATTR:
- value = source.slice(start,p);
- if(value.slice(-1) === '/'){
- el.closed = true;
- value = value.slice(0,-1)
- }
- case S_ATTR_SPACE:
- if(s === S_ATTR_SPACE){
- value = attrName;
- }
- if(s == S_ATTR_NOQUOT_VALUE){
- errorHandler.warning('attribute "'+value+'" missed quot(")!!');
- el.add(attrName,value.replace(/&#?\w+;/g,entityReplacer),start)
- }else{
- if(currentNSMap[''] !== 'http://www.w3.org/1999/xhtml' || !value.match(/^(?:disabled|checked|selected)$/i)){
- errorHandler.warning('attribute "'+value+'" missed value!! "'+value+'" instead!!')
- }
- el.add(value,value,start)
- }
- break;
- case S_EQ:
- throw new Error('attribute value missed!!');
- }
- // console.log(tagName,tagNamePattern,tagNamePattern.test(tagName))
- return p;
- /*xml space '\x20' | #x9 | #xD | #xA; */
- case '\u0080':
- c = ' ';
- default:
- if(c<= ' '){//space
- switch(s){
- case S_TAG:
- el.setTagName(source.slice(start,p));//tagName
- s = S_TAG_SPACE;
- break;
- case S_ATTR:
- attrName = source.slice(start,p)
- s = S_ATTR_SPACE;
- break;
- case S_ATTR_NOQUOT_VALUE:
- var value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);
- errorHandler.warning('attribute "'+value+'" missed quot(")!!');
- el.add(attrName,value,start)
- case S_ATTR_END:
- s = S_TAG_SPACE;
- break;
- //case S_TAG_SPACE:
- //case S_EQ:
- //case S_ATTR_SPACE:
- // void();break;
- //case S_TAG_CLOSE:
- //ignore warning
- }
- }else{//not space
- //S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE
- //S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE
- switch(s){
- //case S_TAG:void();break;
- //case S_ATTR:void();break;
- //case S_ATTR_NOQUOT_VALUE:void();break;
- case S_ATTR_SPACE:
- var tagName = el.tagName;
- if(currentNSMap[''] !== 'http://www.w3.org/1999/xhtml' || !attrName.match(/^(?:disabled|checked|selected)$/i)){
- errorHandler.warning('attribute "'+attrName+'" missed value!! "'+attrName+'" instead2!!')
- }
- el.add(attrName,attrName,start);
- start = p;
- s = S_ATTR;
- break;
- case S_ATTR_END:
- errorHandler.warning('attribute space is required"'+attrName+'"!!')
- case S_TAG_SPACE:
- s = S_ATTR;
- start = p;
- break;
- case S_EQ:
- s = S_ATTR_NOQUOT_VALUE;
- start = p;
- break;
- case S_TAG_CLOSE:
- throw new Error("elements closed character '/' and '>' must be connected to");
- }
- }
- }//end outer switch
- //console.log('p++',p)
- p++;
- }
- }
- /**
- * @return true if has new namespace define
- */
- function appendElement(el,domBuilder,currentNSMap){
- var tagName = el.tagName;
- var localNSMap = null;
- //var currentNSMap = parseStack[parseStack.length-1].currentNSMap;
- var i = el.length;
- while(i--){
- var a = el[i];
- var qName = a.qName;
- var value = a.value;
- var nsp = qName.indexOf(':');
- if(nsp>0){
- var prefix = a.prefix = qName.slice(0,nsp);
- var localName = qName.slice(nsp+1);
- var nsPrefix = prefix === 'xmlns' && localName
- }else{
- localName = qName;
- prefix = null
- nsPrefix = qName === 'xmlns' && ''
- }
- //can not set prefix,because prefix !== ''
- a.localName = localName ;
- //prefix == null for no ns prefix attribute
- if(nsPrefix !== false){//hack!!
- if(localNSMap == null){
- localNSMap = {}
- //console.log(currentNSMap,0)
- _copy(currentNSMap,currentNSMap={})
- //console.log(currentNSMap,1)
- }
- currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;
- a.uri = 'http://www.w3.org/2000/xmlns/'
- domBuilder.startPrefixMapping(nsPrefix, value)
- }
- }
- var i = el.length;
- while(i--){
- a = el[i];
- var prefix = a.prefix;
- if(prefix){//no prefix attribute has no namespace
- if(prefix === 'xml'){
- a.uri = 'http://www.w3.org/XML/1998/namespace';
- }if(prefix !== 'xmlns'){
- a.uri = currentNSMap[prefix || '']
-
- //{console.log('###'+a.qName,domBuilder.locator.systemId+'',currentNSMap,a.uri)}
- }
- }
- }
- var nsp = tagName.indexOf(':');
- if(nsp>0){
- prefix = el.prefix = tagName.slice(0,nsp);
- localName = el.localName = tagName.slice(nsp+1);
- }else{
- prefix = null;//important!!
- localName = el.localName = tagName;
- }
- //no prefix element has default namespace
- var ns = el.uri = currentNSMap[prefix || ''];
- domBuilder.startElement(ns,localName,tagName,el);
- //endPrefixMapping and startPrefixMapping have not any help for dom builder
- //localNSMap = null
- if(el.closed){
- domBuilder.endElement(ns,localName,tagName);
- if(localNSMap){
- for(prefix in localNSMap){
- domBuilder.endPrefixMapping(prefix)
- }
- }
- }else{
- el.currentNSMap = currentNSMap;
- el.localNSMap = localNSMap;
- //parseStack.push(el);
- return true;
- }
- }
- function parseHtmlSpecialContent(source,elStartEnd,tagName,entityReplacer,domBuilder){
- if(/^(?:script|textarea)$/i.test(tagName)){
- var elEndStart = source.indexOf('</'+tagName+'>',elStartEnd);
- var text = source.substring(elStartEnd+1,elEndStart);
- if(/[&<]/.test(text)){
- if(/^script$/i.test(tagName)){
- //if(!/\]\]>/.test(text)){
- //lexHandler.startCDATA();
- domBuilder.characters(text,0,text.length);
- //lexHandler.endCDATA();
- return elEndStart;
- //}
- }//}else{//text area
- text = text.replace(/&#?\w+;/g,entityReplacer);
- domBuilder.characters(text,0,text.length);
- return elEndStart;
- //}
-
- }
- }
- return elStartEnd+1;
- }
- function fixSelfClosed(source,elStartEnd,tagName,closeMap){
- //if(tagName in closeMap){
- var pos = closeMap[tagName];
- if(pos == null){
- //console.log(tagName)
- pos = source.lastIndexOf('</'+tagName+'>')
- if(pos<elStartEnd){//忘记闭合
- pos = source.lastIndexOf('</'+tagName)
- }
- closeMap[tagName] =pos
- }
- return pos<elStartEnd;
- //}
- }
- function _copy(source,target){
- for(var n in source){target[n] = source[n]}
- }
- function parseDCC(source,start,domBuilder,errorHandler){//sure start with '<!'
- var next= source.charAt(start+2)
- switch(next){
- case '-':
- if(source.charAt(start + 3) === '-'){
- var end = source.indexOf('-->',start+4);
- //append comment source.substring(4,end)//<!--
- if(end>start){
- domBuilder.comment(source,start+4,end-start-4);
- return end+3;
- }else{
- errorHandler.error("Unclosed comment");
- return -1;
- }
- }else{
- //error
- return -1;
- }
- default:
- if(source.substr(start+3,6) == 'CDATA['){
- var end = source.indexOf(']]>',start+9);
- domBuilder.startCDATA();
- domBuilder.characters(source,start+9,end-start-9);
- domBuilder.endCDATA()
- return end+3;
- }
- //<!DOCTYPE
- //startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
- var matchs = split(source,start);
- var len = matchs.length;
- if(len>1 && /!doctype/i.test(matchs[0][0])){
- var name = matchs[1][0];
- var pubid = len>3 && /^public$/i.test(matchs[2][0]) && matchs[3][0]
- var sysid = len>4 && matchs[4][0];
- var lastMatch = matchs[len-1]
- domBuilder.startDTD(name,pubid && pubid.replace(/^(['"])(.*?)\1$/,'$2'),
- sysid && sysid.replace(/^(['"])(.*?)\1$/,'$2'));
- domBuilder.endDTD();
-
- return lastMatch.index+lastMatch[0].length
- }
- }
- return -1;
- }
-
-
-
- function parseInstruction(source,start,domBuilder){
- var end = source.indexOf('?>',start);
- if(end){
- var match = source.substring(start,end).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);
- if(match){
- var len = match[0].length;
- domBuilder.processingInstruction(match[1], match[2]) ;
- return end+2;
- }else{//error
- return -1;
- }
- }
- return -1;
- }
-
- /**
- * @param source
- */
- function ElementAttributes(source){
-
- }
- ElementAttributes.prototype = {
- setTagName:function(tagName){
- if(!tagNamePattern.test(tagName)){
- throw new Error('invalid tagName:'+tagName)
- }
- this.tagName = tagName
- },
- add:function(qName,value,offset){
- if(!tagNamePattern.test(qName)){
- throw new Error('invalid attribute:'+qName)
- }
- this[this.length++] = {qName:qName,value:value,offset:offset}
- },
- length:0,
- getLocalName:function(i){return this[i].localName},
- getLocator:function(i){return this[i].locator},
- getQName:function(i){return this[i].qName},
- getURI:function(i){return this[i].uri},
- getValue:function(i){return this[i].value}
- // ,getIndex:function(uri, localName)){
- // if(localName){
- //
- // }else{
- // var qName = uri
- // }
- // },
- // getValue:function(){return this.getValue(this.getIndex.apply(this,arguments))},
- // getType:function(uri,localName){}
- // getType:function(i){},
- }
-
-
-
-
- function _set_proto_(thiz,parent){
- thiz.__proto__ = parent;
- return thiz;
- }
- if(!(_set_proto_({},_set_proto_.prototype) instanceof _set_proto_)){
- _set_proto_ = function(thiz,parent){
- function p(){};
- p.prototype = parent;
- p = new p();
- for(parent in thiz){
- p[parent] = thiz[parent];
- }
- return p;
- }
- }
-
- function split(source,start){
- var match;
- var buf = [];
- var reg = /'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;
- reg.lastIndex = start;
- reg.exec(source);//skip <
- while(match = reg.exec(source)){
- buf.push(match);
- if(match[1])return buf;
- }
- }
-
- exports.XMLReader = XMLReader;
-
-
- },{}]},{},[1])(1)
- });
|