js-yaml-front-client.js 101 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022
  1. /* js-yaml 3.5.2 https://github.com/nodeca/js-yaml */(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.jsyaml = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
  2. 'use strict';
  3. var loader = require('./js-yaml/loader');
  4. var dumper = require('./js-yaml/dumper');
  5. function deprecated(name) {
  6. return function () {
  7. throw new Error('Function ' + name + ' is deprecated and cannot be used.');
  8. };
  9. }
  10. module.exports.Type = require('./js-yaml/type');
  11. module.exports.Schema = require('./js-yaml/schema');
  12. module.exports.FAILSAFE_SCHEMA = require('./js-yaml/schema/failsafe');
  13. module.exports.JSON_SCHEMA = require('./js-yaml/schema/json');
  14. module.exports.CORE_SCHEMA = require('./js-yaml/schema/core');
  15. module.exports.DEFAULT_SAFE_SCHEMA = require('./js-yaml/schema/default_safe');
  16. module.exports.DEFAULT_FULL_SCHEMA = require('./js-yaml/schema/default_full');
  17. module.exports.load = loader.load;
  18. module.exports.loadAll = loader.loadAll;
  19. module.exports.safeLoad = loader.safeLoad;
  20. module.exports.safeLoadAll = loader.safeLoadAll;
  21. module.exports.dump = dumper.dump;
  22. module.exports.safeDump = dumper.safeDump;
  23. module.exports.YAMLException = require('./js-yaml/exception');
  24. // Deprecated schema names from JS-YAML 2.0.x
  25. module.exports.MINIMAL_SCHEMA = require('./js-yaml/schema/failsafe');
  26. module.exports.SAFE_SCHEMA = require('./js-yaml/schema/default_safe');
  27. module.exports.DEFAULT_SCHEMA = require('./js-yaml/schema/default_full');
  28. // Deprecated functions from JS-YAML 1.x.x
  29. module.exports.scan = deprecated('scan');
  30. module.exports.parse = deprecated('parse');
  31. module.exports.compose = deprecated('compose');
  32. module.exports.addConstructor = deprecated('addConstructor');
  33. },{"./js-yaml/dumper":3,"./js-yaml/exception":4,"./js-yaml/loader":5,"./js-yaml/schema":7,"./js-yaml/schema/core":8,"./js-yaml/schema/default_full":9,"./js-yaml/schema/default_safe":10,"./js-yaml/schema/failsafe":11,"./js-yaml/schema/json":12,"./js-yaml/type":13}],2:[function(require,module,exports){
  34. 'use strict';
  35. function isNothing(subject) {
  36. return (typeof subject === 'undefined') || (null === subject);
  37. }
  38. function isObject(subject) {
  39. return (typeof subject === 'object') && (null !== subject);
  40. }
  41. function toArray(sequence) {
  42. if (Array.isArray(sequence)) {
  43. return sequence;
  44. } else if (isNothing(sequence)) {
  45. return [];
  46. }
  47. return [ sequence ];
  48. }
  49. function extend(target, source) {
  50. var index, length, key, sourceKeys;
  51. if (source) {
  52. sourceKeys = Object.keys(source);
  53. for (index = 0, length = sourceKeys.length; index < length; index += 1) {
  54. key = sourceKeys[index];
  55. target[key] = source[key];
  56. }
  57. }
  58. return target;
  59. }
  60. function repeat(string, count) {
  61. var result = '', cycle;
  62. for (cycle = 0; cycle < count; cycle += 1) {
  63. result += string;
  64. }
  65. return result;
  66. }
  67. function isNegativeZero(number) {
  68. return (0 === number) && (Number.NEGATIVE_INFINITY === 1 / number);
  69. }
  70. module.exports.isNothing = isNothing;
  71. module.exports.isObject = isObject;
  72. module.exports.toArray = toArray;
  73. module.exports.repeat = repeat;
  74. module.exports.isNegativeZero = isNegativeZero;
  75. module.exports.extend = extend;
  76. },{}],3:[function(require,module,exports){
  77. 'use strict';
  78. /*eslint-disable no-use-before-define*/
  79. var common = require('./common');
  80. var YAMLException = require('./exception');
  81. var DEFAULT_FULL_SCHEMA = require('./schema/default_full');
  82. var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe');
  83. var _toString = Object.prototype.toString;
  84. var _hasOwnProperty = Object.prototype.hasOwnProperty;
  85. var CHAR_TAB = 0x09; /* Tab */
  86. var CHAR_LINE_FEED = 0x0A; /* LF */
  87. var CHAR_CARRIAGE_RETURN = 0x0D; /* CR */
  88. var CHAR_SPACE = 0x20; /* Space */
  89. var CHAR_EXCLAMATION = 0x21; /* ! */
  90. var CHAR_DOUBLE_QUOTE = 0x22; /* " */
  91. var CHAR_SHARP = 0x23; /* # */
  92. var CHAR_PERCENT = 0x25; /* % */
  93. var CHAR_AMPERSAND = 0x26; /* & */
  94. var CHAR_SINGLE_QUOTE = 0x27; /* ' */
  95. var CHAR_ASTERISK = 0x2A; /* * */
  96. var CHAR_COMMA = 0x2C; /* , */
  97. var CHAR_MINUS = 0x2D; /* - */
  98. var CHAR_COLON = 0x3A; /* : */
  99. var CHAR_GREATER_THAN = 0x3E; /* > */
  100. var CHAR_QUESTION = 0x3F; /* ? */
  101. var CHAR_COMMERCIAL_AT = 0x40; /* @ */
  102. var CHAR_LEFT_SQUARE_BRACKET = 0x5B; /* [ */
  103. var CHAR_RIGHT_SQUARE_BRACKET = 0x5D; /* ] */
  104. var CHAR_GRAVE_ACCENT = 0x60; /* ` */
  105. var CHAR_LEFT_CURLY_BRACKET = 0x7B; /* { */
  106. var CHAR_VERTICAL_LINE = 0x7C; /* | */
  107. var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */
  108. var ESCAPE_SEQUENCES = {};
  109. ESCAPE_SEQUENCES[0x00] = '\\0';
  110. ESCAPE_SEQUENCES[0x07] = '\\a';
  111. ESCAPE_SEQUENCES[0x08] = '\\b';
  112. ESCAPE_SEQUENCES[0x09] = '\\t';
  113. ESCAPE_SEQUENCES[0x0A] = '\\n';
  114. ESCAPE_SEQUENCES[0x0B] = '\\v';
  115. ESCAPE_SEQUENCES[0x0C] = '\\f';
  116. ESCAPE_SEQUENCES[0x0D] = '\\r';
  117. ESCAPE_SEQUENCES[0x1B] = '\\e';
  118. ESCAPE_SEQUENCES[0x22] = '\\"';
  119. ESCAPE_SEQUENCES[0x5C] = '\\\\';
  120. ESCAPE_SEQUENCES[0x85] = '\\N';
  121. ESCAPE_SEQUENCES[0xA0] = '\\_';
  122. ESCAPE_SEQUENCES[0x2028] = '\\L';
  123. ESCAPE_SEQUENCES[0x2029] = '\\P';
  124. var DEPRECATED_BOOLEANS_SYNTAX = [
  125. 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON',
  126. 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF'
  127. ];
  128. function compileStyleMap(schema, map) {
  129. var result, keys, index, length, tag, style, type;
  130. if (null === map) {
  131. return {};
  132. }
  133. result = {};
  134. keys = Object.keys(map);
  135. for (index = 0, length = keys.length; index < length; index += 1) {
  136. tag = keys[index];
  137. style = String(map[tag]);
  138. if ('!!' === tag.slice(0, 2)) {
  139. tag = 'tag:yaml.org,2002:' + tag.slice(2);
  140. }
  141. type = schema.compiledTypeMap[tag];
  142. if (type && _hasOwnProperty.call(type.styleAliases, style)) {
  143. style = type.styleAliases[style];
  144. }
  145. result[tag] = style;
  146. }
  147. return result;
  148. }
  149. function encodeHex(character) {
  150. var string, handle, length;
  151. string = character.toString(16).toUpperCase();
  152. if (character <= 0xFF) {
  153. handle = 'x';
  154. length = 2;
  155. } else if (character <= 0xFFFF) {
  156. handle = 'u';
  157. length = 4;
  158. } else if (character <= 0xFFFFFFFF) {
  159. handle = 'U';
  160. length = 8;
  161. } else {
  162. throw new YAMLException('code point within a string may not be greater than 0xFFFFFFFF');
  163. }
  164. return '\\' + handle + common.repeat('0', length - string.length) + string;
  165. }
  166. function State(options) {
  167. this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
  168. this.indent = Math.max(1, (options['indent'] || 2));
  169. this.skipInvalid = options['skipInvalid'] || false;
  170. this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']);
  171. this.styleMap = compileStyleMap(this.schema, options['styles'] || null);
  172. this.sortKeys = options['sortKeys'] || false;
  173. this.lineWidth = options['lineWidth'] || 80;
  174. this.noRefs = options['noRefs'] || false;
  175. this.implicitTypes = this.schema.compiledImplicit;
  176. this.explicitTypes = this.schema.compiledExplicit;
  177. this.tag = null;
  178. this.result = '';
  179. this.duplicates = [];
  180. this.usedDuplicates = null;
  181. }
  182. function indentString(string, spaces) {
  183. var ind = common.repeat(' ', spaces),
  184. position = 0,
  185. next = -1,
  186. result = '',
  187. line,
  188. length = string.length;
  189. while (position < length) {
  190. next = string.indexOf('\n', position);
  191. if (next === -1) {
  192. line = string.slice(position);
  193. position = length;
  194. } else {
  195. line = string.slice(position, next + 1);
  196. position = next + 1;
  197. }
  198. if (line.length && line !== '\n') {
  199. result += ind;
  200. }
  201. result += line;
  202. }
  203. return result;
  204. }
  205. function generateNextLine(state, level) {
  206. return '\n' + common.repeat(' ', state.indent * level);
  207. }
  208. function testImplicitResolving(state, str) {
  209. var index, length, type;
  210. for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
  211. type = state.implicitTypes[index];
  212. if (type.resolve(str)) {
  213. return true;
  214. }
  215. }
  216. return false;
  217. }
  218. function StringBuilder(source) {
  219. this.source = source;
  220. this.result = '';
  221. this.checkpoint = 0;
  222. }
  223. StringBuilder.prototype.takeUpTo = function (position) {
  224. var er;
  225. if (position < this.checkpoint) {
  226. er = new Error('position should be > checkpoint');
  227. er.position = position;
  228. er.checkpoint = this.checkpoint;
  229. throw er;
  230. }
  231. this.result += this.source.slice(this.checkpoint, position);
  232. this.checkpoint = position;
  233. return this;
  234. };
  235. StringBuilder.prototype.escapeChar = function () {
  236. var character, esc;
  237. character = this.source.charCodeAt(this.checkpoint);
  238. esc = ESCAPE_SEQUENCES[character] || encodeHex(character);
  239. this.result += esc;
  240. this.checkpoint += 1;
  241. return this;
  242. };
  243. StringBuilder.prototype.finish = function () {
  244. if (this.source.length > this.checkpoint) {
  245. this.takeUpTo(this.source.length);
  246. }
  247. };
  248. function writeScalar(state, object, level, iskey) {
  249. var simple, first, spaceWrap, folded, literal, single, double,
  250. sawLineFeed, linePosition, longestLine, indent, max, character,
  251. position, escapeSeq, hexEsc, previous, lineLength, modifier,
  252. trailingLineBreaks, result;
  253. if (0 === object.length) {
  254. state.dump = "''";
  255. return;
  256. }
  257. if (-1 !== DEPRECATED_BOOLEANS_SYNTAX.indexOf(object)) {
  258. state.dump = "'" + object + "'";
  259. return;
  260. }
  261. simple = true;
  262. first = object.length ? object.charCodeAt(0) : 0;
  263. spaceWrap = (CHAR_SPACE === first ||
  264. CHAR_SPACE === object.charCodeAt(object.length - 1));
  265. // Simplified check for restricted first characters
  266. // http://www.yaml.org/spec/1.2/spec.html#ns-plain-first%28c%29
  267. if (CHAR_MINUS === first ||
  268. CHAR_QUESTION === first ||
  269. CHAR_COMMERCIAL_AT === first ||
  270. CHAR_GRAVE_ACCENT === first) {
  271. simple = false;
  272. }
  273. // Can only use > and | if not wrapped in spaces or is not a key.
  274. // Also, don't use if in flow mode.
  275. if (spaceWrap || (state.flowLevel > -1 && state.flowLevel <= level)) {
  276. if (spaceWrap) {
  277. simple = false;
  278. }
  279. folded = false;
  280. literal = false;
  281. } else {
  282. folded = !iskey;
  283. literal = !iskey;
  284. }
  285. single = true;
  286. double = new StringBuilder(object);
  287. sawLineFeed = false;
  288. linePosition = 0;
  289. longestLine = 0;
  290. indent = state.indent * level;
  291. max = state.lineWidth;
  292. if (max === -1) {
  293. // Replace -1 with biggest ingeger number according to
  294. // http://ecma262-5.com/ELS5_HTML.htm#Section_8.5
  295. max = 9007199254740991;
  296. }
  297. if (indent < 40) {
  298. max -= indent;
  299. } else {
  300. max = 40;
  301. }
  302. for (position = 0; position < object.length; position++) {
  303. character = object.charCodeAt(position);
  304. if (simple) {
  305. // Characters that can never appear in the simple scalar
  306. if (!simpleChar(character)) {
  307. simple = false;
  308. } else {
  309. // Still simple. If we make it all the way through like
  310. // this, then we can just dump the string as-is.
  311. continue;
  312. }
  313. }
  314. if (single && character === CHAR_SINGLE_QUOTE) {
  315. single = false;
  316. }
  317. escapeSeq = ESCAPE_SEQUENCES[character];
  318. hexEsc = needsHexEscape(character);
  319. if (!escapeSeq && !hexEsc) {
  320. continue;
  321. }
  322. if (character !== CHAR_LINE_FEED &&
  323. character !== CHAR_DOUBLE_QUOTE &&
  324. character !== CHAR_SINGLE_QUOTE) {
  325. folded = false;
  326. literal = false;
  327. } else if (character === CHAR_LINE_FEED) {
  328. sawLineFeed = true;
  329. single = false;
  330. if (position > 0) {
  331. previous = object.charCodeAt(position - 1);
  332. if (previous === CHAR_SPACE) {
  333. literal = false;
  334. folded = false;
  335. }
  336. }
  337. if (folded) {
  338. lineLength = position - linePosition;
  339. linePosition = position;
  340. if (lineLength > longestLine) {
  341. longestLine = lineLength;
  342. }
  343. }
  344. }
  345. if (character !== CHAR_DOUBLE_QUOTE) {
  346. single = false;
  347. }
  348. double.takeUpTo(position);
  349. double.escapeChar();
  350. }
  351. if (simple && testImplicitResolving(state, object)) {
  352. simple = false;
  353. }
  354. modifier = '';
  355. if (folded || literal) {
  356. trailingLineBreaks = 0;
  357. if (object.charCodeAt(object.length - 1) === CHAR_LINE_FEED) {
  358. trailingLineBreaks += 1;
  359. if (object.charCodeAt(object.length - 2) === CHAR_LINE_FEED) {
  360. trailingLineBreaks += 1;
  361. }
  362. }
  363. if (trailingLineBreaks === 0) {
  364. modifier = '-';
  365. } else if (trailingLineBreaks === 2) {
  366. modifier = '+';
  367. }
  368. }
  369. if (literal && longestLine < max || state.tag !== null) {
  370. folded = false;
  371. }
  372. // If it's literally one line, then don't bother with the literal.
  373. // We may still want to do a fold, though, if it's a super long line.
  374. if (!sawLineFeed) {
  375. literal = false;
  376. }
  377. if (simple) {
  378. state.dump = object;
  379. } else if (single) {
  380. state.dump = '\'' + object + '\'';
  381. } else if (folded) {
  382. result = fold(object, max);
  383. state.dump = '>' + modifier + '\n' + indentString(result, indent);
  384. } else if (literal) {
  385. if (!modifier) {
  386. object = object.replace(/\n$/, '');
  387. }
  388. state.dump = '|' + modifier + '\n' + indentString(object, indent);
  389. } else if (double) {
  390. double.finish();
  391. state.dump = '"' + double.result + '"';
  392. } else {
  393. throw new Error('Failed to dump scalar value');
  394. }
  395. return;
  396. }
  397. // The `trailing` var is a regexp match of any trailing `\n` characters.
  398. //
  399. // There are three cases we care about:
  400. //
  401. // 1. One trailing `\n` on the string. Just use `|` or `>`.
  402. // This is the assumed default. (trailing = null)
  403. // 2. No trailing `\n` on the string. Use `|-` or `>-` to "chomp" the end.
  404. // 3. More than one trailing `\n` on the string. Use `|+` or `>+`.
  405. //
  406. // In the case of `>+`, these line breaks are *not* doubled (like the line
  407. // breaks within the string), so it's important to only end with the exact
  408. // same number as we started.
  409. function fold(object, max) {
  410. var result = '',
  411. position = 0,
  412. length = object.length,
  413. trailing = /\n+$/.exec(object),
  414. newLine;
  415. if (trailing) {
  416. length = trailing.index + 1;
  417. }
  418. while (position < length) {
  419. newLine = object.indexOf('\n', position);
  420. if (newLine > length || newLine === -1) {
  421. if (result) {
  422. result += '\n\n';
  423. }
  424. result += foldLine(object.slice(position, length), max);
  425. position = length;
  426. } else {
  427. if (result) {
  428. result += '\n\n';
  429. }
  430. result += foldLine(object.slice(position, newLine), max);
  431. position = newLine + 1;
  432. }
  433. }
  434. if (trailing && trailing[0] !== '\n') {
  435. result += trailing[0];
  436. }
  437. return result;
  438. }
  439. function foldLine(line, max) {
  440. if (line === '') {
  441. return line;
  442. }
  443. var foldRe = /[^\s] [^\s]/g,
  444. result = '',
  445. prevMatch = 0,
  446. foldStart = 0,
  447. match = foldRe.exec(line),
  448. index,
  449. foldEnd,
  450. folded;
  451. while (match) {
  452. index = match.index;
  453. // when we cross the max len, if the previous match would've
  454. // been ok, use that one, and carry on. If there was no previous
  455. // match on this fold section, then just have a long line.
  456. if (index - foldStart > max) {
  457. if (prevMatch !== foldStart) {
  458. foldEnd = prevMatch;
  459. } else {
  460. foldEnd = index;
  461. }
  462. if (result) {
  463. result += '\n';
  464. }
  465. folded = line.slice(foldStart, foldEnd);
  466. result += folded;
  467. foldStart = foldEnd + 1;
  468. }
  469. prevMatch = index + 1;
  470. match = foldRe.exec(line);
  471. }
  472. if (result) {
  473. result += '\n';
  474. }
  475. // if we end up with one last word at the end, then the last bit might
  476. // be slightly bigger than we wanted, because we exited out of the loop.
  477. if (foldStart !== prevMatch && line.length - foldStart > max) {
  478. result += line.slice(foldStart, prevMatch) + '\n' +
  479. line.slice(prevMatch + 1);
  480. } else {
  481. result += line.slice(foldStart);
  482. }
  483. return result;
  484. }
  485. // Returns true if character can be found in a simple scalar
  486. function simpleChar(character) {
  487. return CHAR_TAB !== character &&
  488. CHAR_LINE_FEED !== character &&
  489. CHAR_CARRIAGE_RETURN !== character &&
  490. CHAR_COMMA !== character &&
  491. CHAR_LEFT_SQUARE_BRACKET !== character &&
  492. CHAR_RIGHT_SQUARE_BRACKET !== character &&
  493. CHAR_LEFT_CURLY_BRACKET !== character &&
  494. CHAR_RIGHT_CURLY_BRACKET !== character &&
  495. CHAR_SHARP !== character &&
  496. CHAR_AMPERSAND !== character &&
  497. CHAR_ASTERISK !== character &&
  498. CHAR_EXCLAMATION !== character &&
  499. CHAR_VERTICAL_LINE !== character &&
  500. CHAR_GREATER_THAN !== character &&
  501. CHAR_SINGLE_QUOTE !== character &&
  502. CHAR_DOUBLE_QUOTE !== character &&
  503. CHAR_PERCENT !== character &&
  504. CHAR_COLON !== character &&
  505. !ESCAPE_SEQUENCES[character] &&
  506. !needsHexEscape(character);
  507. }
  508. // Returns true if the character code needs to be escaped.
  509. function needsHexEscape(character) {
  510. return !((0x00020 <= character && character <= 0x00007E) ||
  511. (0x00085 === character) ||
  512. (0x000A0 <= character && character <= 0x00D7FF) ||
  513. (0x0E000 <= character && character <= 0x00FFFD) ||
  514. (0x10000 <= character && character <= 0x10FFFF));
  515. }
  516. function writeFlowSequence(state, level, object) {
  517. var _result = '',
  518. _tag = state.tag,
  519. index,
  520. length;
  521. for (index = 0, length = object.length; index < length; index += 1) {
  522. // Write only valid elements.
  523. if (writeNode(state, level, object[index], false, false)) {
  524. if (0 !== index) {
  525. _result += ', ';
  526. }
  527. _result += state.dump;
  528. }
  529. }
  530. state.tag = _tag;
  531. state.dump = '[' + _result + ']';
  532. }
  533. function writeBlockSequence(state, level, object, compact) {
  534. var _result = '',
  535. _tag = state.tag,
  536. index,
  537. length;
  538. for (index = 0, length = object.length; index < length; index += 1) {
  539. // Write only valid elements.
  540. if (writeNode(state, level + 1, object[index], true, true)) {
  541. if (!compact || 0 !== index) {
  542. _result += generateNextLine(state, level);
  543. }
  544. _result += '- ' + state.dump;
  545. }
  546. }
  547. state.tag = _tag;
  548. state.dump = _result || '[]'; // Empty sequence if no valid values.
  549. }
  550. function writeFlowMapping(state, level, object) {
  551. var _result = '',
  552. _tag = state.tag,
  553. objectKeyList = Object.keys(object),
  554. index,
  555. length,
  556. objectKey,
  557. objectValue,
  558. pairBuffer;
  559. for (index = 0, length = objectKeyList.length; index < length; index += 1) {
  560. pairBuffer = '';
  561. if (0 !== index) {
  562. pairBuffer += ', ';
  563. }
  564. objectKey = objectKeyList[index];
  565. objectValue = object[objectKey];
  566. if (!writeNode(state, level, objectKey, false, false)) {
  567. continue; // Skip this pair because of invalid key;
  568. }
  569. if (state.dump.length > 1024) {
  570. pairBuffer += '? ';
  571. }
  572. pairBuffer += state.dump + ': ';
  573. if (!writeNode(state, level, objectValue, false, false)) {
  574. continue; // Skip this pair because of invalid value.
  575. }
  576. pairBuffer += state.dump;
  577. // Both key and value are valid.
  578. _result += pairBuffer;
  579. }
  580. state.tag = _tag;
  581. state.dump = '{' + _result + '}';
  582. }
  583. function writeBlockMapping(state, level, object, compact) {
  584. var _result = '',
  585. _tag = state.tag,
  586. objectKeyList = Object.keys(object),
  587. index,
  588. length,
  589. objectKey,
  590. objectValue,
  591. explicitPair,
  592. pairBuffer;
  593. // Allow sorting keys so that the output file is deterministic
  594. if (state.sortKeys === true) {
  595. // Default sorting
  596. objectKeyList.sort();
  597. } else if (typeof state.sortKeys === 'function') {
  598. // Custom sort function
  599. objectKeyList.sort(state.sortKeys);
  600. } else if (state.sortKeys) {
  601. // Something is wrong
  602. throw new YAMLException('sortKeys must be a boolean or a function');
  603. }
  604. for (index = 0, length = objectKeyList.length; index < length; index += 1) {
  605. pairBuffer = '';
  606. if (!compact || 0 !== index) {
  607. pairBuffer += generateNextLine(state, level);
  608. }
  609. objectKey = objectKeyList[index];
  610. objectValue = object[objectKey];
  611. if (!writeNode(state, level + 1, objectKey, true, true, true)) {
  612. continue; // Skip this pair because of invalid key.
  613. }
  614. explicitPair = (null !== state.tag && '?' !== state.tag) ||
  615. (state.dump && state.dump.length > 1024);
  616. if (explicitPair) {
  617. if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
  618. pairBuffer += '?';
  619. } else {
  620. pairBuffer += '? ';
  621. }
  622. }
  623. pairBuffer += state.dump;
  624. if (explicitPair) {
  625. pairBuffer += generateNextLine(state, level);
  626. }
  627. if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
  628. continue; // Skip this pair because of invalid value.
  629. }
  630. if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
  631. pairBuffer += ':';
  632. } else {
  633. pairBuffer += ': ';
  634. }
  635. pairBuffer += state.dump;
  636. // Both key and value are valid.
  637. _result += pairBuffer;
  638. }
  639. state.tag = _tag;
  640. state.dump = _result || '{}'; // Empty mapping if no valid pairs.
  641. }
  642. function detectType(state, object, explicit) {
  643. var _result, typeList, index, length, type, style;
  644. typeList = explicit ? state.explicitTypes : state.implicitTypes;
  645. for (index = 0, length = typeList.length; index < length; index += 1) {
  646. type = typeList[index];
  647. if ((type.instanceOf || type.predicate) &&
  648. (!type.instanceOf || (('object' === typeof object) && (object instanceof type.instanceOf))) &&
  649. (!type.predicate || type.predicate(object))) {
  650. state.tag = explicit ? type.tag : '?';
  651. if (type.represent) {
  652. style = state.styleMap[type.tag] || type.defaultStyle;
  653. if ('[object Function]' === _toString.call(type.represent)) {
  654. _result = type.represent(object, style);
  655. } else if (_hasOwnProperty.call(type.represent, style)) {
  656. _result = type.represent[style](object, style);
  657. } else {
  658. throw new YAMLException('!<' + type.tag + '> tag resolver accepts not "' + style + '" style');
  659. }
  660. state.dump = _result;
  661. }
  662. return true;
  663. }
  664. }
  665. return false;
  666. }
  667. // Serializes `object` and writes it to global `result`.
  668. // Returns true on success, or false on invalid object.
  669. //
  670. function writeNode(state, level, object, block, compact, iskey) {
  671. state.tag = null;
  672. state.dump = object;
  673. if (!detectType(state, object, false)) {
  674. detectType(state, object, true);
  675. }
  676. var type = _toString.call(state.dump);
  677. if (block) {
  678. block = (0 > state.flowLevel || state.flowLevel > level);
  679. }
  680. var objectOrArray = '[object Object]' === type || '[object Array]' === type,
  681. duplicateIndex,
  682. duplicate;
  683. if (objectOrArray) {
  684. duplicateIndex = state.duplicates.indexOf(object);
  685. duplicate = duplicateIndex !== -1;
  686. }
  687. if ((null !== state.tag && '?' !== state.tag) || duplicate || (2 !== state.indent && level > 0)) {
  688. compact = false;
  689. }
  690. if (duplicate && state.usedDuplicates[duplicateIndex]) {
  691. state.dump = '*ref_' + duplicateIndex;
  692. } else {
  693. if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
  694. state.usedDuplicates[duplicateIndex] = true;
  695. }
  696. if ('[object Object]' === type) {
  697. if (block && (0 !== Object.keys(state.dump).length)) {
  698. writeBlockMapping(state, level, state.dump, compact);
  699. if (duplicate) {
  700. state.dump = '&ref_' + duplicateIndex + state.dump;
  701. }
  702. } else {
  703. writeFlowMapping(state, level, state.dump);
  704. if (duplicate) {
  705. state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
  706. }
  707. }
  708. } else if ('[object Array]' === type) {
  709. if (block && (0 !== state.dump.length)) {
  710. writeBlockSequence(state, level, state.dump, compact);
  711. if (duplicate) {
  712. state.dump = '&ref_' + duplicateIndex + state.dump;
  713. }
  714. } else {
  715. writeFlowSequence(state, level, state.dump);
  716. if (duplicate) {
  717. state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
  718. }
  719. }
  720. } else if ('[object String]' === type) {
  721. if ('?' !== state.tag) {
  722. writeScalar(state, state.dump, level, iskey);
  723. }
  724. } else {
  725. if (state.skipInvalid) {
  726. return false;
  727. }
  728. throw new YAMLException('unacceptable kind of an object to dump ' + type);
  729. }
  730. if (null !== state.tag && '?' !== state.tag) {
  731. state.dump = '!<' + state.tag + '> ' + state.dump;
  732. }
  733. }
  734. return true;
  735. }
  736. function getDuplicateReferences(object, state) {
  737. var objects = [],
  738. duplicatesIndexes = [],
  739. index,
  740. length;
  741. inspectNode(object, objects, duplicatesIndexes);
  742. for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
  743. state.duplicates.push(objects[duplicatesIndexes[index]]);
  744. }
  745. state.usedDuplicates = new Array(length);
  746. }
  747. function inspectNode(object, objects, duplicatesIndexes) {
  748. var objectKeyList,
  749. index,
  750. length;
  751. if (null !== object && 'object' === typeof object) {
  752. index = objects.indexOf(object);
  753. if (-1 !== index) {
  754. if (-1 === duplicatesIndexes.indexOf(index)) {
  755. duplicatesIndexes.push(index);
  756. }
  757. } else {
  758. objects.push(object);
  759. if (Array.isArray(object)) {
  760. for (index = 0, length = object.length; index < length; index += 1) {
  761. inspectNode(object[index], objects, duplicatesIndexes);
  762. }
  763. } else {
  764. objectKeyList = Object.keys(object);
  765. for (index = 0, length = objectKeyList.length; index < length; index += 1) {
  766. inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
  767. }
  768. }
  769. }
  770. }
  771. }
  772. function dump(input, options) {
  773. options = options || {};
  774. var state = new State(options);
  775. if (!state.noRefs) {
  776. getDuplicateReferences(input, state);
  777. }
  778. if (writeNode(state, 0, input, true, true)) {
  779. return state.dump + '\n';
  780. }
  781. return '';
  782. }
  783. function safeDump(input, options) {
  784. return dump(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
  785. }
  786. module.exports.dump = dump;
  787. module.exports.safeDump = safeDump;
  788. },{"./common":2,"./exception":4,"./schema/default_full":9,"./schema/default_safe":10}],4:[function(require,module,exports){
  789. // YAML error class. http://stackoverflow.com/questions/8458984
  790. //
  791. 'use strict';
  792. function YAMLException(reason, mark) {
  793. // Super constructor
  794. Error.call(this);
  795. // Include stack trace in error object
  796. if (Error.captureStackTrace) {
  797. // Chrome and NodeJS
  798. Error.captureStackTrace(this, this.constructor);
  799. } else {
  800. // FF, IE 10+ and Safari 6+. Fallback for others
  801. this.stack = (new Error()).stack || '';
  802. }
  803. this.name = 'YAMLException';
  804. this.reason = reason;
  805. this.mark = mark;
  806. this.message = (this.reason || '(unknown reason)') + (this.mark ? ' ' + this.mark.toString() : '');
  807. }
  808. // Inherit from Error
  809. YAMLException.prototype = Object.create(Error.prototype);
  810. YAMLException.prototype.constructor = YAMLException;
  811. YAMLException.prototype.toString = function toString(compact) {
  812. var result = this.name + ': ';
  813. result += this.reason || '(unknown reason)';
  814. if (!compact && this.mark) {
  815. result += ' ' + this.mark.toString();
  816. }
  817. return result;
  818. };
  819. module.exports = YAMLException;
  820. },{}],5:[function(require,module,exports){
  821. 'use strict';
  822. /*eslint-disable max-len,no-use-before-define*/
  823. var common = require('./common');
  824. var YAMLException = require('./exception');
  825. var Mark = require('./mark');
  826. var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe');
  827. var DEFAULT_FULL_SCHEMA = require('./schema/default_full');
  828. var _hasOwnProperty = Object.prototype.hasOwnProperty;
  829. var CONTEXT_FLOW_IN = 1;
  830. var CONTEXT_FLOW_OUT = 2;
  831. var CONTEXT_BLOCK_IN = 3;
  832. var CONTEXT_BLOCK_OUT = 4;
  833. var CHOMPING_CLIP = 1;
  834. var CHOMPING_STRIP = 2;
  835. var CHOMPING_KEEP = 3;
  836. var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
  837. var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
  838. var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
  839. var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
  840. var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
  841. function is_EOL(c) {
  842. return (c === 0x0A/* LF */) || (c === 0x0D/* CR */);
  843. }
  844. function is_WHITE_SPACE(c) {
  845. return (c === 0x09/* Tab */) || (c === 0x20/* Space */);
  846. }
  847. function is_WS_OR_EOL(c) {
  848. return (c === 0x09/* Tab */) ||
  849. (c === 0x20/* Space */) ||
  850. (c === 0x0A/* LF */) ||
  851. (c === 0x0D/* CR */);
  852. }
  853. function is_FLOW_INDICATOR(c) {
  854. return 0x2C/* , */ === c ||
  855. 0x5B/* [ */ === c ||
  856. 0x5D/* ] */ === c ||
  857. 0x7B/* { */ === c ||
  858. 0x7D/* } */ === c;
  859. }
  860. function fromHexCode(c) {
  861. var lc;
  862. if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) {
  863. return c - 0x30;
  864. }
  865. /*eslint-disable no-bitwise*/
  866. lc = c | 0x20;
  867. if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) {
  868. return lc - 0x61 + 10;
  869. }
  870. return -1;
  871. }
  872. function escapedHexLen(c) {
  873. if (c === 0x78/* x */) { return 2; }
  874. if (c === 0x75/* u */) { return 4; }
  875. if (c === 0x55/* U */) { return 8; }
  876. return 0;
  877. }
  878. function fromDecimalCode(c) {
  879. if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) {
  880. return c - 0x30;
  881. }
  882. return -1;
  883. }
  884. function simpleEscapeSequence(c) {
  885. return (c === 0x30/* 0 */) ? '\x00' :
  886. (c === 0x61/* a */) ? '\x07' :
  887. (c === 0x62/* b */) ? '\x08' :
  888. (c === 0x74/* t */) ? '\x09' :
  889. (c === 0x09/* Tab */) ? '\x09' :
  890. (c === 0x6E/* n */) ? '\x0A' :
  891. (c === 0x76/* v */) ? '\x0B' :
  892. (c === 0x66/* f */) ? '\x0C' :
  893. (c === 0x72/* r */) ? '\x0D' :
  894. (c === 0x65/* e */) ? '\x1B' :
  895. (c === 0x20/* Space */) ? ' ' :
  896. (c === 0x22/* " */) ? '\x22' :
  897. (c === 0x2F/* / */) ? '/' :
  898. (c === 0x5C/* \ */) ? '\x5C' :
  899. (c === 0x4E/* N */) ? '\x85' :
  900. (c === 0x5F/* _ */) ? '\xA0' :
  901. (c === 0x4C/* L */) ? '\u2028' :
  902. (c === 0x50/* P */) ? '\u2029' : '';
  903. }
  904. function charFromCodepoint(c) {
  905. if (c <= 0xFFFF) {
  906. return String.fromCharCode(c);
  907. }
  908. // Encode UTF-16 surrogate pair
  909. // https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF
  910. return String.fromCharCode(((c - 0x010000) >> 10) + 0xD800,
  911. ((c - 0x010000) & 0x03FF) + 0xDC00);
  912. }
  913. var simpleEscapeCheck = new Array(256); // integer, for fast access
  914. var simpleEscapeMap = new Array(256);
  915. for (var i = 0; i < 256; i++) {
  916. simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
  917. simpleEscapeMap[i] = simpleEscapeSequence(i);
  918. }
  919. function State(input, options) {
  920. this.input = input;
  921. this.filename = options['filename'] || null;
  922. this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
  923. this.onWarning = options['onWarning'] || null;
  924. this.legacy = options['legacy'] || false;
  925. this.json = options['json'] || false;
  926. this.implicitTypes = this.schema.compiledImplicit;
  927. this.typeMap = this.schema.compiledTypeMap;
  928. this.length = input.length;
  929. this.position = 0;
  930. this.line = 0;
  931. this.lineStart = 0;
  932. this.lineIndent = 0;
  933. this.documents = [];
  934. /*
  935. this.version;
  936. this.checkLineBreaks;
  937. this.tagMap;
  938. this.anchorMap;
  939. this.tag;
  940. this.anchor;
  941. this.kind;
  942. this.result;*/
  943. }
  944. function generateError(state, message) {
  945. return new YAMLException(
  946. message,
  947. new Mark(state.filename, state.input, state.position, state.line, (state.position - state.lineStart)));
  948. }
  949. function throwError(state, message) {
  950. throw generateError(state, message);
  951. }
  952. function throwWarning(state, message) {
  953. if (state.onWarning) {
  954. state.onWarning.call(null, generateError(state, message));
  955. }
  956. }
  957. var directiveHandlers = {
  958. YAML: function handleYamlDirective(state, name, args) {
  959. var match, major, minor;
  960. if (null !== state.version) {
  961. throwError(state, 'duplication of %YAML directive');
  962. }
  963. if (1 !== args.length) {
  964. throwError(state, 'YAML directive accepts exactly one argument');
  965. }
  966. match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
  967. if (null === match) {
  968. throwError(state, 'ill-formed argument of the YAML directive');
  969. }
  970. major = parseInt(match[1], 10);
  971. minor = parseInt(match[2], 10);
  972. if (1 !== major) {
  973. throwError(state, 'unacceptable YAML version of the document');
  974. }
  975. state.version = args[0];
  976. state.checkLineBreaks = (minor < 2);
  977. if (1 !== minor && 2 !== minor) {
  978. throwWarning(state, 'unsupported YAML version of the document');
  979. }
  980. },
  981. TAG: function handleTagDirective(state, name, args) {
  982. var handle, prefix;
  983. if (2 !== args.length) {
  984. throwError(state, 'TAG directive accepts exactly two arguments');
  985. }
  986. handle = args[0];
  987. prefix = args[1];
  988. if (!PATTERN_TAG_HANDLE.test(handle)) {
  989. throwError(state, 'ill-formed tag handle (first argument) of the TAG directive');
  990. }
  991. if (_hasOwnProperty.call(state.tagMap, handle)) {
  992. throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
  993. }
  994. if (!PATTERN_TAG_URI.test(prefix)) {
  995. throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive');
  996. }
  997. state.tagMap[handle] = prefix;
  998. }
  999. };
  1000. function captureSegment(state, start, end, checkJson) {
  1001. var _position, _length, _character, _result;
  1002. if (start < end) {
  1003. _result = state.input.slice(start, end);
  1004. if (checkJson) {
  1005. for (_position = 0, _length = _result.length;
  1006. _position < _length;
  1007. _position += 1) {
  1008. _character = _result.charCodeAt(_position);
  1009. if (!(0x09 === _character ||
  1010. 0x20 <= _character && _character <= 0x10FFFF)) {
  1011. throwError(state, 'expected valid JSON character');
  1012. }
  1013. }
  1014. } else if (PATTERN_NON_PRINTABLE.test(_result)) {
  1015. throwError(state, 'the stream contains non-printable characters');
  1016. }
  1017. state.result += _result;
  1018. }
  1019. }
  1020. function mergeMappings(state, destination, source, overridableKeys) {
  1021. var sourceKeys, key, index, quantity;
  1022. if (!common.isObject(source)) {
  1023. throwError(state, 'cannot merge mappings; the provided source object is unacceptable');
  1024. }
  1025. sourceKeys = Object.keys(source);
  1026. for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
  1027. key = sourceKeys[index];
  1028. if (!_hasOwnProperty.call(destination, key)) {
  1029. destination[key] = source[key];
  1030. overridableKeys[key] = true;
  1031. }
  1032. }
  1033. }
  1034. function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode) {
  1035. var index, quantity;
  1036. keyNode = String(keyNode);
  1037. if (null === _result) {
  1038. _result = {};
  1039. }
  1040. if ('tag:yaml.org,2002:merge' === keyTag) {
  1041. if (Array.isArray(valueNode)) {
  1042. for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
  1043. mergeMappings(state, _result, valueNode[index], overridableKeys);
  1044. }
  1045. } else {
  1046. mergeMappings(state, _result, valueNode, overridableKeys);
  1047. }
  1048. } else {
  1049. if (!state.json &&
  1050. !_hasOwnProperty.call(overridableKeys, keyNode) &&
  1051. _hasOwnProperty.call(_result, keyNode)) {
  1052. throwError(state, 'duplicated mapping key');
  1053. }
  1054. _result[keyNode] = valueNode;
  1055. delete overridableKeys[keyNode];
  1056. }
  1057. return _result;
  1058. }
  1059. function readLineBreak(state) {
  1060. var ch;
  1061. ch = state.input.charCodeAt(state.position);
  1062. if (0x0A/* LF */ === ch) {
  1063. state.position++;
  1064. } else if (0x0D/* CR */ === ch) {
  1065. state.position++;
  1066. if (0x0A/* LF */ === state.input.charCodeAt(state.position)) {
  1067. state.position++;
  1068. }
  1069. } else {
  1070. throwError(state, 'a line break is expected');
  1071. }
  1072. state.line += 1;
  1073. state.lineStart = state.position;
  1074. }
  1075. function skipSeparationSpace(state, allowComments, checkIndent) {
  1076. var lineBreaks = 0,
  1077. ch = state.input.charCodeAt(state.position);
  1078. while (0 !== ch) {
  1079. while (is_WHITE_SPACE(ch)) {
  1080. ch = state.input.charCodeAt(++state.position);
  1081. }
  1082. if (allowComments && 0x23/* # */ === ch) {
  1083. do {
  1084. ch = state.input.charCodeAt(++state.position);
  1085. } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && 0 !== ch);
  1086. }
  1087. if (is_EOL(ch)) {
  1088. readLineBreak(state);
  1089. ch = state.input.charCodeAt(state.position);
  1090. lineBreaks++;
  1091. state.lineIndent = 0;
  1092. while (0x20/* Space */ === ch) {
  1093. state.lineIndent++;
  1094. ch = state.input.charCodeAt(++state.position);
  1095. }
  1096. } else {
  1097. break;
  1098. }
  1099. }
  1100. if (-1 !== checkIndent && 0 !== lineBreaks && state.lineIndent < checkIndent) {
  1101. throwWarning(state, 'deficient indentation');
  1102. }
  1103. return lineBreaks;
  1104. }
  1105. function testDocumentSeparator(state) {
  1106. var _position = state.position,
  1107. ch;
  1108. ch = state.input.charCodeAt(_position);
  1109. // Condition state.position === state.lineStart is tested
  1110. // in parent on each call, for efficiency. No needs to test here again.
  1111. if ((0x2D/* - */ === ch || 0x2E/* . */ === ch) &&
  1112. state.input.charCodeAt(_position + 1) === ch &&
  1113. state.input.charCodeAt(_position + 2) === ch) {
  1114. _position += 3;
  1115. ch = state.input.charCodeAt(_position);
  1116. if (ch === 0 || is_WS_OR_EOL(ch)) {
  1117. return true;
  1118. }
  1119. }
  1120. return false;
  1121. }
  1122. function writeFoldedLines(state, count) {
  1123. if (1 === count) {
  1124. state.result += ' ';
  1125. } else if (count > 1) {
  1126. state.result += common.repeat('\n', count - 1);
  1127. }
  1128. }
  1129. function readPlainScalar(state, nodeIndent, withinFlowCollection) {
  1130. var preceding,
  1131. following,
  1132. captureStart,
  1133. captureEnd,
  1134. hasPendingContent,
  1135. _line,
  1136. _lineStart,
  1137. _lineIndent,
  1138. _kind = state.kind,
  1139. _result = state.result,
  1140. ch;
  1141. ch = state.input.charCodeAt(state.position);
  1142. if (is_WS_OR_EOL(ch) ||
  1143. is_FLOW_INDICATOR(ch) ||
  1144. 0x23/* # */ === ch ||
  1145. 0x26/* & */ === ch ||
  1146. 0x2A/* * */ === ch ||
  1147. 0x21/* ! */ === ch ||
  1148. 0x7C/* | */ === ch ||
  1149. 0x3E/* > */ === ch ||
  1150. 0x27/* ' */ === ch ||
  1151. 0x22/* " */ === ch ||
  1152. 0x25/* % */ === ch ||
  1153. 0x40/* @ */ === ch ||
  1154. 0x60/* ` */ === ch) {
  1155. return false;
  1156. }
  1157. if (0x3F/* ? */ === ch || 0x2D/* - */ === ch) {
  1158. following = state.input.charCodeAt(state.position + 1);
  1159. if (is_WS_OR_EOL(following) ||
  1160. withinFlowCollection && is_FLOW_INDICATOR(following)) {
  1161. return false;
  1162. }
  1163. }
  1164. state.kind = 'scalar';
  1165. state.result = '';
  1166. captureStart = captureEnd = state.position;
  1167. hasPendingContent = false;
  1168. while (0 !== ch) {
  1169. if (0x3A/* : */ === ch) {
  1170. following = state.input.charCodeAt(state.position + 1);
  1171. if (is_WS_OR_EOL(following) ||
  1172. withinFlowCollection && is_FLOW_INDICATOR(following)) {
  1173. break;
  1174. }
  1175. } else if (0x23/* # */ === ch) {
  1176. preceding = state.input.charCodeAt(state.position - 1);
  1177. if (is_WS_OR_EOL(preceding)) {
  1178. break;
  1179. }
  1180. } else if ((state.position === state.lineStart && testDocumentSeparator(state)) ||
  1181. withinFlowCollection && is_FLOW_INDICATOR(ch)) {
  1182. break;
  1183. } else if (is_EOL(ch)) {
  1184. _line = state.line;
  1185. _lineStart = state.lineStart;
  1186. _lineIndent = state.lineIndent;
  1187. skipSeparationSpace(state, false, -1);
  1188. if (state.lineIndent >= nodeIndent) {
  1189. hasPendingContent = true;
  1190. ch = state.input.charCodeAt(state.position);
  1191. continue;
  1192. } else {
  1193. state.position = captureEnd;
  1194. state.line = _line;
  1195. state.lineStart = _lineStart;
  1196. state.lineIndent = _lineIndent;
  1197. break;
  1198. }
  1199. }
  1200. if (hasPendingContent) {
  1201. captureSegment(state, captureStart, captureEnd, false);
  1202. writeFoldedLines(state, state.line - _line);
  1203. captureStart = captureEnd = state.position;
  1204. hasPendingContent = false;
  1205. }
  1206. if (!is_WHITE_SPACE(ch)) {
  1207. captureEnd = state.position + 1;
  1208. }
  1209. ch = state.input.charCodeAt(++state.position);
  1210. }
  1211. captureSegment(state, captureStart, captureEnd, false);
  1212. if (state.result) {
  1213. return true;
  1214. }
  1215. state.kind = _kind;
  1216. state.result = _result;
  1217. return false;
  1218. }
  1219. function readSingleQuotedScalar(state, nodeIndent) {
  1220. var ch,
  1221. captureStart, captureEnd;
  1222. ch = state.input.charCodeAt(state.position);
  1223. if (0x27/* ' */ !== ch) {
  1224. return false;
  1225. }
  1226. state.kind = 'scalar';
  1227. state.result = '';
  1228. state.position++;
  1229. captureStart = captureEnd = state.position;
  1230. while (0 !== (ch = state.input.charCodeAt(state.position))) {
  1231. if (0x27/* ' */ === ch) {
  1232. captureSegment(state, captureStart, state.position, true);
  1233. ch = state.input.charCodeAt(++state.position);
  1234. if (0x27/* ' */ === ch) {
  1235. captureStart = captureEnd = state.position;
  1236. state.position++;
  1237. } else {
  1238. return true;
  1239. }
  1240. } else if (is_EOL(ch)) {
  1241. captureSegment(state, captureStart, captureEnd, true);
  1242. writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
  1243. captureStart = captureEnd = state.position;
  1244. } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
  1245. throwError(state, 'unexpected end of the document within a single quoted scalar');
  1246. } else {
  1247. state.position++;
  1248. captureEnd = state.position;
  1249. }
  1250. }
  1251. throwError(state, 'unexpected end of the stream within a single quoted scalar');
  1252. }
  1253. function readDoubleQuotedScalar(state, nodeIndent) {
  1254. var captureStart,
  1255. captureEnd,
  1256. hexLength,
  1257. hexResult,
  1258. tmp,
  1259. ch;
  1260. ch = state.input.charCodeAt(state.position);
  1261. if (0x22/* " */ !== ch) {
  1262. return false;
  1263. }
  1264. state.kind = 'scalar';
  1265. state.result = '';
  1266. state.position++;
  1267. captureStart = captureEnd = state.position;
  1268. while (0 !== (ch = state.input.charCodeAt(state.position))) {
  1269. if (0x22/* " */ === ch) {
  1270. captureSegment(state, captureStart, state.position, true);
  1271. state.position++;
  1272. return true;
  1273. } else if (0x5C/* \ */ === ch) {
  1274. captureSegment(state, captureStart, state.position, true);
  1275. ch = state.input.charCodeAt(++state.position);
  1276. if (is_EOL(ch)) {
  1277. skipSeparationSpace(state, false, nodeIndent);
  1278. // TODO: rework to inline fn with no type cast?
  1279. } else if (ch < 256 && simpleEscapeCheck[ch]) {
  1280. state.result += simpleEscapeMap[ch];
  1281. state.position++;
  1282. } else if ((tmp = escapedHexLen(ch)) > 0) {
  1283. hexLength = tmp;
  1284. hexResult = 0;
  1285. for (; hexLength > 0; hexLength--) {
  1286. ch = state.input.charCodeAt(++state.position);
  1287. if ((tmp = fromHexCode(ch)) >= 0) {
  1288. hexResult = (hexResult << 4) + tmp;
  1289. } else {
  1290. throwError(state, 'expected hexadecimal character');
  1291. }
  1292. }
  1293. state.result += charFromCodepoint(hexResult);
  1294. state.position++;
  1295. } else {
  1296. throwError(state, 'unknown escape sequence');
  1297. }
  1298. captureStart = captureEnd = state.position;
  1299. } else if (is_EOL(ch)) {
  1300. captureSegment(state, captureStart, captureEnd, true);
  1301. writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
  1302. captureStart = captureEnd = state.position;
  1303. } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
  1304. throwError(state, 'unexpected end of the document within a double quoted scalar');
  1305. } else {
  1306. state.position++;
  1307. captureEnd = state.position;
  1308. }
  1309. }
  1310. throwError(state, 'unexpected end of the stream within a double quoted scalar');
  1311. }
  1312. function readFlowCollection(state, nodeIndent) {
  1313. var readNext = true,
  1314. _line,
  1315. _tag = state.tag,
  1316. _result,
  1317. _anchor = state.anchor,
  1318. following,
  1319. terminator,
  1320. isPair,
  1321. isExplicitPair,
  1322. isMapping,
  1323. overridableKeys = {},
  1324. keyNode,
  1325. keyTag,
  1326. valueNode,
  1327. ch;
  1328. ch = state.input.charCodeAt(state.position);
  1329. if (ch === 0x5B/* [ */) {
  1330. terminator = 0x5D;/* ] */
  1331. isMapping = false;
  1332. _result = [];
  1333. } else if (ch === 0x7B/* { */) {
  1334. terminator = 0x7D;/* } */
  1335. isMapping = true;
  1336. _result = {};
  1337. } else {
  1338. return false;
  1339. }
  1340. if (null !== state.anchor) {
  1341. state.anchorMap[state.anchor] = _result;
  1342. }
  1343. ch = state.input.charCodeAt(++state.position);
  1344. while (0 !== ch) {
  1345. skipSeparationSpace(state, true, nodeIndent);
  1346. ch = state.input.charCodeAt(state.position);
  1347. if (ch === terminator) {
  1348. state.position++;
  1349. state.tag = _tag;
  1350. state.anchor = _anchor;
  1351. state.kind = isMapping ? 'mapping' : 'sequence';
  1352. state.result = _result;
  1353. return true;
  1354. } else if (!readNext) {
  1355. throwError(state, 'missed comma between flow collection entries');
  1356. }
  1357. keyTag = keyNode = valueNode = null;
  1358. isPair = isExplicitPair = false;
  1359. if (0x3F/* ? */ === ch) {
  1360. following = state.input.charCodeAt(state.position + 1);
  1361. if (is_WS_OR_EOL(following)) {
  1362. isPair = isExplicitPair = true;
  1363. state.position++;
  1364. skipSeparationSpace(state, true, nodeIndent);
  1365. }
  1366. }
  1367. _line = state.line;
  1368. composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
  1369. keyTag = state.tag;
  1370. keyNode = state.result;
  1371. skipSeparationSpace(state, true, nodeIndent);
  1372. ch = state.input.charCodeAt(state.position);
  1373. if ((isExplicitPair || state.line === _line) && 0x3A/* : */ === ch) {
  1374. isPair = true;
  1375. ch = state.input.charCodeAt(++state.position);
  1376. skipSeparationSpace(state, true, nodeIndent);
  1377. composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
  1378. valueNode = state.result;
  1379. }
  1380. if (isMapping) {
  1381. storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode);
  1382. } else if (isPair) {
  1383. _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode));
  1384. } else {
  1385. _result.push(keyNode);
  1386. }
  1387. skipSeparationSpace(state, true, nodeIndent);
  1388. ch = state.input.charCodeAt(state.position);
  1389. if (0x2C/* , */ === ch) {
  1390. readNext = true;
  1391. ch = state.input.charCodeAt(++state.position);
  1392. } else {
  1393. readNext = false;
  1394. }
  1395. }
  1396. throwError(state, 'unexpected end of the stream within a flow collection');
  1397. }
  1398. function readBlockScalar(state, nodeIndent) {
  1399. var captureStart,
  1400. folding,
  1401. chomping = CHOMPING_CLIP,
  1402. detectedIndent = false,
  1403. textIndent = nodeIndent,
  1404. emptyLines = 0,
  1405. atMoreIndented = false,
  1406. tmp,
  1407. ch;
  1408. ch = state.input.charCodeAt(state.position);
  1409. if (ch === 0x7C/* | */) {
  1410. folding = false;
  1411. } else if (ch === 0x3E/* > */) {
  1412. folding = true;
  1413. } else {
  1414. return false;
  1415. }
  1416. state.kind = 'scalar';
  1417. state.result = '';
  1418. while (0 !== ch) {
  1419. ch = state.input.charCodeAt(++state.position);
  1420. if (0x2B/* + */ === ch || 0x2D/* - */ === ch) {
  1421. if (CHOMPING_CLIP === chomping) {
  1422. chomping = (0x2B/* + */ === ch) ? CHOMPING_KEEP : CHOMPING_STRIP;
  1423. } else {
  1424. throwError(state, 'repeat of a chomping mode identifier');
  1425. }
  1426. } else if ((tmp = fromDecimalCode(ch)) >= 0) {
  1427. if (tmp === 0) {
  1428. throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one');
  1429. } else if (!detectedIndent) {
  1430. textIndent = nodeIndent + tmp - 1;
  1431. detectedIndent = true;
  1432. } else {
  1433. throwError(state, 'repeat of an indentation width identifier');
  1434. }
  1435. } else {
  1436. break;
  1437. }
  1438. }
  1439. if (is_WHITE_SPACE(ch)) {
  1440. do { ch = state.input.charCodeAt(++state.position); }
  1441. while (is_WHITE_SPACE(ch));
  1442. if (0x23/* # */ === ch) {
  1443. do { ch = state.input.charCodeAt(++state.position); }
  1444. while (!is_EOL(ch) && (0 !== ch));
  1445. }
  1446. }
  1447. while (0 !== ch) {
  1448. readLineBreak(state);
  1449. state.lineIndent = 0;
  1450. ch = state.input.charCodeAt(state.position);
  1451. while ((!detectedIndent || state.lineIndent < textIndent) &&
  1452. (0x20/* Space */ === ch)) {
  1453. state.lineIndent++;
  1454. ch = state.input.charCodeAt(++state.position);
  1455. }
  1456. if (!detectedIndent && state.lineIndent > textIndent) {
  1457. textIndent = state.lineIndent;
  1458. }
  1459. if (is_EOL(ch)) {
  1460. emptyLines++;
  1461. continue;
  1462. }
  1463. // End of the scalar.
  1464. if (state.lineIndent < textIndent) {
  1465. // Perform the chomping.
  1466. if (chomping === CHOMPING_KEEP) {
  1467. state.result += common.repeat('\n', emptyLines);
  1468. } else if (chomping === CHOMPING_CLIP) {
  1469. if (detectedIndent) { // i.e. only if the scalar is not empty.
  1470. state.result += '\n';
  1471. }
  1472. }
  1473. // Break this `while` cycle and go to the funciton's epilogue.
  1474. break;
  1475. }
  1476. // Folded style: use fancy rules to handle line breaks.
  1477. if (folding) {
  1478. // Lines starting with white space characters (more-indented lines) are not folded.
  1479. if (is_WHITE_SPACE(ch)) {
  1480. atMoreIndented = true;
  1481. state.result += common.repeat('\n', emptyLines + 1);
  1482. // End of more-indented block.
  1483. } else if (atMoreIndented) {
  1484. atMoreIndented = false;
  1485. state.result += common.repeat('\n', emptyLines + 1);
  1486. // Just one line break - perceive as the same line.
  1487. } else if (0 === emptyLines) {
  1488. if (detectedIndent) { // i.e. only if we have already read some scalar content.
  1489. state.result += ' ';
  1490. }
  1491. // Several line breaks - perceive as different lines.
  1492. } else {
  1493. state.result += common.repeat('\n', emptyLines);
  1494. }
  1495. // Literal style: just add exact number of line breaks between content lines.
  1496. } else if (detectedIndent) {
  1497. // If current line isn't the first one - count line break from the last content line.
  1498. state.result += common.repeat('\n', emptyLines + 1);
  1499. } else {
  1500. // In case of the first content line - count only empty lines.
  1501. state.result += common.repeat('\n', emptyLines);
  1502. }
  1503. detectedIndent = true;
  1504. emptyLines = 0;
  1505. captureStart = state.position;
  1506. while (!is_EOL(ch) && (0 !== ch)) {
  1507. ch = state.input.charCodeAt(++state.position);
  1508. }
  1509. captureSegment(state, captureStart, state.position, false);
  1510. }
  1511. return true;
  1512. }
  1513. function readBlockSequence(state, nodeIndent) {
  1514. var _line,
  1515. _tag = state.tag,
  1516. _anchor = state.anchor,
  1517. _result = [],
  1518. following,
  1519. detected = false,
  1520. ch;
  1521. if (null !== state.anchor) {
  1522. state.anchorMap[state.anchor] = _result;
  1523. }
  1524. ch = state.input.charCodeAt(state.position);
  1525. while (0 !== ch) {
  1526. if (0x2D/* - */ !== ch) {
  1527. break;
  1528. }
  1529. following = state.input.charCodeAt(state.position + 1);
  1530. if (!is_WS_OR_EOL(following)) {
  1531. break;
  1532. }
  1533. detected = true;
  1534. state.position++;
  1535. if (skipSeparationSpace(state, true, -1)) {
  1536. if (state.lineIndent <= nodeIndent) {
  1537. _result.push(null);
  1538. ch = state.input.charCodeAt(state.position);
  1539. continue;
  1540. }
  1541. }
  1542. _line = state.line;
  1543. composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
  1544. _result.push(state.result);
  1545. skipSeparationSpace(state, true, -1);
  1546. ch = state.input.charCodeAt(state.position);
  1547. if ((state.line === _line || state.lineIndent > nodeIndent) && (0 !== ch)) {
  1548. throwError(state, 'bad indentation of a sequence entry');
  1549. } else if (state.lineIndent < nodeIndent) {
  1550. break;
  1551. }
  1552. }
  1553. if (detected) {
  1554. state.tag = _tag;
  1555. state.anchor = _anchor;
  1556. state.kind = 'sequence';
  1557. state.result = _result;
  1558. return true;
  1559. }
  1560. return false;
  1561. }
  1562. function readBlockMapping(state, nodeIndent, flowIndent) {
  1563. var following,
  1564. allowCompact,
  1565. _line,
  1566. _tag = state.tag,
  1567. _anchor = state.anchor,
  1568. _result = {},
  1569. overridableKeys = {},
  1570. keyTag = null,
  1571. keyNode = null,
  1572. valueNode = null,
  1573. atExplicitKey = false,
  1574. detected = false,
  1575. ch;
  1576. if (null !== state.anchor) {
  1577. state.anchorMap[state.anchor] = _result;
  1578. }
  1579. ch = state.input.charCodeAt(state.position);
  1580. while (0 !== ch) {
  1581. following = state.input.charCodeAt(state.position + 1);
  1582. _line = state.line; // Save the current line.
  1583. //
  1584. // Explicit notation case. There are two separate blocks:
  1585. // first for the key (denoted by "?") and second for the value (denoted by ":")
  1586. //
  1587. if ((0x3F/* ? */ === ch || 0x3A/* : */ === ch) && is_WS_OR_EOL(following)) {
  1588. if (0x3F/* ? */ === ch) {
  1589. if (atExplicitKey) {
  1590. storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
  1591. keyTag = keyNode = valueNode = null;
  1592. }
  1593. detected = true;
  1594. atExplicitKey = true;
  1595. allowCompact = true;
  1596. } else if (atExplicitKey) {
  1597. // i.e. 0x3A/* : */ === character after the explicit key.
  1598. atExplicitKey = false;
  1599. allowCompact = true;
  1600. } else {
  1601. throwError(state, 'incomplete explicit mapping pair; a key node is missed');
  1602. }
  1603. state.position += 1;
  1604. ch = following;
  1605. //
  1606. // Implicit notation case. Flow-style node as the key first, then ":", and the value.
  1607. //
  1608. } else if (composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
  1609. if (state.line === _line) {
  1610. ch = state.input.charCodeAt(state.position);
  1611. while (is_WHITE_SPACE(ch)) {
  1612. ch = state.input.charCodeAt(++state.position);
  1613. }
  1614. if (0x3A/* : */ === ch) {
  1615. ch = state.input.charCodeAt(++state.position);
  1616. if (!is_WS_OR_EOL(ch)) {
  1617. throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping');
  1618. }
  1619. if (atExplicitKey) {
  1620. storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
  1621. keyTag = keyNode = valueNode = null;
  1622. }
  1623. detected = true;
  1624. atExplicitKey = false;
  1625. allowCompact = false;
  1626. keyTag = state.tag;
  1627. keyNode = state.result;
  1628. } else if (detected) {
  1629. throwError(state, 'can not read an implicit mapping pair; a colon is missed');
  1630. } else {
  1631. state.tag = _tag;
  1632. state.anchor = _anchor;
  1633. return true; // Keep the result of `composeNode`.
  1634. }
  1635. } else if (detected) {
  1636. throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key');
  1637. } else {
  1638. state.tag = _tag;
  1639. state.anchor = _anchor;
  1640. return true; // Keep the result of `composeNode`.
  1641. }
  1642. } else {
  1643. break; // Reading is done. Go to the epilogue.
  1644. }
  1645. //
  1646. // Common reading code for both explicit and implicit notations.
  1647. //
  1648. if (state.line === _line || state.lineIndent > nodeIndent) {
  1649. if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
  1650. if (atExplicitKey) {
  1651. keyNode = state.result;
  1652. } else {
  1653. valueNode = state.result;
  1654. }
  1655. }
  1656. if (!atExplicitKey) {
  1657. storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode);
  1658. keyTag = keyNode = valueNode = null;
  1659. }
  1660. skipSeparationSpace(state, true, -1);
  1661. ch = state.input.charCodeAt(state.position);
  1662. }
  1663. if (state.lineIndent > nodeIndent && (0 !== ch)) {
  1664. throwError(state, 'bad indentation of a mapping entry');
  1665. } else if (state.lineIndent < nodeIndent) {
  1666. break;
  1667. }
  1668. }
  1669. //
  1670. // Epilogue.
  1671. //
  1672. // Special case: last mapping's node contains only the key in explicit notation.
  1673. if (atExplicitKey) {
  1674. storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
  1675. }
  1676. // Expose the resulting mapping.
  1677. if (detected) {
  1678. state.tag = _tag;
  1679. state.anchor = _anchor;
  1680. state.kind = 'mapping';
  1681. state.result = _result;
  1682. }
  1683. return detected;
  1684. }
  1685. function readTagProperty(state) {
  1686. var _position,
  1687. isVerbatim = false,
  1688. isNamed = false,
  1689. tagHandle,
  1690. tagName,
  1691. ch;
  1692. ch = state.input.charCodeAt(state.position);
  1693. if (0x21/* ! */ !== ch) {
  1694. return false;
  1695. }
  1696. if (null !== state.tag) {
  1697. throwError(state, 'duplication of a tag property');
  1698. }
  1699. ch = state.input.charCodeAt(++state.position);
  1700. if (0x3C/* < */ === ch) {
  1701. isVerbatim = true;
  1702. ch = state.input.charCodeAt(++state.position);
  1703. } else if (0x21/* ! */ === ch) {
  1704. isNamed = true;
  1705. tagHandle = '!!';
  1706. ch = state.input.charCodeAt(++state.position);
  1707. } else {
  1708. tagHandle = '!';
  1709. }
  1710. _position = state.position;
  1711. if (isVerbatim) {
  1712. do { ch = state.input.charCodeAt(++state.position); }
  1713. while (0 !== ch && 0x3E/* > */ !== ch);
  1714. if (state.position < state.length) {
  1715. tagName = state.input.slice(_position, state.position);
  1716. ch = state.input.charCodeAt(++state.position);
  1717. } else {
  1718. throwError(state, 'unexpected end of the stream within a verbatim tag');
  1719. }
  1720. } else {
  1721. while (0 !== ch && !is_WS_OR_EOL(ch)) {
  1722. if (0x21/* ! */ === ch) {
  1723. if (!isNamed) {
  1724. tagHandle = state.input.slice(_position - 1, state.position + 1);
  1725. if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
  1726. throwError(state, 'named tag handle cannot contain such characters');
  1727. }
  1728. isNamed = true;
  1729. _position = state.position + 1;
  1730. } else {
  1731. throwError(state, 'tag suffix cannot contain exclamation marks');
  1732. }
  1733. }
  1734. ch = state.input.charCodeAt(++state.position);
  1735. }
  1736. tagName = state.input.slice(_position, state.position);
  1737. if (PATTERN_FLOW_INDICATORS.test(tagName)) {
  1738. throwError(state, 'tag suffix cannot contain flow indicator characters');
  1739. }
  1740. }
  1741. if (tagName && !PATTERN_TAG_URI.test(tagName)) {
  1742. throwError(state, 'tag name cannot contain such characters: ' + tagName);
  1743. }
  1744. if (isVerbatim) {
  1745. state.tag = tagName;
  1746. } else if (_hasOwnProperty.call(state.tagMap, tagHandle)) {
  1747. state.tag = state.tagMap[tagHandle] + tagName;
  1748. } else if ('!' === tagHandle) {
  1749. state.tag = '!' + tagName;
  1750. } else if ('!!' === tagHandle) {
  1751. state.tag = 'tag:yaml.org,2002:' + tagName;
  1752. } else {
  1753. throwError(state, 'undeclared tag handle "' + tagHandle + '"');
  1754. }
  1755. return true;
  1756. }
  1757. function readAnchorProperty(state) {
  1758. var _position,
  1759. ch;
  1760. ch = state.input.charCodeAt(state.position);
  1761. if (0x26/* & */ !== ch) {
  1762. return false;
  1763. }
  1764. if (null !== state.anchor) {
  1765. throwError(state, 'duplication of an anchor property');
  1766. }
  1767. ch = state.input.charCodeAt(++state.position);
  1768. _position = state.position;
  1769. while (0 !== ch && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
  1770. ch = state.input.charCodeAt(++state.position);
  1771. }
  1772. if (state.position === _position) {
  1773. throwError(state, 'name of an anchor node must contain at least one character');
  1774. }
  1775. state.anchor = state.input.slice(_position, state.position);
  1776. return true;
  1777. }
  1778. function readAlias(state) {
  1779. var _position, alias,
  1780. ch;
  1781. ch = state.input.charCodeAt(state.position);
  1782. if (0x2A/* * */ !== ch) {
  1783. return false;
  1784. }
  1785. ch = state.input.charCodeAt(++state.position);
  1786. _position = state.position;
  1787. while (0 !== ch && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
  1788. ch = state.input.charCodeAt(++state.position);
  1789. }
  1790. if (state.position === _position) {
  1791. throwError(state, 'name of an alias node must contain at least one character');
  1792. }
  1793. alias = state.input.slice(_position, state.position);
  1794. if (!state.anchorMap.hasOwnProperty(alias)) {
  1795. throwError(state, 'unidentified alias "' + alias + '"');
  1796. }
  1797. state.result = state.anchorMap[alias];
  1798. skipSeparationSpace(state, true, -1);
  1799. return true;
  1800. }
  1801. function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
  1802. var allowBlockStyles,
  1803. allowBlockScalars,
  1804. allowBlockCollections,
  1805. indentStatus = 1, // 1: this>parent, 0: this=parent, -1: this<parent
  1806. atNewLine = false,
  1807. hasContent = false,
  1808. typeIndex,
  1809. typeQuantity,
  1810. type,
  1811. flowIndent,
  1812. blockIndent;
  1813. state.tag = null;
  1814. state.anchor = null;
  1815. state.kind = null;
  1816. state.result = null;
  1817. allowBlockStyles = allowBlockScalars = allowBlockCollections =
  1818. CONTEXT_BLOCK_OUT === nodeContext ||
  1819. CONTEXT_BLOCK_IN === nodeContext;
  1820. if (allowToSeek) {
  1821. if (skipSeparationSpace(state, true, -1)) {
  1822. atNewLine = true;
  1823. if (state.lineIndent > parentIndent) {
  1824. indentStatus = 1;
  1825. } else if (state.lineIndent === parentIndent) {
  1826. indentStatus = 0;
  1827. } else if (state.lineIndent < parentIndent) {
  1828. indentStatus = -1;
  1829. }
  1830. }
  1831. }
  1832. if (1 === indentStatus) {
  1833. while (readTagProperty(state) || readAnchorProperty(state)) {
  1834. if (skipSeparationSpace(state, true, -1)) {
  1835. atNewLine = true;
  1836. allowBlockCollections = allowBlockStyles;
  1837. if (state.lineIndent > parentIndent) {
  1838. indentStatus = 1;
  1839. } else if (state.lineIndent === parentIndent) {
  1840. indentStatus = 0;
  1841. } else if (state.lineIndent < parentIndent) {
  1842. indentStatus = -1;
  1843. }
  1844. } else {
  1845. allowBlockCollections = false;
  1846. }
  1847. }
  1848. }
  1849. if (allowBlockCollections) {
  1850. allowBlockCollections = atNewLine || allowCompact;
  1851. }
  1852. if (1 === indentStatus || CONTEXT_BLOCK_OUT === nodeContext) {
  1853. if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
  1854. flowIndent = parentIndent;
  1855. } else {
  1856. flowIndent = parentIndent + 1;
  1857. }
  1858. blockIndent = state.position - state.lineStart;
  1859. if (1 === indentStatus) {
  1860. if (allowBlockCollections &&
  1861. (readBlockSequence(state, blockIndent) ||
  1862. readBlockMapping(state, blockIndent, flowIndent)) ||
  1863. readFlowCollection(state, flowIndent)) {
  1864. hasContent = true;
  1865. } else {
  1866. if ((allowBlockScalars && readBlockScalar(state, flowIndent)) ||
  1867. readSingleQuotedScalar(state, flowIndent) ||
  1868. readDoubleQuotedScalar(state, flowIndent)) {
  1869. hasContent = true;
  1870. } else if (readAlias(state)) {
  1871. hasContent = true;
  1872. if (null !== state.tag || null !== state.anchor) {
  1873. throwError(state, 'alias node should not have any properties');
  1874. }
  1875. } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
  1876. hasContent = true;
  1877. if (null === state.tag) {
  1878. state.tag = '?';
  1879. }
  1880. }
  1881. if (null !== state.anchor) {
  1882. state.anchorMap[state.anchor] = state.result;
  1883. }
  1884. }
  1885. } else if (0 === indentStatus) {
  1886. // Special case: block sequences are allowed to have same indentation level as the parent.
  1887. // http://www.yaml.org/spec/1.2/spec.html#id2799784
  1888. hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
  1889. }
  1890. }
  1891. if (null !== state.tag && '!' !== state.tag) {
  1892. if ('?' === state.tag) {
  1893. for (typeIndex = 0, typeQuantity = state.implicitTypes.length;
  1894. typeIndex < typeQuantity;
  1895. typeIndex += 1) {
  1896. type = state.implicitTypes[typeIndex];
  1897. // Implicit resolving is not allowed for non-scalar types, and '?'
  1898. // non-specific tag is only assigned to plain scalars. So, it isn't
  1899. // needed to check for 'kind' conformity.
  1900. if (type.resolve(state.result)) { // `state.result` updated in resolver if matched
  1901. state.result = type.construct(state.result);
  1902. state.tag = type.tag;
  1903. if (null !== state.anchor) {
  1904. state.anchorMap[state.anchor] = state.result;
  1905. }
  1906. break;
  1907. }
  1908. }
  1909. } else if (_hasOwnProperty.call(state.typeMap, state.tag)) {
  1910. type = state.typeMap[state.tag];
  1911. if (null !== state.result && type.kind !== state.kind) {
  1912. throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"');
  1913. }
  1914. if (!type.resolve(state.result)) { // `state.result` updated in resolver if matched
  1915. throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag');
  1916. } else {
  1917. state.result = type.construct(state.result);
  1918. if (null !== state.anchor) {
  1919. state.anchorMap[state.anchor] = state.result;
  1920. }
  1921. }
  1922. } else {
  1923. throwError(state, 'unknown tag !<' + state.tag + '>');
  1924. }
  1925. }
  1926. return null !== state.tag || null !== state.anchor || hasContent;
  1927. }
  1928. function readDocument(state) {
  1929. var documentStart = state.position,
  1930. _position,
  1931. directiveName,
  1932. directiveArgs,
  1933. hasDirectives = false,
  1934. ch;
  1935. state.version = null;
  1936. state.checkLineBreaks = state.legacy;
  1937. state.tagMap = {};
  1938. state.anchorMap = {};
  1939. while (0 !== (ch = state.input.charCodeAt(state.position))) {
  1940. skipSeparationSpace(state, true, -1);
  1941. ch = state.input.charCodeAt(state.position);
  1942. if (state.lineIndent > 0 || 0x25/* % */ !== ch) {
  1943. break;
  1944. }
  1945. hasDirectives = true;
  1946. ch = state.input.charCodeAt(++state.position);
  1947. _position = state.position;
  1948. while (0 !== ch && !is_WS_OR_EOL(ch)) {
  1949. ch = state.input.charCodeAt(++state.position);
  1950. }
  1951. directiveName = state.input.slice(_position, state.position);
  1952. directiveArgs = [];
  1953. if (directiveName.length < 1) {
  1954. throwError(state, 'directive name must not be less than one character in length');
  1955. }
  1956. while (0 !== ch) {
  1957. while (is_WHITE_SPACE(ch)) {
  1958. ch = state.input.charCodeAt(++state.position);
  1959. }
  1960. if (0x23/* # */ === ch) {
  1961. do { ch = state.input.charCodeAt(++state.position); }
  1962. while (0 !== ch && !is_EOL(ch));
  1963. break;
  1964. }
  1965. if (is_EOL(ch)) {
  1966. break;
  1967. }
  1968. _position = state.position;
  1969. while (0 !== ch && !is_WS_OR_EOL(ch)) {
  1970. ch = state.input.charCodeAt(++state.position);
  1971. }
  1972. directiveArgs.push(state.input.slice(_position, state.position));
  1973. }
  1974. if (0 !== ch) {
  1975. readLineBreak(state);
  1976. }
  1977. if (_hasOwnProperty.call(directiveHandlers, directiveName)) {
  1978. directiveHandlers[directiveName](state, directiveName, directiveArgs);
  1979. } else {
  1980. throwWarning(state, 'unknown document directive "' + directiveName + '"');
  1981. }
  1982. }
  1983. skipSeparationSpace(state, true, -1);
  1984. if (0 === state.lineIndent &&
  1985. 0x2D/* - */ === state.input.charCodeAt(state.position) &&
  1986. 0x2D/* - */ === state.input.charCodeAt(state.position + 1) &&
  1987. 0x2D/* - */ === state.input.charCodeAt(state.position + 2)) {
  1988. state.position += 3;
  1989. skipSeparationSpace(state, true, -1);
  1990. } else if (hasDirectives) {
  1991. throwError(state, 'directives end mark is expected');
  1992. }
  1993. composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
  1994. skipSeparationSpace(state, true, -1);
  1995. if (state.checkLineBreaks &&
  1996. PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
  1997. throwWarning(state, 'non-ASCII line breaks are interpreted as content');
  1998. }
  1999. state.documents.push(state.result);
  2000. if (state.position === state.lineStart && testDocumentSeparator(state)) {
  2001. if (0x2E/* . */ === state.input.charCodeAt(state.position)) {
  2002. state.position += 3;
  2003. skipSeparationSpace(state, true, -1);
  2004. }
  2005. return;
  2006. }
  2007. if (state.position < (state.length - 1)) {
  2008. throwError(state, 'end of the stream or a document separator is expected');
  2009. } else {
  2010. return;
  2011. }
  2012. }
  2013. function loadDocuments(input, options) {
  2014. input = String(input);
  2015. options = options || {};
  2016. if (input.length !== 0) {
  2017. // Add tailing `\n` if not exists
  2018. if (0x0A/* LF */ !== input.charCodeAt(input.length - 1) &&
  2019. 0x0D/* CR */ !== input.charCodeAt(input.length - 1)) {
  2020. input += '\n';
  2021. }
  2022. // Strip BOM
  2023. if (input.charCodeAt(0) === 0xFEFF) {
  2024. input = input.slice(1);
  2025. }
  2026. }
  2027. var state = new State(input, options);
  2028. // Use 0 as string terminator. That significantly simplifies bounds check.
  2029. state.input += '\0';
  2030. while (0x20/* Space */ === state.input.charCodeAt(state.position)) {
  2031. state.lineIndent += 1;
  2032. state.position += 1;
  2033. }
  2034. while (state.position < (state.length - 1)) {
  2035. readDocument(state);
  2036. }
  2037. return state.documents;
  2038. }
  2039. function loadAll(input, iterator, options) {
  2040. var documents = loadDocuments(input, options), index, length;
  2041. for (index = 0, length = documents.length; index < length; index += 1) {
  2042. iterator(documents[index]);
  2043. }
  2044. }
  2045. function load(input, options) {
  2046. var documents = loadDocuments(input, options);
  2047. if (0 === documents.length) {
  2048. /*eslint-disable no-undefined*/
  2049. return undefined;
  2050. } else if (1 === documents.length) {
  2051. return documents[0];
  2052. }
  2053. throw new YAMLException('expected a single document in the stream, but found more');
  2054. }
  2055. function safeLoadAll(input, output, options) {
  2056. loadAll(input, output, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
  2057. }
  2058. function safeLoad(input, options) {
  2059. return load(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
  2060. }
  2061. module.exports.loadAll = loadAll;
  2062. module.exports.load = load;
  2063. module.exports.safeLoadAll = safeLoadAll;
  2064. module.exports.safeLoad = safeLoad;
  2065. },{"./common":2,"./exception":4,"./mark":6,"./schema/default_full":9,"./schema/default_safe":10}],6:[function(require,module,exports){
  2066. 'use strict';
  2067. var common = require('./common');
  2068. function Mark(name, buffer, position, line, column) {
  2069. this.name = name;
  2070. this.buffer = buffer;
  2071. this.position = position;
  2072. this.line = line;
  2073. this.column = column;
  2074. }
  2075. Mark.prototype.getSnippet = function getSnippet(indent, maxLength) {
  2076. var head, start, tail, end, snippet;
  2077. if (!this.buffer) {
  2078. return null;
  2079. }
  2080. indent = indent || 4;
  2081. maxLength = maxLength || 75;
  2082. head = '';
  2083. start = this.position;
  2084. while (start > 0 && -1 === '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(start - 1))) {
  2085. start -= 1;
  2086. if (this.position - start > (maxLength / 2 - 1)) {
  2087. head = ' ... ';
  2088. start += 5;
  2089. break;
  2090. }
  2091. }
  2092. tail = '';
  2093. end = this.position;
  2094. while (end < this.buffer.length && -1 === '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(end))) {
  2095. end += 1;
  2096. if (end - this.position > (maxLength / 2 - 1)) {
  2097. tail = ' ... ';
  2098. end -= 5;
  2099. break;
  2100. }
  2101. }
  2102. snippet = this.buffer.slice(start, end);
  2103. return common.repeat(' ', indent) + head + snippet + tail + '\n' +
  2104. common.repeat(' ', indent + this.position - start + head.length) + '^';
  2105. };
  2106. Mark.prototype.toString = function toString(compact) {
  2107. var snippet, where = '';
  2108. if (this.name) {
  2109. where += 'in "' + this.name + '" ';
  2110. }
  2111. where += 'at line ' + (this.line + 1) + ', column ' + (this.column + 1);
  2112. if (!compact) {
  2113. snippet = this.getSnippet();
  2114. if (snippet) {
  2115. where += ':\n' + snippet;
  2116. }
  2117. }
  2118. return where;
  2119. };
  2120. module.exports = Mark;
  2121. },{"./common":2}],7:[function(require,module,exports){
  2122. 'use strict';
  2123. /*eslint-disable max-len*/
  2124. var common = require('./common');
  2125. var YAMLException = require('./exception');
  2126. var Type = require('./type');
  2127. function compileList(schema, name, result) {
  2128. var exclude = [];
  2129. schema.include.forEach(function (includedSchema) {
  2130. result = compileList(includedSchema, name, result);
  2131. });
  2132. schema[name].forEach(function (currentType) {
  2133. result.forEach(function (previousType, previousIndex) {
  2134. if (previousType.tag === currentType.tag) {
  2135. exclude.push(previousIndex);
  2136. }
  2137. });
  2138. result.push(currentType);
  2139. });
  2140. return result.filter(function (type, index) {
  2141. return -1 === exclude.indexOf(index);
  2142. });
  2143. }
  2144. function compileMap(/* lists... */) {
  2145. var result = {}, index, length;
  2146. function collectType(type) {
  2147. result[type.tag] = type;
  2148. }
  2149. for (index = 0, length = arguments.length; index < length; index += 1) {
  2150. arguments[index].forEach(collectType);
  2151. }
  2152. return result;
  2153. }
  2154. function Schema(definition) {
  2155. this.include = definition.include || [];
  2156. this.implicit = definition.implicit || [];
  2157. this.explicit = definition.explicit || [];
  2158. this.implicit.forEach(function (type) {
  2159. if (type.loadKind && 'scalar' !== type.loadKind) {
  2160. throw new YAMLException('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.');
  2161. }
  2162. });
  2163. this.compiledImplicit = compileList(this, 'implicit', []);
  2164. this.compiledExplicit = compileList(this, 'explicit', []);
  2165. this.compiledTypeMap = compileMap(this.compiledImplicit, this.compiledExplicit);
  2166. }
  2167. Schema.DEFAULT = null;
  2168. Schema.create = function createSchema() {
  2169. var schemas, types;
  2170. switch (arguments.length) {
  2171. case 1:
  2172. schemas = Schema.DEFAULT;
  2173. types = arguments[0];
  2174. break;
  2175. case 2:
  2176. schemas = arguments[0];
  2177. types = arguments[1];
  2178. break;
  2179. default:
  2180. throw new YAMLException('Wrong number of arguments for Schema.create function');
  2181. }
  2182. schemas = common.toArray(schemas);
  2183. types = common.toArray(types);
  2184. if (!schemas.every(function (schema) { return schema instanceof Schema; })) {
  2185. throw new YAMLException('Specified list of super schemas (or a single Schema object) contains a non-Schema object.');
  2186. }
  2187. if (!types.every(function (type) { return type instanceof Type; })) {
  2188. throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.');
  2189. }
  2190. return new Schema({
  2191. include: schemas,
  2192. explicit: types
  2193. });
  2194. };
  2195. module.exports = Schema;
  2196. },{"./common":2,"./exception":4,"./type":13}],8:[function(require,module,exports){
  2197. // Standard YAML's Core schema.
  2198. // http://www.yaml.org/spec/1.2/spec.html#id2804923
  2199. //
  2200. // NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
  2201. // So, Core schema has no distinctions from JSON schema is JS-YAML.
  2202. 'use strict';
  2203. var Schema = require('../schema');
  2204. module.exports = new Schema({
  2205. include: [
  2206. require('./json')
  2207. ]
  2208. });
  2209. },{"../schema":7,"./json":12}],9:[function(require,module,exports){
  2210. // JS-YAML's default schema for `load` function.
  2211. // It is not described in the YAML specification.
  2212. //
  2213. // This schema is based on JS-YAML's default safe schema and includes
  2214. // JavaScript-specific types: !!js/undefined, !!js/regexp and !!js/function.
  2215. //
  2216. // Also this schema is used as default base schema at `Schema.create` function.
  2217. 'use strict';
  2218. var Schema = require('../schema');
  2219. module.exports = Schema.DEFAULT = new Schema({
  2220. include: [
  2221. require('./default_safe')
  2222. ],
  2223. explicit: [
  2224. require('../type/js/undefined'),
  2225. require('../type/js/regexp'),
  2226. require('../type/js/function')
  2227. ]
  2228. });
  2229. },{"../schema":7,"../type/js/function":18,"../type/js/regexp":19,"../type/js/undefined":20,"./default_safe":10}],10:[function(require,module,exports){
  2230. // JS-YAML's default schema for `safeLoad` function.
  2231. // It is not described in the YAML specification.
  2232. //
  2233. // This schema is based on standard YAML's Core schema and includes most of
  2234. // extra types described at YAML tag repository. (http://yaml.org/type/)
  2235. 'use strict';
  2236. var Schema = require('../schema');
  2237. module.exports = new Schema({
  2238. include: [
  2239. require('./core')
  2240. ],
  2241. implicit: [
  2242. require('../type/timestamp'),
  2243. require('../type/merge')
  2244. ],
  2245. explicit: [
  2246. require('../type/binary'),
  2247. require('../type/omap'),
  2248. require('../type/pairs'),
  2249. require('../type/set')
  2250. ]
  2251. });
  2252. },{"../schema":7,"../type/binary":14,"../type/merge":22,"../type/omap":24,"../type/pairs":25,"../type/set":27,"../type/timestamp":29,"./core":8}],11:[function(require,module,exports){
  2253. // Standard YAML's Failsafe schema.
  2254. // http://www.yaml.org/spec/1.2/spec.html#id2802346
  2255. 'use strict';
  2256. var Schema = require('../schema');
  2257. module.exports = new Schema({
  2258. explicit: [
  2259. require('../type/str'),
  2260. require('../type/seq'),
  2261. require('../type/map')
  2262. ]
  2263. });
  2264. },{"../schema":7,"../type/map":21,"../type/seq":26,"../type/str":28}],12:[function(require,module,exports){
  2265. // Standard YAML's JSON schema.
  2266. // http://www.yaml.org/spec/1.2/spec.html#id2803231
  2267. //
  2268. // NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
  2269. // So, this schema is not such strict as defined in the YAML specification.
  2270. // It allows numbers in binary notaion, use `Null` and `NULL` as `null`, etc.
  2271. 'use strict';
  2272. var Schema = require('../schema');
  2273. module.exports = new Schema({
  2274. include: [
  2275. require('./failsafe')
  2276. ],
  2277. implicit: [
  2278. require('../type/null'),
  2279. require('../type/bool'),
  2280. require('../type/int'),
  2281. require('../type/float')
  2282. ]
  2283. });
  2284. },{"../schema":7,"../type/bool":15,"../type/float":16,"../type/int":17,"../type/null":23,"./failsafe":11}],13:[function(require,module,exports){
  2285. 'use strict';
  2286. var YAMLException = require('./exception');
  2287. var TYPE_CONSTRUCTOR_OPTIONS = [
  2288. 'kind',
  2289. 'resolve',
  2290. 'construct',
  2291. 'instanceOf',
  2292. 'predicate',
  2293. 'represent',
  2294. 'defaultStyle',
  2295. 'styleAliases'
  2296. ];
  2297. var YAML_NODE_KINDS = [
  2298. 'scalar',
  2299. 'sequence',
  2300. 'mapping'
  2301. ];
  2302. function compileStyleAliases(map) {
  2303. var result = {};
  2304. if (null !== map) {
  2305. Object.keys(map).forEach(function (style) {
  2306. map[style].forEach(function (alias) {
  2307. result[String(alias)] = style;
  2308. });
  2309. });
  2310. }
  2311. return result;
  2312. }
  2313. function Type(tag, options) {
  2314. options = options || {};
  2315. Object.keys(options).forEach(function (name) {
  2316. if (-1 === TYPE_CONSTRUCTOR_OPTIONS.indexOf(name)) {
  2317. throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
  2318. }
  2319. });
  2320. // TODO: Add tag format check.
  2321. this.tag = tag;
  2322. this.kind = options['kind'] || null;
  2323. this.resolve = options['resolve'] || function () { return true; };
  2324. this.construct = options['construct'] || function (data) { return data; };
  2325. this.instanceOf = options['instanceOf'] || null;
  2326. this.predicate = options['predicate'] || null;
  2327. this.represent = options['represent'] || null;
  2328. this.defaultStyle = options['defaultStyle'] || null;
  2329. this.styleAliases = compileStyleAliases(options['styleAliases'] || null);
  2330. if (-1 === YAML_NODE_KINDS.indexOf(this.kind)) {
  2331. throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
  2332. }
  2333. }
  2334. module.exports = Type;
  2335. },{"./exception":4}],14:[function(require,module,exports){
  2336. 'use strict';
  2337. /*eslint-disable no-bitwise*/
  2338. // A trick for browserified version.
  2339. // Since we make browserifier to ignore `buffer` module, NodeBuffer will be undefined
  2340. var NodeBuffer = require('buffer').Buffer;
  2341. var Type = require('../type');
  2342. // [ 64, 65, 66 ] -> [ padding, CR, LF ]
  2343. var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r';
  2344. function resolveYamlBinary(data) {
  2345. if (null === data) {
  2346. return false;
  2347. }
  2348. var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP;
  2349. // Convert one by one.
  2350. for (idx = 0; idx < max; idx++) {
  2351. code = map.indexOf(data.charAt(idx));
  2352. // Skip CR/LF
  2353. if (code > 64) { continue; }
  2354. // Fail on illegal characters
  2355. if (code < 0) { return false; }
  2356. bitlen += 6;
  2357. }
  2358. // If there are any bits left, source was corrupted
  2359. return (bitlen % 8) === 0;
  2360. }
  2361. function constructYamlBinary(data) {
  2362. var idx, tailbits,
  2363. input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan
  2364. max = input.length,
  2365. map = BASE64_MAP,
  2366. bits = 0,
  2367. result = [];
  2368. // Collect by 6*4 bits (3 bytes)
  2369. for (idx = 0; idx < max; idx++) {
  2370. if ((idx % 4 === 0) && idx) {
  2371. result.push((bits >> 16) & 0xFF);
  2372. result.push((bits >> 8) & 0xFF);
  2373. result.push(bits & 0xFF);
  2374. }
  2375. bits = (bits << 6) | map.indexOf(input.charAt(idx));
  2376. }
  2377. // Dump tail
  2378. tailbits = (max % 4) * 6;
  2379. if (tailbits === 0) {
  2380. result.push((bits >> 16) & 0xFF);
  2381. result.push((bits >> 8) & 0xFF);
  2382. result.push(bits & 0xFF);
  2383. } else if (tailbits === 18) {
  2384. result.push((bits >> 10) & 0xFF);
  2385. result.push((bits >> 2) & 0xFF);
  2386. } else if (tailbits === 12) {
  2387. result.push((bits >> 4) & 0xFF);
  2388. }
  2389. // Wrap into Buffer for NodeJS and leave Array for browser
  2390. if (NodeBuffer) {
  2391. return new NodeBuffer(result);
  2392. }
  2393. return result;
  2394. }
  2395. function representYamlBinary(object /*, style*/) {
  2396. var result = '', bits = 0, idx, tail,
  2397. max = object.length,
  2398. map = BASE64_MAP;
  2399. // Convert every three bytes to 4 ASCII characters.
  2400. for (idx = 0; idx < max; idx++) {
  2401. if ((idx % 3 === 0) && idx) {
  2402. result += map[(bits >> 18) & 0x3F];
  2403. result += map[(bits >> 12) & 0x3F];
  2404. result += map[(bits >> 6) & 0x3F];
  2405. result += map[bits & 0x3F];
  2406. }
  2407. bits = (bits << 8) + object[idx];
  2408. }
  2409. // Dump tail
  2410. tail = max % 3;
  2411. if (tail === 0) {
  2412. result += map[(bits >> 18) & 0x3F];
  2413. result += map[(bits >> 12) & 0x3F];
  2414. result += map[(bits >> 6) & 0x3F];
  2415. result += map[bits & 0x3F];
  2416. } else if (tail === 2) {
  2417. result += map[(bits >> 10) & 0x3F];
  2418. result += map[(bits >> 4) & 0x3F];
  2419. result += map[(bits << 2) & 0x3F];
  2420. result += map[64];
  2421. } else if (tail === 1) {
  2422. result += map[(bits >> 2) & 0x3F];
  2423. result += map[(bits << 4) & 0x3F];
  2424. result += map[64];
  2425. result += map[64];
  2426. }
  2427. return result;
  2428. }
  2429. function isBinary(object) {
  2430. return NodeBuffer && NodeBuffer.isBuffer(object);
  2431. }
  2432. module.exports = new Type('tag:yaml.org,2002:binary', {
  2433. kind: 'scalar',
  2434. resolve: resolveYamlBinary,
  2435. construct: constructYamlBinary,
  2436. predicate: isBinary,
  2437. represent: representYamlBinary
  2438. });
  2439. },{"../type":13,"buffer":30}],15:[function(require,module,exports){
  2440. 'use strict';
  2441. var Type = require('../type');
  2442. function resolveYamlBoolean(data) {
  2443. if (null === data) {
  2444. return false;
  2445. }
  2446. var max = data.length;
  2447. return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) ||
  2448. (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE'));
  2449. }
  2450. function constructYamlBoolean(data) {
  2451. return data === 'true' ||
  2452. data === 'True' ||
  2453. data === 'TRUE';
  2454. }
  2455. function isBoolean(object) {
  2456. return '[object Boolean]' === Object.prototype.toString.call(object);
  2457. }
  2458. module.exports = new Type('tag:yaml.org,2002:bool', {
  2459. kind: 'scalar',
  2460. resolve: resolveYamlBoolean,
  2461. construct: constructYamlBoolean,
  2462. predicate: isBoolean,
  2463. represent: {
  2464. lowercase: function (object) { return object ? 'true' : 'false'; },
  2465. uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; },
  2466. camelcase: function (object) { return object ? 'True' : 'False'; }
  2467. },
  2468. defaultStyle: 'lowercase'
  2469. });
  2470. },{"../type":13}],16:[function(require,module,exports){
  2471. 'use strict';
  2472. var common = require('../common');
  2473. var Type = require('../type');
  2474. var YAML_FLOAT_PATTERN = new RegExp(
  2475. '^(?:[-+]?(?:[0-9][0-9_]*)\\.[0-9_]*(?:[eE][-+][0-9]+)?' +
  2476. '|\\.[0-9_]+(?:[eE][-+][0-9]+)?' +
  2477. '|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*' +
  2478. '|[-+]?\\.(?:inf|Inf|INF)' +
  2479. '|\\.(?:nan|NaN|NAN))$');
  2480. function resolveYamlFloat(data) {
  2481. if (null === data) {
  2482. return false;
  2483. }
  2484. if (!YAML_FLOAT_PATTERN.test(data)) {
  2485. return false;
  2486. }
  2487. return true;
  2488. }
  2489. function constructYamlFloat(data) {
  2490. var value, sign, base, digits;
  2491. value = data.replace(/_/g, '').toLowerCase();
  2492. sign = '-' === value[0] ? -1 : 1;
  2493. digits = [];
  2494. if (0 <= '+-'.indexOf(value[0])) {
  2495. value = value.slice(1);
  2496. }
  2497. if ('.inf' === value) {
  2498. return (1 === sign) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
  2499. } else if ('.nan' === value) {
  2500. return NaN;
  2501. } else if (0 <= value.indexOf(':')) {
  2502. value.split(':').forEach(function (v) {
  2503. digits.unshift(parseFloat(v, 10));
  2504. });
  2505. value = 0.0;
  2506. base = 1;
  2507. digits.forEach(function (d) {
  2508. value += d * base;
  2509. base *= 60;
  2510. });
  2511. return sign * value;
  2512. }
  2513. return sign * parseFloat(value, 10);
  2514. }
  2515. var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
  2516. function representYamlFloat(object, style) {
  2517. var res;
  2518. if (isNaN(object)) {
  2519. switch (style) {
  2520. case 'lowercase':
  2521. return '.nan';
  2522. case 'uppercase':
  2523. return '.NAN';
  2524. case 'camelcase':
  2525. return '.NaN';
  2526. }
  2527. } else if (Number.POSITIVE_INFINITY === object) {
  2528. switch (style) {
  2529. case 'lowercase':
  2530. return '.inf';
  2531. case 'uppercase':
  2532. return '.INF';
  2533. case 'camelcase':
  2534. return '.Inf';
  2535. }
  2536. } else if (Number.NEGATIVE_INFINITY === object) {
  2537. switch (style) {
  2538. case 'lowercase':
  2539. return '-.inf';
  2540. case 'uppercase':
  2541. return '-.INF';
  2542. case 'camelcase':
  2543. return '-.Inf';
  2544. }
  2545. } else if (common.isNegativeZero(object)) {
  2546. return '-0.0';
  2547. }
  2548. res = object.toString(10);
  2549. // JS stringifier can build scientific format without dots: 5e-100,
  2550. // while YAML requres dot: 5.e-100. Fix it with simple hack
  2551. return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res;
  2552. }
  2553. function isFloat(object) {
  2554. return ('[object Number]' === Object.prototype.toString.call(object)) &&
  2555. (0 !== object % 1 || common.isNegativeZero(object));
  2556. }
  2557. module.exports = new Type('tag:yaml.org,2002:float', {
  2558. kind: 'scalar',
  2559. resolve: resolveYamlFloat,
  2560. construct: constructYamlFloat,
  2561. predicate: isFloat,
  2562. represent: representYamlFloat,
  2563. defaultStyle: 'lowercase'
  2564. });
  2565. },{"../common":2,"../type":13}],17:[function(require,module,exports){
  2566. 'use strict';
  2567. var common = require('../common');
  2568. var Type = require('../type');
  2569. function isHexCode(c) {
  2570. return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) ||
  2571. ((0x41/* A */ <= c) && (c <= 0x46/* F */)) ||
  2572. ((0x61/* a */ <= c) && (c <= 0x66/* f */));
  2573. }
  2574. function isOctCode(c) {
  2575. return ((0x30/* 0 */ <= c) && (c <= 0x37/* 7 */));
  2576. }
  2577. function isDecCode(c) {
  2578. return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */));
  2579. }
  2580. function resolveYamlInteger(data) {
  2581. if (null === data) {
  2582. return false;
  2583. }
  2584. var max = data.length,
  2585. index = 0,
  2586. hasDigits = false,
  2587. ch;
  2588. if (!max) { return false; }
  2589. ch = data[index];
  2590. // sign
  2591. if (ch === '-' || ch === '+') {
  2592. ch = data[++index];
  2593. }
  2594. if (ch === '0') {
  2595. // 0
  2596. if (index + 1 === max) { return true; }
  2597. ch = data[++index];
  2598. // base 2, base 8, base 16
  2599. if (ch === 'b') {
  2600. // base 2
  2601. index++;
  2602. for (; index < max; index++) {
  2603. ch = data[index];
  2604. if (ch === '_') { continue; }
  2605. if (ch !== '0' && ch !== '1') {
  2606. return false;
  2607. }
  2608. hasDigits = true;
  2609. }
  2610. return hasDigits;
  2611. }
  2612. if (ch === 'x') {
  2613. // base 16
  2614. index++;
  2615. for (; index < max; index++) {
  2616. ch = data[index];
  2617. if (ch === '_') { continue; }
  2618. if (!isHexCode(data.charCodeAt(index))) {
  2619. return false;
  2620. }
  2621. hasDigits = true;
  2622. }
  2623. return hasDigits;
  2624. }
  2625. // base 8
  2626. for (; index < max; index++) {
  2627. ch = data[index];
  2628. if (ch === '_') { continue; }
  2629. if (!isOctCode(data.charCodeAt(index))) {
  2630. return false;
  2631. }
  2632. hasDigits = true;
  2633. }
  2634. return hasDigits;
  2635. }
  2636. // base 10 (except 0) or base 60
  2637. for (; index < max; index++) {
  2638. ch = data[index];
  2639. if (ch === '_') { continue; }
  2640. if (ch === ':') { break; }
  2641. if (!isDecCode(data.charCodeAt(index))) {
  2642. return false;
  2643. }
  2644. hasDigits = true;
  2645. }
  2646. if (!hasDigits) { return false; }
  2647. // if !base60 - done;
  2648. if (ch !== ':') { return true; }
  2649. // base60 almost not used, no needs to optimize
  2650. return /^(:[0-5]?[0-9])+$/.test(data.slice(index));
  2651. }
  2652. function constructYamlInteger(data) {
  2653. var value = data, sign = 1, ch, base, digits = [];
  2654. if (value.indexOf('_') !== -1) {
  2655. value = value.replace(/_/g, '');
  2656. }
  2657. ch = value[0];
  2658. if (ch === '-' || ch === '+') {
  2659. if (ch === '-') { sign = -1; }
  2660. value = value.slice(1);
  2661. ch = value[0];
  2662. }
  2663. if ('0' === value) {
  2664. return 0;
  2665. }
  2666. if (ch === '0') {
  2667. if (value[1] === 'b') {
  2668. return sign * parseInt(value.slice(2), 2);
  2669. }
  2670. if (value[1] === 'x') {
  2671. return sign * parseInt(value, 16);
  2672. }
  2673. return sign * parseInt(value, 8);
  2674. }
  2675. if (value.indexOf(':') !== -1) {
  2676. value.split(':').forEach(function (v) {
  2677. digits.unshift(parseInt(v, 10));
  2678. });
  2679. value = 0;
  2680. base = 1;
  2681. digits.forEach(function (d) {
  2682. value += (d * base);
  2683. base *= 60;
  2684. });
  2685. return sign * value;
  2686. }
  2687. return sign * parseInt(value, 10);
  2688. }
  2689. function isInteger(object) {
  2690. return ('[object Number]' === Object.prototype.toString.call(object)) &&
  2691. (0 === object % 1 && !common.isNegativeZero(object));
  2692. }
  2693. module.exports = new Type('tag:yaml.org,2002:int', {
  2694. kind: 'scalar',
  2695. resolve: resolveYamlInteger,
  2696. construct: constructYamlInteger,
  2697. predicate: isInteger,
  2698. represent: {
  2699. binary: function (object) { return '0b' + object.toString(2); },
  2700. octal: function (object) { return '0' + object.toString(8); },
  2701. decimal: function (object) { return object.toString(10); },
  2702. hexadecimal: function (object) { return '0x' + object.toString(16).toUpperCase(); }
  2703. },
  2704. defaultStyle: 'decimal',
  2705. styleAliases: {
  2706. binary: [ 2, 'bin' ],
  2707. octal: [ 8, 'oct' ],
  2708. decimal: [ 10, 'dec' ],
  2709. hexadecimal: [ 16, 'hex' ]
  2710. }
  2711. });
  2712. },{"../common":2,"../type":13}],18:[function(require,module,exports){
  2713. 'use strict';
  2714. var esprima;
  2715. // Browserified version does not have esprima
  2716. //
  2717. // 1. For node.js just require module as deps
  2718. // 2. For browser try to require mudule via external AMD system.
  2719. // If not found - try to fallback to window.esprima. If not
  2720. // found too - then fail to parse.
  2721. //
  2722. try {
  2723. // workaround to exclude package from browserify list.
  2724. var _require = require;
  2725. esprima = _require('esprima');
  2726. } catch (_) {
  2727. /*global window */
  2728. if (typeof window !== 'undefined') { esprima = window.esprima; }
  2729. }
  2730. var Type = require('../../type');
  2731. function resolveJavascriptFunction(data) {
  2732. if (null === data) {
  2733. return false;
  2734. }
  2735. try {
  2736. var source = '(' + data + ')',
  2737. ast = esprima.parse(source, { range: true });
  2738. if ('Program' !== ast.type ||
  2739. 1 !== ast.body.length ||
  2740. 'ExpressionStatement' !== ast.body[0].type ||
  2741. 'FunctionExpression' !== ast.body[0].expression.type) {
  2742. return false;
  2743. }
  2744. return true;
  2745. } catch (err) {
  2746. return false;
  2747. }
  2748. }
  2749. function constructJavascriptFunction(data) {
  2750. /*jslint evil:true*/
  2751. var source = '(' + data + ')',
  2752. ast = esprima.parse(source, { range: true }),
  2753. params = [],
  2754. body;
  2755. if ('Program' !== ast.type ||
  2756. 1 !== ast.body.length ||
  2757. 'ExpressionStatement' !== ast.body[0].type ||
  2758. 'FunctionExpression' !== ast.body[0].expression.type) {
  2759. throw new Error('Failed to resolve function');
  2760. }
  2761. ast.body[0].expression.params.forEach(function (param) {
  2762. params.push(param.name);
  2763. });
  2764. body = ast.body[0].expression.body.range;
  2765. // Esprima's ranges include the first '{' and the last '}' characters on
  2766. // function expressions. So cut them out.
  2767. /*eslint-disable no-new-func*/
  2768. return new Function(params, source.slice(body[0] + 1, body[1] - 1));
  2769. }
  2770. function representJavascriptFunction(object /*, style*/) {
  2771. return object.toString();
  2772. }
  2773. function isFunction(object) {
  2774. return '[object Function]' === Object.prototype.toString.call(object);
  2775. }
  2776. module.exports = new Type('tag:yaml.org,2002:js/function', {
  2777. kind: 'scalar',
  2778. resolve: resolveJavascriptFunction,
  2779. construct: constructJavascriptFunction,
  2780. predicate: isFunction,
  2781. represent: representJavascriptFunction
  2782. });
  2783. },{"../../type":13}],19:[function(require,module,exports){
  2784. 'use strict';
  2785. var Type = require('../../type');
  2786. function resolveJavascriptRegExp(data) {
  2787. if (null === data) {
  2788. return false;
  2789. }
  2790. if (0 === data.length) {
  2791. return false;
  2792. }
  2793. var regexp = data,
  2794. tail = /\/([gim]*)$/.exec(data),
  2795. modifiers = '';
  2796. // if regexp starts with '/' it can have modifiers and must be properly closed
  2797. // `/foo/gim` - modifiers tail can be maximum 3 chars
  2798. if ('/' === regexp[0]) {
  2799. if (tail) {
  2800. modifiers = tail[1];
  2801. }
  2802. if (modifiers.length > 3) { return false; }
  2803. // if expression starts with /, is should be properly terminated
  2804. if (regexp[regexp.length - modifiers.length - 1] !== '/') { return false; }
  2805. regexp = regexp.slice(1, regexp.length - modifiers.length - 1);
  2806. }
  2807. try {
  2808. return true;
  2809. } catch (error) {
  2810. return false;
  2811. }
  2812. }
  2813. function constructJavascriptRegExp(data) {
  2814. var regexp = data,
  2815. tail = /\/([gim]*)$/.exec(data),
  2816. modifiers = '';
  2817. // `/foo/gim` - tail can be maximum 4 chars
  2818. if ('/' === regexp[0]) {
  2819. if (tail) {
  2820. modifiers = tail[1];
  2821. }
  2822. regexp = regexp.slice(1, regexp.length - modifiers.length - 1);
  2823. }
  2824. return new RegExp(regexp, modifiers);
  2825. }
  2826. function representJavascriptRegExp(object /*, style*/) {
  2827. var result = '/' + object.source + '/';
  2828. if (object.global) {
  2829. result += 'g';
  2830. }
  2831. if (object.multiline) {
  2832. result += 'm';
  2833. }
  2834. if (object.ignoreCase) {
  2835. result += 'i';
  2836. }
  2837. return result;
  2838. }
  2839. function isRegExp(object) {
  2840. return '[object RegExp]' === Object.prototype.toString.call(object);
  2841. }
  2842. module.exports = new Type('tag:yaml.org,2002:js/regexp', {
  2843. kind: 'scalar',
  2844. resolve: resolveJavascriptRegExp,
  2845. construct: constructJavascriptRegExp,
  2846. predicate: isRegExp,
  2847. represent: representJavascriptRegExp
  2848. });
  2849. },{"../../type":13}],20:[function(require,module,exports){
  2850. 'use strict';
  2851. var Type = require('../../type');
  2852. function resolveJavascriptUndefined() {
  2853. return true;
  2854. }
  2855. function constructJavascriptUndefined() {
  2856. /*eslint-disable no-undefined*/
  2857. return undefined;
  2858. }
  2859. function representJavascriptUndefined() {
  2860. return '';
  2861. }
  2862. function isUndefined(object) {
  2863. return 'undefined' === typeof object;
  2864. }
  2865. module.exports = new Type('tag:yaml.org,2002:js/undefined', {
  2866. kind: 'scalar',
  2867. resolve: resolveJavascriptUndefined,
  2868. construct: constructJavascriptUndefined,
  2869. predicate: isUndefined,
  2870. represent: representJavascriptUndefined
  2871. });
  2872. },{"../../type":13}],21:[function(require,module,exports){
  2873. 'use strict';
  2874. var Type = require('../type');
  2875. module.exports = new Type('tag:yaml.org,2002:map', {
  2876. kind: 'mapping',
  2877. construct: function (data) { return null !== data ? data : {}; }
  2878. });
  2879. },{"../type":13}],22:[function(require,module,exports){
  2880. 'use strict';
  2881. var Type = require('../type');
  2882. function resolveYamlMerge(data) {
  2883. return '<<' === data || null === data;
  2884. }
  2885. module.exports = new Type('tag:yaml.org,2002:merge', {
  2886. kind: 'scalar',
  2887. resolve: resolveYamlMerge
  2888. });
  2889. },{"../type":13}],23:[function(require,module,exports){
  2890. 'use strict';
  2891. var Type = require('../type');
  2892. function resolveYamlNull(data) {
  2893. if (null === data) {
  2894. return true;
  2895. }
  2896. var max = data.length;
  2897. return (max === 1 && data === '~') ||
  2898. (max === 4 && (data === 'null' || data === 'Null' || data === 'NULL'));
  2899. }
  2900. function constructYamlNull() {
  2901. return null;
  2902. }
  2903. function isNull(object) {
  2904. return null === object;
  2905. }
  2906. module.exports = new Type('tag:yaml.org,2002:null', {
  2907. kind: 'scalar',
  2908. resolve: resolveYamlNull,
  2909. construct: constructYamlNull,
  2910. predicate: isNull,
  2911. represent: {
  2912. canonical: function () { return '~'; },
  2913. lowercase: function () { return 'null'; },
  2914. uppercase: function () { return 'NULL'; },
  2915. camelcase: function () { return 'Null'; }
  2916. },
  2917. defaultStyle: 'lowercase'
  2918. });
  2919. },{"../type":13}],24:[function(require,module,exports){
  2920. 'use strict';
  2921. var Type = require('../type');
  2922. var _hasOwnProperty = Object.prototype.hasOwnProperty;
  2923. var _toString = Object.prototype.toString;
  2924. function resolveYamlOmap(data) {
  2925. if (null === data) {
  2926. return true;
  2927. }
  2928. var objectKeys = [], index, length, pair, pairKey, pairHasKey,
  2929. object = data;
  2930. for (index = 0, length = object.length; index < length; index += 1) {
  2931. pair = object[index];
  2932. pairHasKey = false;
  2933. if ('[object Object]' !== _toString.call(pair)) {
  2934. return false;
  2935. }
  2936. for (pairKey in pair) {
  2937. if (_hasOwnProperty.call(pair, pairKey)) {
  2938. if (!pairHasKey) {
  2939. pairHasKey = true;
  2940. } else {
  2941. return false;
  2942. }
  2943. }
  2944. }
  2945. if (!pairHasKey) {
  2946. return false;
  2947. }
  2948. if (-1 === objectKeys.indexOf(pairKey)) {
  2949. objectKeys.push(pairKey);
  2950. } else {
  2951. return false;
  2952. }
  2953. }
  2954. return true;
  2955. }
  2956. function constructYamlOmap(data) {
  2957. return null !== data ? data : [];
  2958. }
  2959. module.exports = new Type('tag:yaml.org,2002:omap', {
  2960. kind: 'sequence',
  2961. resolve: resolveYamlOmap,
  2962. construct: constructYamlOmap
  2963. });
  2964. },{"../type":13}],25:[function(require,module,exports){
  2965. 'use strict';
  2966. var Type = require('../type');
  2967. var _toString = Object.prototype.toString;
  2968. function resolveYamlPairs(data) {
  2969. if (null === data) {
  2970. return true;
  2971. }
  2972. var index, length, pair, keys, result,
  2973. object = data;
  2974. result = new Array(object.length);
  2975. for (index = 0, length = object.length; index < length; index += 1) {
  2976. pair = object[index];
  2977. if ('[object Object]' !== _toString.call(pair)) {
  2978. return false;
  2979. }
  2980. keys = Object.keys(pair);
  2981. if (1 !== keys.length) {
  2982. return false;
  2983. }
  2984. result[index] = [ keys[0], pair[keys[0]] ];
  2985. }
  2986. return true;
  2987. }
  2988. function constructYamlPairs(data) {
  2989. if (null === data) {
  2990. return [];
  2991. }
  2992. var index, length, pair, keys, result,
  2993. object = data;
  2994. result = new Array(object.length);
  2995. for (index = 0, length = object.length; index < length; index += 1) {
  2996. pair = object[index];
  2997. keys = Object.keys(pair);
  2998. result[index] = [ keys[0], pair[keys[0]] ];
  2999. }
  3000. return result;
  3001. }
  3002. module.exports = new Type('tag:yaml.org,2002:pairs', {
  3003. kind: 'sequence',
  3004. resolve: resolveYamlPairs,
  3005. construct: constructYamlPairs
  3006. });
  3007. },{"../type":13}],26:[function(require,module,exports){
  3008. 'use strict';
  3009. var Type = require('../type');
  3010. module.exports = new Type('tag:yaml.org,2002:seq', {
  3011. kind: 'sequence',
  3012. construct: function (data) { return null !== data ? data : []; }
  3013. });
  3014. },{"../type":13}],27:[function(require,module,exports){
  3015. 'use strict';
  3016. var Type = require('../type');
  3017. var _hasOwnProperty = Object.prototype.hasOwnProperty;
  3018. function resolveYamlSet(data) {
  3019. if (null === data) {
  3020. return true;
  3021. }
  3022. var key, object = data;
  3023. for (key in object) {
  3024. if (_hasOwnProperty.call(object, key)) {
  3025. if (null !== object[key]) {
  3026. return false;
  3027. }
  3028. }
  3029. }
  3030. return true;
  3031. }
  3032. function constructYamlSet(data) {
  3033. return null !== data ? data : {};
  3034. }
  3035. module.exports = new Type('tag:yaml.org,2002:set', {
  3036. kind: 'mapping',
  3037. resolve: resolveYamlSet,
  3038. construct: constructYamlSet
  3039. });
  3040. },{"../type":13}],28:[function(require,module,exports){
  3041. 'use strict';
  3042. var Type = require('../type');
  3043. module.exports = new Type('tag:yaml.org,2002:str', {
  3044. kind: 'scalar',
  3045. construct: function (data) { return null !== data ? data : ''; }
  3046. });
  3047. },{"../type":13}],29:[function(require,module,exports){
  3048. 'use strict';
  3049. var Type = require('../type');
  3050. var YAML_TIMESTAMP_REGEXP = new RegExp(
  3051. '^([0-9][0-9][0-9][0-9])' + // [1] year
  3052. '-([0-9][0-9]?)' + // [2] month
  3053. '-([0-9][0-9]?)' + // [3] day
  3054. '(?:(?:[Tt]|[ \\t]+)' + // ...
  3055. '([0-9][0-9]?)' + // [4] hour
  3056. ':([0-9][0-9])' + // [5] minute
  3057. ':([0-9][0-9])' + // [6] second
  3058. '(?:\\.([0-9]*))?' + // [7] fraction
  3059. '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour
  3060. '(?::([0-9][0-9]))?))?)?$'); // [11] tz_minute
  3061. function resolveYamlTimestamp(data) {
  3062. if (null === data) {
  3063. return false;
  3064. }
  3065. if (YAML_TIMESTAMP_REGEXP.exec(data) === null) {
  3066. return false;
  3067. }
  3068. return true;
  3069. }
  3070. function constructYamlTimestamp(data) {
  3071. var match, year, month, day, hour, minute, second, fraction = 0,
  3072. delta = null, tz_hour, tz_minute, date;
  3073. match = YAML_TIMESTAMP_REGEXP.exec(data);
  3074. if (null === match) {
  3075. throw new Error('Date resolve error');
  3076. }
  3077. // match: [1] year [2] month [3] day
  3078. year = +(match[1]);
  3079. month = +(match[2]) - 1; // JS month starts with 0
  3080. day = +(match[3]);
  3081. if (!match[4]) { // no hour
  3082. return new Date(Date.UTC(year, month, day));
  3083. }
  3084. // match: [4] hour [5] minute [6] second [7] fraction
  3085. hour = +(match[4]);
  3086. minute = +(match[5]);
  3087. second = +(match[6]);
  3088. if (match[7]) {
  3089. fraction = match[7].slice(0, 3);
  3090. while (fraction.length < 3) { // milli-seconds
  3091. fraction += '0';
  3092. }
  3093. fraction = +fraction;
  3094. }
  3095. // match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute
  3096. if (match[9]) {
  3097. tz_hour = +(match[10]);
  3098. tz_minute = +(match[11] || 0);
  3099. delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds
  3100. if ('-' === match[9]) {
  3101. delta = -delta;
  3102. }
  3103. }
  3104. date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
  3105. if (delta) {
  3106. date.setTime(date.getTime() - delta);
  3107. }
  3108. return date;
  3109. }
  3110. function representYamlTimestamp(object /*, style*/) {
  3111. return object.toISOString();
  3112. }
  3113. module.exports = new Type('tag:yaml.org,2002:timestamp', {
  3114. kind: 'scalar',
  3115. resolve: resolveYamlTimestamp,
  3116. construct: constructYamlTimestamp,
  3117. instanceOf: Date,
  3118. represent: representYamlTimestamp
  3119. });
  3120. },{"../type":13}],30:[function(require,module,exports){
  3121. },{}],"/":[function(require,module,exports){
  3122. 'use strict';
  3123. var yaml = require('./lib/js-yaml.js');
  3124. module.exports = yaml;
  3125. },{"./lib/js-yaml.js":1}]},{},[])("/")
  3126. });
  3127. ;(function(jsYaml) {
  3128. jsYaml.parse = function (text, name) {
  3129. name = name || '__content';
  3130. var re = /^(-{3}(?:\n|\r)([\w\W]+?)-{3})?([\w\W]*)*/
  3131. , results = re.exec(text)
  3132. , conf = {}
  3133. , yamlOrJson;
  3134. if((yamlOrJson = results[2])) {
  3135. if(yamlOrJson.charAt(0) === '{') {
  3136. conf = JSON.parse(yamlOrJson);
  3137. } else {
  3138. conf = jsYaml.load(yamlOrJson);
  3139. }
  3140. }
  3141. conf[name] = results[3] ? results[3] : '';
  3142. return conf;
  3143. };
  3144. jsYaml.loadFront = function (context, name) {
  3145. return jsYaml.parse(context, name);
  3146. };
  3147. }(window.jsyaml));