21cc809329a93d6f3d6a756d6dc1294c.js 162 KB

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