4f296c337cb73bd82d9b213741292103.js 161 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832
  1. "no use strict";
  2. !(function(window) {
  3. if (typeof window.window != "undefined" && window.document)
  4. return;
  5. if (window.require && window.define)
  6. return;
  7. if (!window.console) {
  8. window.console = function() {
  9. var msgs = Array.prototype.slice.call(arguments, 0);
  10. postMessage({type: "log", data: msgs});
  11. };
  12. window.console.error =
  13. window.console.warn =
  14. window.console.log =
  15. window.console.trace = window.console;
  16. }
  17. window.window = window;
  18. window.ace = window;
  19. window.onerror = function(message, file, line, col, err) {
  20. postMessage({type: "error", data: {
  21. message: message,
  22. data: err && err.data,
  23. file: file,
  24. line: line,
  25. col: col,
  26. stack: err && err.stack
  27. }});
  28. };
  29. window.normalizeModule = function(parentId, moduleName) {
  30. // normalize plugin requires
  31. if (moduleName.indexOf("!") !== -1) {
  32. var chunks = moduleName.split("!");
  33. return window.normalizeModule(parentId, chunks[0]) + "!" + window.normalizeModule(parentId, chunks[1]);
  34. }
  35. // normalize relative requires
  36. if (moduleName.charAt(0) == ".") {
  37. var base = parentId.split("/").slice(0, -1).join("/");
  38. moduleName = (base ? base + "/" : "") + moduleName;
  39. while (moduleName.indexOf(".") !== -1 && previous != moduleName) {
  40. var previous = moduleName;
  41. moduleName = moduleName.replace(/^\.\//, "").replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
  42. }
  43. }
  44. return moduleName;
  45. };
  46. window.require = function require(parentId, id) {
  47. if (!id) {
  48. id = parentId;
  49. parentId = null;
  50. }
  51. if (!id.charAt)
  52. throw new Error("worker.js require() accepts only (parentId, id) as arguments");
  53. id = window.normalizeModule(parentId, id);
  54. var module = window.require.modules[id];
  55. if (module) {
  56. if (!module.initialized) {
  57. module.initialized = true;
  58. module.exports = module.factory().exports;
  59. }
  60. return module.exports;
  61. }
  62. if (!window.require.tlns)
  63. return console.log("unable to load " + id);
  64. var path = resolveModuleId(id, window.require.tlns);
  65. if (path.slice(-3) != ".js") path += ".js";
  66. window.require.id = id;
  67. window.require.modules[id] = {}; // prevent infinite loop on broken modules
  68. importScripts(path);
  69. return window.require(parentId, id);
  70. };
  71. function resolveModuleId(id, paths) {
  72. var testPath = id, tail = "";
  73. while (testPath) {
  74. var alias = paths[testPath];
  75. if (typeof alias == "string") {
  76. return alias + tail;
  77. } else if (alias) {
  78. return alias.location.replace(/\/*$/, "/") + (tail || alias.main || alias.name);
  79. } else if (alias === false) {
  80. return "";
  81. }
  82. var i = testPath.lastIndexOf("/");
  83. if (i === -1) break;
  84. tail = testPath.substr(i) + tail;
  85. testPath = testPath.slice(0, i);
  86. }
  87. return id;
  88. }
  89. window.require.modules = {};
  90. window.require.tlns = {};
  91. window.define = function(id, deps, factory) {
  92. if (arguments.length == 2) {
  93. factory = deps;
  94. if (typeof id != "string") {
  95. deps = id;
  96. id = window.require.id;
  97. }
  98. } else if (arguments.length == 1) {
  99. factory = id;
  100. deps = [];
  101. id = window.require.id;
  102. }
  103. if (typeof factory != "function") {
  104. window.require.modules[id] = {
  105. exports: factory,
  106. initialized: true
  107. };
  108. return;
  109. }
  110. if (!deps.length)
  111. // If there is no dependencies, we inject "require", "exports" and
  112. // "module" as dependencies, to provide CommonJS compatibility.
  113. deps = ["require", "exports", "module"];
  114. var req = function(childId) {
  115. return window.require(id, childId);
  116. };
  117. window.require.modules[id] = {
  118. exports: {},
  119. factory: function() {
  120. var module = this;
  121. var returnExports = factory.apply(this, deps.slice(0, factory.length).map(function(dep) {
  122. switch (dep) {
  123. // Because "require", "exports" and "module" aren't actual
  124. // dependencies, we must handle them seperately.
  125. case "require": return req;
  126. case "exports": return module.exports;
  127. case "module": return module;
  128. // But for all other dependencies, we can just go ahead and
  129. // require them.
  130. default: return req(dep);
  131. }
  132. }));
  133. if (returnExports)
  134. module.exports = returnExports;
  135. return module;
  136. }
  137. };
  138. };
  139. window.define.amd = {};
  140. window.require.tlns = {};
  141. window.initBaseUrls = function initBaseUrls(topLevelNamespaces) {
  142. for (var i in topLevelNamespaces)
  143. this.require.tlns[i] = topLevelNamespaces[i];
  144. };
  145. window.initSender = function initSender() {
  146. var EventEmitter = window.require("ace/lib/event_emitter").EventEmitter;
  147. var oop = window.require("ace/lib/oop");
  148. var Sender = function() {};
  149. (function() {
  150. oop.implement(this, EventEmitter);
  151. this.callback = function(data, callbackId) {
  152. postMessage({
  153. type: "call",
  154. id: callbackId,
  155. data: data
  156. });
  157. };
  158. this.emit = function(name, data) {
  159. postMessage({
  160. type: "event",
  161. name: name,
  162. data: data
  163. });
  164. };
  165. }).call(Sender.prototype);
  166. return new Sender();
  167. };
  168. var main = window.main = null;
  169. var sender = window.sender = null;
  170. window.onmessage = function(e) {
  171. var msg = e.data;
  172. if (msg.event && sender) {
  173. sender._signal(msg.event, msg.data);
  174. }
  175. else if (msg.command) {
  176. if (main[msg.command])
  177. main[msg.command].apply(main, msg.args);
  178. else if (window[msg.command])
  179. window[msg.command].apply(window, msg.args);
  180. else
  181. throw new Error("Unknown command:" + msg.command);
  182. }
  183. else if (msg.init) {
  184. window.initBaseUrls(msg.tlns);
  185. sender = window.sender = window.initSender();
  186. var clazz = this.require(msg.module)[msg.classname];
  187. main = window.main = new clazz(sender);
  188. }
  189. };
  190. })(this);
  191. ace.define("ace/lib/oop",[], function(require, exports, module){"use strict";
  192. exports.inherits = function (ctor, superCtor) {
  193. ctor.super_ = superCtor;
  194. ctor.prototype = Object.create(superCtor.prototype, {
  195. constructor: {
  196. value: ctor,
  197. enumerable: false,
  198. writable: true,
  199. configurable: true
  200. }
  201. });
  202. };
  203. exports.mixin = function (obj, mixin) {
  204. for (var key in mixin) {
  205. obj[key] = mixin[key];
  206. }
  207. return obj;
  208. };
  209. exports.implement = function (proto, mixin) {
  210. exports.mixin(proto, mixin);
  211. };
  212. });
  213. ace.define("ace/apply_delta",[], function(require, exports, module){"use strict";
  214. function throwDeltaError(delta, errorText) {
  215. console.log("Invalid Delta:", delta);
  216. throw "Invalid Delta: " + errorText;
  217. }
  218. function positionInDocument(docLines, position) {
  219. return position.row >= 0 && position.row < docLines.length &&
  220. position.column >= 0 && position.column <= docLines[position.row].length;
  221. }
  222. function validateDelta(docLines, delta) {
  223. if (delta.action != "insert" && delta.action != "remove")
  224. throwDeltaError(delta, "delta.action must be 'insert' or 'remove'");
  225. if (!(delta.lines instanceof Array))
  226. throwDeltaError(delta, "delta.lines must be an Array");
  227. if (!delta.start || !delta.end)
  228. throwDeltaError(delta, "delta.start/end must be an present");
  229. var start = delta.start;
  230. if (!positionInDocument(docLines, delta.start))
  231. throwDeltaError(delta, "delta.start must be contained in document");
  232. var end = delta.end;
  233. if (delta.action == "remove" && !positionInDocument(docLines, end))
  234. throwDeltaError(delta, "delta.end must contained in document for 'remove' actions");
  235. var numRangeRows = end.row - start.row;
  236. var numRangeLastLineChars = (end.column - (numRangeRows == 0 ? start.column : 0));
  237. if (numRangeRows != delta.lines.length - 1 || delta.lines[numRangeRows].length != numRangeLastLineChars)
  238. throwDeltaError(delta, "delta.range must match delta lines");
  239. }
  240. exports.applyDelta = function (docLines, delta, doNotValidate) {
  241. var row = delta.start.row;
  242. var startColumn = delta.start.column;
  243. var line = docLines[row] || "";
  244. switch (delta.action) {
  245. case "insert":
  246. var lines = delta.lines;
  247. if (lines.length === 1) {
  248. docLines[row] = line.substring(0, startColumn) + delta.lines[0] + line.substring(startColumn);
  249. }
  250. else {
  251. var args = [row, 1].concat(delta.lines);
  252. docLines.splice.apply(docLines, args);
  253. docLines[row] = line.substring(0, startColumn) + docLines[row];
  254. docLines[row + delta.lines.length - 1] += line.substring(startColumn);
  255. }
  256. break;
  257. case "remove":
  258. var endColumn = delta.end.column;
  259. var endRow = delta.end.row;
  260. if (row === endRow) {
  261. docLines[row] = line.substring(0, startColumn) + line.substring(endColumn);
  262. }
  263. else {
  264. docLines.splice(row, endRow - row + 1, line.substring(0, startColumn) + docLines[endRow].substring(endColumn));
  265. }
  266. break;
  267. }
  268. };
  269. });
  270. ace.define("ace/lib/event_emitter",[], function(require, exports, module){"use strict";
  271. var EventEmitter = {};
  272. var stopPropagation = function () { this.propagationStopped = true; };
  273. var preventDefault = function () { this.defaultPrevented = true; };
  274. EventEmitter._emit =
  275. EventEmitter._dispatchEvent = function (eventName, e) {
  276. this._eventRegistry || (this._eventRegistry = {});
  277. this._defaultHandlers || (this._defaultHandlers = {});
  278. var listeners = this._eventRegistry[eventName] || [];
  279. var defaultHandler = this._defaultHandlers[eventName];
  280. if (!listeners.length && !defaultHandler)
  281. return;
  282. if (typeof e != "object" || !e)
  283. e = {};
  284. if (!e.type)
  285. e.type = eventName;
  286. if (!e.stopPropagation)
  287. e.stopPropagation = stopPropagation;
  288. if (!e.preventDefault)
  289. e.preventDefault = preventDefault;
  290. listeners = listeners.slice();
  291. for (var i = 0; i < listeners.length; i++) {
  292. listeners[i](e, this);
  293. if (e.propagationStopped)
  294. break;
  295. }
  296. if (defaultHandler && !e.defaultPrevented)
  297. return defaultHandler(e, this);
  298. };
  299. EventEmitter._signal = function (eventName, e) {
  300. var listeners = (this._eventRegistry || {})[eventName];
  301. if (!listeners)
  302. return;
  303. listeners = listeners.slice();
  304. for (var i = 0; i < listeners.length; i++)
  305. listeners[i](e, this);
  306. };
  307. EventEmitter.once = function (eventName, callback) {
  308. var _self = this;
  309. this.on(eventName, function newCallback() {
  310. _self.off(eventName, newCallback);
  311. callback.apply(null, arguments);
  312. });
  313. if (!callback) {
  314. return new Promise(function (resolve) {
  315. callback = resolve;
  316. });
  317. }
  318. };
  319. EventEmitter.setDefaultHandler = function (eventName, callback) {
  320. var handlers = this._defaultHandlers;
  321. if (!handlers)
  322. handlers = this._defaultHandlers = { _disabled_: {} };
  323. if (handlers[eventName]) {
  324. var old = handlers[eventName];
  325. var disabled = handlers._disabled_[eventName];
  326. if (!disabled)
  327. handlers._disabled_[eventName] = disabled = [];
  328. disabled.push(old);
  329. var i = disabled.indexOf(callback);
  330. if (i != -1)
  331. disabled.splice(i, 1);
  332. }
  333. handlers[eventName] = callback;
  334. };
  335. EventEmitter.removeDefaultHandler = function (eventName, callback) {
  336. var handlers = this._defaultHandlers;
  337. if (!handlers)
  338. return;
  339. var disabled = handlers._disabled_[eventName];
  340. if (handlers[eventName] == callback) {
  341. if (disabled)
  342. this.setDefaultHandler(eventName, disabled.pop());
  343. }
  344. else if (disabled) {
  345. var i = disabled.indexOf(callback);
  346. if (i != -1)
  347. disabled.splice(i, 1);
  348. }
  349. };
  350. EventEmitter.on =
  351. EventEmitter.addEventListener = function (eventName, callback, capturing) {
  352. this._eventRegistry = this._eventRegistry || {};
  353. var listeners = this._eventRegistry[eventName];
  354. if (!listeners)
  355. listeners = this._eventRegistry[eventName] = [];
  356. if (listeners.indexOf(callback) == -1)
  357. listeners[capturing ? "unshift" : "push"](callback);
  358. return callback;
  359. };
  360. EventEmitter.off =
  361. EventEmitter.removeListener =
  362. EventEmitter.removeEventListener = function (eventName, callback) {
  363. this._eventRegistry = this._eventRegistry || {};
  364. var listeners = this._eventRegistry[eventName];
  365. if (!listeners)
  366. return;
  367. var index = listeners.indexOf(callback);
  368. if (index !== -1)
  369. listeners.splice(index, 1);
  370. };
  371. EventEmitter.removeAllListeners = function (eventName) {
  372. if (!eventName)
  373. this._eventRegistry = this._defaultHandlers = undefined;
  374. if (this._eventRegistry)
  375. this._eventRegistry[eventName] = undefined;
  376. if (this._defaultHandlers)
  377. this._defaultHandlers[eventName] = undefined;
  378. };
  379. exports.EventEmitter = EventEmitter;
  380. });
  381. ace.define("ace/range",[], function(require, exports, module){"use strict";
  382. var comparePoints = function (p1, p2) {
  383. return p1.row - p2.row || p1.column - p2.column;
  384. };
  385. var Range = function (startRow, startColumn, endRow, endColumn) {
  386. this.start = {
  387. row: startRow,
  388. column: startColumn
  389. };
  390. this.end = {
  391. row: endRow,
  392. column: endColumn
  393. };
  394. };
  395. (function () {
  396. this.isEqual = function (range) {
  397. return this.start.row === range.start.row &&
  398. this.end.row === range.end.row &&
  399. this.start.column === range.start.column &&
  400. this.end.column === range.end.column;
  401. };
  402. this.toString = function () {
  403. return ("Range: [" + this.start.row + "/" + this.start.column +
  404. "] -> [" + this.end.row + "/" + this.end.column + "]");
  405. };
  406. this.contains = function (row, column) {
  407. return this.compare(row, column) == 0;
  408. };
  409. this.compareRange = function (range) {
  410. var cmp, end = range.end, start = range.start;
  411. cmp = this.compare(end.row, end.column);
  412. if (cmp == 1) {
  413. cmp = this.compare(start.row, start.column);
  414. if (cmp == 1) {
  415. return 2;
  416. }
  417. else if (cmp == 0) {
  418. return 1;
  419. }
  420. else {
  421. return 0;
  422. }
  423. }
  424. else if (cmp == -1) {
  425. return -2;
  426. }
  427. else {
  428. cmp = this.compare(start.row, start.column);
  429. if (cmp == -1) {
  430. return -1;
  431. }
  432. else if (cmp == 1) {
  433. return 42;
  434. }
  435. else {
  436. return 0;
  437. }
  438. }
  439. };
  440. this.comparePoint = function (p) {
  441. return this.compare(p.row, p.column);
  442. };
  443. this.containsRange = function (range) {
  444. return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
  445. };
  446. this.intersects = function (range) {
  447. var cmp = this.compareRange(range);
  448. return (cmp == -1 || cmp == 0 || cmp == 1);
  449. };
  450. this.isEnd = function (row, column) {
  451. return this.end.row == row && this.end.column == column;
  452. };
  453. this.isStart = function (row, column) {
  454. return this.start.row == row && this.start.column == column;
  455. };
  456. this.setStart = function (row, column) {
  457. if (typeof row == "object") {
  458. this.start.column = row.column;
  459. this.start.row = row.row;
  460. }
  461. else {
  462. this.start.row = row;
  463. this.start.column = column;
  464. }
  465. };
  466. this.setEnd = function (row, column) {
  467. if (typeof row == "object") {
  468. this.end.column = row.column;
  469. this.end.row = row.row;
  470. }
  471. else {
  472. this.end.row = row;
  473. this.end.column = column;
  474. }
  475. };
  476. this.inside = function (row, column) {
  477. if (this.compare(row, column) == 0) {
  478. if (this.isEnd(row, column) || this.isStart(row, column)) {
  479. return false;
  480. }
  481. else {
  482. return true;
  483. }
  484. }
  485. return false;
  486. };
  487. this.insideStart = function (row, column) {
  488. if (this.compare(row, column) == 0) {
  489. if (this.isEnd(row, column)) {
  490. return false;
  491. }
  492. else {
  493. return true;
  494. }
  495. }
  496. return false;
  497. };
  498. this.insideEnd = function (row, column) {
  499. if (this.compare(row, column) == 0) {
  500. if (this.isStart(row, column)) {
  501. return false;
  502. }
  503. else {
  504. return true;
  505. }
  506. }
  507. return false;
  508. };
  509. this.compare = function (row, column) {
  510. if (!this.isMultiLine()) {
  511. if (row === this.start.row) {
  512. return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0);
  513. }
  514. }
  515. if (row < this.start.row)
  516. return -1;
  517. if (row > this.end.row)
  518. return 1;
  519. if (this.start.row === row)
  520. return column >= this.start.column ? 0 : -1;
  521. if (this.end.row === row)
  522. return column <= this.end.column ? 0 : 1;
  523. return 0;
  524. };
  525. this.compareStart = function (row, column) {
  526. if (this.start.row == row && this.start.column == column) {
  527. return -1;
  528. }
  529. else {
  530. return this.compare(row, column);
  531. }
  532. };
  533. this.compareEnd = function (row, column) {
  534. if (this.end.row == row && this.end.column == column) {
  535. return 1;
  536. }
  537. else {
  538. return this.compare(row, column);
  539. }
  540. };
  541. this.compareInside = function (row, column) {
  542. if (this.end.row == row && this.end.column == column) {
  543. return 1;
  544. }
  545. else if (this.start.row == row && this.start.column == column) {
  546. return -1;
  547. }
  548. else {
  549. return this.compare(row, column);
  550. }
  551. };
  552. this.clipRows = function (firstRow, lastRow) {
  553. if (this.end.row > lastRow)
  554. var end = { row: lastRow + 1, column: 0 };
  555. else if (this.end.row < firstRow)
  556. var end = { row: firstRow, column: 0 };
  557. if (this.start.row > lastRow)
  558. var start = { row: lastRow + 1, column: 0 };
  559. else if (this.start.row < firstRow)
  560. var start = { row: firstRow, column: 0 };
  561. return Range.fromPoints(start || this.start, end || this.end);
  562. };
  563. this.extend = function (row, column) {
  564. var cmp = this.compare(row, column);
  565. if (cmp == 0)
  566. return this;
  567. else if (cmp == -1)
  568. var start = { row: row, column: column };
  569. else
  570. var end = { row: row, column: column };
  571. return Range.fromPoints(start || this.start, end || this.end);
  572. };
  573. this.isEmpty = function () {
  574. return (this.start.row === this.end.row && this.start.column === this.end.column);
  575. };
  576. this.isMultiLine = function () {
  577. return (this.start.row !== this.end.row);
  578. };
  579. this.clone = function () {
  580. return Range.fromPoints(this.start, this.end);
  581. };
  582. this.collapseRows = function () {
  583. if (this.end.column == 0)
  584. return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row - 1), 0);
  585. else
  586. return new Range(this.start.row, 0, this.end.row, 0);
  587. };
  588. this.toScreenRange = function (session) {
  589. var screenPosStart = session.documentToScreenPosition(this.start);
  590. var screenPosEnd = session.documentToScreenPosition(this.end);
  591. return new Range(screenPosStart.row, screenPosStart.column, screenPosEnd.row, screenPosEnd.column);
  592. };
  593. this.moveBy = function (row, column) {
  594. this.start.row += row;
  595. this.start.column += column;
  596. this.end.row += row;
  597. this.end.column += column;
  598. };
  599. }).call(Range.prototype);
  600. Range.fromPoints = function (start, end) {
  601. return new Range(start.row, start.column, end.row, end.column);
  602. };
  603. Range.comparePoints = comparePoints;
  604. Range.comparePoints = function (p1, p2) {
  605. return p1.row - p2.row || p1.column - p2.column;
  606. };
  607. exports.Range = Range;
  608. });
  609. ace.define("ace/anchor",[], function(require, exports, module){"use strict";
  610. var oop = require("./lib/oop");
  611. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  612. var Anchor = exports.Anchor = function (doc, row, column) {
  613. this.$onChange = this.onChange.bind(this);
  614. this.attach(doc);
  615. if (typeof column == "undefined")
  616. this.setPosition(row.row, row.column);
  617. else
  618. this.setPosition(row, column);
  619. };
  620. (function () {
  621. oop.implement(this, EventEmitter);
  622. this.getPosition = function () {
  623. return this.$clipPositionToDocument(this.row, this.column);
  624. };
  625. this.getDocument = function () {
  626. return this.document;
  627. };
  628. this.$insertRight = false;
  629. this.onChange = function (delta) {
  630. if (delta.start.row == delta.end.row && delta.start.row != this.row)
  631. return;
  632. if (delta.start.row > this.row)
  633. return;
  634. var point = $getTransformedPoint(delta, { row: this.row, column: this.column }, this.$insertRight);
  635. this.setPosition(point.row, point.column, true);
  636. };
  637. function $pointsInOrder(point1, point2, equalPointsInOrder) {
  638. var bColIsAfter = equalPointsInOrder ? point1.column <= point2.column : point1.column < point2.column;
  639. return (point1.row < point2.row) || (point1.row == point2.row && bColIsAfter);
  640. }
  641. function $getTransformedPoint(delta, point, moveIfEqual) {
  642. var deltaIsInsert = delta.action == "insert";
  643. var deltaRowShift = (deltaIsInsert ? 1 : -1) * (delta.end.row - delta.start.row);
  644. var deltaColShift = (deltaIsInsert ? 1 : -1) * (delta.end.column - delta.start.column);
  645. var deltaStart = delta.start;
  646. var deltaEnd = deltaIsInsert ? deltaStart : delta.end; // Collapse insert range.
  647. if ($pointsInOrder(point, deltaStart, moveIfEqual)) {
  648. return {
  649. row: point.row,
  650. column: point.column
  651. };
  652. }
  653. if ($pointsInOrder(deltaEnd, point, !moveIfEqual)) {
  654. return {
  655. row: point.row + deltaRowShift,
  656. column: point.column + (point.row == deltaEnd.row ? deltaColShift : 0)
  657. };
  658. }
  659. return {
  660. row: deltaStart.row,
  661. column: deltaStart.column
  662. };
  663. }
  664. this.setPosition = function (row, column, noClip) {
  665. var pos;
  666. if (noClip) {
  667. pos = {
  668. row: row,
  669. column: column
  670. };
  671. }
  672. else {
  673. pos = this.$clipPositionToDocument(row, column);
  674. }
  675. if (this.row == pos.row && this.column == pos.column)
  676. return;
  677. var old = {
  678. row: this.row,
  679. column: this.column
  680. };
  681. this.row = pos.row;
  682. this.column = pos.column;
  683. this._signal("change", {
  684. old: old,
  685. value: pos
  686. });
  687. };
  688. this.detach = function () {
  689. this.document.off("change", this.$onChange);
  690. };
  691. this.attach = function (doc) {
  692. this.document = doc || this.document;
  693. this.document.on("change", this.$onChange);
  694. };
  695. this.$clipPositionToDocument = function (row, column) {
  696. var pos = {};
  697. if (row >= this.document.getLength()) {
  698. pos.row = Math.max(0, this.document.getLength() - 1);
  699. pos.column = this.document.getLine(pos.row).length;
  700. }
  701. else if (row < 0) {
  702. pos.row = 0;
  703. pos.column = 0;
  704. }
  705. else {
  706. pos.row = row;
  707. pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column));
  708. }
  709. if (column < 0)
  710. pos.column = 0;
  711. return pos;
  712. };
  713. }).call(Anchor.prototype);
  714. });
  715. ace.define("ace/document",[], function(require, exports, module){"use strict";
  716. var oop = require("./lib/oop");
  717. var applyDelta = require("./apply_delta").applyDelta;
  718. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  719. var Range = require("./range").Range;
  720. var Anchor = require("./anchor").Anchor;
  721. var Document = function (textOrLines) {
  722. this.$lines = [""];
  723. if (textOrLines.length === 0) {
  724. this.$lines = [""];
  725. }
  726. else if (Array.isArray(textOrLines)) {
  727. this.insertMergedLines({ row: 0, column: 0 }, textOrLines);
  728. }
  729. else {
  730. this.insert({ row: 0, column: 0 }, textOrLines);
  731. }
  732. };
  733. (function () {
  734. oop.implement(this, EventEmitter);
  735. this.setValue = function (text) {
  736. var len = this.getLength() - 1;
  737. this.remove(new Range(0, 0, len, this.getLine(len).length));
  738. this.insert({ row: 0, column: 0 }, text);
  739. };
  740. this.getValue = function () {
  741. return this.getAllLines().join(this.getNewLineCharacter());
  742. };
  743. this.createAnchor = function (row, column) {
  744. return new Anchor(this, row, column);
  745. };
  746. if ("aaa".split(/a/).length === 0) {
  747. this.$split = function (text) {
  748. return text.replace(/\r\n|\r/g, "\n").split("\n");
  749. };
  750. }
  751. else {
  752. this.$split = function (text) {
  753. return text.split(/\r\n|\r|\n/);
  754. };
  755. }
  756. this.$detectNewLine = function (text) {
  757. var match = text.match(/^.*?(\r\n|\r|\n)/m);
  758. this.$autoNewLine = match ? match[1] : "\n";
  759. this._signal("changeNewLineMode");
  760. };
  761. this.getNewLineCharacter = function () {
  762. switch (this.$newLineMode) {
  763. case "windows":
  764. return "\r\n";
  765. case "unix":
  766. return "\n";
  767. default:
  768. return this.$autoNewLine || "\n";
  769. }
  770. };
  771. this.$autoNewLine = "";
  772. this.$newLineMode = "auto";
  773. this.setNewLineMode = function (newLineMode) {
  774. if (this.$newLineMode === newLineMode)
  775. return;
  776. this.$newLineMode = newLineMode;
  777. this._signal("changeNewLineMode");
  778. };
  779. this.getNewLineMode = function () {
  780. return this.$newLineMode;
  781. };
  782. this.isNewLine = function (text) {
  783. return (text == "\r\n" || text == "\r" || text == "\n");
  784. };
  785. this.getLine = function (row) {
  786. return this.$lines[row] || "";
  787. };
  788. this.getLines = function (firstRow, lastRow) {
  789. return this.$lines.slice(firstRow, lastRow + 1);
  790. };
  791. this.getAllLines = function () {
  792. return this.getLines(0, this.getLength());
  793. };
  794. this.getLength = function () {
  795. return this.$lines.length;
  796. };
  797. this.getTextRange = function (range) {
  798. return this.getLinesForRange(range).join(this.getNewLineCharacter());
  799. };
  800. this.getLinesForRange = function (range) {
  801. var lines;
  802. if (range.start.row === range.end.row) {
  803. lines = [this.getLine(range.start.row).substring(range.start.column, range.end.column)];
  804. }
  805. else {
  806. lines = this.getLines(range.start.row, range.end.row);
  807. lines[0] = (lines[0] || "").substring(range.start.column);
  808. var l = lines.length - 1;
  809. if (range.end.row - range.start.row == l)
  810. lines[l] = lines[l].substring(0, range.end.column);
  811. }
  812. return lines;
  813. };
  814. this.insertLines = function (row, lines) {
  815. console.warn("Use of document.insertLines is deprecated. Use the insertFullLines method instead.");
  816. return this.insertFullLines(row, lines);
  817. };
  818. this.removeLines = function (firstRow, lastRow) {
  819. console.warn("Use of document.removeLines is deprecated. Use the removeFullLines method instead.");
  820. return this.removeFullLines(firstRow, lastRow);
  821. };
  822. this.insertNewLine = function (position) {
  823. console.warn("Use of document.insertNewLine is deprecated. Use insertMergedLines(position, ['', '']) instead.");
  824. return this.insertMergedLines(position, ["", ""]);
  825. };
  826. this.insert = function (position, text) {
  827. if (this.getLength() <= 1)
  828. this.$detectNewLine(text);
  829. return this.insertMergedLines(position, this.$split(text));
  830. };
  831. this.insertInLine = function (position, text) {
  832. var start = this.clippedPos(position.row, position.column);
  833. var end = this.pos(position.row, position.column + text.length);
  834. this.applyDelta({
  835. start: start,
  836. end: end,
  837. action: "insert",
  838. lines: [text]
  839. }, true);
  840. return this.clonePos(end);
  841. };
  842. this.clippedPos = function (row, column) {
  843. var length = this.getLength();
  844. if (row === undefined) {
  845. row = length;
  846. }
  847. else if (row < 0) {
  848. row = 0;
  849. }
  850. else if (row >= length) {
  851. row = length - 1;
  852. column = undefined;
  853. }
  854. var line = this.getLine(row);
  855. if (column == undefined)
  856. column = line.length;
  857. column = Math.min(Math.max(column, 0), line.length);
  858. return { row: row, column: column };
  859. };
  860. this.clonePos = function (pos) {
  861. return { row: pos.row, column: pos.column };
  862. };
  863. this.pos = function (row, column) {
  864. return { row: row, column: column };
  865. };
  866. this.$clipPosition = function (position) {
  867. var length = this.getLength();
  868. if (position.row >= length) {
  869. position.row = Math.max(0, length - 1);
  870. position.column = this.getLine(length - 1).length;
  871. }
  872. else {
  873. position.row = Math.max(0, position.row);
  874. position.column = Math.min(Math.max(position.column, 0), this.getLine(position.row).length);
  875. }
  876. return position;
  877. };
  878. this.insertFullLines = function (row, lines) {
  879. row = Math.min(Math.max(row, 0), this.getLength());
  880. var column = 0;
  881. if (row < this.getLength()) {
  882. lines = lines.concat([""]);
  883. column = 0;
  884. }
  885. else {
  886. lines = [""].concat(lines);
  887. row--;
  888. column = this.$lines[row].length;
  889. }
  890. this.insertMergedLines({ row: row, column: column }, lines);
  891. };
  892. this.insertMergedLines = function (position, lines) {
  893. var start = this.clippedPos(position.row, position.column);
  894. var end = {
  895. row: start.row + lines.length - 1,
  896. column: (lines.length == 1 ? start.column : 0) + lines[lines.length - 1].length
  897. };
  898. this.applyDelta({
  899. start: start,
  900. end: end,
  901. action: "insert",
  902. lines: lines
  903. });
  904. return this.clonePos(end);
  905. };
  906. this.remove = function (range) {
  907. var start = this.clippedPos(range.start.row, range.start.column);
  908. var end = this.clippedPos(range.end.row, range.end.column);
  909. this.applyDelta({
  910. start: start,
  911. end: end,
  912. action: "remove",
  913. lines: this.getLinesForRange({ start: start, end: end })
  914. });
  915. return this.clonePos(start);
  916. };
  917. this.removeInLine = function (row, startColumn, endColumn) {
  918. var start = this.clippedPos(row, startColumn);
  919. var end = this.clippedPos(row, endColumn);
  920. this.applyDelta({
  921. start: start,
  922. end: end,
  923. action: "remove",
  924. lines: this.getLinesForRange({ start: start, end: end })
  925. }, true);
  926. return this.clonePos(start);
  927. };
  928. this.removeFullLines = function (firstRow, lastRow) {
  929. firstRow = Math.min(Math.max(0, firstRow), this.getLength() - 1);
  930. lastRow = Math.min(Math.max(0, lastRow), this.getLength() - 1);
  931. var deleteFirstNewLine = lastRow == this.getLength() - 1 && firstRow > 0;
  932. var deleteLastNewLine = lastRow < this.getLength() - 1;
  933. var startRow = (deleteFirstNewLine ? firstRow - 1 : firstRow);
  934. var startCol = (deleteFirstNewLine ? this.getLine(startRow).length : 0);
  935. var endRow = (deleteLastNewLine ? lastRow + 1 : lastRow);
  936. var endCol = (deleteLastNewLine ? 0 : this.getLine(endRow).length);
  937. var range = new Range(startRow, startCol, endRow, endCol);
  938. var deletedLines = this.$lines.slice(firstRow, lastRow + 1);
  939. this.applyDelta({
  940. start: range.start,
  941. end: range.end,
  942. action: "remove",
  943. lines: this.getLinesForRange(range)
  944. });
  945. return deletedLines;
  946. };
  947. this.removeNewLine = function (row) {
  948. if (row < this.getLength() - 1 && row >= 0) {
  949. this.applyDelta({
  950. start: this.pos(row, this.getLine(row).length),
  951. end: this.pos(row + 1, 0),
  952. action: "remove",
  953. lines: ["", ""]
  954. });
  955. }
  956. };
  957. this.replace = function (range, text) {
  958. if (!(range instanceof Range))
  959. range = Range.fromPoints(range.start, range.end);
  960. if (text.length === 0 && range.isEmpty())
  961. return range.start;
  962. if (text == this.getTextRange(range))
  963. return range.end;
  964. this.remove(range);
  965. var end;
  966. if (text) {
  967. end = this.insert(range.start, text);
  968. }
  969. else {
  970. end = range.start;
  971. }
  972. return end;
  973. };
  974. this.applyDeltas = function (deltas) {
  975. for (var i = 0; i < deltas.length; i++) {
  976. this.applyDelta(deltas[i]);
  977. }
  978. };
  979. this.revertDeltas = function (deltas) {
  980. for (var i = deltas.length - 1; i >= 0; i--) {
  981. this.revertDelta(deltas[i]);
  982. }
  983. };
  984. this.applyDelta = function (delta, doNotValidate) {
  985. var isInsert = delta.action == "insert";
  986. if (isInsert ? delta.lines.length <= 1 && !delta.lines[0]
  987. : !Range.comparePoints(delta.start, delta.end)) {
  988. return;
  989. }
  990. if (isInsert && delta.lines.length > 20000) {
  991. this.$splitAndapplyLargeDelta(delta, 20000);
  992. }
  993. else {
  994. applyDelta(this.$lines, delta, doNotValidate);
  995. this._signal("change", delta);
  996. }
  997. };
  998. this.$safeApplyDelta = function (delta) {
  999. var docLength = this.$lines.length;
  1000. if (delta.action == "remove" && delta.start.row < docLength && delta.end.row < docLength
  1001. || delta.action == "insert" && delta.start.row <= docLength) {
  1002. this.applyDelta(delta);
  1003. }
  1004. };
  1005. this.$splitAndapplyLargeDelta = function (delta, MAX) {
  1006. var lines = delta.lines;
  1007. var l = lines.length - MAX + 1;
  1008. var row = delta.start.row;
  1009. var column = delta.start.column;
  1010. for (var from = 0, to = 0; from < l; from = to) {
  1011. to += MAX - 1;
  1012. var chunk = lines.slice(from, to);
  1013. chunk.push("");
  1014. this.applyDelta({
  1015. start: this.pos(row + from, column),
  1016. end: this.pos(row + to, column = 0),
  1017. action: delta.action,
  1018. lines: chunk
  1019. }, true);
  1020. }
  1021. delta.lines = lines.slice(from);
  1022. delta.start.row = row + from;
  1023. delta.start.column = column;
  1024. this.applyDelta(delta, true);
  1025. };
  1026. this.revertDelta = function (delta) {
  1027. this.$safeApplyDelta({
  1028. start: this.clonePos(delta.start),
  1029. end: this.clonePos(delta.end),
  1030. action: (delta.action == "insert" ? "remove" : "insert"),
  1031. lines: delta.lines.slice()
  1032. });
  1033. };
  1034. this.indexToPosition = function (index, startRow) {
  1035. var lines = this.$lines || this.getAllLines();
  1036. var newlineLength = this.getNewLineCharacter().length;
  1037. for (var i = startRow || 0, l = lines.length; i < l; i++) {
  1038. index -= lines[i].length + newlineLength;
  1039. if (index < 0)
  1040. return { row: i, column: index + lines[i].length + newlineLength };
  1041. }
  1042. return { row: l - 1, column: index + lines[l - 1].length + newlineLength };
  1043. };
  1044. this.positionToIndex = function (pos, startRow) {
  1045. var lines = this.$lines || this.getAllLines();
  1046. var newlineLength = this.getNewLineCharacter().length;
  1047. var index = 0;
  1048. var row = Math.min(pos.row, lines.length);
  1049. for (var i = startRow || 0; i < row; ++i)
  1050. index += lines[i].length + newlineLength;
  1051. return index + pos.column;
  1052. };
  1053. }).call(Document.prototype);
  1054. exports.Document = Document;
  1055. });
  1056. ace.define("ace/lib/lang",[], function(require, exports, module){"use strict";
  1057. exports.last = function (a) {
  1058. return a[a.length - 1];
  1059. };
  1060. exports.stringReverse = function (string) {
  1061. return string.split("").reverse().join("");
  1062. };
  1063. exports.stringRepeat = function (string, count) {
  1064. var result = '';
  1065. while (count > 0) {
  1066. if (count & 1)
  1067. result += string;
  1068. if (count >>= 1)
  1069. string += string;
  1070. }
  1071. return result;
  1072. };
  1073. var trimBeginRegexp = /^\s\s*/;
  1074. var trimEndRegexp = /\s\s*$/;
  1075. exports.stringTrimLeft = function (string) {
  1076. return string.replace(trimBeginRegexp, '');
  1077. };
  1078. exports.stringTrimRight = function (string) {
  1079. return string.replace(trimEndRegexp, '');
  1080. };
  1081. exports.copyObject = function (obj) {
  1082. var copy = {};
  1083. for (var key in obj) {
  1084. copy[key] = obj[key];
  1085. }
  1086. return copy;
  1087. };
  1088. exports.copyArray = function (array) {
  1089. var copy = [];
  1090. for (var i = 0, l = array.length; i < l; i++) {
  1091. if (array[i] && typeof array[i] == "object")
  1092. copy[i] = this.copyObject(array[i]);
  1093. else
  1094. copy[i] = array[i];
  1095. }
  1096. return copy;
  1097. };
  1098. exports.deepCopy = function deepCopy(obj) {
  1099. if (typeof obj !== "object" || !obj)
  1100. return obj;
  1101. var copy;
  1102. if (Array.isArray(obj)) {
  1103. copy = [];
  1104. for (var key = 0; key < obj.length; key++) {
  1105. copy[key] = deepCopy(obj[key]);
  1106. }
  1107. return copy;
  1108. }
  1109. if (Object.prototype.toString.call(obj) !== "[object Object]")
  1110. return obj;
  1111. copy = {};
  1112. for (var key in obj)
  1113. copy[key] = deepCopy(obj[key]);
  1114. return copy;
  1115. };
  1116. exports.arrayToMap = function (arr) {
  1117. var map = {};
  1118. for (var i = 0; i < arr.length; i++) {
  1119. map[arr[i]] = 1;
  1120. }
  1121. return map;
  1122. };
  1123. exports.createMap = function (props) {
  1124. var map = Object.create(null);
  1125. for (var i in props) {
  1126. map[i] = props[i];
  1127. }
  1128. return map;
  1129. };
  1130. exports.arrayRemove = function (array, value) {
  1131. for (var i = 0; i <= array.length; i++) {
  1132. if (value === array[i]) {
  1133. array.splice(i, 1);
  1134. }
  1135. }
  1136. };
  1137. exports.escapeRegExp = function (str) {
  1138. return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
  1139. };
  1140. exports.escapeHTML = function (str) {
  1141. return ("" + str).replace(/&/g, "&#38;").replace(/"/g, "&#34;").replace(/'/g, "&#39;").replace(/</g, "&#60;");
  1142. };
  1143. exports.getMatchOffsets = function (string, regExp) {
  1144. var matches = [];
  1145. string.replace(regExp, function (str) {
  1146. matches.push({
  1147. offset: arguments[arguments.length - 2],
  1148. length: str.length
  1149. });
  1150. });
  1151. return matches;
  1152. };
  1153. exports.deferredCall = function (fcn) {
  1154. var timer = null;
  1155. var callback = function () {
  1156. timer = null;
  1157. fcn();
  1158. };
  1159. var deferred = function (timeout) {
  1160. deferred.cancel();
  1161. timer = setTimeout(callback, timeout || 0);
  1162. return deferred;
  1163. };
  1164. deferred.schedule = deferred;
  1165. deferred.call = function () {
  1166. this.cancel();
  1167. fcn();
  1168. return deferred;
  1169. };
  1170. deferred.cancel = function () {
  1171. clearTimeout(timer);
  1172. timer = null;
  1173. return deferred;
  1174. };
  1175. deferred.isPending = function () {
  1176. return timer;
  1177. };
  1178. return deferred;
  1179. };
  1180. exports.delayedCall = function (fcn, defaultTimeout) {
  1181. var timer = null;
  1182. var callback = function () {
  1183. timer = null;
  1184. fcn();
  1185. };
  1186. var _self = function (timeout) {
  1187. if (timer == null)
  1188. timer = setTimeout(callback, timeout || defaultTimeout);
  1189. };
  1190. _self.delay = function (timeout) {
  1191. timer && clearTimeout(timer);
  1192. timer = setTimeout(callback, timeout || defaultTimeout);
  1193. };
  1194. _self.schedule = _self;
  1195. _self.call = function () {
  1196. this.cancel();
  1197. fcn();
  1198. };
  1199. _self.cancel = function () {
  1200. timer && clearTimeout(timer);
  1201. timer = null;
  1202. };
  1203. _self.isPending = function () {
  1204. return timer;
  1205. };
  1206. return _self;
  1207. };
  1208. });
  1209. ace.define("ace/worker/mirror",[], function(require, exports, module) {
  1210. "use strict";
  1211. var Document = require("../document").Document;
  1212. var lang = require("../lib/lang");
  1213. var Mirror = exports.Mirror = function(sender) {
  1214. this.sender = sender;
  1215. var doc = this.doc = new Document("");
  1216. var deferredUpdate = this.deferredUpdate = lang.delayedCall(this.onUpdate.bind(this));
  1217. var _self = this;
  1218. sender.on("change", function(e) {
  1219. var data = e.data;
  1220. if (data[0].start) {
  1221. doc.applyDeltas(data);
  1222. } else {
  1223. for (var i = 0; i < data.length; i += 2) {
  1224. var d, err;
  1225. if (Array.isArray(data[i+1])) {
  1226. d = {action: "insert", start: data[i], lines: data[i+1]};
  1227. } else {
  1228. d = {action: "remove", start: data[i], end: data[i+1]};
  1229. }
  1230. if ((d.action == "insert" ? d.start : d.end).row >= doc.$lines.length) {
  1231. err = new Error("Invalid delta");
  1232. err.data = {
  1233. path: _self.$path,
  1234. linesLength: doc.$lines.length,
  1235. start: d.start,
  1236. end: d.end
  1237. };
  1238. throw err;
  1239. }
  1240. doc.applyDelta(d, true);
  1241. }
  1242. }
  1243. if (_self.$timeout)
  1244. return deferredUpdate.schedule(_self.$timeout);
  1245. _self.onUpdate();
  1246. });
  1247. };
  1248. (function() {
  1249. this.$timeout = 500;
  1250. this.setTimeout = function(timeout) {
  1251. this.$timeout = timeout;
  1252. };
  1253. this.setValue = function(value) {
  1254. this.doc.setValue(value);
  1255. this.deferredUpdate.schedule(this.$timeout);
  1256. };
  1257. this.getValue = function(callbackId) {
  1258. this.sender.callback(this.doc.getValue(), callbackId);
  1259. };
  1260. this.onUpdate = function() {
  1261. };
  1262. this.isPending = function() {
  1263. return this.deferredUpdate.isPending();
  1264. };
  1265. }).call(Mirror.prototype);
  1266. });
  1267. ace.define("ace/mode/yaml/yaml-lint",[], function(require, exports, module) {
  1268. var $build_deps$ = {require: require, exports: exports, module: module};
  1269. exports = undefined; module = undefined;
  1270. function define(name, deps, m) {
  1271. if (typeof name == "function") {
  1272. m = name; deps = ["require", "exports", "module"]; name = $build_deps$.module.id
  1273. }
  1274. if (typeof name !== "string") {
  1275. m = deps; deps = name; name = $build_deps$.module.id
  1276. }
  1277. if (!m) {
  1278. m = deps; deps = [];
  1279. }
  1280. var ret = typeof m == "function" ?
  1281. m.apply($build_deps$.module, deps.map(function(n){return $build_deps$[n] || require(n)})) : m
  1282. if (ret != undefined) $build_deps$.module.exports = ret;
  1283. }
  1284. define.amd = true;(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.lint = f();}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c=typeof require=="function"&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a;}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r);},p,p.exports,r,e,n,t);}return n[i].exports;}for(var u=typeof require=="function"&&require,i=0;i<t.length;i++)o(t[i]);return o;}return r;})()({1:[function(require,module,exports){
  1285. },{}],2:[function(require,module,exports){
  1286. var fs = require('fs');
  1287. var merge = require('lodash.merge');
  1288. var yaml = require('js-yaml');
  1289. var DEFAULT_LINT_OPTION = {
  1290. schema: 'DEFAULT_SAFE_SCHEMA'
  1291. };
  1292. function lint(content, opts, cb) {
  1293. var options = merge({}, DEFAULT_LINT_OPTION, opts);
  1294. try {
  1295. yaml.safeLoad(content, {
  1296. schema: yaml[options.schema]
  1297. });
  1298. cb();
  1299. } catch (e) {
  1300. cb(e);
  1301. }
  1302. }
  1303. module.exports = {
  1304. lint: lint
  1305. };
  1306. },{"fs":1,"js-yaml":3,"lodash.merge":33}],3:[function(require,module,exports){
  1307. 'use strict';
  1308. var yaml = require('./lib/js-yaml.js');
  1309. module.exports = yaml;
  1310. },{"./lib/js-yaml.js":4}],4:[function(require,module,exports){
  1311. 'use strict';
  1312. var loader = require('./js-yaml/loader');
  1313. var dumper = require('./js-yaml/dumper');
  1314. function deprecated(name) {
  1315. return function () {
  1316. throw new Error('Function ' + name + ' is deprecated and cannot be used.');
  1317. };
  1318. }
  1319. module.exports.Type = require('./js-yaml/type');
  1320. module.exports.Schema = require('./js-yaml/schema');
  1321. module.exports.FAILSAFE_SCHEMA = require('./js-yaml/schema/failsafe');
  1322. module.exports.JSON_SCHEMA = require('./js-yaml/schema/json');
  1323. module.exports.CORE_SCHEMA = require('./js-yaml/schema/core');
  1324. module.exports.DEFAULT_SAFE_SCHEMA = require('./js-yaml/schema/default_safe');
  1325. module.exports.DEFAULT_FULL_SCHEMA = require('./js-yaml/schema/default_full');
  1326. module.exports.load = loader.load;
  1327. module.exports.loadAll = loader.loadAll;
  1328. module.exports.safeLoad = loader.safeLoad;
  1329. module.exports.safeLoadAll = loader.safeLoadAll;
  1330. module.exports.dump = dumper.dump;
  1331. module.exports.safeDump = dumper.safeDump;
  1332. module.exports.YAMLException = require('./js-yaml/exception');
  1333. module.exports.MINIMAL_SCHEMA = require('./js-yaml/schema/failsafe');
  1334. module.exports.SAFE_SCHEMA = require('./js-yaml/schema/default_safe');
  1335. module.exports.DEFAULT_SCHEMA = require('./js-yaml/schema/default_full');
  1336. module.exports.scan = deprecated('scan');
  1337. module.exports.parse = deprecated('parse');
  1338. module.exports.compose = deprecated('compose');
  1339. module.exports.addConstructor = deprecated('addConstructor');
  1340. },{"./js-yaml/dumper":6,"./js-yaml/exception":7,"./js-yaml/loader":8,"./js-yaml/schema":10,"./js-yaml/schema/core":11,"./js-yaml/schema/default_full":12,"./js-yaml/schema/default_safe":13,"./js-yaml/schema/failsafe":14,"./js-yaml/schema/json":15,"./js-yaml/type":16}],5:[function(require,module,exports){
  1341. 'use strict';
  1342. function isNothing(subject) {
  1343. return (typeof subject === 'undefined') || (subject === null);
  1344. }
  1345. function isObject(subject) {
  1346. return (typeof subject === 'object') && (subject !== null);
  1347. }
  1348. function toArray(sequence) {
  1349. if (Array.isArray(sequence)) return sequence;
  1350. else if (isNothing(sequence)) return [];
  1351. return [ sequence ];
  1352. }
  1353. function extend(target, source) {
  1354. var index, length, key, sourceKeys;
  1355. if (source) {
  1356. sourceKeys = Object.keys(source);
  1357. for (index = 0, length = sourceKeys.length; index < length; index += 1) {
  1358. key = sourceKeys[index];
  1359. target[key] = source[key];
  1360. }
  1361. }
  1362. return target;
  1363. }
  1364. function repeat(string, count) {
  1365. var result = '', cycle;
  1366. for (cycle = 0; cycle < count; cycle += 1) {
  1367. result += string;
  1368. }
  1369. return result;
  1370. }
  1371. function isNegativeZero(number) {
  1372. return (number === 0) && (Number.NEGATIVE_INFINITY === 1 / number);
  1373. }
  1374. module.exports.isNothing = isNothing;
  1375. module.exports.isObject = isObject;
  1376. module.exports.toArray = toArray;
  1377. module.exports.repeat = repeat;
  1378. module.exports.isNegativeZero = isNegativeZero;
  1379. module.exports.extend = extend;
  1380. },{}],6:[function(require,module,exports){
  1381. 'use strict';
  1382. var common = require('./common');
  1383. var YAMLException = require('./exception');
  1384. var DEFAULT_FULL_SCHEMA = require('./schema/default_full');
  1385. var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe');
  1386. var _toString = Object.prototype.toString;
  1387. var _hasOwnProperty = Object.prototype.hasOwnProperty;
  1388. var CHAR_TAB = 0x09;
  1389. var CHAR_LINE_FEED = 0x0A;
  1390. var CHAR_SPACE = 0x20;
  1391. var CHAR_EXCLAMATION = 0x21;
  1392. var CHAR_DOUBLE_QUOTE = 0x22;
  1393. var CHAR_SHARP = 0x23;
  1394. var CHAR_PERCENT = 0x25;
  1395. var CHAR_AMPERSAND = 0x26;
  1396. var CHAR_SINGLE_QUOTE = 0x27;
  1397. var CHAR_ASTERISK = 0x2A;
  1398. var CHAR_COMMA = 0x2C;
  1399. var CHAR_MINUS = 0x2D;
  1400. var CHAR_COLON = 0x3A;
  1401. var CHAR_GREATER_THAN = 0x3E;
  1402. var CHAR_QUESTION = 0x3F;
  1403. var CHAR_COMMERCIAL_AT = 0x40;
  1404. var CHAR_LEFT_SQUARE_BRACKET = 0x5B;
  1405. var CHAR_RIGHT_SQUARE_BRACKET = 0x5D;
  1406. var CHAR_GRAVE_ACCENT = 0x60;
  1407. var CHAR_LEFT_CURLY_BRACKET = 0x7B;
  1408. var CHAR_VERTICAL_LINE = 0x7C;
  1409. var CHAR_RIGHT_CURLY_BRACKET = 0x7D;
  1410. var ESCAPE_SEQUENCES = {};
  1411. ESCAPE_SEQUENCES[0x00] = '\\0';
  1412. ESCAPE_SEQUENCES[0x07] = '\\a';
  1413. ESCAPE_SEQUENCES[0x08] = '\\b';
  1414. ESCAPE_SEQUENCES[0x09] = '\\t';
  1415. ESCAPE_SEQUENCES[0x0A] = '\\n';
  1416. ESCAPE_SEQUENCES[0x0B] = '\\v';
  1417. ESCAPE_SEQUENCES[0x0C] = '\\f';
  1418. ESCAPE_SEQUENCES[0x0D] = '\\r';
  1419. ESCAPE_SEQUENCES[0x1B] = '\\e';
  1420. ESCAPE_SEQUENCES[0x22] = '\\"';
  1421. ESCAPE_SEQUENCES[0x5C] = '\\\\';
  1422. ESCAPE_SEQUENCES[0x85] = '\\N';
  1423. ESCAPE_SEQUENCES[0xA0] = '\\_';
  1424. ESCAPE_SEQUENCES[0x2028] = '\\L';
  1425. ESCAPE_SEQUENCES[0x2029] = '\\P';
  1426. var DEPRECATED_BOOLEANS_SYNTAX = [
  1427. 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON',
  1428. 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF'
  1429. ];
  1430. function compileStyleMap(schema, map) {
  1431. var result, keys, index, length, tag, style, type;
  1432. if (map === null) return {};
  1433. result = {};
  1434. keys = Object.keys(map);
  1435. for (index = 0, length = keys.length; index < length; index += 1) {
  1436. tag = keys[index];
  1437. style = String(map[tag]);
  1438. if (tag.slice(0, 2) === '!!') {
  1439. tag = 'tag:yaml.org,2002:' + tag.slice(2);
  1440. }
  1441. type = schema.compiledTypeMap['fallback'][tag];
  1442. if (type && _hasOwnProperty.call(type.styleAliases, style)) {
  1443. style = type.styleAliases[style];
  1444. }
  1445. result[tag] = style;
  1446. }
  1447. return result;
  1448. }
  1449. function encodeHex(character) {
  1450. var string, handle, length;
  1451. string = character.toString(16).toUpperCase();
  1452. if (character <= 0xFF) {
  1453. handle = 'x';
  1454. length = 2;
  1455. } else if (character <= 0xFFFF) {
  1456. handle = 'u';
  1457. length = 4;
  1458. } else if (character <= 0xFFFFFFFF) {
  1459. handle = 'U';
  1460. length = 8;
  1461. } else {
  1462. throw new YAMLException('code point within a string may not be greater than 0xFFFFFFFF');
  1463. }
  1464. return '\\' + handle + common.repeat('0', length - string.length) + string;
  1465. }
  1466. function State(options) {
  1467. this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
  1468. this.indent = Math.max(1, (options['indent'] || 2));
  1469. this.noArrayIndent = options['noArrayIndent'] || false;
  1470. this.skipInvalid = options['skipInvalid'] || false;
  1471. this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']);
  1472. this.styleMap = compileStyleMap(this.schema, options['styles'] || null);
  1473. this.sortKeys = options['sortKeys'] || false;
  1474. this.lineWidth = options['lineWidth'] || 80;
  1475. this.noRefs = options['noRefs'] || false;
  1476. this.noCompatMode = options['noCompatMode'] || false;
  1477. this.condenseFlow = options['condenseFlow'] || false;
  1478. this.implicitTypes = this.schema.compiledImplicit;
  1479. this.explicitTypes = this.schema.compiledExplicit;
  1480. this.tag = null;
  1481. this.result = '';
  1482. this.duplicates = [];
  1483. this.usedDuplicates = null;
  1484. }
  1485. function indentString(string, spaces) {
  1486. var ind = common.repeat(' ', spaces),
  1487. position = 0,
  1488. next = -1,
  1489. result = '',
  1490. line,
  1491. length = string.length;
  1492. while (position < length) {
  1493. next = string.indexOf('\n', position);
  1494. if (next === -1) {
  1495. line = string.slice(position);
  1496. position = length;
  1497. } else {
  1498. line = string.slice(position, next + 1);
  1499. position = next + 1;
  1500. }
  1501. if (line.length && line !== '\n') result += ind;
  1502. result += line;
  1503. }
  1504. return result;
  1505. }
  1506. function generateNextLine(state, level) {
  1507. return '\n' + common.repeat(' ', state.indent * level);
  1508. }
  1509. function testImplicitResolving(state, str) {
  1510. var index, length, type;
  1511. for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
  1512. type = state.implicitTypes[index];
  1513. if (type.resolve(str)) {
  1514. return true;
  1515. }
  1516. }
  1517. return false;
  1518. }
  1519. function isWhitespace(c) {
  1520. return c === CHAR_SPACE || c === CHAR_TAB;
  1521. }
  1522. function isPrintable(c) {
  1523. return (c >= 0x00020 && c <= 0x00007E)
  1524. || ((c >= 0x000A1 && c <= 0x00D7FF) && c !== 0x2028 && c !== 0x2029)
  1525. || ((c >= 0x0E000 && c <= 0x00FFFD) && c !== 0xFEFF /* BOM */)
  1526. || (c >= 0x10000 && c <= 0x10FFFF);
  1527. }
  1528. function isPlainSafe(c) {
  1529. return isPrintable(c) && c !== 0xFEFF
  1530. && c !== CHAR_COMMA
  1531. && c !== CHAR_LEFT_SQUARE_BRACKET
  1532. && c !== CHAR_RIGHT_SQUARE_BRACKET
  1533. && c !== CHAR_LEFT_CURLY_BRACKET
  1534. && c !== CHAR_RIGHT_CURLY_BRACKET
  1535. && c !== CHAR_COLON
  1536. && c !== CHAR_SHARP;
  1537. }
  1538. function isPlainSafeFirst(c) {
  1539. return isPrintable(c) && c !== 0xFEFF
  1540. && !isWhitespace(c) // - s-white
  1541. && c !== CHAR_MINUS
  1542. && c !== CHAR_QUESTION
  1543. && c !== CHAR_COLON
  1544. && c !== CHAR_COMMA
  1545. && c !== CHAR_LEFT_SQUARE_BRACKET
  1546. && c !== CHAR_RIGHT_SQUARE_BRACKET
  1547. && c !== CHAR_LEFT_CURLY_BRACKET
  1548. && c !== CHAR_RIGHT_CURLY_BRACKET
  1549. && c !== CHAR_SHARP
  1550. && c !== CHAR_AMPERSAND
  1551. && c !== CHAR_ASTERISK
  1552. && c !== CHAR_EXCLAMATION
  1553. && c !== CHAR_VERTICAL_LINE
  1554. && c !== CHAR_GREATER_THAN
  1555. && c !== CHAR_SINGLE_QUOTE
  1556. && c !== CHAR_DOUBLE_QUOTE
  1557. && c !== CHAR_PERCENT
  1558. && c !== CHAR_COMMERCIAL_AT
  1559. && c !== CHAR_GRAVE_ACCENT;
  1560. }
  1561. function needIndentIndicator(string) {
  1562. var leadingSpaceRe = /^\n* /;
  1563. return leadingSpaceRe.test(string);
  1564. }
  1565. var STYLE_PLAIN = 1,
  1566. STYLE_SINGLE = 2,
  1567. STYLE_LITERAL = 3,
  1568. STYLE_FOLDED = 4,
  1569. STYLE_DOUBLE = 5;
  1570. function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType) {
  1571. var i;
  1572. var char;
  1573. var hasLineBreak = false;
  1574. var hasFoldableLine = false; // only checked if shouldTrackWidth
  1575. var shouldTrackWidth = lineWidth !== -1;
  1576. var previousLineBreak = -1; // count the first line correctly
  1577. var plain = isPlainSafeFirst(string.charCodeAt(0))
  1578. && !isWhitespace(string.charCodeAt(string.length - 1));
  1579. if (singleLineOnly) {
  1580. for (i = 0; i < string.length; i++) {
  1581. char = string.charCodeAt(i);
  1582. if (!isPrintable(char)) {
  1583. return STYLE_DOUBLE;
  1584. }
  1585. plain = plain && isPlainSafe(char);
  1586. }
  1587. } else {
  1588. for (i = 0; i < string.length; i++) {
  1589. char = string.charCodeAt(i);
  1590. if (char === CHAR_LINE_FEED) {
  1591. hasLineBreak = true;
  1592. if (shouldTrackWidth) {
  1593. hasFoldableLine = hasFoldableLine ||
  1594. (i - previousLineBreak - 1 > lineWidth &&
  1595. string[previousLineBreak + 1] !== ' ');
  1596. previousLineBreak = i;
  1597. }
  1598. } else if (!isPrintable(char)) {
  1599. return STYLE_DOUBLE;
  1600. }
  1601. plain = plain && isPlainSafe(char);
  1602. }
  1603. hasFoldableLine = hasFoldableLine || (shouldTrackWidth &&
  1604. (i - previousLineBreak - 1 > lineWidth &&
  1605. string[previousLineBreak + 1] !== ' '));
  1606. }
  1607. if (!hasLineBreak && !hasFoldableLine) {
  1608. return plain && !testAmbiguousType(string)
  1609. ? STYLE_PLAIN : STYLE_SINGLE;
  1610. }
  1611. if (indentPerLevel > 9 && needIndentIndicator(string)) {
  1612. return STYLE_DOUBLE;
  1613. }
  1614. return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
  1615. }
  1616. function writeScalar(state, string, level, iskey) {
  1617. state.dump = (function () {
  1618. if (string.length === 0) {
  1619. return "''";
  1620. }
  1621. if (!state.noCompatMode &&
  1622. DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1) {
  1623. return "'" + string + "'";
  1624. }
  1625. var indent = state.indent * Math.max(1, level); // no 0-indent scalars
  1626. var lineWidth = state.lineWidth === -1
  1627. ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
  1628. var singleLineOnly = iskey
  1629. || (state.flowLevel > -1 && level >= state.flowLevel);
  1630. function testAmbiguity(string) {
  1631. return testImplicitResolving(state, string);
  1632. }
  1633. switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity)) {
  1634. case STYLE_PLAIN:
  1635. return string;
  1636. case STYLE_SINGLE:
  1637. return "'" + string.replace(/'/g, "''") + "'";
  1638. case STYLE_LITERAL:
  1639. return '|' + blockHeader(string, state.indent)
  1640. + dropEndingNewline(indentString(string, indent));
  1641. case STYLE_FOLDED:
  1642. return '>' + blockHeader(string, state.indent)
  1643. + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
  1644. case STYLE_DOUBLE:
  1645. return '"' + escapeString(string, lineWidth) + '"';
  1646. default:
  1647. throw new YAMLException('impossible error: invalid scalar style');
  1648. }
  1649. }());
  1650. }
  1651. function blockHeader(string, indentPerLevel) {
  1652. var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : '';
  1653. var clip = string[string.length - 1] === '\n';
  1654. var keep = clip && (string[string.length - 2] === '\n' || string === '\n');
  1655. var chomp = keep ? '+' : (clip ? '' : '-');
  1656. return indentIndicator + chomp + '\n';
  1657. }
  1658. function dropEndingNewline(string) {
  1659. return string[string.length - 1] === '\n' ? string.slice(0, -1) : string;
  1660. }
  1661. function foldString(string, width) {
  1662. var lineRe = /(\n+)([^\n]*)/g;
  1663. var result = (function () {
  1664. var nextLF = string.indexOf('\n');
  1665. nextLF = nextLF !== -1 ? nextLF : string.length;
  1666. lineRe.lastIndex = nextLF;
  1667. return foldLine(string.slice(0, nextLF), width);
  1668. }());
  1669. var prevMoreIndented = string[0] === '\n' || string[0] === ' ';
  1670. var moreIndented;
  1671. var match;
  1672. while ((match = lineRe.exec(string))) {
  1673. var prefix = match[1], line = match[2];
  1674. moreIndented = (line[0] === ' ');
  1675. result += prefix
  1676. + (!prevMoreIndented && !moreIndented && line !== ''
  1677. ? '\n' : '')
  1678. + foldLine(line, width);
  1679. prevMoreIndented = moreIndented;
  1680. }
  1681. return result;
  1682. }
  1683. function foldLine(line, width) {
  1684. if (line === '' || line[0] === ' ') return line;
  1685. var breakRe = / [^ ]/g; // note: the match index will always be <= length-2.
  1686. var match;
  1687. var start = 0, end, curr = 0, next = 0;
  1688. var result = '';
  1689. while ((match = breakRe.exec(line))) {
  1690. next = match.index;
  1691. if (next - start > width) {
  1692. end = (curr > start) ? curr : next; // derive end <= length-2
  1693. result += '\n' + line.slice(start, end);
  1694. start = end + 1; // derive start <= length-1
  1695. }
  1696. curr = next;
  1697. }
  1698. result += '\n';
  1699. if (line.length - start > width && curr > start) {
  1700. result += line.slice(start, curr) + '\n' + line.slice(curr + 1);
  1701. } else {
  1702. result += line.slice(start);
  1703. }
  1704. return result.slice(1); // drop extra \n joiner
  1705. }
  1706. function escapeString(string) {
  1707. var result = '';
  1708. var char, nextChar;
  1709. var escapeSeq;
  1710. for (var i = 0; i < string.length; i++) {
  1711. char = string.charCodeAt(i);
  1712. if (char >= 0xD800 && char <= 0xDBFF/* high surrogate */) {
  1713. nextChar = string.charCodeAt(i + 1);
  1714. if (nextChar >= 0xDC00 && nextChar <= 0xDFFF/* low surrogate */) {
  1715. result += encodeHex((char - 0xD800) * 0x400 + nextChar - 0xDC00 + 0x10000);
  1716. i++; continue;
  1717. }
  1718. }
  1719. escapeSeq = ESCAPE_SEQUENCES[char];
  1720. result += !escapeSeq && isPrintable(char)
  1721. ? string[i]
  1722. : escapeSeq || encodeHex(char);
  1723. }
  1724. return result;
  1725. }
  1726. function writeFlowSequence(state, level, object) {
  1727. var _result = '',
  1728. _tag = state.tag,
  1729. index,
  1730. length;
  1731. for (index = 0, length = object.length; index < length; index += 1) {
  1732. if (writeNode(state, level, object[index], false, false)) {
  1733. if (index !== 0) _result += ',' + (!state.condenseFlow ? ' ' : '');
  1734. _result += state.dump;
  1735. }
  1736. }
  1737. state.tag = _tag;
  1738. state.dump = '[' + _result + ']';
  1739. }
  1740. function writeBlockSequence(state, level, object, compact) {
  1741. var _result = '',
  1742. _tag = state.tag,
  1743. index,
  1744. length;
  1745. for (index = 0, length = object.length; index < length; index += 1) {
  1746. if (writeNode(state, level + 1, object[index], true, true)) {
  1747. if (!compact || index !== 0) {
  1748. _result += generateNextLine(state, level);
  1749. }
  1750. if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
  1751. _result += '-';
  1752. } else {
  1753. _result += '- ';
  1754. }
  1755. _result += state.dump;
  1756. }
  1757. }
  1758. state.tag = _tag;
  1759. state.dump = _result || '[]'; // Empty sequence if no valid values.
  1760. }
  1761. function writeFlowMapping(state, level, object) {
  1762. var _result = '',
  1763. _tag = state.tag,
  1764. objectKeyList = Object.keys(object),
  1765. index,
  1766. length,
  1767. objectKey,
  1768. objectValue,
  1769. pairBuffer;
  1770. for (index = 0, length = objectKeyList.length; index < length; index += 1) {
  1771. pairBuffer = state.condenseFlow ? '"' : '';
  1772. if (index !== 0) pairBuffer += ', ';
  1773. objectKey = objectKeyList[index];
  1774. objectValue = object[objectKey];
  1775. if (!writeNode(state, level, objectKey, false, false)) {
  1776. continue; // Skip this pair because of invalid key;
  1777. }
  1778. if (state.dump.length > 1024) pairBuffer += '? ';
  1779. pairBuffer += state.dump + (state.condenseFlow ? '"' : '') + ':' + (state.condenseFlow ? '' : ' ');
  1780. if (!writeNode(state, level, objectValue, false, false)) {
  1781. continue; // Skip this pair because of invalid value.
  1782. }
  1783. pairBuffer += state.dump;
  1784. _result += pairBuffer;
  1785. }
  1786. state.tag = _tag;
  1787. state.dump = '{' + _result + '}';
  1788. }
  1789. function writeBlockMapping(state, level, object, compact) {
  1790. var _result = '',
  1791. _tag = state.tag,
  1792. objectKeyList = Object.keys(object),
  1793. index,
  1794. length,
  1795. objectKey,
  1796. objectValue,
  1797. explicitPair,
  1798. pairBuffer;
  1799. if (state.sortKeys === true) {
  1800. objectKeyList.sort();
  1801. } else if (typeof state.sortKeys === 'function') {
  1802. objectKeyList.sort(state.sortKeys);
  1803. } else if (state.sortKeys) {
  1804. throw new YAMLException('sortKeys must be a boolean or a function');
  1805. }
  1806. for (index = 0, length = objectKeyList.length; index < length; index += 1) {
  1807. pairBuffer = '';
  1808. if (!compact || index !== 0) {
  1809. pairBuffer += generateNextLine(state, level);
  1810. }
  1811. objectKey = objectKeyList[index];
  1812. objectValue = object[objectKey];
  1813. if (!writeNode(state, level + 1, objectKey, true, true, true)) {
  1814. continue; // Skip this pair because of invalid key.
  1815. }
  1816. explicitPair = (state.tag !== null && state.tag !== '?') ||
  1817. (state.dump && state.dump.length > 1024);
  1818. if (explicitPair) {
  1819. if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
  1820. pairBuffer += '?';
  1821. } else {
  1822. pairBuffer += '? ';
  1823. }
  1824. }
  1825. pairBuffer += state.dump;
  1826. if (explicitPair) {
  1827. pairBuffer += generateNextLine(state, level);
  1828. }
  1829. if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
  1830. continue; // Skip this pair because of invalid value.
  1831. }
  1832. if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
  1833. pairBuffer += ':';
  1834. } else {
  1835. pairBuffer += ': ';
  1836. }
  1837. pairBuffer += state.dump;
  1838. _result += pairBuffer;
  1839. }
  1840. state.tag = _tag;
  1841. state.dump = _result || '{}'; // Empty mapping if no valid pairs.
  1842. }
  1843. function detectType(state, object, explicit) {
  1844. var _result, typeList, index, length, type, style;
  1845. typeList = explicit ? state.explicitTypes : state.implicitTypes;
  1846. for (index = 0, length = typeList.length; index < length; index += 1) {
  1847. type = typeList[index];
  1848. if ((type.instanceOf || type.predicate) &&
  1849. (!type.instanceOf || ((typeof object === 'object') && (object instanceof type.instanceOf))) &&
  1850. (!type.predicate || type.predicate(object))) {
  1851. state.tag = explicit ? type.tag : '?';
  1852. if (type.represent) {
  1853. style = state.styleMap[type.tag] || type.defaultStyle;
  1854. if (_toString.call(type.represent) === '[object Function]') {
  1855. _result = type.represent(object, style);
  1856. } else if (_hasOwnProperty.call(type.represent, style)) {
  1857. _result = type.represent[style](object, style);
  1858. } else {
  1859. throw new YAMLException('!<' + type.tag + '> tag resolver accepts not "' + style + '" style');
  1860. }
  1861. state.dump = _result;
  1862. }
  1863. return true;
  1864. }
  1865. }
  1866. return false;
  1867. }
  1868. function writeNode(state, level, object, block, compact, iskey) {
  1869. state.tag = null;
  1870. state.dump = object;
  1871. if (!detectType(state, object, false)) {
  1872. detectType(state, object, true);
  1873. }
  1874. var type = _toString.call(state.dump);
  1875. if (block) {
  1876. block = (state.flowLevel < 0 || state.flowLevel > level);
  1877. }
  1878. var objectOrArray = type === '[object Object]' || type === '[object Array]',
  1879. duplicateIndex,
  1880. duplicate;
  1881. if (objectOrArray) {
  1882. duplicateIndex = state.duplicates.indexOf(object);
  1883. duplicate = duplicateIndex !== -1;
  1884. }
  1885. if ((state.tag !== null && state.tag !== '?') || duplicate || (state.indent !== 2 && level > 0)) {
  1886. compact = false;
  1887. }
  1888. if (duplicate && state.usedDuplicates[duplicateIndex]) {
  1889. state.dump = '*ref_' + duplicateIndex;
  1890. } else {
  1891. if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
  1892. state.usedDuplicates[duplicateIndex] = true;
  1893. }
  1894. if (type === '[object Object]') {
  1895. if (block && (Object.keys(state.dump).length !== 0)) {
  1896. writeBlockMapping(state, level, state.dump, compact);
  1897. if (duplicate) {
  1898. state.dump = '&ref_' + duplicateIndex + state.dump;
  1899. }
  1900. } else {
  1901. writeFlowMapping(state, level, state.dump);
  1902. if (duplicate) {
  1903. state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
  1904. }
  1905. }
  1906. } else if (type === '[object Array]') {
  1907. var arrayLevel = (state.noArrayIndent && (level > 0)) ? level - 1 : level;
  1908. if (block && (state.dump.length !== 0)) {
  1909. writeBlockSequence(state, arrayLevel, state.dump, compact);
  1910. if (duplicate) {
  1911. state.dump = '&ref_' + duplicateIndex + state.dump;
  1912. }
  1913. } else {
  1914. writeFlowSequence(state, arrayLevel, state.dump);
  1915. if (duplicate) {
  1916. state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
  1917. }
  1918. }
  1919. } else if (type === '[object String]') {
  1920. if (state.tag !== '?') {
  1921. writeScalar(state, state.dump, level, iskey);
  1922. }
  1923. } else {
  1924. if (state.skipInvalid) return false;
  1925. throw new YAMLException('unacceptable kind of an object to dump ' + type);
  1926. }
  1927. if (state.tag !== null && state.tag !== '?') {
  1928. state.dump = '!<' + state.tag + '> ' + state.dump;
  1929. }
  1930. }
  1931. return true;
  1932. }
  1933. function getDuplicateReferences(object, state) {
  1934. var objects = [],
  1935. duplicatesIndexes = [],
  1936. index,
  1937. length;
  1938. inspectNode(object, objects, duplicatesIndexes);
  1939. for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
  1940. state.duplicates.push(objects[duplicatesIndexes[index]]);
  1941. }
  1942. state.usedDuplicates = new Array(length);
  1943. }
  1944. function inspectNode(object, objects, duplicatesIndexes) {
  1945. var objectKeyList,
  1946. index,
  1947. length;
  1948. if (object !== null && typeof object === 'object') {
  1949. index = objects.indexOf(object);
  1950. if (index !== -1) {
  1951. if (duplicatesIndexes.indexOf(index) === -1) {
  1952. duplicatesIndexes.push(index);
  1953. }
  1954. } else {
  1955. objects.push(object);
  1956. if (Array.isArray(object)) {
  1957. for (index = 0, length = object.length; index < length; index += 1) {
  1958. inspectNode(object[index], objects, duplicatesIndexes);
  1959. }
  1960. } else {
  1961. objectKeyList = Object.keys(object);
  1962. for (index = 0, length = objectKeyList.length; index < length; index += 1) {
  1963. inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
  1964. }
  1965. }
  1966. }
  1967. }
  1968. }
  1969. function dump(input, options) {
  1970. options = options || {};
  1971. var state = new State(options);
  1972. if (!state.noRefs) getDuplicateReferences(input, state);
  1973. if (writeNode(state, 0, input, true, true)) return state.dump + '\n';
  1974. return '';
  1975. }
  1976. function safeDump(input, options) {
  1977. return dump(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
  1978. }
  1979. module.exports.dump = dump;
  1980. module.exports.safeDump = safeDump;
  1981. },{"./common":5,"./exception":7,"./schema/default_full":12,"./schema/default_safe":13}],7:[function(require,module,exports){
  1982. 'use strict';
  1983. function YAMLException(reason, mark) {
  1984. Error.call(this);
  1985. this.name = 'YAMLException';
  1986. this.reason = reason;
  1987. this.mark = mark;
  1988. this.message = (this.reason || '(unknown reason)') + (this.mark ? ' ' + this.mark.toString() : '');
  1989. if (Error.captureStackTrace) {
  1990. Error.captureStackTrace(this, this.constructor);
  1991. } else {
  1992. this.stack = (new Error()).stack || '';
  1993. }
  1994. }
  1995. YAMLException.prototype = Object.create(Error.prototype);
  1996. YAMLException.prototype.constructor = YAMLException;
  1997. YAMLException.prototype.toString = function toString(compact) {
  1998. var result = this.name + ': ';
  1999. result += this.reason || '(unknown reason)';
  2000. if (!compact && this.mark) {
  2001. result += ' ' + this.mark.toString();
  2002. }
  2003. return result;
  2004. };
  2005. module.exports = YAMLException;
  2006. },{}],8:[function(require,module,exports){
  2007. 'use strict';
  2008. var common = require('./common');
  2009. var YAMLException = require('./exception');
  2010. var Mark = require('./mark');
  2011. var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe');
  2012. var DEFAULT_FULL_SCHEMA = require('./schema/default_full');
  2013. var _hasOwnProperty = Object.prototype.hasOwnProperty;
  2014. var CONTEXT_FLOW_IN = 1;
  2015. var CONTEXT_FLOW_OUT = 2;
  2016. var CONTEXT_BLOCK_IN = 3;
  2017. var CONTEXT_BLOCK_OUT = 4;
  2018. var CHOMPING_CLIP = 1;
  2019. var CHOMPING_STRIP = 2;
  2020. var CHOMPING_KEEP = 3;
  2021. var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
  2022. var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
  2023. var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
  2024. var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
  2025. var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
  2026. function is_EOL(c) {
  2027. return (c === 0x0A/* LF */) || (c === 0x0D/* CR */);
  2028. }
  2029. function is_WHITE_SPACE(c) {
  2030. return (c === 0x09/* Tab */) || (c === 0x20/* Space */);
  2031. }
  2032. function is_WS_OR_EOL(c) {
  2033. return (c === 0x09/* Tab */) ||
  2034. (c === 0x20/* Space */) ||
  2035. (c === 0x0A/* LF */) ||
  2036. (c === 0x0D/* CR */);
  2037. }
  2038. function is_FLOW_INDICATOR(c) {
  2039. return c === 0x2C/* , */ ||
  2040. c === 0x5B/* [ */ ||
  2041. c === 0x5D/* ] */ ||
  2042. c === 0x7B/* { */ ||
  2043. c === 0x7D/* } */;
  2044. }
  2045. function fromHexCode(c) {
  2046. var lc;
  2047. if ((c/* 0 */ >= 0x30) && (c <= 0x39/* 9 */)) {
  2048. return c - 0x30;
  2049. }
  2050. lc = c | 0x20;
  2051. if ((lc/* a */ >= 0x61) && (lc <= 0x66/* f */)) {
  2052. return lc - 0x61 + 10;
  2053. }
  2054. return -1;
  2055. }
  2056. function escapedHexLen(c) {
  2057. if (c === 0x78/* x */) { return 2; }
  2058. if (c === 0x75/* u */) { return 4; }
  2059. if (c === 0x55/* U */) { return 8; }
  2060. return 0;
  2061. }
  2062. function fromDecimalCode(c) {
  2063. if ((c/* 0 */ >= 0x30) && (c <= 0x39/* 9 */)) {
  2064. return c - 0x30;
  2065. }
  2066. return -1;
  2067. }
  2068. function simpleEscapeSequence(c) {
  2069. return (c === 0x30/* 0 */) ? '\x00' :
  2070. (c === 0x61/* a */) ? '\x07' :
  2071. (c === 0x62/* b */) ? '\x08' :
  2072. (c === 0x74/* t */) ? '\x09' :
  2073. (c === 0x09/* Tab */) ? '\x09' :
  2074. (c === 0x6E/* n */) ? '\x0A' :
  2075. (c === 0x76/* v */) ? '\x0B' :
  2076. (c === 0x66/* f */) ? '\x0C' :
  2077. (c === 0x72/* r */) ? '\x0D' :
  2078. (c === 0x65/* e */) ? '\x1B' :
  2079. (c === 0x20/* Space */) ? ' ' :
  2080. (c === 0x22/* " */) ? '\x22' :
  2081. (c === 0x2F/* / */) ? '/' :
  2082. (c === 0x5C/* \ */) ? '\x5C' :
  2083. (c === 0x4E/* N */) ? '\x85' :
  2084. (c === 0x5F/* _ */) ? '\xA0' :
  2085. (c === 0x4C/* L */) ? '\u2028' :
  2086. (c === 0x50/* P */) ? '\u2029' : '';
  2087. }
  2088. function charFromCodepoint(c) {
  2089. if (c <= 0xFFFF) {
  2090. return String.fromCharCode(c);
  2091. }
  2092. return String.fromCharCode(
  2093. ((c - 0x010000) >> 10) + 0xD800,
  2094. ((c - 0x010000) & 0x03FF) + 0xDC00
  2095. );
  2096. }
  2097. var simpleEscapeCheck = new Array(256); // integer, for fast access
  2098. var simpleEscapeMap = new Array(256);
  2099. for (var i = 0; i < 256; i++) {
  2100. simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
  2101. simpleEscapeMap[i] = simpleEscapeSequence(i);
  2102. }
  2103. function State(input, options) {
  2104. this.input = input;
  2105. this.filename = options['filename'] || null;
  2106. this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
  2107. this.onWarning = options['onWarning'] || null;
  2108. this.legacy = options['legacy'] || false;
  2109. this.json = options['json'] || false;
  2110. this.listener = options['listener'] || null;
  2111. this.implicitTypes = this.schema.compiledImplicit;
  2112. this.typeMap = this.schema.compiledTypeMap;
  2113. this.length = input.length;
  2114. this.position = 0;
  2115. this.line = 0;
  2116. this.lineStart = 0;
  2117. this.lineIndent = 0;
  2118. this.documents = [];
  2119. }
  2120. function generateError(state, message) {
  2121. return new YAMLException(
  2122. message,
  2123. new Mark(state.filename, state.input, state.position, state.line, (state.position - state.lineStart)));
  2124. }
  2125. function throwError(state, message) {
  2126. throw generateError(state, message);
  2127. }
  2128. function throwWarning(state, message) {
  2129. if (state.onWarning) {
  2130. state.onWarning.call(null, generateError(state, message));
  2131. }
  2132. }
  2133. var directiveHandlers = {
  2134. YAML: function handleYamlDirective(state, name, args) {
  2135. var match, major, minor;
  2136. if (state.version !== null) {
  2137. throwError(state, 'duplication of %YAML directive');
  2138. }
  2139. if (args.length !== 1) {
  2140. throwError(state, 'YAML directive accepts exactly one argument');
  2141. }
  2142. match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
  2143. if (match === null) {
  2144. throwError(state, 'ill-formed argument of the YAML directive');
  2145. }
  2146. major = parseInt(match[1], 10);
  2147. minor = parseInt(match[2], 10);
  2148. if (major !== 1) {
  2149. throwError(state, 'unacceptable YAML version of the document');
  2150. }
  2151. state.version = args[0];
  2152. state.checkLineBreaks = (minor < 2);
  2153. if (minor !== 1 && minor !== 2) {
  2154. throwWarning(state, 'unsupported YAML version of the document');
  2155. }
  2156. },
  2157. TAG: function handleTagDirective(state, name, args) {
  2158. var handle, prefix;
  2159. if (args.length !== 2) {
  2160. throwError(state, 'TAG directive accepts exactly two arguments');
  2161. }
  2162. handle = args[0];
  2163. prefix = args[1];
  2164. if (!PATTERN_TAG_HANDLE.test(handle)) {
  2165. throwError(state, 'ill-formed tag handle (first argument) of the TAG directive');
  2166. }
  2167. if (_hasOwnProperty.call(state.tagMap, handle)) {
  2168. throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
  2169. }
  2170. if (!PATTERN_TAG_URI.test(prefix)) {
  2171. throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive');
  2172. }
  2173. state.tagMap[handle] = prefix;
  2174. }
  2175. };
  2176. function captureSegment(state, start, end, checkJson) {
  2177. var _position, _length, _character, _result;
  2178. if (start < end) {
  2179. _result = state.input.slice(start, end);
  2180. if (checkJson) {
  2181. for (_position = 0, _length = _result.length; _position < _length; _position += 1) {
  2182. _character = _result.charCodeAt(_position);
  2183. if (!(_character === 0x09 ||
  2184. (_character >= 0x20 && _character <= 0x10FFFF))) {
  2185. throwError(state, 'expected valid JSON character');
  2186. }
  2187. }
  2188. } else if (PATTERN_NON_PRINTABLE.test(_result)) {
  2189. throwError(state, 'the stream contains non-printable characters');
  2190. }
  2191. state.result += _result;
  2192. }
  2193. }
  2194. function mergeMappings(state, destination, source, overridableKeys) {
  2195. var sourceKeys, key, index, quantity;
  2196. if (!common.isObject(source)) {
  2197. throwError(state, 'cannot merge mappings; the provided source object is unacceptable');
  2198. }
  2199. sourceKeys = Object.keys(source);
  2200. for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
  2201. key = sourceKeys[index];
  2202. if (!_hasOwnProperty.call(destination, key)) {
  2203. destination[key] = source[key];
  2204. overridableKeys[key] = true;
  2205. }
  2206. }
  2207. }
  2208. function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startPos) {
  2209. var index, quantity;
  2210. keyNode = String(keyNode);
  2211. if (_result === null) {
  2212. _result = {};
  2213. }
  2214. if (keyTag === 'tag:yaml.org,2002:merge') {
  2215. if (Array.isArray(valueNode)) {
  2216. for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
  2217. mergeMappings(state, _result, valueNode[index], overridableKeys);
  2218. }
  2219. } else {
  2220. mergeMappings(state, _result, valueNode, overridableKeys);
  2221. }
  2222. } else {
  2223. if (!state.json &&
  2224. !_hasOwnProperty.call(overridableKeys, keyNode) &&
  2225. _hasOwnProperty.call(_result, keyNode)) {
  2226. state.line = startLine || state.line;
  2227. state.position = startPos || state.position;
  2228. throwError(state, 'duplicated mapping key');
  2229. }
  2230. _result[keyNode] = valueNode;
  2231. delete overridableKeys[keyNode];
  2232. }
  2233. return _result;
  2234. }
  2235. function readLineBreak(state) {
  2236. var ch;
  2237. ch = state.input.charCodeAt(state.position);
  2238. if (ch === 0x0A/* LF */) {
  2239. state.position++;
  2240. } else if (ch === 0x0D/* CR */) {
  2241. state.position++;
  2242. if (state.input.charCodeAt(state.position) === 0x0A/* LF */) {
  2243. state.position++;
  2244. }
  2245. } else {
  2246. throwError(state, 'a line break is expected');
  2247. }
  2248. state.line += 1;
  2249. state.lineStart = state.position;
  2250. }
  2251. function skipSeparationSpace(state, allowComments, checkIndent) {
  2252. var lineBreaks = 0,
  2253. ch = state.input.charCodeAt(state.position);
  2254. while (ch !== 0) {
  2255. while (is_WHITE_SPACE(ch)) {
  2256. ch = state.input.charCodeAt(++state.position);
  2257. }
  2258. if (allowComments && ch === 0x23/* # */) {
  2259. do {
  2260. ch = state.input.charCodeAt(++state.position);
  2261. } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && ch !== 0);
  2262. }
  2263. if (is_EOL(ch)) {
  2264. readLineBreak(state);
  2265. ch = state.input.charCodeAt(state.position);
  2266. lineBreaks++;
  2267. state.lineIndent = 0;
  2268. while (ch === 0x20/* Space */) {
  2269. state.lineIndent++;
  2270. ch = state.input.charCodeAt(++state.position);
  2271. }
  2272. } else {
  2273. break;
  2274. }
  2275. }
  2276. if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
  2277. throwWarning(state, 'deficient indentation');
  2278. }
  2279. return lineBreaks;
  2280. }
  2281. function testDocumentSeparator(state) {
  2282. var _position = state.position,
  2283. ch;
  2284. ch = state.input.charCodeAt(_position);
  2285. if ((ch === 0x2D/* - */ || ch === 0x2E/* . */) &&
  2286. ch === state.input.charCodeAt(_position + 1) &&
  2287. ch === state.input.charCodeAt(_position + 2)) {
  2288. _position += 3;
  2289. ch = state.input.charCodeAt(_position);
  2290. if (ch === 0 || is_WS_OR_EOL(ch)) {
  2291. return true;
  2292. }
  2293. }
  2294. return false;
  2295. }
  2296. function writeFoldedLines(state, count) {
  2297. if (count === 1) {
  2298. state.result += ' ';
  2299. } else if (count > 1) {
  2300. state.result += common.repeat('\n', count - 1);
  2301. }
  2302. }
  2303. function readPlainScalar(state, nodeIndent, withinFlowCollection) {
  2304. var preceding,
  2305. following,
  2306. captureStart,
  2307. captureEnd,
  2308. hasPendingContent,
  2309. _line,
  2310. _lineStart,
  2311. _lineIndent,
  2312. _kind = state.kind,
  2313. _result = state.result,
  2314. ch;
  2315. ch = state.input.charCodeAt(state.position);
  2316. if (is_WS_OR_EOL(ch) ||
  2317. is_FLOW_INDICATOR(ch) ||
  2318. ch === 0x23/* # */ ||
  2319. ch === 0x26/* & */ ||
  2320. ch === 0x2A/* * */ ||
  2321. ch === 0x21/* ! */ ||
  2322. ch === 0x7C/* | */ ||
  2323. ch === 0x3E/* > */ ||
  2324. ch === 0x27/* ' */ ||
  2325. ch === 0x22/* " */ ||
  2326. ch === 0x25/* % */ ||
  2327. ch === 0x40/* @ */ ||
  2328. ch === 0x60/* ` */) {
  2329. return false;
  2330. }
  2331. if (ch === 0x3F/* ? */ || ch === 0x2D/* - */) {
  2332. following = state.input.charCodeAt(state.position + 1);
  2333. if (is_WS_OR_EOL(following) ||
  2334. withinFlowCollection && is_FLOW_INDICATOR(following)) {
  2335. return false;
  2336. }
  2337. }
  2338. state.kind = 'scalar';
  2339. state.result = '';
  2340. captureStart = captureEnd = state.position;
  2341. hasPendingContent = false;
  2342. while (ch !== 0) {
  2343. if (ch === 0x3A/* : */) {
  2344. following = state.input.charCodeAt(state.position + 1);
  2345. if (is_WS_OR_EOL(following) ||
  2346. withinFlowCollection && is_FLOW_INDICATOR(following)) {
  2347. break;
  2348. }
  2349. } else if (ch === 0x23/* # */) {
  2350. preceding = state.input.charCodeAt(state.position - 1);
  2351. if (is_WS_OR_EOL(preceding)) {
  2352. break;
  2353. }
  2354. } else if ((state.position === state.lineStart && testDocumentSeparator(state)) ||
  2355. withinFlowCollection && is_FLOW_INDICATOR(ch)) {
  2356. break;
  2357. } else if (is_EOL(ch)) {
  2358. _line = state.line;
  2359. _lineStart = state.lineStart;
  2360. _lineIndent = state.lineIndent;
  2361. skipSeparationSpace(state, false, -1);
  2362. if (state.lineIndent >= nodeIndent) {
  2363. hasPendingContent = true;
  2364. ch = state.input.charCodeAt(state.position);
  2365. continue;
  2366. } else {
  2367. state.position = captureEnd;
  2368. state.line = _line;
  2369. state.lineStart = _lineStart;
  2370. state.lineIndent = _lineIndent;
  2371. break;
  2372. }
  2373. }
  2374. if (hasPendingContent) {
  2375. captureSegment(state, captureStart, captureEnd, false);
  2376. writeFoldedLines(state, state.line - _line);
  2377. captureStart = captureEnd = state.position;
  2378. hasPendingContent = false;
  2379. }
  2380. if (!is_WHITE_SPACE(ch)) {
  2381. captureEnd = state.position + 1;
  2382. }
  2383. ch = state.input.charCodeAt(++state.position);
  2384. }
  2385. captureSegment(state, captureStart, captureEnd, false);
  2386. if (state.result) {
  2387. return true;
  2388. }
  2389. state.kind = _kind;
  2390. state.result = _result;
  2391. return false;
  2392. }
  2393. function readSingleQuotedScalar(state, nodeIndent) {
  2394. var ch,
  2395. captureStart, captureEnd;
  2396. ch = state.input.charCodeAt(state.position);
  2397. if (ch !== 0x27/* ' */) {
  2398. return false;
  2399. }
  2400. state.kind = 'scalar';
  2401. state.result = '';
  2402. state.position++;
  2403. captureStart = captureEnd = state.position;
  2404. while ((ch = state.input.charCodeAt(state.position)) !== 0) {
  2405. if (ch === 0x27/* ' */) {
  2406. captureSegment(state, captureStart, state.position, true);
  2407. ch = state.input.charCodeAt(++state.position);
  2408. if (ch === 0x27/* ' */) {
  2409. captureStart = state.position;
  2410. state.position++;
  2411. captureEnd = state.position;
  2412. } else {
  2413. return true;
  2414. }
  2415. } else if (is_EOL(ch)) {
  2416. captureSegment(state, captureStart, captureEnd, true);
  2417. writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
  2418. captureStart = captureEnd = state.position;
  2419. } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
  2420. throwError(state, 'unexpected end of the document within a single quoted scalar');
  2421. } else {
  2422. state.position++;
  2423. captureEnd = state.position;
  2424. }
  2425. }
  2426. throwError(state, 'unexpected end of the stream within a single quoted scalar');
  2427. }
  2428. function readDoubleQuotedScalar(state, nodeIndent) {
  2429. var captureStart,
  2430. captureEnd,
  2431. hexLength,
  2432. hexResult,
  2433. tmp,
  2434. ch;
  2435. ch = state.input.charCodeAt(state.position);
  2436. if (ch !== 0x22/* " */) {
  2437. return false;
  2438. }
  2439. state.kind = 'scalar';
  2440. state.result = '';
  2441. state.position++;
  2442. captureStart = captureEnd = state.position;
  2443. while ((ch = state.input.charCodeAt(state.position)) !== 0) {
  2444. if (ch === 0x22/* " */) {
  2445. captureSegment(state, captureStart, state.position, true);
  2446. state.position++;
  2447. return true;
  2448. } else if (ch === 0x5C/* \ */) {
  2449. captureSegment(state, captureStart, state.position, true);
  2450. ch = state.input.charCodeAt(++state.position);
  2451. if (is_EOL(ch)) {
  2452. skipSeparationSpace(state, false, nodeIndent);
  2453. } else if (ch < 256 && simpleEscapeCheck[ch]) {
  2454. state.result += simpleEscapeMap[ch];
  2455. state.position++;
  2456. } else if ((tmp = escapedHexLen(ch)) > 0) {
  2457. hexLength = tmp;
  2458. hexResult = 0;
  2459. for (; hexLength > 0; hexLength--) {
  2460. ch = state.input.charCodeAt(++state.position);
  2461. if ((tmp = fromHexCode(ch)) >= 0) {
  2462. hexResult = (hexResult << 4) + tmp;
  2463. } else {
  2464. throwError(state, 'expected hexadecimal character');
  2465. }
  2466. }
  2467. state.result += charFromCodepoint(hexResult);
  2468. state.position++;
  2469. } else {
  2470. throwError(state, 'unknown escape sequence');
  2471. }
  2472. captureStart = captureEnd = state.position;
  2473. } else if (is_EOL(ch)) {
  2474. captureSegment(state, captureStart, captureEnd, true);
  2475. writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
  2476. captureStart = captureEnd = state.position;
  2477. } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
  2478. throwError(state, 'unexpected end of the document within a double quoted scalar');
  2479. } else {
  2480. state.position++;
  2481. captureEnd = state.position;
  2482. }
  2483. }
  2484. throwError(state, 'unexpected end of the stream within a double quoted scalar');
  2485. }
  2486. function readFlowCollection(state, nodeIndent) {
  2487. var readNext = true,
  2488. _line,
  2489. _tag = state.tag,
  2490. _result,
  2491. _anchor = state.anchor,
  2492. following,
  2493. terminator,
  2494. isPair,
  2495. isExplicitPair,
  2496. isMapping,
  2497. overridableKeys = {},
  2498. keyNode,
  2499. keyTag,
  2500. valueNode,
  2501. ch;
  2502. ch = state.input.charCodeAt(state.position);
  2503. if (ch === 0x5B/* [ */) {
  2504. terminator = 0x5D;
  2505. isMapping = false;
  2506. _result = [];
  2507. } else if (ch === 0x7B/* { */) {
  2508. terminator = 0x7D;
  2509. isMapping = true;
  2510. _result = {};
  2511. } else {
  2512. return false;
  2513. }
  2514. if (state.anchor !== null) {
  2515. state.anchorMap[state.anchor] = _result;
  2516. }
  2517. ch = state.input.charCodeAt(++state.position);
  2518. while (ch !== 0) {
  2519. skipSeparationSpace(state, true, nodeIndent);
  2520. ch = state.input.charCodeAt(state.position);
  2521. if (ch === terminator) {
  2522. state.position++;
  2523. state.tag = _tag;
  2524. state.anchor = _anchor;
  2525. state.kind = isMapping ? 'mapping' : 'sequence';
  2526. state.result = _result;
  2527. return true;
  2528. } else if (!readNext) {
  2529. throwError(state, 'missed comma between flow collection entries');
  2530. }
  2531. keyTag = keyNode = valueNode = null;
  2532. isPair = isExplicitPair = false;
  2533. if (ch === 0x3F/* ? */) {
  2534. following = state.input.charCodeAt(state.position + 1);
  2535. if (is_WS_OR_EOL(following)) {
  2536. isPair = isExplicitPair = true;
  2537. state.position++;
  2538. skipSeparationSpace(state, true, nodeIndent);
  2539. }
  2540. }
  2541. _line = state.line;
  2542. composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
  2543. keyTag = state.tag;
  2544. keyNode = state.result;
  2545. skipSeparationSpace(state, true, nodeIndent);
  2546. ch = state.input.charCodeAt(state.position);
  2547. if ((isExplicitPair || state.line === _line) && ch === 0x3A/* : */) {
  2548. isPair = true;
  2549. ch = state.input.charCodeAt(++state.position);
  2550. skipSeparationSpace(state, true, nodeIndent);
  2551. composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
  2552. valueNode = state.result;
  2553. }
  2554. if (isMapping) {
  2555. storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode);
  2556. } else if (isPair) {
  2557. _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode));
  2558. } else {
  2559. _result.push(keyNode);
  2560. }
  2561. skipSeparationSpace(state, true, nodeIndent);
  2562. ch = state.input.charCodeAt(state.position);
  2563. if (ch === 0x2C/* , */) {
  2564. readNext = true;
  2565. ch = state.input.charCodeAt(++state.position);
  2566. } else {
  2567. readNext = false;
  2568. }
  2569. }
  2570. throwError(state, 'unexpected end of the stream within a flow collection');
  2571. }
  2572. function readBlockScalar(state, nodeIndent) {
  2573. var captureStart,
  2574. folding,
  2575. chomping = CHOMPING_CLIP,
  2576. didReadContent = false,
  2577. detectedIndent = false,
  2578. textIndent = nodeIndent,
  2579. emptyLines = 0,
  2580. atMoreIndented = false,
  2581. tmp,
  2582. ch;
  2583. ch = state.input.charCodeAt(state.position);
  2584. if (ch === 0x7C/* | */) {
  2585. folding = false;
  2586. } else if (ch === 0x3E/* > */) {
  2587. folding = true;
  2588. } else {
  2589. return false;
  2590. }
  2591. state.kind = 'scalar';
  2592. state.result = '';
  2593. while (ch !== 0) {
  2594. ch = state.input.charCodeAt(++state.position);
  2595. if (ch === 0x2B/* + */ || ch === 0x2D/* - */) {
  2596. if (CHOMPING_CLIP === chomping) {
  2597. chomping = (ch === 0x2B/* + */) ? CHOMPING_KEEP : CHOMPING_STRIP;
  2598. } else {
  2599. throwError(state, 'repeat of a chomping mode identifier');
  2600. }
  2601. } else if ((tmp = fromDecimalCode(ch)) >= 0) {
  2602. if (tmp === 0) {
  2603. throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one');
  2604. } else if (!detectedIndent) {
  2605. textIndent = nodeIndent + tmp - 1;
  2606. detectedIndent = true;
  2607. } else {
  2608. throwError(state, 'repeat of an indentation width identifier');
  2609. }
  2610. } else {
  2611. break;
  2612. }
  2613. }
  2614. if (is_WHITE_SPACE(ch)) {
  2615. do { ch = state.input.charCodeAt(++state.position); }
  2616. while (is_WHITE_SPACE(ch));
  2617. if (ch === 0x23/* # */) {
  2618. do { ch = state.input.charCodeAt(++state.position); }
  2619. while (!is_EOL(ch) && (ch !== 0));
  2620. }
  2621. }
  2622. while (ch !== 0) {
  2623. readLineBreak(state);
  2624. state.lineIndent = 0;
  2625. ch = state.input.charCodeAt(state.position);
  2626. while ((!detectedIndent || state.lineIndent < textIndent) &&
  2627. (ch === 0x20/* Space */)) {
  2628. state.lineIndent++;
  2629. ch = state.input.charCodeAt(++state.position);
  2630. }
  2631. if (!detectedIndent && state.lineIndent > textIndent) {
  2632. textIndent = state.lineIndent;
  2633. }
  2634. if (is_EOL(ch)) {
  2635. emptyLines++;
  2636. continue;
  2637. }
  2638. if (state.lineIndent < textIndent) {
  2639. if (chomping === CHOMPING_KEEP) {
  2640. state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
  2641. } else if (chomping === CHOMPING_CLIP) {
  2642. if (didReadContent) { // i.e. only if the scalar is not empty.
  2643. state.result += '\n';
  2644. }
  2645. }
  2646. break;
  2647. }
  2648. if (folding) {
  2649. if (is_WHITE_SPACE(ch)) {
  2650. atMoreIndented = true;
  2651. state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
  2652. } else if (atMoreIndented) {
  2653. atMoreIndented = false;
  2654. state.result += common.repeat('\n', emptyLines + 1);
  2655. } else if (emptyLines === 0) {
  2656. if (didReadContent) { // i.e. only if we have already read some scalar content.
  2657. state.result += ' ';
  2658. }
  2659. } else {
  2660. state.result += common.repeat('\n', emptyLines);
  2661. }
  2662. } else {
  2663. state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
  2664. }
  2665. didReadContent = true;
  2666. detectedIndent = true;
  2667. emptyLines = 0;
  2668. captureStart = state.position;
  2669. while (!is_EOL(ch) && (ch !== 0)) {
  2670. ch = state.input.charCodeAt(++state.position);
  2671. }
  2672. captureSegment(state, captureStart, state.position, false);
  2673. }
  2674. return true;
  2675. }
  2676. function readBlockSequence(state, nodeIndent) {
  2677. var _line,
  2678. _tag = state.tag,
  2679. _anchor = state.anchor,
  2680. _result = [],
  2681. following,
  2682. detected = false,
  2683. ch;
  2684. if (state.anchor !== null) {
  2685. state.anchorMap[state.anchor] = _result;
  2686. }
  2687. ch = state.input.charCodeAt(state.position);
  2688. while (ch !== 0) {
  2689. if (ch !== 0x2D/* - */) {
  2690. break;
  2691. }
  2692. following = state.input.charCodeAt(state.position + 1);
  2693. if (!is_WS_OR_EOL(following)) {
  2694. break;
  2695. }
  2696. detected = true;
  2697. state.position++;
  2698. if (skipSeparationSpace(state, true, -1)) {
  2699. if (state.lineIndent <= nodeIndent) {
  2700. _result.push(null);
  2701. ch = state.input.charCodeAt(state.position);
  2702. continue;
  2703. }
  2704. }
  2705. _line = state.line;
  2706. composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
  2707. _result.push(state.result);
  2708. skipSeparationSpace(state, true, -1);
  2709. ch = state.input.charCodeAt(state.position);
  2710. if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) {
  2711. throwError(state, 'bad indentation of a sequence entry');
  2712. } else if (state.lineIndent < nodeIndent) {
  2713. break;
  2714. }
  2715. }
  2716. if (detected) {
  2717. state.tag = _tag;
  2718. state.anchor = _anchor;
  2719. state.kind = 'sequence';
  2720. state.result = _result;
  2721. return true;
  2722. }
  2723. return false;
  2724. }
  2725. function readBlockMapping(state, nodeIndent, flowIndent) {
  2726. var following,
  2727. allowCompact,
  2728. _line,
  2729. _pos,
  2730. _tag = state.tag,
  2731. _anchor = state.anchor,
  2732. _result = {},
  2733. overridableKeys = {},
  2734. keyTag = null,
  2735. keyNode = null,
  2736. valueNode = null,
  2737. atExplicitKey = false,
  2738. detected = false,
  2739. ch;
  2740. if (state.anchor !== null) {
  2741. state.anchorMap[state.anchor] = _result;
  2742. }
  2743. ch = state.input.charCodeAt(state.position);
  2744. while (ch !== 0) {
  2745. following = state.input.charCodeAt(state.position + 1);
  2746. _line = state.line; // Save the current line.
  2747. _pos = state.position;
  2748. if ((ch === 0x3F/* ? */ || ch === 0x3A/* : */) && is_WS_OR_EOL(following)) {
  2749. if (ch === 0x3F/* ? */) {
  2750. if (atExplicitKey) {
  2751. storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
  2752. keyTag = keyNode = valueNode = null;
  2753. }
  2754. detected = true;
  2755. atExplicitKey = true;
  2756. allowCompact = true;
  2757. } else if (atExplicitKey) {
  2758. atExplicitKey = false;
  2759. allowCompact = true;
  2760. } else {
  2761. throwError(state, 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line');
  2762. }
  2763. state.position += 1;
  2764. ch = following;
  2765. } else if (composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
  2766. if (state.line === _line) {
  2767. ch = state.input.charCodeAt(state.position);
  2768. while (is_WHITE_SPACE(ch)) {
  2769. ch = state.input.charCodeAt(++state.position);
  2770. }
  2771. if (ch === 0x3A/* : */) {
  2772. ch = state.input.charCodeAt(++state.position);
  2773. if (!is_WS_OR_EOL(ch)) {
  2774. throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping');
  2775. }
  2776. if (atExplicitKey) {
  2777. storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
  2778. keyTag = keyNode = valueNode = null;
  2779. }
  2780. detected = true;
  2781. atExplicitKey = false;
  2782. allowCompact = false;
  2783. keyTag = state.tag;
  2784. keyNode = state.result;
  2785. } else if (detected) {
  2786. throwError(state, 'can not read an implicit mapping pair; a colon is missed');
  2787. } else {
  2788. state.tag = _tag;
  2789. state.anchor = _anchor;
  2790. return true; // Keep the result of `composeNode`.
  2791. }
  2792. } else if (detected) {
  2793. throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key');
  2794. } else {
  2795. state.tag = _tag;
  2796. state.anchor = _anchor;
  2797. return true; // Keep the result of `composeNode`.
  2798. }
  2799. } else {
  2800. break; // Reading is done. Go to the epilogue.
  2801. }
  2802. if (state.line === _line || state.lineIndent > nodeIndent) {
  2803. if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
  2804. if (atExplicitKey) {
  2805. keyNode = state.result;
  2806. } else {
  2807. valueNode = state.result;
  2808. }
  2809. }
  2810. if (!atExplicitKey) {
  2811. storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _pos);
  2812. keyTag = keyNode = valueNode = null;
  2813. }
  2814. skipSeparationSpace(state, true, -1);
  2815. ch = state.input.charCodeAt(state.position);
  2816. }
  2817. if (state.lineIndent > nodeIndent && (ch !== 0)) {
  2818. throwError(state, 'bad indentation of a mapping entry');
  2819. } else if (state.lineIndent < nodeIndent) {
  2820. break;
  2821. }
  2822. }
  2823. if (atExplicitKey) {
  2824. storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
  2825. }
  2826. if (detected) {
  2827. state.tag = _tag;
  2828. state.anchor = _anchor;
  2829. state.kind = 'mapping';
  2830. state.result = _result;
  2831. }
  2832. return detected;
  2833. }
  2834. function readTagProperty(state) {
  2835. var _position,
  2836. isVerbatim = false,
  2837. isNamed = false,
  2838. tagHandle,
  2839. tagName,
  2840. ch;
  2841. ch = state.input.charCodeAt(state.position);
  2842. if (ch !== 0x21/* ! */) return false;
  2843. if (state.tag !== null) {
  2844. throwError(state, 'duplication of a tag property');
  2845. }
  2846. ch = state.input.charCodeAt(++state.position);
  2847. if (ch === 0x3C/* < */) {
  2848. isVerbatim = true;
  2849. ch = state.input.charCodeAt(++state.position);
  2850. } else if (ch === 0x21/* ! */) {
  2851. isNamed = true;
  2852. tagHandle = '!!';
  2853. ch = state.input.charCodeAt(++state.position);
  2854. } else {
  2855. tagHandle = '!';
  2856. }
  2857. _position = state.position;
  2858. if (isVerbatim) {
  2859. do { ch = state.input.charCodeAt(++state.position); }
  2860. while (ch !== 0 && ch !== 0x3E/* > */);
  2861. if (state.position < state.length) {
  2862. tagName = state.input.slice(_position, state.position);
  2863. ch = state.input.charCodeAt(++state.position);
  2864. } else {
  2865. throwError(state, 'unexpected end of the stream within a verbatim tag');
  2866. }
  2867. } else {
  2868. while (ch !== 0 && !is_WS_OR_EOL(ch)) {
  2869. if (ch === 0x21/* ! */) {
  2870. if (!isNamed) {
  2871. tagHandle = state.input.slice(_position - 1, state.position + 1);
  2872. if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
  2873. throwError(state, 'named tag handle cannot contain such characters');
  2874. }
  2875. isNamed = true;
  2876. _position = state.position + 1;
  2877. } else {
  2878. throwError(state, 'tag suffix cannot contain exclamation marks');
  2879. }
  2880. }
  2881. ch = state.input.charCodeAt(++state.position);
  2882. }
  2883. tagName = state.input.slice(_position, state.position);
  2884. if (PATTERN_FLOW_INDICATORS.test(tagName)) {
  2885. throwError(state, 'tag suffix cannot contain flow indicator characters');
  2886. }
  2887. }
  2888. if (tagName && !PATTERN_TAG_URI.test(tagName)) {
  2889. throwError(state, 'tag name cannot contain such characters: ' + tagName);
  2890. }
  2891. if (isVerbatim) {
  2892. state.tag = tagName;
  2893. } else if (_hasOwnProperty.call(state.tagMap, tagHandle)) {
  2894. state.tag = state.tagMap[tagHandle] + tagName;
  2895. } else if (tagHandle === '!') {
  2896. state.tag = '!' + tagName;
  2897. } else if (tagHandle === '!!') {
  2898. state.tag = 'tag:yaml.org,2002:' + tagName;
  2899. } else {
  2900. throwError(state, 'undeclared tag handle "' + tagHandle + '"');
  2901. }
  2902. return true;
  2903. }
  2904. function readAnchorProperty(state) {
  2905. var _position,
  2906. ch;
  2907. ch = state.input.charCodeAt(state.position);
  2908. if (ch !== 0x26/* & */) return false;
  2909. if (state.anchor !== null) {
  2910. throwError(state, 'duplication of an anchor property');
  2911. }
  2912. ch = state.input.charCodeAt(++state.position);
  2913. _position = state.position;
  2914. while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
  2915. ch = state.input.charCodeAt(++state.position);
  2916. }
  2917. if (state.position === _position) {
  2918. throwError(state, 'name of an anchor node must contain at least one character');
  2919. }
  2920. state.anchor = state.input.slice(_position, state.position);
  2921. return true;
  2922. }
  2923. function readAlias(state) {
  2924. var _position, alias,
  2925. ch;
  2926. ch = state.input.charCodeAt(state.position);
  2927. if (ch !== 0x2A/* * */) return false;
  2928. ch = state.input.charCodeAt(++state.position);
  2929. _position = state.position;
  2930. while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
  2931. ch = state.input.charCodeAt(++state.position);
  2932. }
  2933. if (state.position === _position) {
  2934. throwError(state, 'name of an alias node must contain at least one character');
  2935. }
  2936. alias = state.input.slice(_position, state.position);
  2937. if (!state.anchorMap.hasOwnProperty(alias)) {
  2938. throwError(state, 'unidentified alias "' + alias + '"');
  2939. }
  2940. state.result = state.anchorMap[alias];
  2941. skipSeparationSpace(state, true, -1);
  2942. return true;
  2943. }
  2944. function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
  2945. var allowBlockStyles,
  2946. allowBlockScalars,
  2947. allowBlockCollections,
  2948. indentStatus = 1, // 1: this>parent, 0: this=parent, -1: this<parent
  2949. atNewLine = false,
  2950. hasContent = false,
  2951. typeIndex,
  2952. typeQuantity,
  2953. type,
  2954. flowIndent,
  2955. blockIndent;
  2956. if (state.listener !== null) {
  2957. state.listener('open', state);
  2958. }
  2959. state.tag = null;
  2960. state.anchor = null;
  2961. state.kind = null;
  2962. state.result = null;
  2963. allowBlockStyles = allowBlockScalars = allowBlockCollections =
  2964. CONTEXT_BLOCK_OUT === nodeContext ||
  2965. CONTEXT_BLOCK_IN === nodeContext;
  2966. if (allowToSeek) {
  2967. if (skipSeparationSpace(state, true, -1)) {
  2968. atNewLine = true;
  2969. if (state.lineIndent > parentIndent) {
  2970. indentStatus = 1;
  2971. } else if (state.lineIndent === parentIndent) {
  2972. indentStatus = 0;
  2973. } else if (state.lineIndent < parentIndent) {
  2974. indentStatus = -1;
  2975. }
  2976. }
  2977. }
  2978. if (indentStatus === 1) {
  2979. while (readTagProperty(state) || readAnchorProperty(state)) {
  2980. if (skipSeparationSpace(state, true, -1)) {
  2981. atNewLine = true;
  2982. allowBlockCollections = allowBlockStyles;
  2983. if (state.lineIndent > parentIndent) {
  2984. indentStatus = 1;
  2985. } else if (state.lineIndent === parentIndent) {
  2986. indentStatus = 0;
  2987. } else if (state.lineIndent < parentIndent) {
  2988. indentStatus = -1;
  2989. }
  2990. } else {
  2991. allowBlockCollections = false;
  2992. }
  2993. }
  2994. }
  2995. if (allowBlockCollections) {
  2996. allowBlockCollections = atNewLine || allowCompact;
  2997. }
  2998. if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
  2999. if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
  3000. flowIndent = parentIndent;
  3001. } else {
  3002. flowIndent = parentIndent + 1;
  3003. }
  3004. blockIndent = state.position - state.lineStart;
  3005. if (indentStatus === 1) {
  3006. if (allowBlockCollections &&
  3007. (readBlockSequence(state, blockIndent) ||
  3008. readBlockMapping(state, blockIndent, flowIndent)) ||
  3009. readFlowCollection(state, flowIndent)) {
  3010. hasContent = true;
  3011. } else {
  3012. if ((allowBlockScalars && readBlockScalar(state, flowIndent)) ||
  3013. readSingleQuotedScalar(state, flowIndent) ||
  3014. readDoubleQuotedScalar(state, flowIndent)) {
  3015. hasContent = true;
  3016. } else if (readAlias(state)) {
  3017. hasContent = true;
  3018. if (state.tag !== null || state.anchor !== null) {
  3019. throwError(state, 'alias node should not have any properties');
  3020. }
  3021. } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
  3022. hasContent = true;
  3023. if (state.tag === null) {
  3024. state.tag = '?';
  3025. }
  3026. }
  3027. if (state.anchor !== null) {
  3028. state.anchorMap[state.anchor] = state.result;
  3029. }
  3030. }
  3031. } else if (indentStatus === 0) {
  3032. hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
  3033. }
  3034. }
  3035. if (state.tag !== null && state.tag !== '!') {
  3036. if (state.tag === '?') {
  3037. for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
  3038. type = state.implicitTypes[typeIndex];
  3039. if (type.resolve(state.result)) { // `state.result` updated in resolver if matched
  3040. state.result = type.construct(state.result);
  3041. state.tag = type.tag;
  3042. if (state.anchor !== null) {
  3043. state.anchorMap[state.anchor] = state.result;
  3044. }
  3045. break;
  3046. }
  3047. }
  3048. } else if (_hasOwnProperty.call(state.typeMap[state.kind || 'fallback'], state.tag)) {
  3049. type = state.typeMap[state.kind || 'fallback'][state.tag];
  3050. if (state.result !== null && type.kind !== state.kind) {
  3051. throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"');
  3052. }
  3053. if (!type.resolve(state.result)) { // `state.result` updated in resolver if matched
  3054. throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag');
  3055. } else {
  3056. state.result = type.construct(state.result);
  3057. if (state.anchor !== null) {
  3058. state.anchorMap[state.anchor] = state.result;
  3059. }
  3060. }
  3061. } else {
  3062. throwError(state, 'unknown tag !<' + state.tag + '>');
  3063. }
  3064. }
  3065. if (state.listener !== null) {
  3066. state.listener('close', state);
  3067. }
  3068. return state.tag !== null || state.anchor !== null || hasContent;
  3069. }
  3070. function readDocument(state) {
  3071. var documentStart = state.position,
  3072. _position,
  3073. directiveName,
  3074. directiveArgs,
  3075. hasDirectives = false,
  3076. ch;
  3077. state.version = null;
  3078. state.checkLineBreaks = state.legacy;
  3079. state.tagMap = {};
  3080. state.anchorMap = {};
  3081. while ((ch = state.input.charCodeAt(state.position)) !== 0) {
  3082. skipSeparationSpace(state, true, -1);
  3083. ch = state.input.charCodeAt(state.position);
  3084. if (state.lineIndent > 0 || ch !== 0x25/* % */) {
  3085. break;
  3086. }
  3087. hasDirectives = true;
  3088. ch = state.input.charCodeAt(++state.position);
  3089. _position = state.position;
  3090. while (ch !== 0 && !is_WS_OR_EOL(ch)) {
  3091. ch = state.input.charCodeAt(++state.position);
  3092. }
  3093. directiveName = state.input.slice(_position, state.position);
  3094. directiveArgs = [];
  3095. if (directiveName.length < 1) {
  3096. throwError(state, 'directive name must not be less than one character in length');
  3097. }
  3098. while (ch !== 0) {
  3099. while (is_WHITE_SPACE(ch)) {
  3100. ch = state.input.charCodeAt(++state.position);
  3101. }
  3102. if (ch === 0x23/* # */) {
  3103. do { ch = state.input.charCodeAt(++state.position); }
  3104. while (ch !== 0 && !is_EOL(ch));
  3105. break;
  3106. }
  3107. if (is_EOL(ch)) break;
  3108. _position = state.position;
  3109. while (ch !== 0 && !is_WS_OR_EOL(ch)) {
  3110. ch = state.input.charCodeAt(++state.position);
  3111. }
  3112. directiveArgs.push(state.input.slice(_position, state.position));
  3113. }
  3114. if (ch !== 0) readLineBreak(state);
  3115. if (_hasOwnProperty.call(directiveHandlers, directiveName)) {
  3116. directiveHandlers[directiveName](state, directiveName, directiveArgs);
  3117. } else {
  3118. throwWarning(state, 'unknown document directive "' + directiveName + '"');
  3119. }
  3120. }
  3121. skipSeparationSpace(state, true, -1);
  3122. if (state.lineIndent === 0 &&
  3123. state.input.charCodeAt(state.position) === 0x2D/* - */ &&
  3124. state.input.charCodeAt(state.position + 1) === 0x2D/* - */ &&
  3125. state.input.charCodeAt(state.position + 2) === 0x2D/* - */) {
  3126. state.position += 3;
  3127. skipSeparationSpace(state, true, -1);
  3128. } else if (hasDirectives) {
  3129. throwError(state, 'directives end mark is expected');
  3130. }
  3131. composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
  3132. skipSeparationSpace(state, true, -1);
  3133. if (state.checkLineBreaks &&
  3134. PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
  3135. throwWarning(state, 'non-ASCII line breaks are interpreted as content');
  3136. }
  3137. state.documents.push(state.result);
  3138. if (state.position === state.lineStart && testDocumentSeparator(state)) {
  3139. if (state.input.charCodeAt(state.position) === 0x2E/* . */) {
  3140. state.position += 3;
  3141. skipSeparationSpace(state, true, -1);
  3142. }
  3143. return;
  3144. }
  3145. if (state.position < (state.length - 1)) {
  3146. throwError(state, 'end of the stream or a document separator is expected');
  3147. } else {
  3148. return;
  3149. }
  3150. }
  3151. function loadDocuments(input, options) {
  3152. input = String(input);
  3153. options = options || {};
  3154. if (input.length !== 0) {
  3155. if (input.charCodeAt(input.length - 1) !== 0x0A/* LF */ &&
  3156. input.charCodeAt(input.length - 1) !== 0x0D/* CR */) {
  3157. input += '\n';
  3158. }
  3159. if (input.charCodeAt(0) === 0xFEFF) {
  3160. input = input.slice(1);
  3161. }
  3162. }
  3163. var state = new State(input, options);
  3164. state.input += '\0';
  3165. while (state.input.charCodeAt(state.position) === 0x20/* Space */) {
  3166. state.lineIndent += 1;
  3167. state.position += 1;
  3168. }
  3169. while (state.position < (state.length - 1)) {
  3170. readDocument(state);
  3171. }
  3172. return state.documents;
  3173. }
  3174. function loadAll(input, iterator, options) {
  3175. var documents = loadDocuments(input, options), index, length;
  3176. if (typeof iterator !== 'function') {
  3177. return documents;
  3178. }
  3179. for (index = 0, length = documents.length; index < length; index += 1) {
  3180. iterator(documents[index]);
  3181. }
  3182. }
  3183. function load(input, options) {
  3184. var documents = loadDocuments(input, options);
  3185. if (documents.length === 0) {
  3186. return undefined;
  3187. } else if (documents.length === 1) {
  3188. return documents[0];
  3189. }
  3190. throw new YAMLException('expected a single document in the stream, but found more');
  3191. }
  3192. function safeLoadAll(input, output, options) {
  3193. if (typeof output === 'function') {
  3194. loadAll(input, output, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
  3195. } else {
  3196. return loadAll(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
  3197. }
  3198. }
  3199. function safeLoad(input, options) {
  3200. return load(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
  3201. }
  3202. module.exports.loadAll = loadAll;
  3203. module.exports.load = load;
  3204. module.exports.safeLoadAll = safeLoadAll;
  3205. module.exports.safeLoad = safeLoad;
  3206. },{"./common":5,"./exception":7,"./mark":9,"./schema/default_full":12,"./schema/default_safe":13}],9:[function(require,module,exports){
  3207. 'use strict';
  3208. var common = require('./common');
  3209. function Mark(name, buffer, position, line, column) {
  3210. this.name = name;
  3211. this.buffer = buffer;
  3212. this.position = position;
  3213. this.line = line;
  3214. this.column = column;
  3215. }
  3216. Mark.prototype.getSnippet = function getSnippet(indent, maxLength) {
  3217. var head, start, tail, end, snippet;
  3218. if (!this.buffer) return null;
  3219. indent = indent || 4;
  3220. maxLength = maxLength || 75;
  3221. head = '';
  3222. start = this.position;
  3223. while (start > 0 && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(start - 1)) === -1) {
  3224. start -= 1;
  3225. if (this.position - start > (maxLength / 2 - 1)) {
  3226. head = ' ... ';
  3227. start += 5;
  3228. break;
  3229. }
  3230. }
  3231. tail = '';
  3232. end = this.position;
  3233. while (end < this.buffer.length && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(end)) === -1) {
  3234. end += 1;
  3235. if (end - this.position > (maxLength / 2 - 1)) {
  3236. tail = ' ... ';
  3237. end -= 5;
  3238. break;
  3239. }
  3240. }
  3241. snippet = this.buffer.slice(start, end);
  3242. return common.repeat(' ', indent) + head + snippet + tail + '\n' +
  3243. common.repeat(' ', indent + this.position - start + head.length) + '^';
  3244. };
  3245. Mark.prototype.toString = function toString(compact) {
  3246. var snippet, where = '';
  3247. if (this.name) {
  3248. where += 'in "' + this.name + '" ';
  3249. }
  3250. where += 'at line ' + (this.line + 1) + ', column ' + (this.column + 1);
  3251. if (!compact) {
  3252. snippet = this.getSnippet();
  3253. if (snippet) {
  3254. where += ':\n' + snippet;
  3255. }
  3256. }
  3257. return where;
  3258. };
  3259. module.exports = Mark;
  3260. },{"./common":5}],10:[function(require,module,exports){
  3261. 'use strict';
  3262. var common = require('./common');
  3263. var YAMLException = require('./exception');
  3264. var Type = require('./type');
  3265. function compileList(schema, name, result) {
  3266. var exclude = [];
  3267. schema.include.forEach(function (includedSchema) {
  3268. result = compileList(includedSchema, name, result);
  3269. });
  3270. schema[name].forEach(function (currentType) {
  3271. result.forEach(function (previousType, previousIndex) {
  3272. if (previousType.tag === currentType.tag && previousType.kind === currentType.kind) {
  3273. exclude.push(previousIndex);
  3274. }
  3275. });
  3276. result.push(currentType);
  3277. });
  3278. return result.filter(function (type, index) {
  3279. return exclude.indexOf(index) === -1;
  3280. });
  3281. }
  3282. function compileMap(/* lists... */) {
  3283. var result = {
  3284. scalar: {},
  3285. sequence: {},
  3286. mapping: {},
  3287. fallback: {}
  3288. }, index, length;
  3289. function collectType(type) {
  3290. result[type.kind][type.tag] = result['fallback'][type.tag] = type;
  3291. }
  3292. for (index = 0, length = arguments.length; index < length; index += 1) {
  3293. arguments[index].forEach(collectType);
  3294. }
  3295. return result;
  3296. }
  3297. function Schema(definition) {
  3298. this.include = definition.include || [];
  3299. this.implicit = definition.implicit || [];
  3300. this.explicit = definition.explicit || [];
  3301. this.implicit.forEach(function (type) {
  3302. if (type.loadKind && type.loadKind !== 'scalar') {
  3303. throw new YAMLException('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.');
  3304. }
  3305. });
  3306. this.compiledImplicit = compileList(this, 'implicit', []);
  3307. this.compiledExplicit = compileList(this, 'explicit', []);
  3308. this.compiledTypeMap = compileMap(this.compiledImplicit, this.compiledExplicit);
  3309. }
  3310. Schema.DEFAULT = null;
  3311. Schema.create = function createSchema() {
  3312. var schemas, types;
  3313. switch (arguments.length) {
  3314. case 1:
  3315. schemas = Schema.DEFAULT;
  3316. types = arguments[0];
  3317. break;
  3318. case 2:
  3319. schemas = arguments[0];
  3320. types = arguments[1];
  3321. break;
  3322. default:
  3323. throw new YAMLException('Wrong number of arguments for Schema.create function');
  3324. }
  3325. schemas = common.toArray(schemas);
  3326. types = common.toArray(types);
  3327. if (!schemas.every(function (schema) { return schema instanceof Schema; })) {
  3328. throw new YAMLException('Specified list of super schemas (or a single Schema object) contains a non-Schema object.');
  3329. }
  3330. if (!types.every(function (type) { return type instanceof Type; })) {
  3331. throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.');
  3332. }
  3333. return new Schema({
  3334. include: schemas,
  3335. explicit: types
  3336. });
  3337. };
  3338. module.exports = Schema;
  3339. },{"./common":5,"./exception":7,"./type":16}],11:[function(require,module,exports){
  3340. 'use strict';
  3341. var Schema = require('../schema');
  3342. module.exports = new Schema({
  3343. include: [
  3344. require('./json')
  3345. ]
  3346. });
  3347. },{"../schema":10,"./json":15}],12:[function(require,module,exports){
  3348. 'use strict';
  3349. var Schema = require('../schema');
  3350. module.exports = Schema.DEFAULT = new Schema({
  3351. include: [
  3352. require('./default_safe')
  3353. ],
  3354. explicit: [
  3355. require('../type/js/undefined'),
  3356. require('../type/js/regexp'),
  3357. require('../type/js/function')
  3358. ]
  3359. });
  3360. },{"../schema":10,"../type/js/function":21,"../type/js/regexp":22,"../type/js/undefined":23,"./default_safe":13}],13:[function(require,module,exports){
  3361. 'use strict';
  3362. var Schema = require('../schema');
  3363. module.exports = new Schema({
  3364. include: [
  3365. require('./core')
  3366. ],
  3367. implicit: [
  3368. require('../type/timestamp'),
  3369. require('../type/merge')
  3370. ],
  3371. explicit: [
  3372. require('../type/binary'),
  3373. require('../type/omap'),
  3374. require('../type/pairs'),
  3375. require('../type/set')
  3376. ]
  3377. });
  3378. },{"../schema":10,"../type/binary":17,"../type/merge":25,"../type/omap":27,"../type/pairs":28,"../type/set":30,"../type/timestamp":32,"./core":11}],14:[function(require,module,exports){
  3379. 'use strict';
  3380. var Schema = require('../schema');
  3381. module.exports = new Schema({
  3382. explicit: [
  3383. require('../type/str'),
  3384. require('../type/seq'),
  3385. require('../type/map')
  3386. ]
  3387. });
  3388. },{"../schema":10,"../type/map":24,"../type/seq":29,"../type/str":31}],15:[function(require,module,exports){
  3389. 'use strict';
  3390. var Schema = require('../schema');
  3391. module.exports = new Schema({
  3392. include: [
  3393. require('./failsafe')
  3394. ],
  3395. implicit: [
  3396. require('../type/null'),
  3397. require('../type/bool'),
  3398. require('../type/int'),
  3399. require('../type/float')
  3400. ]
  3401. });
  3402. },{"../schema":10,"../type/bool":18,"../type/float":19,"../type/int":20,"../type/null":26,"./failsafe":14}],16:[function(require,module,exports){
  3403. 'use strict';
  3404. var YAMLException = require('./exception');
  3405. var TYPE_CONSTRUCTOR_OPTIONS = [
  3406. 'kind',
  3407. 'resolve',
  3408. 'construct',
  3409. 'instanceOf',
  3410. 'predicate',
  3411. 'represent',
  3412. 'defaultStyle',
  3413. 'styleAliases'
  3414. ];
  3415. var YAML_NODE_KINDS = [
  3416. 'scalar',
  3417. 'sequence',
  3418. 'mapping'
  3419. ];
  3420. function compileStyleAliases(map) {
  3421. var result = {};
  3422. if (map !== null) {
  3423. Object.keys(map).forEach(function (style) {
  3424. map[style].forEach(function (alias) {
  3425. result[String(alias)] = style;
  3426. });
  3427. });
  3428. }
  3429. return result;
  3430. }
  3431. function Type(tag, options) {
  3432. options = options || {};
  3433. Object.keys(options).forEach(function (name) {
  3434. if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
  3435. throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
  3436. }
  3437. });
  3438. this.tag = tag;
  3439. this.kind = options['kind'] || null;
  3440. this.resolve = options['resolve'] || function () { return true; };
  3441. this.construct = options['construct'] || function (data) { return data; };
  3442. this.instanceOf = options['instanceOf'] || null;
  3443. this.predicate = options['predicate'] || null;
  3444. this.represent = options['represent'] || null;
  3445. this.defaultStyle = options['defaultStyle'] || null;
  3446. this.styleAliases = compileStyleAliases(options['styleAliases'] || null);
  3447. if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
  3448. throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
  3449. }
  3450. }
  3451. module.exports = Type;
  3452. },{"./exception":7}],17:[function(require,module,exports){
  3453. 'use strict';
  3454. var NodeBuffer;
  3455. try {
  3456. var _require = require;
  3457. NodeBuffer = _require('buffer').Buffer;
  3458. } catch (__) {}
  3459. var Type = require('../type');
  3460. var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r';
  3461. function resolveYamlBinary(data) {
  3462. if (data === null) return false;
  3463. var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP;
  3464. for (idx = 0; idx < max; idx++) {
  3465. code = map.indexOf(data.charAt(idx));
  3466. if (code > 64) continue;
  3467. if (code < 0) return false;
  3468. bitlen += 6;
  3469. }
  3470. return (bitlen % 8) === 0;
  3471. }
  3472. function constructYamlBinary(data) {
  3473. var idx, tailbits,
  3474. input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan
  3475. max = input.length,
  3476. map = BASE64_MAP,
  3477. bits = 0,
  3478. result = [];
  3479. for (idx = 0; idx < max; idx++) {
  3480. if ((idx % 4 === 0) && idx) {
  3481. result.push((bits >> 16) & 0xFF);
  3482. result.push((bits >> 8) & 0xFF);
  3483. result.push(bits & 0xFF);
  3484. }
  3485. bits = (bits << 6) | map.indexOf(input.charAt(idx));
  3486. }
  3487. tailbits = (max % 4) * 6;
  3488. if (tailbits === 0) {
  3489. result.push((bits >> 16) & 0xFF);
  3490. result.push((bits >> 8) & 0xFF);
  3491. result.push(bits & 0xFF);
  3492. } else if (tailbits === 18) {
  3493. result.push((bits >> 10) & 0xFF);
  3494. result.push((bits >> 2) & 0xFF);
  3495. } else if (tailbits === 12) {
  3496. result.push((bits >> 4) & 0xFF);
  3497. }
  3498. if (NodeBuffer) {
  3499. return NodeBuffer.from ? NodeBuffer.from(result) : new NodeBuffer(result);
  3500. }
  3501. return result;
  3502. }
  3503. function representYamlBinary(object /*, style*/) {
  3504. var result = '', bits = 0, idx, tail,
  3505. max = object.length,
  3506. map = BASE64_MAP;
  3507. for (idx = 0; idx < max; idx++) {
  3508. if ((idx % 3 === 0) && idx) {
  3509. result += map[(bits >> 18) & 0x3F];
  3510. result += map[(bits >> 12) & 0x3F];
  3511. result += map[(bits >> 6) & 0x3F];
  3512. result += map[bits & 0x3F];
  3513. }
  3514. bits = (bits << 8) + object[idx];
  3515. }
  3516. tail = max % 3;
  3517. if (tail === 0) {
  3518. result += map[(bits >> 18) & 0x3F];
  3519. result += map[(bits >> 12) & 0x3F];
  3520. result += map[(bits >> 6) & 0x3F];
  3521. result += map[bits & 0x3F];
  3522. } else if (tail === 2) {
  3523. result += map[(bits >> 10) & 0x3F];
  3524. result += map[(bits >> 4) & 0x3F];
  3525. result += map[(bits << 2) & 0x3F];
  3526. result += map[64];
  3527. } else if (tail === 1) {
  3528. result += map[(bits >> 2) & 0x3F];
  3529. result += map[(bits << 4) & 0x3F];
  3530. result += map[64];
  3531. result += map[64];
  3532. }
  3533. return result;
  3534. }
  3535. function isBinary(object) {
  3536. return NodeBuffer && NodeBuffer.isBuffer(object);
  3537. }
  3538. module.exports = new Type('tag:yaml.org,2002:binary', {
  3539. kind: 'scalar',
  3540. resolve: resolveYamlBinary,
  3541. construct: constructYamlBinary,
  3542. predicate: isBinary,
  3543. represent: representYamlBinary
  3544. });
  3545. },{"../type":16}],18:[function(require,module,exports){
  3546. 'use strict';
  3547. var Type = require('../type');
  3548. function resolveYamlBoolean(data) {
  3549. if (data === null) return false;
  3550. var max = data.length;
  3551. return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) ||
  3552. (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE'));
  3553. }
  3554. function constructYamlBoolean(data) {
  3555. return data === 'true' ||
  3556. data === 'True' ||
  3557. data === 'TRUE';
  3558. }
  3559. function isBoolean(object) {
  3560. return Object.prototype.toString.call(object) === '[object Boolean]';
  3561. }
  3562. module.exports = new Type('tag:yaml.org,2002:bool', {
  3563. kind: 'scalar',
  3564. resolve: resolveYamlBoolean,
  3565. construct: constructYamlBoolean,
  3566. predicate: isBoolean,
  3567. represent: {
  3568. lowercase: function (object) { return object ? 'true' : 'false'; },
  3569. uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; },
  3570. camelcase: function (object) { return object ? 'True' : 'False'; }
  3571. },
  3572. defaultStyle: 'lowercase'
  3573. });
  3574. },{"../type":16}],19:[function(require,module,exports){
  3575. 'use strict';
  3576. var common = require('../common');
  3577. var Type = require('../type');
  3578. var YAML_FLOAT_PATTERN = new RegExp(
  3579. '^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' +
  3580. '|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' +
  3581. '|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*' +
  3582. '|[-+]?\\.(?:inf|Inf|INF)' +
  3583. '|\\.(?:nan|NaN|NAN))$');
  3584. function resolveYamlFloat(data) {
  3585. if (data === null) return false;
  3586. if (!YAML_FLOAT_PATTERN.test(data) ||
  3587. data[data.length - 1] === '_') {
  3588. return false;
  3589. }
  3590. return true;
  3591. }
  3592. function constructYamlFloat(data) {
  3593. var value, sign, base, digits;
  3594. value = data.replace(/_/g, '').toLowerCase();
  3595. sign = value[0] === '-' ? -1 : 1;
  3596. digits = [];
  3597. if ('+-'.indexOf(value[0]) >= 0) {
  3598. value = value.slice(1);
  3599. }
  3600. if (value === '.inf') {
  3601. return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
  3602. } else if (value === '.nan') {
  3603. return NaN;
  3604. } else if (value.indexOf(':') >= 0) {
  3605. value.split(':').forEach(function (v) {
  3606. digits.unshift(parseFloat(v, 10));
  3607. });
  3608. value = 0.0;
  3609. base = 1;
  3610. digits.forEach(function (d) {
  3611. value += d * base;
  3612. base *= 60;
  3613. });
  3614. return sign * value;
  3615. }
  3616. return sign * parseFloat(value, 10);
  3617. }
  3618. var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
  3619. function representYamlFloat(object, style) {
  3620. var res;
  3621. if (isNaN(object)) {
  3622. switch (style) {
  3623. case 'lowercase': return '.nan';
  3624. case 'uppercase': return '.NAN';
  3625. case 'camelcase': return '.NaN';
  3626. }
  3627. } else if (Number.POSITIVE_INFINITY === object) {
  3628. switch (style) {
  3629. case 'lowercase': return '.inf';
  3630. case 'uppercase': return '.INF';
  3631. case 'camelcase': return '.Inf';
  3632. }
  3633. } else if (Number.NEGATIVE_INFINITY === object) {
  3634. switch (style) {
  3635. case 'lowercase': return '-.inf';
  3636. case 'uppercase': return '-.INF';
  3637. case 'camelcase': return '-.Inf';
  3638. }
  3639. } else if (common.isNegativeZero(object)) {
  3640. return '-0.0';
  3641. }
  3642. res = object.toString(10);
  3643. return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res;
  3644. }
  3645. function isFloat(object) {
  3646. return (Object.prototype.toString.call(object) === '[object Number]') &&
  3647. (object % 1 !== 0 || common.isNegativeZero(object));
  3648. }
  3649. module.exports = new Type('tag:yaml.org,2002:float', {
  3650. kind: 'scalar',
  3651. resolve: resolveYamlFloat,
  3652. construct: constructYamlFloat,
  3653. predicate: isFloat,
  3654. represent: representYamlFloat,
  3655. defaultStyle: 'lowercase'
  3656. });
  3657. },{"../common":5,"../type":16}],20:[function(require,module,exports){
  3658. 'use strict';
  3659. var common = require('../common');
  3660. var Type = require('../type');
  3661. function isHexCode(c) {
  3662. return ((c/* 0 */ >= 0x30) && (c <= 0x39/* 9 */)) ||
  3663. ((c/* A */ >= 0x41) && (c <= 0x46/* F */)) ||
  3664. ((c/* a */ >= 0x61) && (c <= 0x66/* f */));
  3665. }
  3666. function isOctCode(c) {
  3667. return ((c/* 0 */ >= 0x30) && (c <= 0x37/* 7 */));
  3668. }
  3669. function isDecCode(c) {
  3670. return ((c/* 0 */ >= 0x30) && (c <= 0x39/* 9 */));
  3671. }
  3672. function resolveYamlInteger(data) {
  3673. if (data === null) return false;
  3674. var max = data.length,
  3675. index = 0,
  3676. hasDigits = false,
  3677. ch;
  3678. if (!max) return false;
  3679. ch = data[index];
  3680. if (ch === '-' || ch === '+') {
  3681. ch = data[++index];
  3682. }
  3683. if (ch === '0') {
  3684. if (index + 1 === max) return true;
  3685. ch = data[++index];
  3686. if (ch === 'b') {
  3687. index++;
  3688. for (; index < max; index++) {
  3689. ch = data[index];
  3690. if (ch === '_') continue;
  3691. if (ch !== '0' && ch !== '1') return false;
  3692. hasDigits = true;
  3693. }
  3694. return hasDigits && ch !== '_';
  3695. }
  3696. if (ch === 'x') {
  3697. index++;
  3698. for (; index < max; index++) {
  3699. ch = data[index];
  3700. if (ch === '_') continue;
  3701. if (!isHexCode(data.charCodeAt(index))) return false;
  3702. hasDigits = true;
  3703. }
  3704. return hasDigits && ch !== '_';
  3705. }
  3706. for (; index < max; index++) {
  3707. ch = data[index];
  3708. if (ch === '_') continue;
  3709. if (!isOctCode(data.charCodeAt(index))) return false;
  3710. hasDigits = true;
  3711. }
  3712. return hasDigits && ch !== '_';
  3713. }
  3714. if (ch === '_') return false;
  3715. for (; index < max; index++) {
  3716. ch = data[index];
  3717. if (ch === '_') continue;
  3718. if (ch === ':') break;
  3719. if (!isDecCode(data.charCodeAt(index))) {
  3720. return false;
  3721. }
  3722. hasDigits = true;
  3723. }
  3724. if (!hasDigits || ch === '_') return false;
  3725. if (ch !== ':') return true;
  3726. return /^(:[0-5]?[0-9])+$/.test(data.slice(index));
  3727. }
  3728. function constructYamlInteger(data) {
  3729. var value = data, sign = 1, ch, base, digits = [];
  3730. if (value.indexOf('_') !== -1) {
  3731. value = value.replace(/_/g, '');
  3732. }
  3733. ch = value[0];
  3734. if (ch === '-' || ch === '+') {
  3735. if (ch === '-') sign = -1;
  3736. value = value.slice(1);
  3737. ch = value[0];
  3738. }
  3739. if (value === '0') return 0;
  3740. if (ch === '0') {
  3741. if (value[1] === 'b') return sign * parseInt(value.slice(2), 2);
  3742. if (value[1] === 'x') return sign * parseInt(value, 16);
  3743. return sign * parseInt(value, 8);
  3744. }
  3745. if (value.indexOf(':') !== -1) {
  3746. value.split(':').forEach(function (v) {
  3747. digits.unshift(parseInt(v, 10));
  3748. });
  3749. value = 0;
  3750. base = 1;
  3751. digits.forEach(function (d) {
  3752. value += (d * base);
  3753. base *= 60;
  3754. });
  3755. return sign * value;
  3756. }
  3757. return sign * parseInt(value, 10);
  3758. }
  3759. function isInteger(object) {
  3760. return (Object.prototype.toString.call(object)) === '[object Number]' &&
  3761. (object % 1 === 0 && !common.isNegativeZero(object));
  3762. }
  3763. module.exports = new Type('tag:yaml.org,2002:int', {
  3764. kind: 'scalar',
  3765. resolve: resolveYamlInteger,
  3766. construct: constructYamlInteger,
  3767. predicate: isInteger,
  3768. represent: {
  3769. binary: function (obj) { return obj >= 0 ? '0b' + obj.toString(2) : '-0b' + obj.toString(2).slice(1); },
  3770. octal: function (obj) { return obj >= 0 ? '0' + obj.toString(8) : '-0' + obj.toString(8).slice(1); },
  3771. decimal: function (obj) { return obj.toString(10); },
  3772. hexadecimal: function (obj) { return obj >= 0 ? '0x' + obj.toString(16).toUpperCase() : '-0x' + obj.toString(16).toUpperCase().slice(1); }
  3773. },
  3774. defaultStyle: 'decimal',
  3775. styleAliases: {
  3776. binary: [ 2, 'bin' ],
  3777. octal: [ 8, 'oct' ],
  3778. decimal: [ 10, 'dec' ],
  3779. hexadecimal: [ 16, 'hex' ]
  3780. }
  3781. });
  3782. },{"../common":5,"../type":16}],21:[function(require,module,exports){
  3783. 'use strict';
  3784. var esprima;
  3785. try {
  3786. var _require = require;
  3787. esprima = _require('esprima');
  3788. } catch (_) {
  3789. if (typeof window !== 'undefined') esprima = window.esprima;
  3790. }
  3791. var Type = require('../../type');
  3792. function resolveJavascriptFunction(data) {
  3793. if (data === null) return false;
  3794. try {
  3795. var source = '(' + data + ')',
  3796. ast = esprima.parse(source, { range: true });
  3797. if (ast.type !== 'Program' ||
  3798. ast.body.length !== 1 ||
  3799. ast.body[0].type !== 'ExpressionStatement' ||
  3800. (ast.body[0].expression.type !== 'ArrowFunctionExpression' &&
  3801. ast.body[0].expression.type !== 'FunctionExpression')) {
  3802. return false;
  3803. }
  3804. return true;
  3805. } catch (err) {
  3806. return false;
  3807. }
  3808. }
  3809. function constructJavascriptFunction(data) {
  3810. var source = '(' + data + ')',
  3811. ast = esprima.parse(source, { range: true }),
  3812. params = [],
  3813. body;
  3814. if (ast.type !== 'Program' ||
  3815. ast.body.length !== 1 ||
  3816. ast.body[0].type !== 'ExpressionStatement' ||
  3817. (ast.body[0].expression.type !== 'ArrowFunctionExpression' &&
  3818. ast.body[0].expression.type !== 'FunctionExpression')) {
  3819. throw new Error('Failed to resolve function');
  3820. }
  3821. ast.body[0].expression.params.forEach(function (param) {
  3822. params.push(param.name);
  3823. });
  3824. body = ast.body[0].expression.body.range;
  3825. if (ast.body[0].expression.body.type === 'BlockStatement') {
  3826. return new Function(params, source.slice(body[0] + 1, body[1] - 1));
  3827. }
  3828. return new Function(params, 'return ' + source.slice(body[0], body[1]));
  3829. }
  3830. function representJavascriptFunction(object /*, style*/) {
  3831. return object.toString();
  3832. }
  3833. function isFunction(object) {
  3834. return Object.prototype.toString.call(object) === '[object Function]';
  3835. }
  3836. module.exports = new Type('tag:yaml.org,2002:js/function', {
  3837. kind: 'scalar',
  3838. resolve: resolveJavascriptFunction,
  3839. construct: constructJavascriptFunction,
  3840. predicate: isFunction,
  3841. represent: representJavascriptFunction
  3842. });
  3843. },{"../../type":16}],22:[function(require,module,exports){
  3844. 'use strict';
  3845. var Type = require('../../type');
  3846. function resolveJavascriptRegExp(data) {
  3847. if (data === null) return false;
  3848. if (data.length === 0) return false;
  3849. var regexp = data,
  3850. tail = /\/([gim]*)$/.exec(data),
  3851. modifiers = '';
  3852. if (regexp[0] === '/') {
  3853. if (tail) modifiers = tail[1];
  3854. if (modifiers.length > 3) return false;
  3855. if (regexp[regexp.length - modifiers.length - 1] !== '/') return false;
  3856. }
  3857. return true;
  3858. }
  3859. function constructJavascriptRegExp(data) {
  3860. var regexp = data,
  3861. tail = /\/([gim]*)$/.exec(data),
  3862. modifiers = '';
  3863. if (regexp[0] === '/') {
  3864. if (tail) modifiers = tail[1];
  3865. regexp = regexp.slice(1, regexp.length - modifiers.length - 1);
  3866. }
  3867. return new RegExp(regexp, modifiers);
  3868. }
  3869. function representJavascriptRegExp(object /*, style*/) {
  3870. var result = '/' + object.source + '/';
  3871. if (object.global) result += 'g';
  3872. if (object.multiline) result += 'm';
  3873. if (object.ignoreCase) result += 'i';
  3874. return result;
  3875. }
  3876. function isRegExp(object) {
  3877. return Object.prototype.toString.call(object) === '[object RegExp]';
  3878. }
  3879. module.exports = new Type('tag:yaml.org,2002:js/regexp', {
  3880. kind: 'scalar',
  3881. resolve: resolveJavascriptRegExp,
  3882. construct: constructJavascriptRegExp,
  3883. predicate: isRegExp,
  3884. represent: representJavascriptRegExp
  3885. });
  3886. },{"../../type":16}],23:[function(require,module,exports){
  3887. 'use strict';
  3888. var Type = require('../../type');
  3889. function resolveJavascriptUndefined() {
  3890. return true;
  3891. }
  3892. function constructJavascriptUndefined() {
  3893. return undefined;
  3894. }
  3895. function representJavascriptUndefined() {
  3896. return '';
  3897. }
  3898. function isUndefined(object) {
  3899. return typeof object === 'undefined';
  3900. }
  3901. module.exports = new Type('tag:yaml.org,2002:js/undefined', {
  3902. kind: 'scalar',
  3903. resolve: resolveJavascriptUndefined,
  3904. construct: constructJavascriptUndefined,
  3905. predicate: isUndefined,
  3906. represent: representJavascriptUndefined
  3907. });
  3908. },{"../../type":16}],24:[function(require,module,exports){
  3909. 'use strict';
  3910. var Type = require('../type');
  3911. module.exports = new Type('tag:yaml.org,2002:map', {
  3912. kind: 'mapping',
  3913. construct: function (data) { return data !== null ? data : {}; }
  3914. });
  3915. },{"../type":16}],25:[function(require,module,exports){
  3916. 'use strict';
  3917. var Type = require('../type');
  3918. function resolveYamlMerge(data) {
  3919. return data === '<<' || data === null;
  3920. }
  3921. module.exports = new Type('tag:yaml.org,2002:merge', {
  3922. kind: 'scalar',
  3923. resolve: resolveYamlMerge
  3924. });
  3925. },{"../type":16}],26:[function(require,module,exports){
  3926. 'use strict';
  3927. var Type = require('../type');
  3928. function resolveYamlNull(data) {
  3929. if (data === null) return true;
  3930. var max = data.length;
  3931. return (max === 1 && data === '~') ||
  3932. (max === 4 && (data === 'null' || data === 'Null' || data === 'NULL'));
  3933. }
  3934. function constructYamlNull() {
  3935. return null;
  3936. }
  3937. function isNull(object) {
  3938. return object === null;
  3939. }
  3940. module.exports = new Type('tag:yaml.org,2002:null', {
  3941. kind: 'scalar',
  3942. resolve: resolveYamlNull,
  3943. construct: constructYamlNull,
  3944. predicate: isNull,
  3945. represent: {
  3946. canonical: function () { return '~'; },
  3947. lowercase: function () { return 'null'; },
  3948. uppercase: function () { return 'NULL'; },
  3949. camelcase: function () { return 'Null'; }
  3950. },
  3951. defaultStyle: 'lowercase'
  3952. });
  3953. },{"../type":16}],27:[function(require,module,exports){
  3954. 'use strict';
  3955. var Type = require('../type');
  3956. var _hasOwnProperty = Object.prototype.hasOwnProperty;
  3957. var _toString = Object.prototype.toString;
  3958. function resolveYamlOmap(data) {
  3959. if (data === null) return true;
  3960. var objectKeys = [], index, length, pair, pairKey, pairHasKey,
  3961. object = data;
  3962. for (index = 0, length = object.length; index < length; index += 1) {
  3963. pair = object[index];
  3964. pairHasKey = false;
  3965. if (_toString.call(pair) !== '[object Object]') return false;
  3966. for (pairKey in pair) {
  3967. if (_hasOwnProperty.call(pair, pairKey)) {
  3968. if (!pairHasKey) pairHasKey = true;
  3969. else return false;
  3970. }
  3971. }
  3972. if (!pairHasKey) return false;
  3973. if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);
  3974. else return false;
  3975. }
  3976. return true;
  3977. }
  3978. function constructYamlOmap(data) {
  3979. return data !== null ? data : [];
  3980. }
  3981. module.exports = new Type('tag:yaml.org,2002:omap', {
  3982. kind: 'sequence',
  3983. resolve: resolveYamlOmap,
  3984. construct: constructYamlOmap
  3985. });
  3986. },{"../type":16}],28:[function(require,module,exports){
  3987. 'use strict';
  3988. var Type = require('../type');
  3989. var _toString = Object.prototype.toString;
  3990. function resolveYamlPairs(data) {
  3991. if (data === null) return true;
  3992. var index, length, pair, keys, result,
  3993. object = data;
  3994. result = new Array(object.length);
  3995. for (index = 0, length = object.length; index < length; index += 1) {
  3996. pair = object[index];
  3997. if (_toString.call(pair) !== '[object Object]') return false;
  3998. keys = Object.keys(pair);
  3999. if (keys.length !== 1) return false;
  4000. result[index] = [ keys[0], pair[keys[0]] ];
  4001. }
  4002. return true;
  4003. }
  4004. function constructYamlPairs(data) {
  4005. if (data === null) return [];
  4006. var index, length, pair, keys, result,
  4007. object = data;
  4008. result = new Array(object.length);
  4009. for (index = 0, length = object.length; index < length; index += 1) {
  4010. pair = object[index];
  4011. keys = Object.keys(pair);
  4012. result[index] = [ keys[0], pair[keys[0]] ];
  4013. }
  4014. return result;
  4015. }
  4016. module.exports = new Type('tag:yaml.org,2002:pairs', {
  4017. kind: 'sequence',
  4018. resolve: resolveYamlPairs,
  4019. construct: constructYamlPairs
  4020. });
  4021. },{"../type":16}],29:[function(require,module,exports){
  4022. 'use strict';
  4023. var Type = require('../type');
  4024. module.exports = new Type('tag:yaml.org,2002:seq', {
  4025. kind: 'sequence',
  4026. construct: function (data) { return data !== null ? data : []; }
  4027. });
  4028. },{"../type":16}],30:[function(require,module,exports){
  4029. 'use strict';
  4030. var Type = require('../type');
  4031. var _hasOwnProperty = Object.prototype.hasOwnProperty;
  4032. function resolveYamlSet(data) {
  4033. if (data === null) return true;
  4034. var key, object = data;
  4035. for (key in object) {
  4036. if (_hasOwnProperty.call(object, key)) {
  4037. if (object[key] !== null) return false;
  4038. }
  4039. }
  4040. return true;
  4041. }
  4042. function constructYamlSet(data) {
  4043. return data !== null ? data : {};
  4044. }
  4045. module.exports = new Type('tag:yaml.org,2002:set', {
  4046. kind: 'mapping',
  4047. resolve: resolveYamlSet,
  4048. construct: constructYamlSet
  4049. });
  4050. },{"../type":16}],31:[function(require,module,exports){
  4051. 'use strict';
  4052. var Type = require('../type');
  4053. module.exports = new Type('tag:yaml.org,2002:str', {
  4054. kind: 'scalar',
  4055. construct: function (data) { return data !== null ? data : ''; }
  4056. });
  4057. },{"../type":16}],32:[function(require,module,exports){
  4058. 'use strict';
  4059. var Type = require('../type');
  4060. var YAML_DATE_REGEXP = new RegExp(
  4061. '^([0-9][0-9][0-9][0-9])' + // [1] year
  4062. '-([0-9][0-9])' + // [2] month
  4063. '-([0-9][0-9])$'); // [3] day
  4064. var YAML_TIMESTAMP_REGEXP = new RegExp(
  4065. '^([0-9][0-9][0-9][0-9])' + // [1] year
  4066. '-([0-9][0-9]?)' + // [2] month
  4067. '-([0-9][0-9]?)' + // [3] day
  4068. '(?:[Tt]|[ \\t]+)' + // ...
  4069. '([0-9][0-9]?)' + // [4] hour
  4070. ':([0-9][0-9])' + // [5] minute
  4071. ':([0-9][0-9])' + // [6] second
  4072. '(?:\\.([0-9]*))?' + // [7] fraction
  4073. '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour
  4074. '(?::([0-9][0-9]))?))?$'); // [11] tz_minute
  4075. function resolveYamlTimestamp(data) {
  4076. if (data === null) return false;
  4077. if (YAML_DATE_REGEXP.exec(data) !== null) return true;
  4078. if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
  4079. return false;
  4080. }
  4081. function constructYamlTimestamp(data) {
  4082. var match, year, month, day, hour, minute, second, fraction = 0,
  4083. delta = null, tz_hour, tz_minute, date;
  4084. match = YAML_DATE_REGEXP.exec(data);
  4085. if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
  4086. if (match === null) throw new Error('Date resolve error');
  4087. year = +(match[1]);
  4088. month = +(match[2]) - 1; // JS month starts with 0
  4089. day = +(match[3]);
  4090. if (!match[4]) { // no hour
  4091. return new Date(Date.UTC(year, month, day));
  4092. }
  4093. hour = +(match[4]);
  4094. minute = +(match[5]);
  4095. second = +(match[6]);
  4096. if (match[7]) {
  4097. fraction = match[7].slice(0, 3);
  4098. while (fraction.length < 3) { // milli-seconds
  4099. fraction += '0';
  4100. }
  4101. fraction = +fraction;
  4102. }
  4103. if (match[9]) {
  4104. tz_hour = +(match[10]);
  4105. tz_minute = +(match[11] || 0);
  4106. delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds
  4107. if (match[9] === '-') delta = -delta;
  4108. }
  4109. date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
  4110. if (delta) date.setTime(date.getTime() - delta);
  4111. return date;
  4112. }
  4113. function representYamlTimestamp(object /*, style*/) {
  4114. return object.toISOString();
  4115. }
  4116. module.exports = new Type('tag:yaml.org,2002:timestamp', {
  4117. kind: 'scalar',
  4118. resolve: resolveYamlTimestamp,
  4119. construct: constructYamlTimestamp,
  4120. instanceOf: Date,
  4121. represent: representYamlTimestamp
  4122. });
  4123. },{"../type":16}],33:[function(require,module,exports){
  4124. (function (global){
  4125. var LARGE_ARRAY_SIZE = 200;
  4126. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  4127. var HOT_COUNT = 800,
  4128. HOT_SPAN = 16;
  4129. var MAX_SAFE_INTEGER = 9007199254740991;
  4130. var argsTag = '[object Arguments]',
  4131. arrayTag = '[object Array]',
  4132. asyncTag = '[object AsyncFunction]',
  4133. boolTag = '[object Boolean]',
  4134. dateTag = '[object Date]',
  4135. errorTag = '[object Error]',
  4136. funcTag = '[object Function]',
  4137. genTag = '[object GeneratorFunction]',
  4138. mapTag = '[object Map]',
  4139. numberTag = '[object Number]',
  4140. nullTag = '[object Null]',
  4141. objectTag = '[object Object]',
  4142. proxyTag = '[object Proxy]',
  4143. regexpTag = '[object RegExp]',
  4144. setTag = '[object Set]',
  4145. stringTag = '[object String]',
  4146. undefinedTag = '[object Undefined]',
  4147. weakMapTag = '[object WeakMap]';
  4148. var arrayBufferTag = '[object ArrayBuffer]',
  4149. dataViewTag = '[object DataView]',
  4150. float32Tag = '[object Float32Array]',
  4151. float64Tag = '[object Float64Array]',
  4152. int8Tag = '[object Int8Array]',
  4153. int16Tag = '[object Int16Array]',
  4154. int32Tag = '[object Int32Array]',
  4155. uint8Tag = '[object Uint8Array]',
  4156. uint8ClampedTag = '[object Uint8ClampedArray]',
  4157. uint16Tag = '[object Uint16Array]',
  4158. uint32Tag = '[object Uint32Array]';
  4159. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  4160. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  4161. var reIsUint = /^(?:0|[1-9]\d*)$/;
  4162. var typedArrayTags = {};
  4163. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  4164. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  4165. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  4166. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  4167. typedArrayTags[uint32Tag] = true;
  4168. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  4169. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  4170. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  4171. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  4172. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  4173. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  4174. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  4175. typedArrayTags[weakMapTag] = false;
  4176. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  4177. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  4178. var root = freeGlobal || freeSelf || Function('return this')();
  4179. var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
  4180. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  4181. var moduleExports = freeModule && freeModule.exports === freeExports;
  4182. var freeProcess = moduleExports && freeGlobal.process;
  4183. var nodeUtil = (function() {
  4184. try {
  4185. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  4186. } catch (e) {}
  4187. }());
  4188. var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  4189. function apply(func, thisArg, args) {
  4190. switch (args.length) {
  4191. case 0: return func.call(thisArg);
  4192. case 1: return func.call(thisArg, args[0]);
  4193. case 2: return func.call(thisArg, args[0], args[1]);
  4194. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  4195. }
  4196. return func.apply(thisArg, args);
  4197. }
  4198. function baseTimes(n, iteratee) {
  4199. var index = -1,
  4200. result = Array(n);
  4201. while (++index < n) {
  4202. result[index] = iteratee(index);
  4203. }
  4204. return result;
  4205. }
  4206. function baseUnary(func) {
  4207. return function(value) {
  4208. return func(value);
  4209. };
  4210. }
  4211. function getValue(object, key) {
  4212. return object == null ? undefined : object[key];
  4213. }
  4214. function overArg(func, transform) {
  4215. return function(arg) {
  4216. return func(transform(arg));
  4217. };
  4218. }
  4219. function safeGet(object, key) {
  4220. return key == '__proto__'
  4221. ? undefined
  4222. : object[key];
  4223. }
  4224. var arrayProto = Array.prototype,
  4225. funcProto = Function.prototype,
  4226. objectProto = Object.prototype;
  4227. var coreJsData = root['__core-js_shared__'];
  4228. var funcToString = funcProto.toString;
  4229. var hasOwnProperty = objectProto.hasOwnProperty;
  4230. var maskSrcKey = (function() {
  4231. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  4232. return uid ? ('Symbol(src)_1.' + uid) : '';
  4233. }());
  4234. var nativeObjectToString = objectProto.toString;
  4235. var objectCtorString = funcToString.call(Object);
  4236. var reIsNative = RegExp('^' +
  4237. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  4238. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  4239. );
  4240. var Buffer = moduleExports ? root.Buffer : undefined,
  4241. Symbol = root.Symbol,
  4242. Uint8Array = root.Uint8Array,
  4243. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
  4244. getPrototype = overArg(Object.getPrototypeOf, Object),
  4245. objectCreate = Object.create,
  4246. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  4247. splice = arrayProto.splice,
  4248. symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  4249. var defineProperty = (function() {
  4250. try {
  4251. var func = getNative(Object, 'defineProperty');
  4252. func({}, '', {});
  4253. return func;
  4254. } catch (e) {}
  4255. }());
  4256. var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
  4257. nativeMax = Math.max,
  4258. nativeNow = Date.now;
  4259. var Map = getNative(root, 'Map'),
  4260. nativeCreate = getNative(Object, 'create');
  4261. var baseCreate = (function() {
  4262. function object() {}
  4263. return function(proto) {
  4264. if (!isObject(proto)) {
  4265. return {};
  4266. }
  4267. if (objectCreate) {
  4268. return objectCreate(proto);
  4269. }
  4270. object.prototype = proto;
  4271. var result = new object;
  4272. object.prototype = undefined;
  4273. return result;
  4274. };
  4275. }());
  4276. function Hash(entries) {
  4277. var index = -1,
  4278. length = entries == null ? 0 : entries.length;
  4279. this.clear();
  4280. while (++index < length) {
  4281. var entry = entries[index];
  4282. this.set(entry[0], entry[1]);
  4283. }
  4284. }
  4285. function hashClear() {
  4286. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  4287. this.size = 0;
  4288. }
  4289. function hashDelete(key) {
  4290. var result = this.has(key) && delete this.__data__[key];
  4291. this.size -= result ? 1 : 0;
  4292. return result;
  4293. }
  4294. function hashGet(key) {
  4295. var data = this.__data__;
  4296. if (nativeCreate) {
  4297. var result = data[key];
  4298. return result === HASH_UNDEFINED ? undefined : result;
  4299. }
  4300. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  4301. }
  4302. function hashHas(key) {
  4303. var data = this.__data__;
  4304. return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
  4305. }
  4306. function hashSet(key, value) {
  4307. var data = this.__data__;
  4308. this.size += this.has(key) ? 0 : 1;
  4309. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  4310. return this;
  4311. }
  4312. Hash.prototype.clear = hashClear;
  4313. Hash.prototype['delete'] = hashDelete;
  4314. Hash.prototype.get = hashGet;
  4315. Hash.prototype.has = hashHas;
  4316. Hash.prototype.set = hashSet;
  4317. function ListCache(entries) {
  4318. var index = -1,
  4319. length = entries == null ? 0 : entries.length;
  4320. this.clear();
  4321. while (++index < length) {
  4322. var entry = entries[index];
  4323. this.set(entry[0], entry[1]);
  4324. }
  4325. }
  4326. function listCacheClear() {
  4327. this.__data__ = [];
  4328. this.size = 0;
  4329. }
  4330. function listCacheDelete(key) {
  4331. var data = this.__data__,
  4332. index = assocIndexOf(data, key);
  4333. if (index < 0) {
  4334. return false;
  4335. }
  4336. var lastIndex = data.length - 1;
  4337. if (index == lastIndex) {
  4338. data.pop();
  4339. } else {
  4340. splice.call(data, index, 1);
  4341. }
  4342. --this.size;
  4343. return true;
  4344. }
  4345. function listCacheGet(key) {
  4346. var data = this.__data__,
  4347. index = assocIndexOf(data, key);
  4348. return index < 0 ? undefined : data[index][1];
  4349. }
  4350. function listCacheHas(key) {
  4351. return assocIndexOf(this.__data__, key) > -1;
  4352. }
  4353. function listCacheSet(key, value) {
  4354. var data = this.__data__,
  4355. index = assocIndexOf(data, key);
  4356. if (index < 0) {
  4357. ++this.size;
  4358. data.push([key, value]);
  4359. } else {
  4360. data[index][1] = value;
  4361. }
  4362. return this;
  4363. }
  4364. ListCache.prototype.clear = listCacheClear;
  4365. ListCache.prototype['delete'] = listCacheDelete;
  4366. ListCache.prototype.get = listCacheGet;
  4367. ListCache.prototype.has = listCacheHas;
  4368. ListCache.prototype.set = listCacheSet;
  4369. function MapCache(entries) {
  4370. var index = -1,
  4371. length = entries == null ? 0 : entries.length;
  4372. this.clear();
  4373. while (++index < length) {
  4374. var entry = entries[index];
  4375. this.set(entry[0], entry[1]);
  4376. }
  4377. }
  4378. function mapCacheClear() {
  4379. this.size = 0;
  4380. this.__data__ = {
  4381. 'hash': new Hash,
  4382. 'map': new (Map || ListCache),
  4383. 'string': new Hash
  4384. };
  4385. }
  4386. function mapCacheDelete(key) {
  4387. var result = getMapData(this, key)['delete'](key);
  4388. this.size -= result ? 1 : 0;
  4389. return result;
  4390. }
  4391. function mapCacheGet(key) {
  4392. return getMapData(this, key).get(key);
  4393. }
  4394. function mapCacheHas(key) {
  4395. return getMapData(this, key).has(key);
  4396. }
  4397. function mapCacheSet(key, value) {
  4398. var data = getMapData(this, key),
  4399. size = data.size;
  4400. data.set(key, value);
  4401. this.size += data.size == size ? 0 : 1;
  4402. return this;
  4403. }
  4404. MapCache.prototype.clear = mapCacheClear;
  4405. MapCache.prototype['delete'] = mapCacheDelete;
  4406. MapCache.prototype.get = mapCacheGet;
  4407. MapCache.prototype.has = mapCacheHas;
  4408. MapCache.prototype.set = mapCacheSet;
  4409. function Stack(entries) {
  4410. var data = this.__data__ = new ListCache(entries);
  4411. this.size = data.size;
  4412. }
  4413. function stackClear() {
  4414. this.__data__ = new ListCache;
  4415. this.size = 0;
  4416. }
  4417. function stackDelete(key) {
  4418. var data = this.__data__,
  4419. result = data['delete'](key);
  4420. this.size = data.size;
  4421. return result;
  4422. }
  4423. function stackGet(key) {
  4424. return this.__data__.get(key);
  4425. }
  4426. function stackHas(key) {
  4427. return this.__data__.has(key);
  4428. }
  4429. function stackSet(key, value) {
  4430. var data = this.__data__;
  4431. if (data instanceof ListCache) {
  4432. var pairs = data.__data__;
  4433. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  4434. pairs.push([key, value]);
  4435. this.size = ++data.size;
  4436. return this;
  4437. }
  4438. data = this.__data__ = new MapCache(pairs);
  4439. }
  4440. data.set(key, value);
  4441. this.size = data.size;
  4442. return this;
  4443. }
  4444. Stack.prototype.clear = stackClear;
  4445. Stack.prototype['delete'] = stackDelete;
  4446. Stack.prototype.get = stackGet;
  4447. Stack.prototype.has = stackHas;
  4448. Stack.prototype.set = stackSet;
  4449. function arrayLikeKeys(value, inherited) {
  4450. var isArr = isArray(value),
  4451. isArg = !isArr && isArguments(value),
  4452. isBuff = !isArr && !isArg && isBuffer(value),
  4453. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  4454. skipIndexes = isArr || isArg || isBuff || isType,
  4455. result = skipIndexes ? baseTimes(value.length, String) : [],
  4456. length = result.length;
  4457. for (var key in value) {
  4458. if ((inherited || hasOwnProperty.call(value, key)) &&
  4459. !(skipIndexes && (
  4460. key == 'length' ||
  4461. (isBuff && (key == 'offset' || key == 'parent')) ||
  4462. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  4463. isIndex(key, length)
  4464. ))) {
  4465. result.push(key);
  4466. }
  4467. }
  4468. return result;
  4469. }
  4470. function assignMergeValue(object, key, value) {
  4471. if ((value !== undefined && !eq(object[key], value)) ||
  4472. (value === undefined && !(key in object))) {
  4473. baseAssignValue(object, key, value);
  4474. }
  4475. }
  4476. function assignValue(object, key, value) {
  4477. var objValue = object[key];
  4478. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  4479. (value === undefined && !(key in object))) {
  4480. baseAssignValue(object, key, value);
  4481. }
  4482. }
  4483. function assocIndexOf(array, key) {
  4484. var length = array.length;
  4485. while (length--) {
  4486. if (eq(array[length][0], key)) {
  4487. return length;
  4488. }
  4489. }
  4490. return -1;
  4491. }
  4492. function baseAssignValue(object, key, value) {
  4493. if (key == '__proto__' && defineProperty) {
  4494. defineProperty(object, key, {
  4495. 'configurable': true,
  4496. 'enumerable': true,
  4497. 'value': value,
  4498. 'writable': true
  4499. });
  4500. } else {
  4501. object[key] = value;
  4502. }
  4503. }
  4504. var baseFor = createBaseFor();
  4505. function baseGetTag(value) {
  4506. if (value == null) {
  4507. return value === undefined ? undefinedTag : nullTag;
  4508. }
  4509. return (symToStringTag && symToStringTag in Object(value))
  4510. ? getRawTag(value)
  4511. : objectToString(value);
  4512. }
  4513. function baseIsArguments(value) {
  4514. return isObjectLike(value) && baseGetTag(value) == argsTag;
  4515. }
  4516. function baseIsNative(value) {
  4517. if (!isObject(value) || isMasked(value)) {
  4518. return false;
  4519. }
  4520. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  4521. return pattern.test(toSource(value));
  4522. }
  4523. function baseIsTypedArray(value) {
  4524. return isObjectLike(value) &&
  4525. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  4526. }
  4527. function baseKeysIn(object) {
  4528. if (!isObject(object)) {
  4529. return nativeKeysIn(object);
  4530. }
  4531. var isProto = isPrototype(object),
  4532. result = [];
  4533. for (var key in object) {
  4534. if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  4535. result.push(key);
  4536. }
  4537. }
  4538. return result;
  4539. }
  4540. function baseMerge(object, source, srcIndex, customizer, stack) {
  4541. if (object === source) {
  4542. return;
  4543. }
  4544. baseFor(source, function(srcValue, key) {
  4545. if (isObject(srcValue)) {
  4546. stack || (stack = new Stack);
  4547. baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  4548. }
  4549. else {
  4550. var newValue = customizer
  4551. ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
  4552. : undefined;
  4553. if (newValue === undefined) {
  4554. newValue = srcValue;
  4555. }
  4556. assignMergeValue(object, key, newValue);
  4557. }
  4558. }, keysIn);
  4559. }
  4560. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  4561. var objValue = safeGet(object, key),
  4562. srcValue = safeGet(source, key),
  4563. stacked = stack.get(srcValue);
  4564. if (stacked) {
  4565. assignMergeValue(object, key, stacked);
  4566. return;
  4567. }
  4568. var newValue = customizer
  4569. ? customizer(objValue, srcValue, (key + ''), object, source, stack)
  4570. : undefined;
  4571. var isCommon = newValue === undefined;
  4572. if (isCommon) {
  4573. var isArr = isArray(srcValue),
  4574. isBuff = !isArr && isBuffer(srcValue),
  4575. isTyped = !isArr && !isBuff && isTypedArray(srcValue);
  4576. newValue = srcValue;
  4577. if (isArr || isBuff || isTyped) {
  4578. if (isArray(objValue)) {
  4579. newValue = objValue;
  4580. }
  4581. else if (isArrayLikeObject(objValue)) {
  4582. newValue = copyArray(objValue);
  4583. }
  4584. else if (isBuff) {
  4585. isCommon = false;
  4586. newValue = cloneBuffer(srcValue, true);
  4587. }
  4588. else if (isTyped) {
  4589. isCommon = false;
  4590. newValue = cloneTypedArray(srcValue, true);
  4591. }
  4592. else {
  4593. newValue = [];
  4594. }
  4595. }
  4596. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  4597. newValue = objValue;
  4598. if (isArguments(objValue)) {
  4599. newValue = toPlainObject(objValue);
  4600. }
  4601. else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
  4602. newValue = initCloneObject(srcValue);
  4603. }
  4604. }
  4605. else {
  4606. isCommon = false;
  4607. }
  4608. }
  4609. if (isCommon) {
  4610. stack.set(srcValue, newValue);
  4611. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  4612. stack['delete'](srcValue);
  4613. }
  4614. assignMergeValue(object, key, newValue);
  4615. }
  4616. function baseRest(func, start) {
  4617. return setToString(overRest(func, start, identity), func + '');
  4618. }
  4619. var baseSetToString = !defineProperty ? identity : function(func, string) {
  4620. return defineProperty(func, 'toString', {
  4621. 'configurable': true,
  4622. 'enumerable': false,
  4623. 'value': constant(string),
  4624. 'writable': true
  4625. });
  4626. };
  4627. function cloneBuffer(buffer, isDeep) {
  4628. if (isDeep) {
  4629. return buffer.slice();
  4630. }
  4631. var length = buffer.length,
  4632. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  4633. buffer.copy(result);
  4634. return result;
  4635. }
  4636. function cloneArrayBuffer(arrayBuffer) {
  4637. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  4638. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  4639. return result;
  4640. }
  4641. function cloneTypedArray(typedArray, isDeep) {
  4642. var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  4643. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  4644. }
  4645. function copyArray(source, array) {
  4646. var index = -1,
  4647. length = source.length;
  4648. array || (array = Array(length));
  4649. while (++index < length) {
  4650. array[index] = source[index];
  4651. }
  4652. return array;
  4653. }
  4654. function copyObject(source, props, object, customizer) {
  4655. var isNew = !object;
  4656. object || (object = {});
  4657. var index = -1,
  4658. length = props.length;
  4659. while (++index < length) {
  4660. var key = props[index];
  4661. var newValue = customizer
  4662. ? customizer(object[key], source[key], key, object, source)
  4663. : undefined;
  4664. if (newValue === undefined) {
  4665. newValue = source[key];
  4666. }
  4667. if (isNew) {
  4668. baseAssignValue(object, key, newValue);
  4669. } else {
  4670. assignValue(object, key, newValue);
  4671. }
  4672. }
  4673. return object;
  4674. }
  4675. function createAssigner(assigner) {
  4676. return baseRest(function(object, sources) {
  4677. var index = -1,
  4678. length = sources.length,
  4679. customizer = length > 1 ? sources[length - 1] : undefined,
  4680. guard = length > 2 ? sources[2] : undefined;
  4681. customizer = (assigner.length > 3 && typeof customizer == 'function')
  4682. ? (length--, customizer)
  4683. : undefined;
  4684. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  4685. customizer = length < 3 ? undefined : customizer;
  4686. length = 1;
  4687. }
  4688. object = Object(object);
  4689. while (++index < length) {
  4690. var source = sources[index];
  4691. if (source) {
  4692. assigner(object, source, index, customizer);
  4693. }
  4694. }
  4695. return object;
  4696. });
  4697. }
  4698. function createBaseFor(fromRight) {
  4699. return function(object, iteratee, keysFunc) {
  4700. var index = -1,
  4701. iterable = Object(object),
  4702. props = keysFunc(object),
  4703. length = props.length;
  4704. while (length--) {
  4705. var key = props[fromRight ? length : ++index];
  4706. if (iteratee(iterable[key], key, iterable) === false) {
  4707. break;
  4708. }
  4709. }
  4710. return object;
  4711. };
  4712. }
  4713. function getMapData(map, key) {
  4714. var data = map.__data__;
  4715. return isKeyable(key)
  4716. ? data[typeof key == 'string' ? 'string' : 'hash']
  4717. : data.map;
  4718. }
  4719. function getNative(object, key) {
  4720. var value = getValue(object, key);
  4721. return baseIsNative(value) ? value : undefined;
  4722. }
  4723. function getRawTag(value) {
  4724. var isOwn = hasOwnProperty.call(value, symToStringTag),
  4725. tag = value[symToStringTag];
  4726. try {
  4727. value[symToStringTag] = undefined;
  4728. var unmasked = true;
  4729. } catch (e) {}
  4730. var result = nativeObjectToString.call(value);
  4731. if (unmasked) {
  4732. if (isOwn) {
  4733. value[symToStringTag] = tag;
  4734. } else {
  4735. delete value[symToStringTag];
  4736. }
  4737. }
  4738. return result;
  4739. }
  4740. function initCloneObject(object) {
  4741. return (typeof object.constructor == 'function' && !isPrototype(object))
  4742. ? baseCreate(getPrototype(object))
  4743. : {};
  4744. }
  4745. function isIndex(value, length) {
  4746. var type = typeof value;
  4747. length = length == null ? MAX_SAFE_INTEGER : length;
  4748. return !!length &&
  4749. (type == 'number' ||
  4750. (type != 'symbol' && reIsUint.test(value))) &&
  4751. (value > -1 && value % 1 == 0 && value < length);
  4752. }
  4753. function isIterateeCall(value, index, object) {
  4754. if (!isObject(object)) {
  4755. return false;
  4756. }
  4757. var type = typeof index;
  4758. if (type == 'number'
  4759. ? (isArrayLike(object) && isIndex(index, object.length))
  4760. : (type == 'string' && index in object)
  4761. ) {
  4762. return eq(object[index], value);
  4763. }
  4764. return false;
  4765. }
  4766. function isKeyable(value) {
  4767. var type = typeof value;
  4768. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  4769. ? (value !== '__proto__')
  4770. : (value === null);
  4771. }
  4772. function isMasked(func) {
  4773. return !!maskSrcKey && (maskSrcKey in func);
  4774. }
  4775. function isPrototype(value) {
  4776. var Ctor = value && value.constructor,
  4777. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  4778. return value === proto;
  4779. }
  4780. function nativeKeysIn(object) {
  4781. var result = [];
  4782. if (object != null) {
  4783. for (var key in Object(object)) {
  4784. result.push(key);
  4785. }
  4786. }
  4787. return result;
  4788. }
  4789. function objectToString(value) {
  4790. return nativeObjectToString.call(value);
  4791. }
  4792. function overRest(func, start, transform) {
  4793. start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
  4794. return function() {
  4795. var args = arguments,
  4796. index = -1,
  4797. length = nativeMax(args.length - start, 0),
  4798. array = Array(length);
  4799. while (++index < length) {
  4800. array[index] = args[start + index];
  4801. }
  4802. index = -1;
  4803. var otherArgs = Array(start + 1);
  4804. while (++index < start) {
  4805. otherArgs[index] = args[index];
  4806. }
  4807. otherArgs[start] = transform(array);
  4808. return apply(func, this, otherArgs);
  4809. };
  4810. }
  4811. var setToString = shortOut(baseSetToString);
  4812. function shortOut(func) {
  4813. var count = 0,
  4814. lastCalled = 0;
  4815. return function() {
  4816. var stamp = nativeNow(),
  4817. remaining = HOT_SPAN - (stamp - lastCalled);
  4818. lastCalled = stamp;
  4819. if (remaining > 0) {
  4820. if (++count >= HOT_COUNT) {
  4821. return arguments[0];
  4822. }
  4823. } else {
  4824. count = 0;
  4825. }
  4826. return func.apply(undefined, arguments);
  4827. };
  4828. }
  4829. function toSource(func) {
  4830. if (func != null) {
  4831. try {
  4832. return funcToString.call(func);
  4833. } catch (e) {}
  4834. try {
  4835. return (func + '');
  4836. } catch (e) {}
  4837. }
  4838. return '';
  4839. }
  4840. function eq(value, other) {
  4841. return value === other || (value !== value && other !== other);
  4842. }
  4843. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  4844. return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
  4845. !propertyIsEnumerable.call(value, 'callee');
  4846. };
  4847. var isArray = Array.isArray;
  4848. function isArrayLike(value) {
  4849. return value != null && isLength(value.length) && !isFunction(value);
  4850. }
  4851. function isArrayLikeObject(value) {
  4852. return isObjectLike(value) && isArrayLike(value);
  4853. }
  4854. var isBuffer = nativeIsBuffer || stubFalse;
  4855. function isFunction(value) {
  4856. if (!isObject(value)) {
  4857. return false;
  4858. }
  4859. var tag = baseGetTag(value);
  4860. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  4861. }
  4862. function isLength(value) {
  4863. return typeof value == 'number' &&
  4864. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  4865. }
  4866. function isObject(value) {
  4867. var type = typeof value;
  4868. return value != null && (type == 'object' || type == 'function');
  4869. }
  4870. function isObjectLike(value) {
  4871. return value != null && typeof value == 'object';
  4872. }
  4873. function isPlainObject(value) {
  4874. if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
  4875. return false;
  4876. }
  4877. var proto = getPrototype(value);
  4878. if (proto === null) {
  4879. return true;
  4880. }
  4881. var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
  4882. return typeof Ctor == 'function' && Ctor instanceof Ctor &&
  4883. funcToString.call(Ctor) == objectCtorString;
  4884. }
  4885. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  4886. function toPlainObject(value) {
  4887. return copyObject(value, keysIn(value));
  4888. }
  4889. function keysIn(object) {
  4890. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  4891. }
  4892. var merge = createAssigner(function(object, source, srcIndex) {
  4893. baseMerge(object, source, srcIndex);
  4894. });
  4895. function constant(value) {
  4896. return function() {
  4897. return value;
  4898. };
  4899. }
  4900. function identity(value) {
  4901. return value;
  4902. }
  4903. function stubFalse() {
  4904. return false;
  4905. }
  4906. module.exports = merge;
  4907. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {});
  4908. },{}]},{},[2])(2);
  4909. });
  4910. });
  4911. ace.define("ace/mode/yaml_worker",[], function(require, exports) {
  4912. "use strict";
  4913. var oop = require("../lib/oop");
  4914. var Mirror = require("../worker/mirror").Mirror;
  4915. var lint = require("./yaml/yaml-lint").lint;
  4916. var YamlWorker = exports.YamlWorker = function(sender) {
  4917. Mirror.call(this, sender);
  4918. this.setTimeout(500);
  4919. this.setOptions();
  4920. };
  4921. oop.inherits(YamlWorker, Mirror);
  4922. (function() {
  4923. this.setOptions = function() {
  4924. this.doc.getValue() && this.deferredUpdate.schedule(100);
  4925. };
  4926. this.changeOptions = function(newOptions) {
  4927. oop.mixin(this.options, newOptions);
  4928. this.doc.getValue() && this.deferredUpdate.schedule(100);
  4929. };
  4930. this.onUpdate = function() {
  4931. var _this = this;
  4932. var value = this.doc.getValue();
  4933. var errors = [];
  4934. lint(value, {}, function(error) {
  4935. if (!error) {
  4936. _this.sender.emit("annotate", errors);
  4937. return;
  4938. }
  4939. errors.push({
  4940. row: error.mark.line,
  4941. column: error.mark.column,
  4942. text: error.reason,
  4943. type: 'error',
  4944. raw: error
  4945. });
  4946. _this.sender.emit("annotate", errors);
  4947. });
  4948. };
  4949. }).call(YamlWorker.prototype);
  4950. });