4f296c337cb73bd82d9b213741292103.js 161 KB

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