+107
| #!/usr/bin/env node | ||
| import { readFileSync } from 'node:fs' | ||
| import argparse from 'argparse' | ||
| import { loadAll, dump } from 'js-yaml' | ||
| const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url))) | ||
| /// ///////////////////////////////////////////////////////////////////////////// | ||
| const cli = new argparse.ArgumentParser({ | ||
| prog: 'js-yaml', | ||
| add_help: true | ||
| }) | ||
| cli.add_argument('-v', '--version', { | ||
| action: 'version', | ||
| version: pkg.version | ||
| }) | ||
| cli.add_argument('-c', '--compact', { | ||
| help: 'Display errors in compact mode', | ||
| action: 'store_true' | ||
| }) | ||
| // deprecated (not needed after we removed output colors) | ||
| // option suppressed, but not completely removed for compatibility | ||
| cli.add_argument('-j', '--to-json', { | ||
| help: argparse.SUPPRESS, | ||
| dest: 'json', | ||
| action: 'store_true' | ||
| }) | ||
| cli.add_argument('-t', '--trace', { | ||
| help: 'Show stack trace on error', | ||
| action: 'store_true' | ||
| }) | ||
| cli.add_argument('file', { | ||
| help: 'File to read, utf-8 encoded without BOM', | ||
| nargs: '?', | ||
| default: '-' | ||
| }) | ||
| /// ///////////////////////////////////////////////////////////////////////////// | ||
| const options = cli.parse_args() | ||
| /// ///////////////////////////////////////////////////////////////////////////// | ||
| // '-' means stdin (fd 0); a terminal there => nothing piped in, show help | ||
| if (options.file === '-' && process.stdin.isTTY) { | ||
| cli.print_help() | ||
| process.exit(1) | ||
| } | ||
| let input | ||
| try { | ||
| input = readFileSync(options.file === '-' ? 0 : options.file, 'utf8') | ||
| } catch (error) { | ||
| if (error.code === 'ENOENT') { | ||
| console.error(`File not found: ${options.file}`) | ||
| process.exit(2) | ||
| } | ||
| console.error( | ||
| (options.trace && error.stack) || | ||
| error.message || | ||
| String(error)) | ||
| process.exit(1) | ||
| } | ||
| let output | ||
| let isYaml | ||
| try { | ||
| output = JSON.parse(input) | ||
| isYaml = false | ||
| } catch (err) { | ||
| if (err instanceof SyntaxError) { | ||
| try { | ||
| output = [] | ||
| loadAll(input, (doc) => { output.push(doc) }, {}) | ||
| isYaml = true | ||
| if (output.length === 0) output = null | ||
| else if (output.length === 1) output = output[0] | ||
| } catch (e) { | ||
| if (options.trace && err.stack) console.error(e.stack) | ||
| else console.error(e.toString(options.compact)) | ||
| process.exit(1) | ||
| } | ||
| } else { | ||
| console.error( | ||
| (options.trace && err.stack) || | ||
| err.message || | ||
| String(err)) | ||
| process.exit(1) | ||
| } | ||
| } | ||
| if (isYaml) console.log(JSON.stringify(output, null, ' ')) | ||
| else console.log(dump(output)) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
| (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.jsyaml={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Symbol(`NOT_RESOLVED`),n=Symbol(`MERGE_KEY`);function r(e,t){var n,r,i,a,o,s;return{tagName:e,nodeKind:`scalar`,implicit:(n=t.implicit)==null?!1:n,matchByTagPrefix:(r=t.matchByTagPrefix)==null?!1:r,implicitFirstChars:(i=t.implicitFirstChars)==null?null:i,resolve:t.resolve,identify:(a=t.identify)==null?null:a,represent:(o=t.represent)==null?(e=>String(e)):o,representTagName:(s=t.representTagName)==null?null:s}}function i(e,t){var n,r,i,a;return{tagName:e,nodeKind:`sequence`,implicit:!1,matchByTagPrefix:(n=t.matchByTagPrefix)==null?!1:n,create:t.create,addItem:t.addItem,identify:(r=t.identify)==null?null:r,represent:(i=t.represent)==null?(e=>e):i,representTagName:(a=t.representTagName)==null?null:a}}function a(e,t){var n,r,i,a;return{tagName:e,nodeKind:`mapping`,implicit:!1,matchByTagPrefix:(n=t.matchByTagPrefix)==null?!1:n,create:t.create,addPair:t.addPair,has:t.has,keys:t.keys,get:t.get,identify:(r=t.identify)==null?null:r,represent:(i=t.represent)==null?(e=>e):i,representTagName:(a=t.representTagName)==null?null:a}}var o=r(`tag:yaml.org,2002:str`,{resolve:e=>e,identify:e=>typeof e==`string`}),s=[``,`~`,`null`,`Null`,`NULL`],c=r(`tag:yaml.org,2002:null`,{implicit:!0,implicitFirstChars:[``,`~`,`n`,`N`],resolve:e=>s.indexOf(e)===-1?t:null,identify:e=>e===null,represent:()=>`null`}),l=r(`tag:yaml.org,2002:null`,{implicit:!0,implicitFirstChars:[`n`],resolve:(e,n)=>e===`null`||n&&e===``?null:t,identify:e=>e===null,represent:()=>`null`}),u=[``,`~`,`null`,`Null`,`NULL`],d=r(`tag:yaml.org,2002:null`,{implicit:!0,implicitFirstChars:[``,`~`,`n`,`N`],resolve:e=>u.indexOf(e)===-1?t:null,identify:e=>e===null,represent:()=>`null`}),f=[`true`,`True`,`TRUE`],p=[`false`,`False`,`FALSE`],m=r(`tag:yaml.org,2002:bool`,{implicit:!0,implicitFirstChars:[`t`,`T`,`f`,`F`],resolve:e=>f.indexOf(e)===-1?p.indexOf(e)===-1?t:!1:!0,identify:e=>Object.prototype.toString.call(e)===`[object Boolean]`,represent:e=>e?`true`:`false`}),h=[`true`],ee=[`false`],te=r(`tag:yaml.org,2002:bool`,{implicit:!0,implicitFirstChars:[`t`,`f`],resolve:e=>h.indexOf(e)===-1?ee.indexOf(e)===-1?t:!1:!0,identify:e=>Object.prototype.toString.call(e)===`[object Boolean]`,represent:e=>e?`true`:`false`}),ne=[`true`,`True`,`TRUE`,`y`,`Y`,`yes`,`Yes`,`YES`,`on`,`On`,`ON`],re=[`false`,`False`,`FALSE`,`n`,`N`,`no`,`No`,`NO`,`off`,`Off`,`OFF`],ie=r(`tag:yaml.org,2002:bool`,{implicit:!0,implicitFirstChars:[`y`,`Y`,`n`,`N`,`t`,`T`,`f`,`F`,`o`,`O`],resolve:e=>ne.indexOf(e)===-1?re.indexOf(e)===-1?t:!1:!0,identify:e=>Object.prototype.toString.call(e)===`[object Boolean]`,represent:e=>e?`true`:`false`}),ae=RegExp(`^(?:0o[0-7]+|0x[0-9a-fA-F]+|[-+]?[0-9]+)$`),oe=RegExp(`^(?:[-+]?0b[0-1]+|[-+]?0o[0-7]+|[-+]?0x[0-9a-fA-F]+|[-+]?[0-9]+)$`);function se(e){let t=e,n=1;return(t[0]===`-`||t[0]===`+`)&&(t[0]===`-`&&(n=-1),t=t.slice(1)),t.startsWith(`0b`)?n*parseInt(t.slice(2),2):t.startsWith(`0o`)?n*parseInt(t.slice(2),8):t.startsWith(`0x`)?n*parseInt(t.slice(2),16):n*parseInt(t,10)}function ce(e,n){if(n){if(!oe.test(e))return t}else if(!ae.test(e))return t;let r=se(e);return Number.isFinite(r)?r:t}var le=r(`tag:yaml.org,2002:int`,{implicit:!0,implicitFirstChars:[`-`,`+`,...`0123456789`],resolve:ce,identify:e=>Object.prototype.toString.call(e)===`[object Number]`&&e%1==0&&!Object.is(e,-0),represent:e=>e.toString(10)}),ue=RegExp(`^-?(?:0|[1-9][0-9]*)$`),de=RegExp(`^(?:[-+]?0b[0-1]+|[-+]?0o[0-7]+|[-+]?0x[0-9a-fA-F]+|[-+]?[0-9]+)$`);function fe(e){let t=e,n=1;return(t[0]===`-`||t[0]===`+`)&&(t[0]===`-`&&(n=-1),t=t.slice(1)),t.startsWith(`0b`)?n*parseInt(t.slice(2),2):t.startsWith(`0o`)?n*parseInt(t.slice(2),8):t.startsWith(`0x`)?n*parseInt(t.slice(2),16):n*parseInt(t,10)}function pe(e,n){if(n){if(!de.test(e))return t}else if(!ue.test(e))return t;let r=fe(e);return Number.isFinite(r)?r:t}var me=r(`tag:yaml.org,2002:int`,{implicit:!0,implicitFirstChars:[`-`,...`0123456789`],resolve:pe,identify:e=>Object.prototype.toString.call(e)===`[object Number]`&&e%1==0&&!Object.is(e,-0),represent:e=>e.toString(10)}),he=RegExp(`^(?:[-+]?0b[0-1_]+|[-+]?0[0-7_]+|[-+]?0x[0-9a-fA-F_]+|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+|[-+]?(?:0|[1-9][0-9_]*))$`);function ge(e){let t=e.replace(/_/g,``),n=1;if((t[0]===`-`||t[0]===`+`)&&(t[0]===`-`&&(n=-1),t=t.slice(1)),t.startsWith(`0b`))return n*parseInt(t.slice(2),2);if(t.startsWith(`0x`))return n*parseInt(t.slice(2),16);if(t.includes(`:`)){let e=0;for(let n of t.split(`:`))e=e*60+Number(n);return n*e}return t!==`0`&&t[0]===`0`?n*parseInt(t,8):n*parseInt(t,10)}function _e(e){if(!he.test(e))return t;let n=ge(e);return Number.isFinite(n)?n:t}var ve=r(`tag:yaml.org,2002:int`,{implicit:!0,implicitFirstChars:[`-`,`+`,...`0123456789`],resolve:_e,identify:e=>Object.prototype.toString.call(e)===`[object Number]`&&e%1==0&&!Object.is(e,-0),represent:e=>e.toString(10)}),ye=RegExp(`^(?:[-+]?[0-9]+(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|[-+]?\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$`),be=RegExp(`^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$`);function xe(e){if(!ye.test(e))return t;let n=e.toLowerCase(),r=n[0]===`-`?-1:1;if(`+-`.includes(n[0])&&(n=n.slice(1)),n===`.inf`)return r===1?1/0:-1/0;if(n===`.nan`)return NaN;let i=r*parseFloat(n);return Number.isFinite(i)||be.test(e)?i:t}function Se(e){if(isNaN(e))return`.nan`;if(e===1/0)return`.inf`;if(e===-1/0)return`-.inf`;if(Object.is(e,-0))return`-0.0`;let t=e.toString(10);return/^[-+]?[0-9]+e/.test(t)?t.replace(`e`,`.e`):t}var Ce=r(`tag:yaml.org,2002:float`,{implicit:!0,implicitFirstChars:[`-`,`+`,`.`,...`0123456789`],resolve:xe,identify:e=>Object.prototype.toString.call(e)===`[object Number]`&&(e%1!=0||Object.is(e,-0)),represent:Se}),we=RegExp(`^-?(?:0|[1-9][0-9]*)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$`),Te=RegExp(`^(?:[-+]?[0-9]+(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|[-+]?\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$`);function Ee(e,n){if(n){if(!Te.test(e))return t;let n=e.toLowerCase(),r=n[0]===`-`?-1:1;if(`+-`.includes(n[0])&&(n=n.slice(1)),n===`.inf`)return r===1?1/0:-1/0;if(n===`.nan`)return NaN;let i=r*parseFloat(n);return Number.isFinite(i)?i:t}if(!we.test(e))return t;let r=Number(e);return Number.isFinite(r)?r:t}function De(e){if(isNaN(e))return`.nan`;if(e===1/0)return`.inf`;if(e===-1/0)return`-.inf`;if(Object.is(e,-0))return`-0.0`;let t=e.toString(10);return/^[-+]?[0-9]+e/.test(t)?t.replace(`e`,`.e`):t}var Oe=r(`tag:yaml.org,2002:float`,{implicit:!0,implicitFirstChars:[`-`,...`0123456789`],resolve:Ee,identify:e=>Object.prototype.toString.call(e)===`[object Number]`&&(e%1!=0||Object.is(e,-0)),represent:De}),ke=RegExp(`^(?:[-+]?(?:(?:[0-9][0-9_]*)?\\.[0-9_]*)(?:[eE][-+][0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$`),Ae=RegExp(`^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$`);function je(e){if(!ke.test(e))return t;let n=e.toLowerCase().replace(/_/g,``),r=n[0]===`-`?-1:1;if(`+-`.includes(n[0])&&(n=n.slice(1)),n===`.inf`)return r===1?1/0:-1/0;if(n===`.nan`)return NaN;let i=0;if(n.includes(`:`)){for(let e of n.split(`:`))i=i*60+Number(e);i*=r}else i=r*parseFloat(n);return Number.isFinite(i)||Ae.test(e)?i:t}function Me(e){if(isNaN(e))return`.nan`;if(e===1/0)return`.inf`;if(e===-1/0)return`-.inf`;if(Object.is(e,-0))return`-0.0`;let t=e.toString(10);return/^[-+]?[0-9]+e/.test(t)?t.replace(`e`,`.e`):t}var Ne=r(`tag:yaml.org,2002:float`,{implicit:!0,implicitFirstChars:[`-`,`+`,`.`,...`0123456789`],resolve:je,identify:e=>Object.prototype.toString.call(e)===`[object Number]`&&(e%1!=0||Object.is(e,-0)),represent:Me}),Pe=r(`tag:yaml.org,2002:merge`,{implicit:!0,implicitFirstChars:[`<`],resolve:(e,r)=>e===`<<`||r&&e===``?n:t}),Fe=/^[A-Za-z0-9+/]*={0,2}$/;function Ie(e){let n=e.replace(/\s/g,``);if(n.length%4!=0||!Fe.test(n))return t;let r=atob(n),i=new Uint8Array(r.length);for(let e=0;e<r.length;e++)i[e]=r.charCodeAt(e);return i}function Le(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}var Re=r(`tag:yaml.org,2002:binary`,{resolve:Ie,identify:e=>Object.prototype.toString.call(e)===`[object Uint8Array]`,represent:Le}),ze=RegExp(`^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$`),Be=RegExp(`^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$`);function Ve(e){let n=ze.exec(e);if(n===null&&(n=Be.exec(e)),n===null)return t;let r=+n[1],i=n[2]-1,a=+n[3];if(!n[4]){let e=new Date(Date.UTC(r,i,a));return e.getUTCFullYear()!==r||e.getUTCMonth()!==i||e.getUTCDate()!==a?t:e}let o=+n[4],s=+n[5],c=+n[6],l=0;if(o>23||s>59||c>59)return t;if(n[7]){let e=n[7].slice(0,3);for(;e.length<3;)e+=`0`;l=+e}let u=new Date(Date.UTC(r,i,a,o,s,c,l));if(u.getUTCFullYear()!==r||u.getUTCMonth()!==i||u.getUTCDate()!==a)return t;if(n[9]){let e=+n[10],r=+(n[11]||0);if(e>23||r>59)return t;let i=(e*60+r)*6e4;u.setTime(u.getTime()-(n[9]===`-`?-i:i))}return u}var He=r(`tag:yaml.org,2002:timestamp`,{implicit:!0,implicitFirstChars:[...`0123456789`],resolve:Ve,identify:e=>e instanceof Date,represent:e=>e.toISOString()}),Ue=i(`tag:yaml.org,2002:seq`,{create:()=>[],addItem:(e,t)=>{e.push(t)},identify:Array.isArray}),We=i(`tag:yaml.org,2002:omap`,{create:()=>[],addItem:(e,t)=>{if(Object.prototype.toString.call(t)!==`[object Object]`)return`cannot resolve an ordered map item`;let n=t,r=Object.keys(n);if(r.length!==1)return`cannot resolve an ordered map item`;for(let t of e)if(Object.prototype.hasOwnProperty.call(t,r[0]))return`cannot resolve an ordered map item`;return e.push(n),``}}),Ge=i(`tag:yaml.org,2002:pairs`,{create:()=>[],addItem:(e,t)=>{if(t instanceof Map)return t.size===1?(e.push(t.entries().next().value),``):`cannot resolve a pairs item`;if(Object.prototype.toString.call(t)!==`[object Object]`)return`cannot resolve a pairs item`;let n=t,r=Object.keys(n);return r.length===1?(e.push([r[0],n[r[0]]]),``):`cannot resolve a pairs item`}});function Ke(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function qe(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}var Je=a(`tag:yaml.org,2002:map`,{create:()=>({}),identify:Ke,represent:e=>{let t=new Map;for(let n of Object.keys(e))t.set(n,e[n]);return t},addPair:(e,t,n)=>{if(typeof t==`object`&&t)return`object-based map does not support complex keys`;let r=String(t);return r===`__proto__`?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,``},has:(e,t)=>typeof t==`object`&&t?!1:Object.prototype.hasOwnProperty.call(e,String(t)),keys:e=>Object.keys(e),get:(e,t)=>e[String(t)]}),Ye=a(`tag:yaml.org,2002:set`,{create:()=>new Set,identify:e=>e instanceof Set,represent:e=>{let t=new Map;for(let n of e)t.set(n,null);return t},addPair:(e,t,n)=>n===null?(e.add(t),``):`cannot resolve a set item`,has:(e,t)=>e.has(t),keys:e=>e.keys(),get:()=>null});function Xe(e){"@babel/helpers - typeof";return Xe=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Xe(e)}function Ze(e,t){if(Xe(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(Xe(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Qe(e){var t=Ze(e,`string`);return Xe(t)==`symbol`?t:t+``}function g(e,t,n){return(t=Qe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function $e(){return{scalar:{},sequence:{},mapping:{}}}function et(){return{scalar:[],sequence:[],mapping:[]}}function tt(e){let t=[];for(let n of e){let e=t.length;for(let r=0;r<t.length;r++){let i=t[r];if(i.nodeKind===n.nodeKind&&i.tagName===n.tagName&&i.matchByTagPrefix===n.matchByTagPrefix){e=r;break}}t[e]=n}return t}var _=class e{constructor(e){g(this,`tags`,void 0),g(this,`implicitScalarTags`,void 0),g(this,`implicitScalarByFirstChar`,void 0),g(this,`implicitScalarAnyFirstChar`,void 0),g(this,`defaultScalarTag`,void 0),g(this,`defaultSequenceTag`,void 0),g(this,`defaultMappingTag`,void 0),g(this,`exact`,void 0),g(this,`prefix`,void 0);let t=tt(e),n=[],r=$e(),i=et();for(let e of t){if(e.nodeKind===`scalar`&&e.implicit){if(e.matchByTagPrefix)throw Error(`Implicit scalar tags cannot match by tag prefix`);n.push(e)}switch(e.nodeKind){case`scalar`:e.matchByTagPrefix?i.scalar.push(e):r.scalar[e.tagName]=e;break;case`sequence`:e.matchByTagPrefix?i.sequence.push(e):r.sequence[e.tagName]=e;break;case`mapping`:e.matchByTagPrefix?i.mapping.push(e):r.mapping[e.tagName]=e;break}}let a=n.filter(e=>e.implicitFirstChars===null),o=new Set;for(let e of n)if(e.implicitFirstChars!==null)for(let t of e.implicitFirstChars)o.add(t);let s=new Map;for(let e of o)s.set(e,n.filter(t=>t.implicitFirstChars===null||t.implicitFirstChars.indexOf(e)!==-1));let c=r.scalar[`tag:yaml.org,2002:str`];if(!c)throw Error(`schema does not define the default scalar tag (tag:yaml.org,2002:str)`);this.tags=t,this.implicitScalarTags=n,this.implicitScalarByFirstChar=s,this.implicitScalarAnyFirstChar=a,this.defaultScalarTag=c,this.defaultSequenceTag=r.sequence[`tag:yaml.org,2002:seq`],this.defaultMappingTag=r.mapping[`tag:yaml.org,2002:map`],this.exact=r,this.prefix=i}withTags(...t){let n=[];for(let e of t)n=n.concat(e);return new e([...this.tags,...n])}},nt=new _([o,Ue,Je]),rt=new _([...nt.tags,l,te,me,Oe]),it=new _([...nt.tags,c,m,le,Ce]),at=new _([...nt.tags,d,ie,ve,Ne,He,Pe,Re,We,Ge,Ye]),ot=a(`tag:yaml.org,2002:map`,{create:()=>new Map,addPair:(e,t,n)=>(e.set(t,n),``),has:(e,t)=>e.has(t),keys:e=>e.keys(),get:(e,t)=>e.get(t),identify:e=>e instanceof Map||Ke(e),represent:e=>{if(e instanceof Map)return e;let t=new Map,n=e;for(let e of Object.keys(n))t.set(e,n[e]);return t}});function st(e){if(Array.isArray(e)){let t=Array.prototype.slice.call(e);for(let e=0;e<t.length;e++){if(Array.isArray(t[e]))return null;typeof t[e]==`object`&&Object.prototype.toString.call(t[e])===`[object Object]`&&(t[e]=`[object Object]`)}return String(t)}return typeof e==`object`&&Object.prototype.toString.call(e)===`[object Object]`?`[object Object]`:String(e)}var ct=a(`tag:yaml.org,2002:map`,{create:()=>({}),identify:Ke,represent:e=>{let t=new Map;for(let n of Object.keys(e))t.set(n,e[n]);return t},addPair:(e,t,n)=>{let r=st(t);return r===null?`nested arrays are not supported inside keys`:(r===`__proto__`?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,``)},has:(e,t)=>{let n=st(t);return n!==null&&Object.prototype.hasOwnProperty.call(e,n)},keys:e=>Object.keys(e),get:(e,t)=>e[String(t)]});function lt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function v(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?lt(Object(n),!0).forEach(function(t){g(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):lt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var ut={maxLength:79,indent:1,linesBefore:3,linesAfter:2};function dt(e,t,n,r,i){let a=``,o=``,s=Math.floor(i/2)-1;return r-t>s&&(a=` ... `,t=r-s+a.length),n-r>s&&(o=` ...`,n=r+s-o.length),{str:a+e.slice(t,n).replace(/\t/g,`→`)+o,pos:r-t+a.length}}function ft(e,t){return` `.repeat(Math.max(t-e.length,0))+e}function pt(e,t){if(!e.buffer)return null;let n=v(v({},ut),t),r=/\r?\n|\r|\0/g,i=[0],a=[],o,s=-1;for(;o=r.exec(e.buffer);)a.push(o.index),i.push(o.index+o[0].length),e.position<=o.index&&s<0&&(s=i.length-2);s<0&&(s=i.length-1);let c=``,l=Math.min(e.line+n.linesAfter,a.length).toString().length,u=n.maxLength-(n.indent+l+3);for(let t=1;t<=n.linesBefore&&!(s-t<0);t++){let r=dt(e.buffer,i[s-t],a[s-t],e.position-(i[s]-i[s-t]),u);c=`${` `.repeat(n.indent)}${ft((e.line-t+1).toString(),l)} | ${r.str}\n${c}`}let d=dt(e.buffer,i[s],a[s],e.position,u);c+=`${` `.repeat(n.indent)}${ft((e.line+1).toString(),l)} | ${d.str}\n`,c+=`${`-`.repeat(n.indent+l+3+d.pos)}^\n`;for(let t=1;t<=n.linesAfter&&!(s+t>=a.length);t++){let r=dt(e.buffer,i[s+t],a[s+t],e.position-(i[s]-i[s+t]),u);c+=`${` `.repeat(n.indent)}${ft((e.line+t+1).toString(),l)} | ${r.str}\n`}return c.replace(/\n$/,``)}function mt(e,t){let n=``;return e.mark?(e.mark.name&&(n+=`in "${e.mark.name}" `),n+=`(${e.mark.line+1}:${e.mark.column+1})`,!t&&e.mark.snippet&&(n+=`\n\n${e.mark.snippet}`),`${e.reason} ${n}`):e.reason}var y=class extends Error{constructor(e,t){super(),g(this,`reason`,void 0),g(this,`mark`,void 0),this.name=`YAMLException`,this.reason=e,this.mark=t,this.message=mt(this,!1),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}toString(e){return`${this.name}: ${mt(this,e)}`}};function ht(e,t,n,r=``){let i=0,a=0;for(let n=0;n<t;n++){let t=e.charCodeAt(n);t===10?(i++,a=n+1):t===13&&(i++,e.charCodeAt(n+1)===10&&n++,a=n+1)}let o={name:r,buffer:e,position:t,line:i,column:t-a};throw o.snippet=pt(o),new y(n,o)}var gt=1,_t=2,vt=3,yt=4,bt=5,xt=6,St=1,Ct=2,wt=3,Tt=4,Et=5,Dt=1,Ot=2,kt=1,At=2,jt=3,Mt=-1;function Nt(e){switch(e){case 48:return`\0`;case 97:return`\x07`;case 98:return`\b`;case 116:return` `;case 9:return` `;case 110:return` | ||
| `;case 118:return`\v`;case 102:return`\f`;case 114:return`\r`;case 101:return`\x1B`;case 32:return` `;case 34:return`"`;case 47:return`/`;case 92:return`\\`;case 78:return` `;case 95:return`\xA0`;case 76:return`\u2028`;case 80:return`\u2029`;default:return``}}var Pt=Array(256),Ft=Array(256);for(let e=0;e<256;e++)Pt[e]=+!!Nt(e),Ft[e]=Nt(e);function It(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function Lt(e){return e>=48&&e<=57?e-48:(e|32)-97+10}function Rt(e){return e===120?2:e===117?4:8}function zt(e,t,n){let r=0;for(;t<n;){let n=e.charCodeAt(t);if(n===10)r++,t++;else if(n===13)r++,t++,e.charCodeAt(t)===10&&t++;else if(n===32||n===9)t++;else break}return{position:t,breaks:r}}function Bt(e){return e===1?` `:` | ||
| `.repeat(e-1)}function Vt(e,t,n){let r=``,i=t,a=t,o=t;for(;i<n;){let t=e.charCodeAt(i);if(t===10||t===13){r+=e.slice(a,o);let t=zt(e,i,n);r+=Bt(t.breaks),i=a=o=t.position}else i++,t!==32&&t!==9&&(o=i)}return r+e.slice(a,o)}function Ht(e,t,n){let r=``,i=t,a=t,o=t;for(;i<n;){let t=e.charCodeAt(i);if(t===39)r+=e.slice(a,i)+`'`,i+=2,a=o=i;else if(t===10||t===13){r+=e.slice(a,o);let t=zt(e,i,n);r+=Bt(t.breaks),i=a=o=t.position}else i++,t!==32&&t!==9&&(o=i)}return r+e.slice(a,n)}function Ut(e,t,n){let r=``,i=t,a=t,o=t;for(;i<n;){let t=e.charCodeAt(i);if(t===92){r+=e.slice(a,i),i++;let t=e.charCodeAt(i);if(t===10||t===13)i=zt(e,i,n).position;else if(t<256&&Pt[t])r+=Ft[t],i++;else{let n=Rt(t),a=0;for(;n>0;n--){i++;let t=Lt(e.charCodeAt(i));a=(a<<4)+t}r+=It(a),i++}a=o=i}else if(t===10||t===13){r+=e.slice(a,o);let t=zt(e,i,n);r+=Bt(t.breaks),i=a=o=t.position}else i++,t!==32&&t!==9&&(o=i)}return r+e.slice(a,n)}function Wt(e,t,n,r,i,a){let o=r<0?0:r,s=e.slice(t,n).replace(/\r\n?/g,` | ||
| `),c=s===``?[]:(s.endsWith(` | ||
| `)?s.slice(0,-1):s).split(` | ||
| `),l=``,u=!1,d=0,f=!1;for(let e of c){let t=0;for(;t<o&&e.charCodeAt(t)===32;)t++;if(r<0||t>=e.length){d++;continue}let n=e.slice(o),i=n.charCodeAt(0);a?i===32||i===9?(f=!0,l+=` | ||
| `.repeat(u?1+d:d)):f?(f=!1,l+=` | ||
| `.repeat(d+1)):d===0?u&&(l+=` `):l+=` | ||
| `.repeat(d):l+=` | ||
| `.repeat(u?1+d:d),l+=n,u=!0,d=0}return i===3?l+=` | ||
| `.repeat(u?1+d:d):i!==2&&u&&(l+=` | ||
| `),l}function Gt(e,t){if(t.valueStart===Mt)return``;let{valueStart:n,valueEnd:r}=t;if(t.fast)return e.slice(n,r);switch(t.style){case 2:return Ht(e,n,r);case 3:return Ut(e,n,r);case 4:return Wt(e,n,r,t.indent,t.chomping,!1);case 5:return Wt(e,n,r,t.indent,t.chomping,!0);default:return Vt(e,n,r)}}var Kt={"!":`!`,"!!":`tag:yaml.org,2002:`};function qt(e){return encodeURI(e).replace(/!/g,`%21`)}function Jt(e,t){var n,r;if(e.startsWith(`!<`)&&e.endsWith(`>`))return decodeURIComponent(e.slice(2,-1));let i=e.indexOf(`!`,1),a=i===-1?`!`:e.slice(0,i+1),o=(n=(r=t==null?void 0:t[a])==null?Kt[a]:r)==null?a:n;return decodeURIComponent(o)+decodeURIComponent(e.slice(a.length))}function Yt(e){let t=e;return t.charCodeAt(0)===33?(t=t.slice(1),`!${qt(t)}`):t.slice(0,18)===`tag:yaml.org,2002:`?`!!${qt(t.slice(18))}`:`!<${qt(t)}>`}var b=-1,Xt={filename:``,schema:it,json:!1,maxMergeSeqLength:20};function Zt(e){return`tagStart`in e&&e.tagStart!==b?e.tagStart:`anchorStart`in e&&e.anchorStart!==b?e.anchorStart:`valueStart`in e&&e.valueStart!==b?e.valueStart:`start`in e?e.start:0}function x(e,t){ht(e.source,e.position,t,e.filename)}function Qt(e,t,n){let r=e[n];if(r)return r;for(let e of t)if(n.startsWith(e.tagName))return e}function $t(e,t,n,r,i){let a=Qt(t,n,r);if(a)return a;x(e,`unknown ${i} tag !<${r}>`)}function en(e,n){let r=Gt(e.source,n),i=n.tagStart===b?``:e.source.slice(n.tagStart,n.tagEnd),a=e.schema.defaultScalarTag;if(i!==``){var o;if(i===`!`)return{value:r,tag:a};let n=Jt(i,e.tagHandlers),s=Qt(e.schema.exact.scalar,e.schema.prefix.scalar,n);if(s){let i=s.resolve(r,!0,n);return i===t&&x(e,`cannot resolve a node with !<${n}> explicit tag`),{value:i,tag:s}}let c=(o=Qt(e.schema.exact.mapping,e.schema.prefix.mapping,n))==null?Qt(e.schema.exact.sequence,e.schema.prefix.sequence,n):o;if(c)return r!==``&&x(e,`cannot resolve a node with !<${n}> explicit tag`),{value:c.create(n),tag:c};x(e,`unknown scalar tag !<${n}>`)}if(n.style===1){var s;let n=(s=e.schema.implicitScalarByFirstChar.get(r.charAt(0)))==null?e.schema.implicitScalarAnyFirstChar:s;for(let e of n){let n=e.resolve(r,!1,e.tagName);if(n!==t)return{value:n,tag:e}}}return{value:a.resolve(r,!1,a.tagName),tag:a}}function tn(e,t,n,r,i,a){let o=t.tagStart===b?``:e.source.slice(t.tagStart,t.tagEnd),s=o===``||o===`!`?i:Jt(o,e.tagHandlers);return{tagName:s,tag:$t(e,n,r,s,a)}}function nn(e){return e.nodeKind===`mapping`}function rn(e,t,n,r){for(let a of r.keys(n)){var i;if(t.tag.has(t.value,a))continue;let o=t.tag.addPair(t.value,a,r.get(n,a));o&&x(e,o),((i=t.overridable)==null?t.overridable=new Set:i).add(a)}}function an(e,t,n,r){if(e.position=t.keyPosition,nn(r))rn(e,t,n,r);else if(r.nodeKind===`sequence`&&Array.isArray(n)){let r=new Set;for(let i of n)r.has(i)||(r.add(i),rn(e,t,i,t.tag))}else x(e,`cannot merge mappings; the provided source object is unacceptable`)}function on(e,t,r,i,a){var o,s;if(e.position=t.keyPosition,r===n){an(e,t,i,a);return}!e.json&&t.tag.has(t.value,r)&&!((o=t.overridable)!=null&&o.has(r))&&x(e,`duplicated mapping key`);let c=t.tag.addPair(t.value,r,i);c&&x(e,c),(s=t.overridable)==null||s.delete(r)}function sn(e,t,n){let r=e.frames[e.frames.length-1];if(r.kind===`document`)r.value=t,r.hasValue=!0;else if(r.kind===`sequence`){r.merge&&(nn(n)||x(e,`cannot merge mappings; the provided source object is unacceptable`),r.index>=e.maxMergeSeqLength&&x(e,`merge sequence length exceeded maxMergeSeqLength (${e.maxMergeSeqLength})`));let i=r.tag.addItem(r.value,t,r.index++);i&&x(e,i)}else if(r.hasKey){let i=r.key;r.key=void 0,r.hasKey=!1,on(e,r,i,t,n)}else r.key=t,r.keyPosition=e.position,r.hasKey=!0}function cn(e,t,n,r){t.anchorStart!==b&&e.anchors.set(e.source.slice(t.anchorStart,t.anchorEnd),{value:n,tag:r})}function ln(e,t){let r=v(v(v({},Xt),t),{},{events:e,documents:[],eventIndex:0,position:0,frames:[],anchors:new Map,tagHandlers:Object.create(null)});for(;r.eventIndex<r.events.length;){let e=r.events[r.eventIndex++];switch(r.position=Zt(e),e.type){case 1:r.anchors=new Map,r.tagHandlers=Object.create(null);for(let t of e.directives)t.kind===`tag`&&(r.tagHandlers[t.handle]=t.prefix);r.frames.push({kind:`document`,position:r.position,value:void 0,hasValue:!1});break;case 4:{let{value:t,tag:n}=en(r,e);cn(r,e,t,n),sn(r,t,n);break}case 2:{let t=tn(r,e,r.schema.exact.sequence,r.schema.prefix.sequence,`tag:yaml.org,2002:seq`,`sequence`),i=t.tag.create(t.tagName);cn(r,e,i,t.tag);let a=r.frames[r.frames.length-1],o=a!==void 0&&a.kind===`mapping`&&a.hasKey&&a.key===n;r.frames.push({kind:`sequence`,position:r.position,value:i,tag:t.tag,index:0,merge:o});break}case 3:{let t=tn(r,e,r.schema.exact.mapping,r.schema.prefix.mapping,`tag:yaml.org,2002:map`,`mapping`),n=t.tag.create(t.tagName);cn(r,e,n,t.tag),r.frames.push({kind:`mapping`,position:r.position,value:n,tag:t.tag,key:void 0,keyPosition:r.position,hasKey:!1,overridable:null});break}case 5:{let t=r.source.slice(e.anchorStart,e.anchorEnd),n=r.anchors.get(t);n||x(r,`unidentified alias "${t}"`),sn(r,n.value,n.tag);break}case 6:{let e=r.frames.pop();e.kind===`document`?r.documents.push(e.value):sn(r,e.value,e.tag);break}}}return r.documents}var S=-1,un=Object.prototype.hasOwnProperty,C=1,dn=2,fn=3,pn=4,mn=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,hn=/[,\[\]{}]/,gn=/^(?:!|!!|![0-9A-Za-z-]+!)$/,_n=String.raw`(?:%[0-9A-Fa-f]{2}|[0-9A-Za-z\-#;/?:@&=+$,_.!~*'()\[\]])`,vn=String.raw`(?:%[0-9A-Fa-f]{2}|[0-9A-Za-z\-#;/?:@&=+$.~*'()_])`,yn=RegExp(`^(?:${_n})*$`),bn=RegExp(`^(?:${vn})+$`),xn=RegExp(`^(?:!(?:${_n})*|${vn}(?:${_n})*)$`),Sn={filename:``,maxDepth:100};function Cn(e,t,n){e.events.push({type:1,explicitStart:t,explicitEnd:n,directives:e.directives})}function wn(e,t,n,r,i,a,o){e.events.push({type:2,start:t,anchorStart:n,anchorEnd:r,tagStart:i,tagEnd:a,style:o})}function w(e,t,n,r,i,a,o){e.events.push({type:3,start:t,anchorStart:n,anchorEnd:r,tagStart:i,tagEnd:a,style:o})}function T(e,t,n,r,i,a,o,s,c=1,l=-1,u=!1){e.events.push({type:4,valueStart:t,valueEnd:n,anchorStart:r,anchorEnd:i,tagStart:a,tagEnd:o,style:s,chomping:c,indent:l,fast:u})}function Tn(e,t,n){e.events.push({type:5,anchorStart:t,anchorEnd:n})}function E(e){e.events.push({type:6})}function D(e){T(e,S,S,S,S,S,S,1)}function En(){return{anchorStart:S,anchorEnd:S,tagStart:S,tagEnd:S}}function O(e){return{position:e.position,line:e.line,lineStart:e.lineStart,lineIndent:e.lineIndent,firstTabInLine:e.firstTabInLine,eventsLength:e.events.length}}function k(e,t){e.position=t.position,e.line=t.line,e.lineStart=t.lineStart,e.lineIndent=t.lineIndent,e.firstTabInLine=t.firstTabInLine,e.events.length=t.eventsLength}function A(e,t){ht(e.input.slice(0,e.length),e.position,t,e.filename)}function j(e){return e===10||e===13}function M(e){return e===9||e===32}function N(e){return M(e)||j(e)}function P(e){return e===0||N(e)}function F(e){return e===44||e===91||e===93||e===123||e===125}function Dn(e){return e>=48&&e<=57?e-48:-1}function On(e){if(e>=48&&e<=57)return e-48;let t=e|32;return t>=97&&t<=102?t-97+10:-1}function kn(e){return e===120?2:e===117?4:e===85?8:0}function An(e){return e===48||e===97||e===98||e===116||e===9||e===110||e===118||e===102||e===114||e===101||e===32||e===34||e===47||e===92||e===78||e===95||e===76||e===80}function jn(e){e.input.charCodeAt(e.position)===10?e.position++:(e.position++,e.input.charCodeAt(e.position)===10&&e.position++),e.line++,e.lineStart=e.position,e.lineIndent=0,e.firstTabInLine=-1}function I(e,t){let n=0,r=e.input.charCodeAt(e.position),i=e.position===e.lineStart||N(e.input.charCodeAt(e.position-1));for(;r!==0;){for(;M(r);)i=!0,r===9&&e.firstTabInLine===-1&&(e.firstTabInLine=e.position),r=e.input.charCodeAt(++e.position);if(t&&i&&r===35)do r=e.input.charCodeAt(++e.position);while(!j(r)&&r!==0);if(!j(r))break;for(jn(e),n++,i=!0,r=e.input.charCodeAt(e.position);r===32;)e.lineIndent++,r=e.input.charCodeAt(++e.position)}return n}function L(e,t=e.position){let n=e.input.charCodeAt(t);if((n===45||n===46)&&n===e.input.charCodeAt(t+1)&&n===e.input.charCodeAt(t+2)){let n=e.input.charCodeAt(t+3);return n===0||N(n)}return!1}function Mn(e){let t=e.input.charCodeAt(e.position);for(;t!==0&&!j(t);)t=e.input.charCodeAt(++e.position)}function Nn(e,t,n){mn.test(e.input.slice(t,n))&&A(e,`the stream contains non-printable characters`)}function Pn(e,t,n){if(e.input.charCodeAt(e.position)!==33)return!1;t.tagStart!==S&&A(e,`duplication of a tag property`);let r=e.position,i=!1,a=!1,o=`!`,s=e.input.charCodeAt(++e.position);s===60?(i=!0,s=e.input.charCodeAt(++e.position)):s===33&&(a=!0,o=`!!`,s=e.input.charCodeAt(++e.position));let c=e.position,l;if(i){for(;s!==0&&s!==62;)s=e.input.charCodeAt(++e.position);s!==62&&A(e,`unexpected end of the stream within a verbatim tag`),l=e.input.slice(c,e.position),e.position++}else{for(;s!==0&&!N(s)&&!(n&&F(s));)s===33&&(a?A(e,`tag suffix cannot contain exclamation marks`):(o=e.input.slice(c-1,e.position+1),gn.test(o)||A(e,`named tag handle cannot contain such characters`),a=!0,c=e.position+1)),s=e.input.charCodeAt(++e.position);l=e.input.slice(c,e.position),hn.test(l)&&A(e,`tag suffix cannot contain flow indicator characters`)}return l&&!(i?yn.test(l):bn.test(l))&&A(e,`tag name cannot contain such characters: ${l}`),!i&&o!==`!`&&o!==`!!`&&!un.call(e.tagHandlers,o)&&A(e,`undeclared tag handle "${o}"`),t.tagStart=r,t.tagEnd=e.position,!0}function Fn(e,t){if(e.input.charCodeAt(e.position)!==38)return!1;t.anchorStart!==S&&A(e,`duplication of an anchor property`),e.position++;let n=e.position;for(;e.input.charCodeAt(e.position)!==0&&!N(e.input.charCodeAt(e.position))&&!F(e.input.charCodeAt(e.position));)e.position++;return e.position===n&&A(e,`name of an anchor node must contain at least one character`),t.anchorStart=n,t.anchorEnd=e.position,!0}function In(e,t){if(e.input.charCodeAt(e.position)!==42)return!1;(t.anchorStart!==S||t.tagStart!==S)&&A(e,`alias node should not have any properties`),e.position++;let n=e.position;for(;e.input.charCodeAt(e.position)!==0&&!N(e.input.charCodeAt(e.position))&&!F(e.input.charCodeAt(e.position));)e.position++;return e.position===n&&A(e,`name of an alias node must contain at least one character`),Tn(e,n,e.position),!0}function Ln(e,t){I(e,!1),e.lineIndent<t&&A(e,`deficient indentation`)}function Rn(e,t,n){if(e.input.charCodeAt(e.position)!==39)return!1;e.position++;let r=e.position,i=!0;for(;e.input.charCodeAt(e.position)!==0;){let a=e.input.charCodeAt(e.position);if(a===39){if(e.input.charCodeAt(e.position+1)===39){i=!1,e.position+=2;continue}let t=e.position;return e.position++,T(e,r,t,n.anchorStart,n.anchorEnd,n.tagStart,n.tagEnd,2,1,-1,i),!0}j(a)?(i=!1,Ln(e,t)):e.position===e.lineStart&&L(e)?A(e,`unexpected end of the document within a single quoted scalar`):a!==9&&a<32?A(e,`expected valid JSON character`):e.position++}A(e,`unexpected end of the stream within a single quoted scalar`)}function zn(e,t,n){if(e.input.charCodeAt(e.position)!==34)return!1;e.position++;let r=e.position,i=!0;for(;e.input.charCodeAt(e.position)!==0;){let a=e.input.charCodeAt(e.position);if(a===34){let t=e.position;return e.position++,T(e,r,t,n.anchorStart,n.anchorEnd,n.tagStart,n.tagEnd,3,1,-1,i),!0}if(a===92){i=!1;let n=e.input.charCodeAt(++e.position);if(j(n))Ln(e,t);else if(An(n))e.position++;else{let t=kn(n);for(t===0&&A(e,`unknown escape sequence`);t-- >0;)e.position++,On(e.input.charCodeAt(e.position))<0&&A(e,`expected hexadecimal character`);e.position++}}else j(a)?(i=!1,Ln(e,t)):e.position===e.lineStart&&L(e)?A(e,`unexpected end of the document within a double quoted scalar`):a!==9&&a<32?A(e,`expected valid JSON character`):e.position++}A(e,`unexpected end of the stream within a double quoted scalar`)}function Bn(e,t,n){let r=e.input.charCodeAt(e.position),i=1,a=-1,o=!1;if(r!==124&&r!==62)return!1;let s=r===124?4:5;for(e.position++;e.input.charCodeAt(e.position)!==0;){let n=e.input.charCodeAt(e.position),r=Dn(n);if(n===43||n===45)i!==1&&A(e,`repeat of a chomping mode identifier`),i=n===43?3:2,e.position++;else if(r>=0)r===0&&A(e,`bad explicit indentation width of a block scalar; it cannot be less than one`),o&&A(e,`repeat of an indentation width identifier`),a=t+r-1,o=!0,e.position++;else break}let c=!1;for(;M(e.input.charCodeAt(e.position));)c=!0,e.position++;c&&e.input.charCodeAt(e.position)===35&&Mn(e),j(e.input.charCodeAt(e.position))?jn(e):e.input.charCodeAt(e.position)!==0&&A(e,`a line break is expected`);let l=o?a:-1,u=0,d=e.position,f=e.position;for(;e.input.charCodeAt(e.position)!==0;){let n=e.position,r=0;for(;e.input.charCodeAt(n+r)===32;)r++;let i=e.input.charCodeAt(n+r);if(i===0){l>=0?r>l&&(f=n+r):r>0&&(f=n+r);break}if(n===e.lineStart&&L(e,n))break;if(!o&&l===-1&&j(i)&&(u=Math.max(u,r)),!o&&l===-1&&!j(i)&&(i===9&&r<t&&(e.position=n+r,A(e,`tab characters must not be used in indentation`)),r<u&&(e.position=n+r,A(e,`bad indentation of a mapping entry`))),l===-1&&i!==0&&!j(i)&&r<t){e.lineIndent=r,e.position=n+r;break}!o&&i!==0&&!j(i)&&l===-1&&(l=r);let a=l===-1?t+1:l;if(i!==0&&!j(i)&&r<a){e.lineIndent=r,e.position=n+r;break}Mn(e),f=e.position,j(e.input.charCodeAt(e.position))&&(jn(e),f=e.position)}return Nn(e,d,f),T(e,d,f,n.anchorStart,n.anchorEnd,n.tagStart,n.tagEnd,s,i,l),!0}function Vn(e,t){let n=e.input.charCodeAt(e.position),r=t===C;if(n===0||N(n)||n===35||n===38||n===42||n===33||n===124||n===62||n===39||n===34||n===37||n===64||n===96||r&&F(n))return!1;if(n===63||n===45){let t=e.input.charCodeAt(e.position+1);if(P(t)||r&&F(t))return!1}return!0}function Hn(e,t,n,r){if(!Vn(e,n))return!1;let i=e.position,a=e.position,o=e.input.charCodeAt(e.position),s=n===C,c=!1;for(;o!==0&&!(e.position===e.lineStart&&L(e));){if(o===58){let t=e.input.charCodeAt(e.position+1);if(P(t)||s&&F(t))break}else if(o===35){if(N(e.input.charCodeAt(e.position-1)))break}else if(s&&F(o))break;else if(j(o)){let n=e.position,r=e.line,i=e.lineStart,a=e.lineIndent;if(I(e,!1),e.lineIndent>=t){c=!0,o=e.input.charCodeAt(e.position);continue}e.position=n,e.line=r,e.lineStart=i,e.lineIndent=a;break}M(o)||(a=e.position+1),o=e.input.charCodeAt(++e.position)}return a===i?!1:(Nn(e,i,a),T(e,i,a,r.anchorStart,r.anchorEnd,r.tagStart,r.tagEnd,1,1,-1,!c),!0)}function R(e,t){let n=e.line;I(e,!0),(e.line>n&&e.lineIndent<t||e.firstTabInLine!==-1&&e.lineIndent<t)&&A(e,`deficient indentation`)}function Un(e,t,n){let r=e.input.charCodeAt(e.position),i=r===123,a=e.position,o=!0;if(r!==91&&r!==123)return!1;let s=i?125:93;for(i?w(e,a,n.anchorStart,n.anchorEnd,n.tagStart,n.tagEnd,2):wn(e,a,n.anchorStart,n.anchorEnd,n.tagStart,n.tagEnd,2),e.position++;e.input.charCodeAt(e.position)!==0;){R(e,t);let n=e.input.charCodeAt(e.position);if(n===s)return e.position++,E(e),!0;o?n===44&&A(e,`expected the node content, but found ','`):A(e,`missed comma between flow collection entries`);let r=!1,a=!1;n===63&&N(e.input.charCodeAt(e.position+1))&&(r=a=!0,e.position+=1,R(e,t));let c=e.line,l=O(e),u=z(e,t,C,!1,!0);R(e,t),n=e.input.charCodeAt(e.position),(i||a||e.line===c)&&n===58?(r=!0,e.position++,R(e,t),i?u||D(e):(k(e,l),w(e,l.position,S,S,S,S,2),z(e,t,C,!1,!0)||D(e),R(e,t),e.position++,R(e,t)),z(e,t,C,!1,!0)||D(e),R(e,t),i||E(e)):i&&r?(u||D(e),D(e)):i?D(e):r&&(k(e,l),w(e,l.position,S,S,S,S,2),z(e,t,C,!1,!0),D(e),E(e)),n=e.input.charCodeAt(e.position),n===44?(o=!0,e.position++):o=!1}A(e,`unexpected end of the stream within a flow collection`)}function Wn(e,t,n){if(e.firstTabInLine!==-1||e.input.charCodeAt(e.position)!==45||!P(e.input.charCodeAt(e.position+1)))return!1;for(wn(e,e.position,n.anchorStart,n.anchorEnd,n.tagStart,n.tagEnd,1);e.input.charCodeAt(e.position)===45&&P(e.input.charCodeAt(e.position+1));){e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,A(e,`tab characters must not be used in indentation`));let n=e.line;e.position++;let r=I(e,!0)>0;if(e.firstTabInLine!==-1&&e.input.charCodeAt(e.position)===45&&P(e.input.charCodeAt(e.position+1))&&A(e,`bad indentation of a sequence entry`),r&&e.lineIndent<=t?D(e):z(e,t,fn,!1,!0),I(e,!0),e.lineIndent<t||e.position>=e.length)break;e.lineIndent>t&&A(e,`bad indentation of a sequence entry`),e.line===n&&e.input.charCodeAt(e.position)===45&&P(e.input.charCodeAt(e.position+1))&&A(e,`bad indentation of a sequence entry`)}return E(e),!0}function Gn(e,t,n,r){let i=!1,a=!1,o=!1,s=!1;if(e.firstTabInLine!==-1)return!1;let c=e.input.charCodeAt(e.position);for(;c!==0;){!i&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,A(e,`tab characters must not be used in indentation`));let l=e.input.charCodeAt(e.position+1),u=e.line;if((c===63||c===58)&&P(l))o||(w(e,e.position,r.anchorStart,r.anchorEnd,r.tagStart,r.tagEnd,1),o=!0),c===63?(i&&D(e),a=!0,i=!0):i?i=!1:(D(e),a=!0,i=!1),e.position+=1,s=!0;else{i&&(D(e),i=!1);let t=O(e);if(!z(e,n,dn,!1,!0))break;if(e.line===u){for(c=e.input.charCodeAt(e.position);M(c);)c=e.input.charCodeAt(++e.position);if(c===58){if(c=e.input.charCodeAt(++e.position),P(c)||A(e,`a whitespace character is expected after the key-value separator within a block mapping`),!o){for(k(e,t),w(e,t.position,r.anchorStart,r.anchorEnd,r.tagStart,r.tagEnd,1),o=!0,z(e,n,dn,!1,!0),c=e.input.charCodeAt(e.position);M(c);)c=e.input.charCodeAt(++e.position);e.position++}a=!0,i=!1,s=!1}else if(a)A(e,`expected ':' after a mapping key`);else return r.anchorStart!==S||r.tagStart!==S?(k(e,t),!1):!0}else if(a)A(e,`can not read a block mapping entry; a multiline key may not be an implicit key`);else return r.anchorStart!==S||r.tagStart!==S?(k(e,t),!1):!0}if(z(e,t,pn,!0,s)&&(s=!1),i||s&&(D(e),s=!1),I(e,!0),c=e.input.charCodeAt(e.position),(e.line===u||e.lineIndent>t)&&c!==0)A(e,`bad indentation of a mapping entry`);else if(e.lineIndent<t)break}return a?(i&&D(e),o&&E(e),!0):!1}function z(e,t,n,r,i,a=!0){e.depth>=e.maxDepth&&A(e,`nesting exceeded maxDepth (${e.maxDepth})`),e.depth++;let o=1,s=!1,c=!1,l=null,u=En(),d=n===pn||n===fn,f=d,p=d;if(r&&I(e,!0)&&(s=!0,o=e.lineIndent>t?1:e.lineIndent===t?0:-1),e.position===e.lineStart&&L(e))return e.depth--,!1;if(o===1)for(;;){let r=e.input.charCodeAt(e.position),i=O(e);if(s&&o!==1&&(r===33||r===38))break;if(s&&p&&(u.tagStart!==S||u.anchorStart!==S)&&(r===33||r===38)){var m;let n=O(e),r=t+1;if(Gn(e,e.position-e.lineStart,r,u)&&((m=e.events[n.eventsLength])==null?void 0:m.type)===3)return e.depth--,!0;k(e,n)}if(s&&(r===33&&u.tagStart!==S||r===38&&u.anchorStart!==S)||!Pn(e,u,n===C)&&!Fn(e,u))break;l===null&&(l=i),I(e,!0)?(s=!0,f=p,o=e.lineIndent>t?1:e.lineIndent===t?0:-1):f=!1}if(f&&(f=s||i),o===1||n===pn){let r=n===C||n===dn?t:t+1,i=e.position-e.lineStart;if(o===1)if(f&&(Wn(e,i,u)||Gn(e,i,r,u))||Un(e,r,u))c=!0;else{let t=e.input.charCodeAt(e.position);if(l!==null&&a&&p&&!f&&t!==124&&t!==62){var h;let t=O(e),n=l.position-l.lineStart;k(e,l),Gn(e,n,r,En())&&((h=e.events[t.eventsLength])==null?void 0:h.type)===3?c=!0:k(e,t)}!c&&(d&&Bn(e,r,u)||Rn(e,r,u)||zn(e,r,u)||In(e,u)||Hn(e,r,n,u))&&(c=!0)}else o===0&&(c=f&&Wn(e,i,u))}return d=d&&!c,!c&&(u.anchorStart!==S||u.tagStart!==S||d)&&(T(e,S,S,u.anchorStart,u.anchorEnd,u.tagStart,u.tagEnd,1),c=!0),e.depth--,c||u.anchorStart!==S||u.tagStart!==S}function Kn(e){if(e.lineIndent>0||e.input.charCodeAt(e.position)!==37)return!1;e.position++;let t=e.position;for(;e.input.charCodeAt(e.position)!==0&&!N(e.input.charCodeAt(e.position));)e.position++;let n=e.input.slice(t,e.position),r=[];for(n.length===0&&A(e,`directive name must not be less than one character in length`);e.input.charCodeAt(e.position)!==0&&!j(e.input.charCodeAt(e.position));){for(;M(e.input.charCodeAt(e.position));)e.position++;if(e.input.charCodeAt(e.position)===35||j(e.input.charCodeAt(e.position))||e.input.charCodeAt(e.position)===0)break;let t=e.position;for(;e.input.charCodeAt(e.position)!==0&&!N(e.input.charCodeAt(e.position));)e.position++;r.push(e.input.slice(t,e.position))}if(j(e.input.charCodeAt(e.position))&&jn(e),n===`YAML`){e.directives.some(e=>e.kind===`yaml`)&&A(e,`duplication of %YAML directive`),r.length!==1&&A(e,`YAML directive accepts exactly one argument`);let t=/^([0-9]+)\.([0-9]+)$/.exec(r[0]);t===null&&A(e,`ill-formed argument of the YAML directive`),parseInt(t[1],10)!==1&&A(e,`unacceptable YAML version of the document`),e.directives.push({kind:`yaml`,version:r[0]})}else if(n===`TAG`){r.length!==2&&A(e,`TAG directive accepts exactly two arguments`);let[t,n]=r;gn.test(t)||A(e,`ill-formed tag handle (first argument) of the TAG directive`),un.call(e.tagHandlers,t)&&A(e,`there is a previously declared suffix for "${t}" tag handle`),xn.test(n)||A(e,`ill-formed tag prefix (second argument) of the TAG directive`),e.tagHandlers[t]=n,e.directives.push({kind:`tag`,handle:t,prefix:n})}return!0}function qn(e){e.directives=[],e.tagHandlers=Object.create(null);let t=!1;for(I(e,!0);Kn(e);)t=!0,I(e,!0);let n=!1,r=!1,i=!0;if(e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45&&P(e.input.charCodeAt(e.position+3))){n=!0;let t=e.line;e.position+=3,I(e,!0),i=e.line>t}else t&&A(e,`directives end mark is expected`);let a=e.events.length;if(!n&&e.position===e.lineStart&&e.input.charCodeAt(e.position)===46&&L(e)){e.position+=3,I(e,!0);return}if(Cn(e,n,!1),z(e,e.lineIndent-1,pn,!1,i,i)||D(e),I(e,!0),e.position===e.lineStart&&L(e)&&(r=e.input.charCodeAt(e.position)===46,r)){let t=e.line;e.position+=3,I(e,!0),e.line===t&&e.position<e.length&&A(e,`end of the stream or a document separator is expected`)}let o=e.events[a];(o==null?void 0:o.type)===1&&(o.explicitEnd=r),E(e),!r&&e.position<e.length&&!(e.position===e.lineStart&&L(e))&&A(e,`end of the stream or a document separator is expected`)}function Jn(e,t){let n=e.length,r=v(v(v({},Sn),t),{},{input:`${e}\0`,length:n,position:0,line:0,lineStart:0,lineIndent:0,firstTabInLine:-1,depth:0,directives:[],tagHandlers:Object.create(null),events:[]}),i=e.indexOf(`\0`);for(i!==-1&&ht(e,i,`null byte is not allowed in input`,r.filename),r.input.charCodeAt(r.position)===65279&&r.position++;r.position<r.length&&(I(r,!0),!(r.position>=r.length));){let e=r.position;qn(r),r.position===e&&A(r,`can not read a document`)}return r.events}var Yn=v(v({},Sn),Xt);function Xn(e,t={}){let n=v(v({},Yn),t),r=String(e),i=Object.keys(Sn),a=Object.keys(Xt);return ln(Jn(r,qe(n,i)),v(v({},qe(n,a)),{},{source:r}))}function Zn(e,t,n){let r=null;typeof t==`function`?r=t:typeof t==`object`&&t&&(n=t);let i=Xn(e,n);if(r===null)return i;for(let e of i)r(e)}function Qn(e,t){let n=Xn(e,t);if(n.length===0)throw new y(`expected a document, but the input is empty`);if(n.length===1)return n[0];throw new y(`expected a single document in the stream, but found more`)}var B=class{constructor(){g(this,`tagged`,!1),g(this,`flow`,!1),g(this,`singleQuoted`,!1),g(this,`doubleQuoted`,!1),g(this,`literal`,!1),g(this,`folded`,!1)}},V=Symbol(`INVALID`);function $n(e){let t=new Set([e.defaultScalarTag,e.defaultSequenceTag,e.defaultMappingTag].filter(e=>e!==void 0)),n=e.implicitScalarTags,r=e.tags.filter(e=>!(e.nodeKind===`scalar`&&e.implicit)&&!t.has(e)),i=e.tags.filter(e=>t.has(e));return[...n.map(e=>({tag:e,implicitTag:!0})),...r.map(e=>({tag:e,implicitTag:!1})),...i.map(e=>({tag:e,implicitTag:!0}))]}function er(e,t){for(let n=0,r=e.representTypes.length;n<r;n+=1){let{tag:r,implicitTag:i}=e.representTypes[n];if(r.identify&&r.identify(t)){let e;return e=r.matchByTagPrefix&&r.representTagName?r.representTagName(t):r.tagName,{tag:r,tagName:e,implicitTag:i}}}return null}function H(e,t){if(!e.noRefs&&typeof t==`object`&&t){let n=e.refs.get(t);if(n)return n.anchor===void 0&&(n.anchor=`ref_${e.refCounter++}`),{kind:`alias`,tag:``,style:new B,anchor:n.anchor}}let n=er(e,t);if(!n){if(t===void 0||e.skipInvalid)return V;throw new y(`unacceptable kind of an object to dump ${Object.prototype.toString.call(t)}`)}let{tag:r,tagName:i,implicitTag:a}=n,o=a?i:Yt(i);if(r.nodeKind===`scalar`){let e=new B;return e.tagged=!a,{kind:`scalar`,tag:o,style:e,value:r.represent(t)}}if(r.nodeKind===`sequence`){let n=r.represent(t),i=new B;i.tagged=!a;let s={kind:`sequence`,tag:o,style:i,items:[]};e.noRefs||e.refs.set(t,s);for(let t=0,r=n.length;t<r;t+=1){let r=H(e,n[t]);r===V&&n[t]===void 0&&(r=H(e,null)),r!==V&&s.items.push(r)}return s}let s=r.represent(t),c=new B;c.tagged=!a;let l={kind:`mapping`,tag:o,style:c,items:[]};e.noRefs||e.refs.set(t,l);for(let[t,n]of s){let r=H(e,t);if(r===V)continue;let i=H(e,n);i!==V&&l.items.push({key:r,value:i})}return l}function tr(e,t,n={}){var r,i;let a=H({representTypes:$n(t),noRefs:(r=n.noRefs)==null?!1:r,skipInvalid:(i=n.skipInvalid)==null?!1:i,refs:new Map,refCounter:0},e);return[{contents:a===V?null:a,directives:[]}]}var nr=Symbol(`visit:break`),rr=Symbol(`visit:skip`);function ir(e,t,n){let r=t(e,n);if(r===nr)return!0;if(r===rr)return!1;let i=n.depth+1;switch(e.kind){case`sequence`:for(let n of e.items)if(ir(n,t,{depth:i,parent:e,isKey:!1}))return!0;break;case`mapping`:for(let{key:n,value:r}of e.items)if(ir(n,t,{depth:i,parent:e,isKey:!0})||ir(r,t,{depth:i,parent:e,isKey:!1}))return!0;break}return!1}function ar(e,t){for(let n of e)if(n.contents&&ir(n.contents,t,{depth:0,parent:null,isKey:!1}))return}var or=65279,sr=9,U=10,cr=13,lr=32,ur=33,dr=34,fr=35,pr=37,mr=38,hr=39,gr=42,_r=44,vr=45,W=58,yr=61,br=62,xr=63,Sr=64,Cr=91,wr=93,Tr=96,Er=123,Dr=124,Or=125,G={};G[0]=`\\0`,G[7]=`\\a`,G[8]=`\\b`,G[9]=`\\t`,G[10]=`\\n`,G[11]=`\\v`,G[12]=`\\f`,G[13]=`\\r`,G[27]=`\\e`,G[34]=`\\"`,G[92]=`\\\\`,G[133]=`\\N`,G[160]=`\\_`,G[8232]=`\\L`,G[8233]=`\\P`;var kr={indent:2,seqNoIndent:!1,seqInlineFirst:!0,sortKeys:!1,lineWidth:80,flowBracketPadding:!1,flowSkipCommaSpace:!1,flowSkipColonSpace:!1,quoteFlowKeys:!1,quoteStyle:`auto`,tagBeforeAnchor:!1};function Ar(e){return e.style.tagged?e.tag:Yt(e.tag)}function jr(e){let t=v(v({},kr),e);return v(v({},t),{},{defaultScalarTagName:t.schema.defaultScalarTag.tagName,implicitResolvers:t.schema.implicitScalarTags})}function Mr(e){let t=e.toString(16).toUpperCase(),n=e<=255?`x`:`u`,r=e<=255?2:4;return`\\${n}${`0`.repeat(r-t.length)}${t}`}function Nr(e,t){let n=` `.repeat(t),r=0,i=``,a=e.length;for(;r<a;){let t,o=e.indexOf(` | ||
| `,r);o===-1?(t=e.slice(r),r=a):(t=e.slice(r,o+1),r=o+1),t.length&&t!==` | ||
| `&&(i+=n),i+=t}return i}function Pr(e,t){return`\n${` `.repeat(e.indent*t)}`}function Fr(e,t){let n=e.indent*Math.max(1,t);return{indent:n,blockIndent:t===0?e.indent+1:e.indent,lineWidth:e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-n)}}function Ir(e,n){for(let r=0,i=e.implicitResolvers.length;r<i;r+=1){let i=e.implicitResolvers[r];if(i.resolve(n,!1,i.tagName)!==t)return i.tagName}return e.defaultScalarTagName}function K(e){return e===lr||e===sr}function Lr(e){let t=e.charCodeAt(0);if(t!==vr&&t!==46||e.charCodeAt(1)!==t||e.charCodeAt(2)!==t)return!1;if(e.length===3)return!0;let n=e.charCodeAt(3);return K(n)||n===cr||n===U}function q(e){return e>=32&&e<=126||e>=161&&e<=55295&&e!==8232&&e!==8233||e>=57344&&e<=65533&&e!==or||e>=65536&&e<=1114111}function Rr(e){return q(e)&&e!==or&&e!==cr&&e!==U}function zr(e,t,n){let r=Rr(e),i=r&&!K(e);return(n?r:r&&e!==_r&&e!==Cr&&e!==wr&&e!==Er&&e!==Or)&&e!==fr&&!(t===W&&!i)||Rr(t)&&!K(t)&&e===fr||t===W&&i}function Br(e){return q(e)&&e!==or&&!K(e)&&e!==vr&&e!==xr&&e!==W&&e!==_r&&e!==Cr&&e!==wr&&e!==Er&&e!==Or&&e!==fr&&e!==mr&&e!==gr&&e!==ur&&e!==Dr&&e!==yr&&e!==br&&e!==hr&&e!==dr&&e!==pr&&e!==Sr&&e!==Tr}function Vr(e,t){let n=J(e,0);if(Br(n))return!0;if(e.length>1&&(n===vr||n===xr||n===W)){let r=J(e,1);return!K(r)&&zr(r,n,t)}return!1}function Hr(e){return!K(e)&&e!==W}function J(e,t){let n=e.charCodeAt(t),r;return n>=55296&&n<=56319&&t+1<e.length&&(r=e.charCodeAt(t+1),r>=56320&&r<=57343)?(n-55296)*1024+r-56320+65536:n}function Ur(e){return/^\n* /.test(e)}var Y=1,X=2,Wr=3,Gr=4,Z=5;function Kr(e,t,n,r,i){let{blockIndent:a,lineWidth:o}=n,s=e.quoteStyle!==`auto`,c,l=0,u=-1,d=!1,f=!1,p=o!==-1,m=-1,h=!Lr(t)&&Vr(t,i)&&Hr(J(t,t.length-1));if(r||s)for(c=0;c<t.length;l>=65536?c+=2:c++){if(l=J(t,c),!q(l))return Z;h=h&&zr(l,u,i),u=l}else{for(c=0;c<t.length;l>=65536?c+=2:c++){if(l=J(t,c),l===U)d=!0,p&&(f=f||c-m-1>o&&t[m+1]!==` `,m=c);else if(!q(l))return Z;h=h&&zr(l,u,i),u=l}f=f||p&&c-m-1>o&&t[m+1]!==` `}return!d&&!f?h&&!s?Y:e.quoteStyle===`double`?Z:X:a>9&&Ur(t)?Z:f?Gr:Wr}function qr(e,t,n){let{indent:r,blockIndent:i,lineWidth:a}=n;switch(t){case Y:return Xr(e,r);case X:return`'${Xr(e,r).replace(/'/g,`''`)}'`;case Wr:return`|`+Yr(e,i)+Zr(Nr(e,r));case Gr:return`>`+Yr(e,i)+Zr(Nr(Qr(e,a),r));case Z:return`"${ei(e)}"`}}function Jr(e,t,n,r,i){let a=r||!i;if(t.style.singleQuoted)return X;if(t.style.doubleQuoted)return Z;if(!a){if(t.style.literal)return Wr;if(t.style.folded)return Gr}let o=t.value;if(o.length===0)return e.quoteStyle===`auto`&&(t.style.tagged||Ir(e,o)===t.tag)?Y:e.quoteStyle===`double`?Z:X;let s=Kr(e,o,n,a,i);return s===Y&&!t.style.tagged&&Ir(e,o)!==t.tag?X:s}function Yr(e,t){let n=Ur(e)?String(t):``,r=e[e.length-1]===` | ||
| `;return`${n}${r&&(e[e.length-2]===` | ||
| `||e===` | ||
| `)?`+`:r?``:`-`}\n`}function Xr(e,t){let n=e.indexOf(` | ||
| `);if(n===-1)return e;let r=` `.repeat(t),i=e.slice(0,n),a=/(\n+)([^\n]*)/g;a.lastIndex=n;let o;for(;o=a.exec(e);){let e=o[1].length,t=o[2];i+=` | ||
| `.repeat(e+1)+r+t}return i}function Zr(e){return e[e.length-1]===` | ||
| `?e.slice(0,-1):e}function Qr(e,t){let n=/(\n+)([^\n]*)/g,r=e.indexOf(` | ||
| `);r===-1&&(r=e.length),n.lastIndex=r;let i=$r(e.slice(0,r),t),a=e[0]===` | ||
| `||e[0]===` `,o,s;for(;s=n.exec(e);){let e=s[1],n=s[2];o=n[0]===` `,i+=e+(!a&&!o&&n!==``?` | ||
| `:``)+$r(n,t),a=o}return i}function $r(e,t){if(e===``||e[0]===` `)return e;let n=/ [^ ]/g,r,i=0,a,o=0,s=0,c=``;for(;r=n.exec(e);)s=r.index,s-i>t&&(a=o>i?o:s,c+=`\n${e.slice(i,a)}`,i=a+1),o=s;return c+=` | ||
| `,e.length-i>t&&o>i?c+=`${e.slice(i,o)}\n${e.slice(o+1)}`:c+=e.slice(i),c.slice(1)}function ei(e){let t=``,n=0;for(let r=0;r<e.length;n>=65536?r+=2:r++){n=J(e,r);let i=G[n];if(i){t+=i;continue}if(q(n)){t+=e[r],n>=65536&&(t+=e[r+1]);continue}t+=Mr(n)}return t}function ti(e,t,n){let r=``;for(let i=0,a=n.items.length;i<a;i+=1){let a=Q(e,t,n.items[i],{});r!==``&&(r+=`,${e.flowSkipCommaSpace?``:` `}`),r+=a}let i=e.flowBracketPadding&&r!==``?` `:``;return`[${i}${r}${i}]`}function ni(e,t,n,r){let i=``;for(let a=0,o=n.items.length;a<o;a+=1){let o=Q(e,t+1,n.items[a],{block:!0,compact:e.seqInlineFirst,isblockseq:!0});(!r||i!==``)&&(i+=Pr(e,t)),o===``||U===o.charCodeAt(0)?i+=`-`:i+=`- `,i+=o}return i}function ri(e,t,n){let r=``,i=ai(e,n.items);for(let{key:n,value:a}of i){let i=``;r!==``&&(i+=`,${e.flowSkipCommaSpace?``:` `}`);let o=Q(e,t,n,{}),s=o.length>1024;s?i+=`? `:e.quoteFlowKeys&&(i+=`"`);let c=Q(e,t,a,{}),l=e.flowSkipColonSpace||c===``?``:` `;i+=`${o}${e.quoteFlowKeys&&!s?`"`:``}:${l}${c}`,r+=i}let a=e.flowBracketPadding&&r!==``?` `:``;return`{${a}${r}${a}}`}function ii(e){return e.kind===`scalar`?e.value:e}function ai(e,t){if(!e.sortKeys)return t;let n=t.slice();if(e.sortKeys===!0)n.sort((e,t)=>{let n=ii(e.key),r=ii(t.key);return n<r?-1:+(n>r)});else{let t=e.sortKeys;n.sort((e,n)=>t(ii(e.key),ii(n.key)))}return n}function oi(e,t,n,r){let i=``,a=ai(e,n.items);for(let n=0,o=a.length;n<o;n+=1){let o=``;(!r||i!==``)&&(o+=Pr(e,t));let{key:s,value:c}=a[n],l=(s.kind===`mapping`||s.kind===`sequence`)&&!s.style.flow&&s.items.length!==0||s.kind===`scalar`&&(s.style.literal||s.style.folded),u=l?Q(e,t+1,s,{block:!0,compact:!0,isblockseq:!si(e,s,t+1)}):Q(e,t+1,s,{block:!0,compact:!0,iskey:!0}),d=s.kind===`scalar`&&s.value.indexOf(` | ||
| `)!==-1,f=l||d||u.length>1024;f&&(u&&U===u.charCodeAt(0)?o+=`?`:o+=`? `),o+=u,f&&(o+=Pr(e,t));let p=Q(e,t+1,c,{block:!0,compact:f,isblockseq:f&&!si(e,c,t+1)}),m=s.kind===`scalar`&&s.value===``&&u!==``&&u.charCodeAt(u.length-1)!==hr&&u.charCodeAt(u.length-1)!==dr,h=!f&&(s.kind===`alias`||m)?` `:``;p===``||U===p.charCodeAt(0)?o+=`${h}:`:o+=`${h}: `,o+=p,i+=o}return i}function si(e,t,n){return t.style.tagged||t.anchor!==void 0||e.indent<2&&n>0}function Q(e,t,n,r){var i;if(n.kind===`alias`)return`*${n.anchor}`;let{block:a=!1,iskey:o=!1,isblockseq:s=!1}=r,c=(i=r.compact)==null?!1:i,l=n.anchor!==void 0;si(e,n,t)&&(c=!1);let u,d=n.style.tagged,f=a&&(n.kind===`mapping`||n.kind===`sequence`)&&!n.style.flow&&n.items.length!==0;if(n.kind===`mapping`)u=f?oi(e,t,n,c):ri(e,t,n);else if(n.kind===`sequence`)u=f?e.seqNoIndent&&!s&&t>0?ni(e,t-1,n,c):ni(e,t,n,c):ti(e,t,n);else{let r=Fr(e,t),i=Jr(e,n,r,o,a);u=qr(n.value,i,r),d=n.style.tagged||i!==Y&&n.tag!==e.defaultScalarTagName}if(f&&c&&t>0&&e.indent>2&&(u=`${` `.repeat(e.indent-2)}${u}`),d||l){let t=[],r=d?Ar(n):null,i=l?`&${n.anchor}`:null;e.tagBeforeAnchor?(r!==null&&t.push(r),i!==null&&t.push(i)):(i!==null&&t.push(i),r!==null&&t.push(r));let a=u===``||u.charCodeAt(0)===U?``:` `;u=`${t.join(` `)}${a}${u}`}return u}function ci(e){return(e.kind===`sequence`||e.kind===`mapping`)&&!e.style.flow&&e.items.length!==0&&!e.style.tagged&&e.anchor===void 0}function li(e){let t=e;for(;(t.kind===`sequence`||t.kind===`mapping`)&&!t.style.flow&&t.items.length!==0;)t=t.kind===`sequence`?t.items[t.items.length-1]:t.items[t.items.length-1].value;if(t.kind!==`scalar`||!(t.style.literal||t.style.folded))return!1;let{value:n}=t;return n.endsWith(` | ||
| `)||n===` | ||
| `}function ui(e){let t=``;for(let n of e.directives){if(n.kind===`yaml`){t+=`%YAML ${n.version}\n`;continue}let{handle:e,prefix:r}=n;t+=`%TAG ${e} ${r}\n`}return t}function di(e,t){let n=jr(t),r=``,i=!1;for(let t=0;t<e.length;t+=1){let a=e[t],o=ui(a),s=o!==``,c=a.explicitStart||s||t>0&&!i;if(r+=o,a.contents===null)c&&(r+=`--- | ||
| `);else if(c){let e=Q(n,0,a.contents,{block:!0,compact:!0}),t=e===``?``:s||ci(a.contents)?` | ||
| `:` `;r+=`---${t}${e}\n`}else r+=Q(n,0,a.contents,{block:!0,compact:!0})+` | ||
| `;i=a.explicitEnd||a.contents!==null&&li(a.contents),i&&(r+=`... | ||
| `)}return r}var fi=at.withTags(v(v({},ve),{},{resolve:(e,n,r)=>{let i=ve.resolve(e,n,r);return i===t?le.resolve(e,n,r):i}}),v(v({},Ne),{},{resolve:(e,n,r)=>{let i=Ne.resolve(e,n,r);return i===t?Ce.resolve(e,n,r):i}})),pi=v(v({},kr),{},{schema:fi,skipInvalid:!1,noRefs:!1,flowLevel:-1,transform:()=>{}});function mi(e,t={}){let n=v(v({},pi),t),r=tr(e,n.schema,{noRefs:n.noRefs,skipInvalid:n.skipInvalid});return n.flowLevel>=0&&ar(r,(e,t)=>{if(!(t.depth<n.flowLevel))return e.style.flow=!0,rr}),n.transform(r),di(r,v(v({},qe(n,Object.keys(kr))),{},{schema:n.schema}))}var $=-1;function hi(e){return`tagStart`in e&&e.tagStart!==$?e.tagStart:`anchorStart`in e&&e.anchorStart!==$?e.anchorStart:`valueStart`in e&&e.valueStart!==$?e.valueStart:`start`in e?e.start:0}function gi(e,t){return t.tagStart===$?``:e.source.slice(t.tagStart,t.tagEnd)}function _i(e,t){return t.anchorStart===$?void 0:e.source.slice(t.anchorStart,t.anchorEnd)}function vi(e,n){var r;let{schema:i}=e,a=(r=i.implicitScalarByFirstChar.get(n.charAt(0)))==null?i.implicitScalarAnyFirstChar:r;for(let e of a)if(e.resolve(n,!1,e.tagName)!==t)return e.tagName;return i.defaultScalarTag.tagName}function yi(e,t){let n=Gt(e.source,t),r=gi(e,t),i=new B;switch(t.style){case 2:i.singleQuoted=!0;break;case 3:i.doubleQuoted=!0;break;case 4:i.literal=!0;break;case 5:i.folded=!0;break}let a;return r===``?a=t.style===1?vi(e,n):e.schema.defaultScalarTag.tagName:(i.tagged=!0,a=r),{kind:`scalar`,tag:a,style:i,anchor:_i(e,t),value:n}}function bi(e,t,n){let r=gi(e,t),i=new B;t.style===2&&(i.flow=!0);let a;return r===``?a=n:(a=r,i.tagged=!0),{tag:a,style:i,anchor:_i(e,t)}}function xi(e,t){let n=e.frames[e.frames.length-1];n.kind===`document`?n.doc.contents=t:n.kind===`sequence`?n.node.items.push(t):n.key?(n.node.items.push({key:n.key,value:t}),n.key=null):n.key=t}function Si(e,t){let n={source:t.source,schema:t.schema,eventIndex:0,position:0,frames:[],documents:[]};for(;n.eventIndex<e.length;){let t=e[n.eventIndex++];switch(n.position=hi(t),t.type){case 1:{let e={contents:null,explicitStart:t.explicitStart,explicitEnd:t.explicitEnd,directives:t.directives};n.frames.push({kind:`document`,doc:e});break}case 4:xi(n,yi(n,t));break;case 2:{let{tag:e,style:r,anchor:i}=bi(n,t,`tag:yaml.org,2002:seq`),a={kind:`sequence`,tag:e,style:r,anchor:i,items:[]};n.frames.push({kind:`sequence`,node:a});break}case 3:{let{tag:e,style:r,anchor:i}=bi(n,t,`tag:yaml.org,2002:map`),a={kind:`mapping`,tag:e,style:r,anchor:i,items:[]};n.frames.push({kind:`mapping`,node:a,key:null});break}case 5:{let e=n.source.slice(t.anchorStart,t.anchorEnd);xi(n,{kind:`alias`,tag:``,style:new B,anchor:e});break}case 6:{let e=n.frames.pop();e.kind===`document`?n.documents.push(e.doc):xi(n,e.node);break}}}return n.documents}e.CHOMPING_CLIP=kt,e.CHOMPING_KEEP=jt,e.CHOMPING_STRIP=At,e.COLLECTION_STYLE_BLOCK=Dt,e.COLLECTION_STYLE_FLOW=Ot,e.CORE_SCHEMA=it,e.EVENT_ALIAS=bt,e.EVENT_DOCUMENT=gt,e.EVENT_MAPPING=vt,e.EVENT_POP=xt,e.EVENT_SCALAR=yt,e.EVENT_SEQUENCE=_t,e.FAILSAFE_SCHEMA=nt,e.JSON_SCHEMA=rt,e.MERGE_KEY=n,e.NOT_RESOLVED=t,e.SCALAR_STYLE_DOUBLE_QUOTED=wt,e.SCALAR_STYLE_FOLDED_BLOCK=Et,e.SCALAR_STYLE_LITERAL_BLOCK=Tt,e.SCALAR_STYLE_PLAIN=St,e.SCALAR_STYLE_SINGLE_QUOTED=Ct,e.Schema=_,e.Style=B,e.VISIT_BREAK=nr,e.VISIT_SKIP=rr,e.YAML11_SCHEMA=at,e.YAMLException=y,e.binaryTag=Re,e.boolCoreTag=m,e.boolJsonTag=te,e.boolYaml11Tag=ie,e.constructFromEvents=ln,e.defineMappingTag=a,e.defineScalarTag=r,e.defineSequenceTag=i,e.dump=mi,e.eventsToAst=Si,e.floatCoreTag=Ce,e.floatJsonTag=Oe,e.floatYaml11Tag=Ne,e.getScalarValue=Gt,e.intCoreTag=le,e.intJsonTag=me,e.intYaml11Tag=ve,e.jsToAst=tr,e.legacyMapTag=ct,e.load=Qn,e.loadAll=Zn,e.mapTag=Je,e.mergeTag=Pe,e.nullCoreTag=c,e.nullJsonTag=l,e.nullYaml11Tag=d,e.omapTag=We,e.pairsTag=Ge,e.parseEvents=Jn,e.present=di,e.realMapTag=ot,e.seqTag=Ue,e.setTag=Ye,e.strTag=o,e.timestampTag=He,e.visit=ar}); | ||
| //# sourceMappingURL=js-yaml.umd.min.js.map |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
| declare const NOT_RESOLVED: unique symbol; | ||
| declare const MERGE_KEY: unique symbol; | ||
| type ScalarRepresent = (data: any) => string; | ||
| type SequenceRepresent = (data: any) => ArrayLike<unknown>; | ||
| type MappingRepresent = (data: any) => Map<unknown, unknown>; | ||
| type IdentifyFn = (data: any) => boolean; | ||
| type RepresentTagNameFn = (data: any) => string; | ||
| interface ScalarTagDefinition<Result = unknown> { | ||
| tagName: string; | ||
| nodeKind: 'scalar'; | ||
| implicit: boolean; | ||
| matchByTagPrefix: boolean; | ||
| implicitFirstChars: readonly string[] | null; | ||
| resolve: (source: string, isExplicit: boolean, tagName: string) => Result | typeof NOT_RESOLVED; | ||
| identify: IdentifyFn | null; | ||
| represent: ScalarRepresent; | ||
| representTagName: RepresentTagNameFn | null; | ||
| } | ||
| interface SequenceTagDefinition<Container = unknown> { | ||
| tagName: string; | ||
| nodeKind: 'sequence'; | ||
| implicit: false; | ||
| matchByTagPrefix: boolean; | ||
| create: (tagName: string) => Container; | ||
| addItem: (container: Container, item: unknown, index: number) => void | string; | ||
| identify: IdentifyFn | null; | ||
| represent: SequenceRepresent; | ||
| representTagName: RepresentTagNameFn | null; | ||
| } | ||
| interface MappingTagDefinition<Container = unknown> { | ||
| tagName: string; | ||
| nodeKind: 'mapping'; | ||
| implicit: false; | ||
| matchByTagPrefix: boolean; | ||
| create: (tagName: string) => Container; | ||
| addPair: (container: Container, key: unknown, value: unknown) => string; | ||
| has: (container: Container, key: unknown) => boolean; | ||
| keys: (container: Container) => Iterable<unknown>; | ||
| get: (container: Container, key: unknown) => unknown; | ||
| identify: IdentifyFn | null; | ||
| represent: MappingRepresent; | ||
| representTagName: RepresentTagNameFn | null; | ||
| } | ||
| type TagDefinition = ScalarTagDefinition<any> | SequenceTagDefinition<any> | MappingTagDefinition<any>; | ||
| interface ScalarTagOptions<Result> { | ||
| implicit?: boolean; | ||
| matchByTagPrefix?: boolean; | ||
| implicitFirstChars?: readonly string[] | null; | ||
| resolve: ScalarTagDefinition<Result>['resolve']; | ||
| identify?: ScalarTagDefinition<Result>['identify']; | ||
| represent?: ScalarTagDefinition<Result>['represent']; | ||
| representTagName?: ScalarTagDefinition<Result>['representTagName']; | ||
| } | ||
| type RepresentOptions<Container, Canonical, Represent> = { | ||
| identify?: null; | ||
| represent?: Represent; | ||
| representTagName?: RepresentTagNameFn | null; | ||
| } | (Container extends Canonical ? { | ||
| identify?: IdentifyFn | null; | ||
| represent?: Represent; | ||
| representTagName?: RepresentTagNameFn | null; | ||
| } : { | ||
| identify: IdentifyFn; | ||
| represent: Represent; | ||
| representTagName?: RepresentTagNameFn | null; | ||
| }); | ||
| type SequenceTagOptions<Container> = { | ||
| matchByTagPrefix?: boolean; | ||
| create: SequenceTagDefinition<Container>['create']; | ||
| addItem: SequenceTagDefinition<Container>['addItem']; | ||
| } & RepresentOptions<Container, ArrayLike<unknown>, SequenceRepresent>; | ||
| type MappingTagOptions<Container> = { | ||
| matchByTagPrefix?: boolean; | ||
| create: MappingTagDefinition<Container>['create']; | ||
| addPair: MappingTagDefinition<Container>['addPair']; | ||
| has: MappingTagDefinition<Container>['has']; | ||
| keys: MappingTagDefinition<Container>['keys']; | ||
| get: MappingTagDefinition<Container>['get']; | ||
| } & RepresentOptions<Container, Map<unknown, unknown>, MappingRepresent>; | ||
| declare function defineScalarTag<Result>(tagName: string, options: ScalarTagOptions<Result>): ScalarTagDefinition<Result>; | ||
| declare function defineSequenceTag<Container>(tagName: string, options: SequenceTagOptions<Container>): SequenceTagDefinition<Container>; | ||
| declare function defineMappingTag<Container>(tagName: string, options: MappingTagOptions<Container>): MappingTagDefinition<Container>; | ||
| interface TagDefinitionMap { | ||
| scalar: Record<string, ScalarTagDefinition>; | ||
| sequence: Record<string, SequenceTagDefinition>; | ||
| mapping: Record<string, MappingTagDefinition>; | ||
| } | ||
| interface TagDefinitionListMap { | ||
| scalar: ScalarTagDefinition[]; | ||
| sequence: SequenceTagDefinition[]; | ||
| mapping: MappingTagDefinition[]; | ||
| } | ||
| declare class Schema { | ||
| readonly tags: readonly TagDefinition[]; | ||
| readonly implicitScalarTags: readonly ScalarTagDefinition[]; | ||
| readonly implicitScalarByFirstChar: ReadonlyMap<string, readonly ScalarTagDefinition[]>; | ||
| readonly implicitScalarAnyFirstChar: readonly ScalarTagDefinition[]; | ||
| readonly defaultScalarTag: ScalarTagDefinition; | ||
| readonly defaultSequenceTag: SequenceTagDefinition | undefined; | ||
| readonly defaultMappingTag: MappingTagDefinition | undefined; | ||
| readonly exact: TagDefinitionMap; | ||
| readonly prefix: TagDefinitionListMap; | ||
| constructor(tags: readonly TagDefinition[]); | ||
| withTags(...tags: Array<TagDefinition | readonly TagDefinition[]>): Schema; | ||
| } | ||
| declare const FAILSAFE_SCHEMA: Schema; | ||
| declare const JSON_SCHEMA: Schema; | ||
| declare const CORE_SCHEMA: Schema; | ||
| declare const YAML11_SCHEMA: Schema; | ||
| declare const strTag: ScalarTagDefinition<string>; | ||
| declare const nullCoreTag: ScalarTagDefinition<null>; | ||
| declare const nullJsonTag: ScalarTagDefinition<null>; | ||
| declare const nullYaml11Tag: ScalarTagDefinition<null>; | ||
| declare const boolCoreTag: ScalarTagDefinition<boolean>; | ||
| declare const boolJsonTag: ScalarTagDefinition<boolean>; | ||
| declare const boolYaml11Tag: ScalarTagDefinition<boolean>; | ||
| declare const intCoreTag: ScalarTagDefinition<number>; | ||
| declare const intJsonTag: ScalarTagDefinition<number>; | ||
| declare const intYaml11Tag: ScalarTagDefinition<number>; | ||
| declare const floatCoreTag: ScalarTagDefinition<number>; | ||
| declare const floatJsonTag: ScalarTagDefinition<number>; | ||
| declare const floatYaml11Tag: ScalarTagDefinition<number>; | ||
| declare const mergeTag: ScalarTagDefinition<typeof MERGE_KEY>; | ||
| declare const binaryTag: ScalarTagDefinition<Uint8Array<ArrayBuffer>>; | ||
| declare const timestampTag: ScalarTagDefinition<Date>; | ||
| declare const seqTag: SequenceTagDefinition<unknown[]>; | ||
| type OmapItem = Record<string, unknown>; | ||
| declare const omapTag: SequenceTagDefinition<OmapItem[]>; | ||
| type Pair = [unknown, unknown]; | ||
| declare const pairsTag: SequenceTagDefinition<Pair[]>; | ||
| type StringMapping$1 = Record<string, unknown>; | ||
| declare const mapTag: MappingTagDefinition<StringMapping$1>; | ||
| type RealMapping = Map<unknown, unknown>; | ||
| declare const realMapTag: MappingTagDefinition<RealMapping>; | ||
| type StringMapping = Record<string, unknown>; | ||
| declare const legacyMapTag: MappingTagDefinition<StringMapping>; | ||
| declare const setTag: MappingTagDefinition<Set<unknown>>; | ||
| declare const EVENT_DOCUMENT = 1; | ||
| declare const EVENT_SEQUENCE = 2; | ||
| declare const EVENT_MAPPING = 3; | ||
| declare const EVENT_SCALAR = 4; | ||
| declare const EVENT_ALIAS = 5; | ||
| declare const EVENT_POP = 6; | ||
| declare const SCALAR_STYLE_PLAIN = 1; | ||
| declare const SCALAR_STYLE_SINGLE_QUOTED = 2; | ||
| declare const SCALAR_STYLE_DOUBLE_QUOTED = 3; | ||
| declare const SCALAR_STYLE_LITERAL_BLOCK = 4; | ||
| declare const SCALAR_STYLE_FOLDED_BLOCK = 5; | ||
| type ScalarStyle = typeof SCALAR_STYLE_PLAIN | typeof SCALAR_STYLE_SINGLE_QUOTED | typeof SCALAR_STYLE_DOUBLE_QUOTED | typeof SCALAR_STYLE_LITERAL_BLOCK | typeof SCALAR_STYLE_FOLDED_BLOCK; | ||
| declare const COLLECTION_STYLE_BLOCK = 1; | ||
| declare const COLLECTION_STYLE_FLOW = 2; | ||
| type CollectionStyle = typeof COLLECTION_STYLE_BLOCK | typeof COLLECTION_STYLE_FLOW; | ||
| declare const CHOMPING_CLIP = 1; | ||
| declare const CHOMPING_STRIP = 2; | ||
| declare const CHOMPING_KEEP = 3; | ||
| type Chomping = typeof CHOMPING_CLIP | typeof CHOMPING_STRIP | typeof CHOMPING_KEEP; | ||
| type DocumentDirective = { | ||
| kind: 'yaml'; | ||
| version: string; | ||
| } | { | ||
| kind: 'tag'; | ||
| handle: string; | ||
| prefix: string; | ||
| }; | ||
| interface DocumentEvent { | ||
| type: typeof EVENT_DOCUMENT; | ||
| explicitStart: boolean; | ||
| explicitEnd: boolean; | ||
| directives: DocumentDirective[]; | ||
| } | ||
| interface SequenceEvent { | ||
| type: typeof EVENT_SEQUENCE; | ||
| start: number; | ||
| anchorStart: number; | ||
| anchorEnd: number; | ||
| tagStart: number; | ||
| tagEnd: number; | ||
| style: CollectionStyle; | ||
| } | ||
| interface MappingEvent { | ||
| type: typeof EVENT_MAPPING; | ||
| start: number; | ||
| anchorStart: number; | ||
| anchorEnd: number; | ||
| tagStart: number; | ||
| tagEnd: number; | ||
| style: CollectionStyle; | ||
| } | ||
| interface ScalarEvent { | ||
| type: typeof EVENT_SCALAR; | ||
| valueStart: number; | ||
| valueEnd: number; | ||
| anchorStart: number; | ||
| anchorEnd: number; | ||
| tagStart: number; | ||
| tagEnd: number; | ||
| style: ScalarStyle; | ||
| chomping: Chomping; | ||
| indent: number; | ||
| fast: boolean; | ||
| } | ||
| interface AliasEvent { | ||
| type: typeof EVENT_ALIAS; | ||
| anchorStart: number; | ||
| anchorEnd: number; | ||
| } | ||
| interface PopEvent { | ||
| type: typeof EVENT_POP; | ||
| } | ||
| type Event = DocumentEvent | SequenceEvent | MappingEvent | ScalarEvent | AliasEvent | PopEvent; | ||
| interface ConstructorOptions { | ||
| source: string; | ||
| filename?: string; | ||
| schema?: Schema; | ||
| json?: boolean; | ||
| maxMergeSeqLength?: number; | ||
| } | ||
| declare function constructFromEvents(events: Event[], options: ConstructorOptions): unknown[]; | ||
| interface ParserOptions { | ||
| filename?: string; | ||
| maxDepth?: number; | ||
| } | ||
| declare function parseEvents(input: string, options: ParserOptions): Event[]; | ||
| interface LoadOptions extends ParserOptions, Omit<ConstructorOptions, 'source'> { | ||
| } | ||
| type LoadAllIterator = (document: unknown) => void; | ||
| declare function loadAll(input: string, options?: LoadOptions): unknown[]; | ||
| declare function loadAll(input: string, iterator: null, options?: LoadOptions): unknown[]; | ||
| declare function loadAll(input: string, iterator: LoadAllIterator, options?: LoadOptions): void; | ||
| declare function load(input: string, options?: LoadOptions): unknown; | ||
| declare class Style { | ||
| tagged: boolean; | ||
| flow: boolean; | ||
| singleQuoted: boolean; | ||
| doubleQuoted: boolean; | ||
| literal: boolean; | ||
| folded: boolean; | ||
| } | ||
| interface NodeBase { | ||
| tag: string; | ||
| style: Style; | ||
| anchor?: string; | ||
| commentBefore?: string; | ||
| comment?: string; | ||
| commentAfter?: string; | ||
| blankBefore?: number; | ||
| } | ||
| interface ScalarNode extends NodeBase { | ||
| kind: 'scalar'; | ||
| value: string; | ||
| } | ||
| interface SequenceNode extends NodeBase { | ||
| kind: 'sequence'; | ||
| items: Node[]; | ||
| } | ||
| interface MappingNode extends NodeBase { | ||
| kind: 'mapping'; | ||
| items: Array<{ | ||
| key: Node; | ||
| value: Node; | ||
| }>; | ||
| } | ||
| interface AliasNode extends NodeBase { | ||
| kind: 'alias'; | ||
| anchor: string; | ||
| } | ||
| type Node = ScalarNode | SequenceNode | MappingNode | AliasNode; | ||
| interface Document { | ||
| contents: Node | null; | ||
| explicitStart?: boolean; | ||
| explicitEnd?: boolean; | ||
| directives: DocumentDirective[]; | ||
| } | ||
| interface PresenterOptions { | ||
| schema: Schema; | ||
| indent?: number; | ||
| seqNoIndent?: boolean; | ||
| seqInlineFirst?: boolean; | ||
| sortKeys?: boolean | ((a: any, b: any) => number); | ||
| lineWidth?: number; | ||
| flowBracketPadding?: boolean; | ||
| flowSkipCommaSpace?: boolean; | ||
| flowSkipColonSpace?: boolean; | ||
| quoteFlowKeys?: boolean; | ||
| quoteStyle?: 'auto' | 'single' | 'double'; | ||
| tagBeforeAnchor?: boolean; | ||
| } | ||
| declare function present(documents: Document[], options: PresenterOptions): string; | ||
| interface DumpOptions extends Omit<PresenterOptions, 'schema'> { | ||
| schema?: Schema; | ||
| skipInvalid?: boolean; | ||
| noRefs?: boolean; | ||
| flowLevel?: number; | ||
| transform?: (documents: Document[]) => void; | ||
| } | ||
| declare function dump(input: any, options?: DumpOptions): string; | ||
| interface SnippetMark { | ||
| name?: string | null; | ||
| buffer: string; | ||
| position: number; | ||
| line: number; | ||
| column: number; | ||
| snippet?: string | null; | ||
| } | ||
| declare class YAMLException extends Error { | ||
| reason: string; | ||
| mark?: SnippetMark; | ||
| constructor(reason: string, mark?: SnippetMark); | ||
| toString(compact?: boolean): string; | ||
| } | ||
| declare function getScalarValue(input: string, scalar: ScalarEvent): string; | ||
| interface FromEventsOptions { | ||
| source: string; | ||
| schema: Schema; | ||
| } | ||
| declare function eventsToAst(events: Event[], options: FromEventsOptions): Document[]; | ||
| interface FromJsOptions { | ||
| noRefs?: boolean; | ||
| skipInvalid?: boolean; | ||
| } | ||
| declare function jsToAst(input: unknown, schema: Schema, options?: FromJsOptions): Document[]; | ||
| declare const VISIT_BREAK: unique symbol; | ||
| declare const VISIT_SKIP: unique symbol; | ||
| type VisitControl = typeof VISIT_BREAK | typeof VISIT_SKIP | undefined | void; | ||
| interface VisitContext { | ||
| depth: number; | ||
| parent: Node | null; | ||
| isKey: boolean; | ||
| } | ||
| type Visitor = (node: Node, ctx: VisitContext) => VisitControl; | ||
| declare function visit(documents: Document[], visitor: Visitor): void; | ||
| export { CHOMPING_CLIP, CHOMPING_KEEP, CHOMPING_STRIP, COLLECTION_STYLE_BLOCK, COLLECTION_STYLE_FLOW, CORE_SCHEMA, EVENT_ALIAS, EVENT_DOCUMENT, EVENT_MAPPING, EVENT_POP, EVENT_SCALAR, EVENT_SEQUENCE, FAILSAFE_SCHEMA, JSON_SCHEMA, MERGE_KEY, NOT_RESOLVED, SCALAR_STYLE_DOUBLE_QUOTED, SCALAR_STYLE_FOLDED_BLOCK, SCALAR_STYLE_LITERAL_BLOCK, SCALAR_STYLE_PLAIN, SCALAR_STYLE_SINGLE_QUOTED, Schema, Style, VISIT_BREAK, VISIT_SKIP, YAML11_SCHEMA, YAMLException, binaryTag, boolCoreTag, boolJsonTag, boolYaml11Tag, constructFromEvents, defineMappingTag, defineScalarTag, defineSequenceTag, dump, eventsToAst, floatCoreTag, floatJsonTag, floatYaml11Tag, getScalarValue, intCoreTag, intJsonTag, intYaml11Tag, jsToAst, legacyMapTag, load, loadAll, mapTag, mergeTag, nullCoreTag, nullJsonTag, nullYaml11Tag, omapTag, pairsTag, parseEvents, present, realMapTag, seqTag, setTag, strTag, timestampTag, visit }; | ||
| export type { AliasEvent, AliasNode, ConstructorOptions, Document, DocumentDirective, DocumentEvent, DumpOptions, Event, FromEventsOptions, FromJsOptions, LoadOptions, MappingEvent, MappingNode, MappingTagDefinition, MappingTagOptions, Node, NodeBase, ParserOptions, PopEvent, PresenterOptions, ScalarEvent, ScalarNode, ScalarTagDefinition, ScalarTagOptions, SequenceEvent, SequenceNode, SequenceTagDefinition, SequenceTagOptions, TagDefinition, VisitContext, Visitor }; |
+26
-12
| { | ||
| "name": "js-yaml", | ||
| "version": "4.2.0", | ||
| "version": "5.0.0", | ||
| "description": "YAML 1.2 parser and serializer", | ||
@@ -30,4 +30,2 @@ "keywords": [ | ||
| "files": [ | ||
| "index.js", | ||
| "lib/", | ||
| "bin/", | ||
@@ -37,10 +35,19 @@ "dist/" | ||
| "bin": { | ||
| "js-yaml": "bin/js-yaml.js" | ||
| "js-yaml": "bin/js-yaml.mjs" | ||
| }, | ||
| "main": "./dist/js-yaml.cjs.js", | ||
| "module": "./dist/js-yaml.mjs", | ||
| "types": "./dist/js-yaml.d.ts", | ||
| "exports": { | ||
| ".": { | ||
| "types": "./dist/js-yaml.d.ts", | ||
| "import": "./dist/js-yaml.mjs", | ||
| "require": "./index.js" | ||
| "require": "./dist/js-yaml.cjs.js" | ||
| }, | ||
| "./browser": { | ||
| "types": "./dist/js-yaml.d.ts", | ||
| "import": "./dist/browser/js-yaml.esm.min.mjs", | ||
| "require": "./dist/browser/js-yaml.umd.min.js", | ||
| "default": "./dist/browser/js-yaml.umd.min.js" | ||
| }, | ||
| "./package.json": "./package.json" | ||
@@ -51,14 +58,16 @@ }, | ||
| "lint-fix": "eslint . --fix", | ||
| "test": "npm run lint && npm run test:core && npm run test:build", | ||
| "test:core": "node --test test/core/*.test.*", | ||
| "test:build": "npm run build && node --test test/build/*.test.*", | ||
| "coverage": "npm run build && c8 --include 'lib/**' -r text -r html -r lcov node --test test/core/*.test.*", | ||
| "type-check": "tsc --noEmit", | ||
| "test": "npm run lint && npm run build && npm run type-check && npm run test:examples && npm run spec:get && node --test 'test/core/**/*.test.mjs' 'test/spec/*.test.mjs'", | ||
| "test:examples": "node --test 'examples/*.mjs'", | ||
| "test:spec": "npm run build && npm run spec:get && node test/spec/spec.test.mjs", | ||
| "spec:get": "node support/get-yaml-test-suite.mjs", | ||
| "spec:update": "node support/get-yaml-test-suite.mjs update", | ||
| "coverage": "npm run build && npm run spec:get && c8 --include 'dist/js-yaml.mjs' --include 'src/**' -r text -r html -r lcov node --test 'test/core/**/*.test.mjs' 'test/spec/*.test.mjs'", | ||
| "build": "node support/build-dist.mjs", | ||
| "build:demo": "npm run lint && node support/build_demo.mjs", | ||
| "gh-demo": "npm run build:demo && gh-pages -d demo -f", | ||
| "benchmark:deps": "npm install --prefix benchmark/extra/", | ||
| "prepack": "npm test && npm run build && npm run build:demo", | ||
| "postpublish": "npm run gh-demo" | ||
| }, | ||
| "unpkg": "dist/js-yaml.min.js", | ||
| "jsdelivr": "dist/js-yaml.min.js", | ||
| "dependencies": { | ||
@@ -68,2 +77,4 @@ "argparse": "^2.0.1" | ||
| "devDependencies": { | ||
| "@streamparser/json": "^0.0.22", | ||
| "@types/node": "^24.12.2", | ||
| "c8": "^11.0.0", | ||
@@ -74,4 +85,7 @@ "codemirror": "^5.65.21", | ||
| "gh-pages": "^6.3.0", | ||
| "mitata": "^1.0.34", | ||
| "neostandard": "^0.13.0", | ||
| "tinybench": "^6.0.2", | ||
| "rollup": "^4.62.2", | ||
| "rollup-plugin-dts": "^6.4.1", | ||
| "typescript": "^6.0.3", | ||
| "vite": "^8.0.14", | ||
@@ -78,0 +92,0 @@ "vite-plugin-node-polyfills": "^0.28.0", |
+118
-143
@@ -10,5 +10,5 @@ JS-YAML - YAML 1.2 parser / writer for JavaScript | ||
| This is an implementation of [YAML](https://yaml.org/), a human-friendly data | ||
| serialization language. Started as [PyYAML](https://pyyaml.org/) port, it was | ||
| completely rewritten from scratch. Now it's very fast, and supports 1.2 spec. | ||
| A fast and complete [YAML](https://yaml.org/) parser and writer for JavaScript. | ||
| Supports both the 1.2 and 1.1 specs, and passes the entire | ||
| [YAML Test Suite](https://github.com/yaml/yaml-test-suite). | ||
@@ -19,4 +19,2 @@ | ||
| ### YAML module for node.js | ||
| ``` | ||
@@ -26,44 +24,21 @@ npm install js-yaml | ||
| Upgrading from v4? See the [v5 migration guide](docs/migrate_v4_to_v5.md). | ||
| ### CLI executable | ||
| If you want to inspect your YAML files from CLI, install js-yaml globally: | ||
| ``` | ||
| npm install -g js-yaml | ||
| ``` | ||
| #### Usage | ||
| ``` | ||
| usage: js-yaml [-h] [-v] [-c] [-t] file | ||
| Positional arguments: | ||
| file File with YAML document(s) | ||
| Optional arguments: | ||
| -h, --help Show this help message and exit. | ||
| -v, --version Show program's version number and exit. | ||
| -c, --compact Display errors in compact mode | ||
| -t, --trace Show stack trace on error | ||
| ``` | ||
| API | ||
| --- | ||
| Here we cover the most 'useful' methods. If you need advanced details (creating | ||
| your own tags), see [examples](https://github.com/nodeca/js-yaml/tree/master/examples) | ||
| for more info. | ||
| Here we cover the most useful methods. If you need advanced details (such as | ||
| creating your own tags), see the [examples](examples/) for more info. | ||
| ``` javascript | ||
| const yaml = require('js-yaml'); | ||
| const fs = require('fs'); | ||
| import { load } from 'js-yaml' | ||
| import { readFileSync } from 'node:fs' | ||
| // Get document, or throw exception on error | ||
| try { | ||
| const doc = yaml.load(fs.readFileSync('/home/ixti/example.yml', 'utf8')); | ||
| console.log(doc); | ||
| const doc = load(readFileSync('example.yml', 'utf8')) | ||
| console.log(doc) | ||
| } catch (e) { | ||
| console.log(e); | ||
| console.log(e) | ||
| } | ||
@@ -75,6 +50,10 @@ ``` | ||
| Parses `string` as single YAML document. Returns either a | ||
| plain object, a string, a number, `null` or `undefined`, or throws `YAMLException` on error. By default, does | ||
| not support regexps, functions and undefined. | ||
| Parses `string` as a single YAML document. Throws `YAMLException` on error. | ||
| This function **does not** understand multi-document or empty sources; it throws | ||
| an exception on those. | ||
| > [!WARNING] | ||
| > When processing untrusted input, see the | ||
| > [security considerations](docs/safety.md). | ||
| options: | ||
@@ -84,37 +63,52 @@ | ||
| error/warning messages. | ||
| - `onWarning` _(default: null)_ - function to call on warning messages. | ||
| Loader will call this function with an instance of `YAMLException` for each warning. | ||
| - `schema` _(default: `DEFAULT_SCHEMA`)_ - specifies a schema to use. | ||
| - `FAILSAFE_SCHEMA` - only strings, arrays and plain objects: | ||
| https://www.yaml.org/spec/1.2/spec.html#id2802346 | ||
| - `JSON_SCHEMA` - all JSON-supported types: | ||
| https://www.yaml.org/spec/1.2/spec.html#id2803231 | ||
| - `CORE_SCHEMA` - same as `JSON_SCHEMA`: | ||
| https://www.yaml.org/spec/1.2/spec.html#id2804923 | ||
| - `DEFAULT_SCHEMA` - all supported YAML types. | ||
| - `json` _(default: false)_ - compatibility with JSON.parse behaviour. If true, then duplicate keys in a mapping will override values rather than throwing an error. | ||
| - `maxDepth` _(default: 100)_ - limits nesting depth for collections. | ||
| - `maxMergeSeqLength` _(default: 20)_ - limits the number of elements in merge | ||
| - `schema` _(default: `CORE_SCHEMA`)_ - specifies a schema to use. | ||
| - `FAILSAFE_SCHEMA` - only strings, arrays and plain objects. | ||
| - `JSON_SCHEMA` - all JSON-supported types. | ||
| - `CORE_SCHEMA` - a superset of `JSON_SCHEMA`, accepting more notations for | ||
| the same types. | ||
| - `YAML11_SCHEMA` - adds the legacy YAML 1.1 types (`!!binary`, `!!timestamp`, | ||
| `!!omap`, `!!pairs`, `!!set`, merge keys `<<`, and the broader 1.1 scalar | ||
| notations). | ||
| - `json` _(default: false)_ - compatibility with `JSON.parse` behaviour. If | ||
| `true`, duplicate keys in a mapping override values rather than throwing an | ||
| error. | ||
| - `maxDepth` _(default: 100)_ - limits the nesting depth for collections (does | ||
| not take aliases into account). | ||
| - `maxMergeSeqLength` _(default: 20)_ - limits the number of items in merge | ||
| (`<<`) sequences. | ||
| NOTE: This function **does not** understand multi-document sources, it throws | ||
| exception on those. | ||
| > [!NOTE] | ||
| > | ||
| > The default `CORE_SCHEMA` comes without the `!!merge` tag. You can easily | ||
| > enable it if needed: | ||
| > | ||
| > ``` javascript | ||
| > import { load, CORE_SCHEMA, mergeTag } from 'js-yaml' | ||
| > | ||
| > load(data, { schema: CORE_SCHEMA.withTags(mergeTag) }) | ||
| > ``` | ||
| NOTE: JS-YAML **does not** support schema-specific tag resolution restrictions. | ||
| So, the JSON schema is not as strictly defined in the YAML specification. | ||
| It allows numbers in any notation, use `Null` and `NULL` as `null`, etc. | ||
| The core schema also has no such restrictions. It allows binary notation for integers. | ||
| > [!WARNING] | ||
| > | ||
| > The default `mapTag` is `{}`-object based and does not allow complex keys | ||
| > (objects, arrays and so on). That's an intentional choice for convenience. | ||
| > Also, non-string scalar keys, such as `null`, numbers or booleans, are | ||
| > converted to strings. | ||
| > | ||
| > In the rare cases where you really need complex keys, use `realMapTag` in the | ||
| > schema instead. It stores any key exactly as provided, at the cost of less | ||
| > convenient access. | ||
| See [examples](examples/) for advanced customization approaches. | ||
| ### loadAll (string [, iterator] [, options ]) | ||
| Same as `load()`, but understands multi-document sources. Applies | ||
| `iterator` to each document if specified, or returns array of documents. | ||
| ### loadAll (string [, options ]) | ||
| Same as `load()`, but understands multi-document sources. Returns an array of | ||
| documents. | ||
| ``` javascript | ||
| const yaml = require('js-yaml'); | ||
| import { loadAll } from 'js-yaml' | ||
| yaml.loadAll(data, function (doc) { | ||
| console.log(doc); | ||
| }); | ||
| console.log(loadAll(data)) | ||
| ``` | ||
@@ -125,5 +119,6 @@ | ||
| Serializes `object` as a YAML document. Uses `DEFAULT_SCHEMA`, so it will | ||
| throw an exception if you try to dump regexps or functions. However, you can | ||
| disable exceptions by setting the `skipInvalid` option to `true`. | ||
| Serializes `object` as a YAML document. By default it can dump every supported | ||
| YAML type, so it throws an exception if you try to dump regexps or functions. | ||
| However, you can disable exceptions by setting the `skipInvalid` option to | ||
| `true`. | ||
@@ -133,60 +128,37 @@ options: | ||
| - `indent` _(default: 2)_ - indentation width to use (in spaces). | ||
| - `noArrayIndent` _(default: false)_ - when true, will not add an indentation level to array elements | ||
| - `skipInvalid` _(default: false)_ - do not throw on invalid types (like function | ||
| in the safe schema) and skip pairs and single values with such types. | ||
| - `flowLevel` _(default: -1)_ - specifies level of nesting, when to switch from | ||
| block to flow style for collections. -1 means block style everwhere | ||
| - `styles` - "tag" => "style" map. Each tag may have own set of styles. | ||
| - `schema` _(default: `DEFAULT_SCHEMA`)_ specifies a schema to use. | ||
| - `flowLevel` _(default: -1)_ - nesting level at which collections switch from | ||
| block to flow style (`-1` means never). | ||
| - `seqNoIndent` _(default: false)_ - when `true`, does not add an indentation | ||
| level to array elements, `␣␣- 1` => `- 1`. | ||
| - `seqInlineFirst` _(default: true)_ - when `true`, allows a nested collection | ||
| to start on the same line after `-`, `-\n - 1` => `- - 1`. | ||
| - `skipInvalid` _(default: false)_ - do not throw on invalid types (such as a | ||
| function in the schema). Invalid mapping pairs and sequence items are skipped; | ||
| `undefined` sequence items are serialized as `null`. | ||
| - `schema` _(default: a `YAML11_SCHEMA`-based schema)_ - specifies a schema to | ||
| use. | ||
| - `sortKeys` _(default: `false`)_ - if `true`, sort keys when dumping YAML. If a | ||
| function, use the function to sort the keys. | ||
| - `lineWidth` _(default: `80`)_ - set max line width. Set `-1` for unlimited width. | ||
| - `noRefs` _(default: `false`)_ - if `true`, don't convert duplicate objects into references | ||
| - `noCompatMode` _(default: `false`)_ - if `true` don't try to be compatible with older | ||
| yaml versions. Currently: don't quote "yes", "no" and so on, as required for YAML 1.1 | ||
| - `condenseFlow` _(default: `false`)_ - if `true` flow sequences will be condensed, omitting the space between `a, b`. Eg. `'[a,b]'`, and omitting the space between `key: value` and quoting the key. Eg. `'{"a":b}'` Can be useful when using yaml for pretty URL query params as spaces are %-encoded. | ||
| - `quotingType` _(`'` or `"`, default: `'`)_ - strings will be quoted using this quoting style. If you specify single quotes, double quotes will still be used for non-printable characters. | ||
| - `forceQuotes` _(default: `false`)_ - if `true`, all non-key strings will be quoted even if they normally don't need to. | ||
| - `replacer` - callback `function (key, value)` called recursively on each key/value in source object (see `replacer` docs for `JSON.stringify`). | ||
| - `lineWidth` _(default: `80`)_ - sets the max line width. Set `-1` for unlimited | ||
| width. | ||
| - `noRefs` _(default: `false`)_ - if `true`, don't convert duplicate objects into | ||
| references; inline them instead. | ||
| - `quoteStyle` _(`auto`, `single`, or `double`, default: `auto`)_ - force quotes | ||
| to single/double, or select the most suitable. | ||
| - `flowBracketPadding` _(default: `false`)_ - add spaces inside flow collection | ||
| brackets, `{a: 1}` => `{ a: 1 }`. | ||
| - `flowSkipCommaSpace` _(default: `false`)_ - omit the space after commas in | ||
| flow collections, `[1, 2]` => `[1,2]`. | ||
| - `flowSkipColonSpace` _(default: `false`)_ - omit the space after `:` in flow | ||
| mappings, `{a: 1}` => `{a:1}`. | ||
| - `quoteFlowKeys` _(default: `false`)_ - quote flow mapping keys, `{a: 1}` => | ||
| `{"a": 1}`. | ||
| - `tagBeforeAnchor` _(default: `false`)_ - print an explicit tag before an | ||
| anchor, `&ref_0 !!set` => `!!set &ref_0`. | ||
| - `transform` - a function `(documents: Document[]) => void` that can mutate the | ||
| generated AST before it is rendered. | ||
| The following table show availlable styles (e.g. "canonical", | ||
| "binary"...) available for each tag (.e.g. !!null, !!int ...). Yaml | ||
| output is shown on the right side after `=>` (default setting) or `->`: | ||
| See [examples](examples/) for advanced customization approaches. | ||
| ``` none | ||
| !!null | ||
| "canonical" -> "~" | ||
| "lowercase" => "null" | ||
| "uppercase" -> "NULL" | ||
| "camelcase" -> "Null" | ||
| "empty" -> "" | ||
| !!int | ||
| "binary" -> "0b1", "0b101010", "0b1110001111010" | ||
| "octal" -> "0o1", "0o52", "0o16172" | ||
| "decimal" => "1", "42", "7290" | ||
| "hexadecimal" -> "0x1", "0x2A", "0x1C7A" | ||
| !!bool | ||
| "lowercase" => "true", "false" | ||
| "uppercase" -> "TRUE", "FALSE" | ||
| "camelcase" -> "True", "False" | ||
| !!float | ||
| "lowercase" => ".nan", '.inf' | ||
| "uppercase" -> ".NAN", '.INF' | ||
| "camelcase" -> ".NaN", '.Inf' | ||
| ``` | ||
| Example: | ||
| ``` javascript | ||
| dump(object, { | ||
| 'styles': { | ||
| '!!null': 'canonical' // dump null as ~ | ||
| }, | ||
| 'sortKeys': true // sort object keys | ||
| }); | ||
| ``` | ||
| Supported YAML types | ||
@@ -201,15 +173,26 @@ -------------------- | ||
| !!null '' # null | ||
| !!bool 'yes' # bool | ||
| !!bool 'true' # bool | ||
| !!int '3...' # number | ||
| !!float '3.14...' # number | ||
| !!binary '...base64...' # buffer | ||
| !!timestamp 'YYYY-...' # date | ||
| !!omap [ ... ] # array of key-value pairs | ||
| !!pairs [ ... ] # array or array pairs | ||
| !!set { ... } # array of objects with given keys and null values | ||
| !!str '...' # string | ||
| !!seq [ ... ] # array | ||
| !!map { ... } # object | ||
| !!map { ... } # object (or Map) | ||
| ``` | ||
| The types below are only available in `YAML11_SCHEMA` (not in the default | ||
| `CORE_SCHEMA`): | ||
| ``` | ||
| !!binary '...base64...' # Uint8Array | ||
| !!timestamp 'YYYY-...' # date | ||
| !!set { ... } # Set | ||
| # Legacy YAML 1.1 compatibility only; these types cannot be dumped. | ||
| !!omap [ ... ] # array of key-value pairs | ||
| !!pairs [ ... ] # array of array pairs | ||
| ``` | ||
| To preserve complex keys in the first position of a `!!pairs` item, replace | ||
| the default object-based map with `realMapTag` in the schema. | ||
| **JavaScript-specific tags** | ||
@@ -221,20 +204,12 @@ | ||
| Caveats | ||
| ------- | ||
| CLI | ||
| --- | ||
| Note, that you use arrays or objects as key in JS-YAML. JS does not allow objects | ||
| or arrays as keys, and stringifies (by calling `toString()` method) them at the | ||
| moment of adding them. | ||
| This can be useful sometimes for a quick check. | ||
| ``` yaml | ||
| --- | ||
| ? [ foo, bar ] | ||
| : - baz | ||
| ? { foo: bar } | ||
| : - baz | ||
| - baz | ||
| ``` | ||
| npx js-yaml -h | ||
| ``` | ||
| ``` javascript | ||
| { "foo,bar": ["baz"], "[object Object]": ["baz", "baz"] } | ||
| ``` | ||
| Note: the CLI script comes with minimal options, and there are no big plans to | ||
| extend it. |
-117
| #!/usr/bin/env node | ||
| 'use strict' | ||
| const fs = require('fs') | ||
| const argparse = require('argparse') | ||
| const yaml = require('..') | ||
| /// ///////////////////////////////////////////////////////////////////////////// | ||
| const cli = new argparse.ArgumentParser({ | ||
| prog: 'js-yaml', | ||
| add_help: true | ||
| }) | ||
| cli.add_argument('-v', '--version', { | ||
| action: 'version', | ||
| version: require('../package.json').version | ||
| }) | ||
| cli.add_argument('-c', '--compact', { | ||
| help: 'Display errors in compact mode', | ||
| action: 'store_true' | ||
| }) | ||
| // deprecated (not needed after we removed output colors) | ||
| // option suppressed, but not completely removed for compatibility | ||
| cli.add_argument('-j', '--to-json', { | ||
| help: argparse.SUPPRESS, | ||
| dest: 'json', | ||
| action: 'store_true' | ||
| }) | ||
| cli.add_argument('-t', '--trace', { | ||
| help: 'Show stack trace on error', | ||
| action: 'store_true' | ||
| }) | ||
| cli.add_argument('file', { | ||
| help: 'File to read, utf-8 encoded without BOM', | ||
| nargs: '?', | ||
| default: '-' | ||
| }) | ||
| /// ///////////////////////////////////////////////////////////////////////////// | ||
| const options = cli.parse_args() | ||
| /// ///////////////////////////////////////////////////////////////////////////// | ||
| function readFile (filename, encoding, callback) { | ||
| if (options.file === '-') { | ||
| // read from stdin | ||
| const chunks = [] | ||
| process.stdin.on('data', function (chunk) { | ||
| chunks.push(chunk) | ||
| }) | ||
| process.stdin.on('end', function () { | ||
| return callback(null, Buffer.concat(chunks).toString(encoding)) | ||
| }) | ||
| } else { | ||
| fs.readFile(filename, encoding, callback) | ||
| } | ||
| } | ||
| readFile(options.file, 'utf8', function (error, input) { | ||
| let output | ||
| let isYaml | ||
| if (error) { | ||
| if (error.code === 'ENOENT') { | ||
| console.error('File not found: ' + options.file) | ||
| process.exit(2) | ||
| } | ||
| console.error( | ||
| (options.trace && error.stack) || | ||
| error.message || | ||
| String(error)) | ||
| process.exit(1) | ||
| } | ||
| try { | ||
| output = JSON.parse(input) | ||
| isYaml = false | ||
| } catch (err) { | ||
| if (err instanceof SyntaxError) { | ||
| try { | ||
| output = [] | ||
| yaml.loadAll(input, function (doc) { output.push(doc) }, {}) | ||
| isYaml = true | ||
| if (output.length === 0) output = null | ||
| else if (output.length === 1) output = output[0] | ||
| } catch (e) { | ||
| if (options.trace && err.stack) console.error(e.stack) | ||
| else console.error(e.toString(options.compact)) | ||
| process.exit(1) | ||
| } | ||
| } else { | ||
| console.error( | ||
| (options.trace && err.stack) || | ||
| err.message || | ||
| String(err)) | ||
| process.exit(1) | ||
| } | ||
| } | ||
| if (isYaml) console.log(JSON.stringify(output, null, ' ')) | ||
| else console.log(yaml.dump(output)) | ||
| }) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
| (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.jsyaml={}))})(this,function(e){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,s=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),c=(e,t,a,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=i(t),l=0,u=c.length,d;l<u;l++)d=c[l],!o.call(e,d)&&d!==a&&n(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(s=r(t,d))||s.enumerable});return e},l=(e,r,i)=>(i=e==null?{}:t(a(e)),c(r||!e||!e.__esModule?n(i,`default`,{value:e,enumerable:!0}):i,e)),u=s(((e,t)=>{function n(e){return e==null}function r(e){return typeof e==`object`&&!!e}function i(e){return Array.isArray(e)?e:n(e)?[]:[e]}function a(e,t){if(t){let n=Object.keys(t);for(let r=0,i=n.length;r<i;r+=1){let i=n[r];e[i]=t[i]}}return e}function o(e,t){let n=``;for(let r=0;r<t;r+=1)n+=e;return n}function s(e){return e===0&&1/e==-1/0}t.exports.isNothing=n,t.exports.isObject=r,t.exports.toArray=i,t.exports.repeat=o,t.exports.isNegativeZero=s,t.exports.extend=a})),d=s(((e,t)=>{function n(e,t){let n=``,r=e.reason||`(unknown reason)`;return e.mark?(e.mark.name&&(n+=`in "`+e.mark.name+`" `),n+=`(`+(e.mark.line+1)+`:`+(e.mark.column+1)+`)`,!t&&e.mark.snippet&&(n+=` | ||
| `+e.mark.snippet),r+` `+n):r}function r(e,t){Error.call(this),this.name=`YAMLException`,this.reason=e,this.mark=t,this.message=n(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=Error().stack||``}r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r.prototype.toString=function(e){return this.name+`: `+n(this,e)},t.exports=r})),f=s(((e,t)=>{var n=u();function r(e,t,n,r,i){let a=``,o=``,s=Math.floor(i/2)-1;return r-t>s&&(a=` ... `,t=r-s+a.length),n-r>s&&(o=` ...`,n=r+s-o.length),{str:a+e.slice(t,n).replace(/\t/g,`→`)+o,pos:r-t+a.length}}function i(e,t){return n.repeat(` `,t-e.length)+e}function a(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),typeof t.indent!=`number`&&(t.indent=1),typeof t.linesBefore!=`number`&&(t.linesBefore=3),typeof t.linesAfter!=`number`&&(t.linesAfter=2);let a=/\r?\n|\r|\0/g,o=[0],s=[],c,l=-1;for(;c=a.exec(e.buffer);)s.push(c.index),o.push(c.index+c[0].length),e.position<=c.index&&l<0&&(l=o.length-2);l<0&&(l=o.length-1);let u=``,d=Math.min(e.line+t.linesAfter,s.length).toString().length,f=t.maxLength-(t.indent+d+3);for(let a=1;a<=t.linesBefore&&!(l-a<0);a++){let c=r(e.buffer,o[l-a],s[l-a],e.position-(o[l]-o[l-a]),f);u=n.repeat(` `,t.indent)+i((e.line-a+1).toString(),d)+` | `+c.str+` | ||
| `+u}let p=r(e.buffer,o[l],s[l],e.position,f);u+=n.repeat(` `,t.indent)+i((e.line+1).toString(),d)+` | `+p.str+` | ||
| `,u+=n.repeat(`-`,t.indent+d+3+p.pos)+`^ | ||
| `;for(let a=1;a<=t.linesAfter&&!(l+a>=s.length);a++){let c=r(e.buffer,o[l+a],s[l+a],e.position-(o[l]-o[l+a]),f);u+=n.repeat(` `,t.indent)+i((e.line+a+1).toString(),d)+` | `+c.str+` | ||
| `}return u.replace(/\n$/,``)}t.exports=a})),p=s(((e,t)=>{var n=d(),r=[`kind`,`multi`,`resolve`,`construct`,`instanceOf`,`predicate`,`represent`,`representName`,`defaultStyle`,`styleAliases`],i=[`scalar`,`sequence`,`mapping`];function a(e){let t={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(e){t[String(e)]=n})}),t}function o(e,t){if(t=t||{},Object.keys(t).forEach(function(t){if(r.indexOf(t)===-1)throw new n(`Unknown option "`+t+`" is met in definition of "`+e+`" YAML type.`)}),this.options=t,this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(e){return e},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.representName=t.representName||null,this.defaultStyle=t.defaultStyle||null,this.multi=t.multi||!1,this.styleAliases=a(t.styleAliases||null),i.indexOf(this.kind)===-1)throw new n(`Unknown kind "`+this.kind+`" is specified for "`+e+`" YAML type.`)}t.exports=o})),m=s(((e,t)=>{var n=d(),r=p();function i(e,t){let n=[];return e[t].forEach(function(e){let t=n.length;n.forEach(function(n,r){n.tag===e.tag&&n.kind===e.kind&&n.multi===e.multi&&(t=r)}),n[t]=e}),n}function a(){let e={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function t(t){t.multi?(e.multi[t.kind].push(t),e.multi.fallback.push(t)):e[t.kind][t.tag]=e.fallback[t.tag]=t}for(let e=0,n=arguments.length;e<n;e+=1)arguments[e].forEach(t);return e}function o(e){return this.extend(e)}o.prototype.extend=function(e){let t=[],s=[];if(e instanceof r)s.push(e);else if(Array.isArray(e))s=s.concat(e);else if(e&&(Array.isArray(e.implicit)||Array.isArray(e.explicit)))e.implicit&&(t=t.concat(e.implicit)),e.explicit&&(s=s.concat(e.explicit));else throw new n(`Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })`);t.forEach(function(e){if(!(e instanceof r))throw new n(`Specified list of YAML types (or a single Type object) contains a non-Type object.`);if(e.loadKind&&e.loadKind!==`scalar`)throw new n(`There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.`);if(e.multi)throw new n(`There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.`)}),s.forEach(function(e){if(!(e instanceof r))throw new n(`Specified list of YAML types (or a single Type object) contains a non-Type object.`)});let c=Object.create(o.prototype);return c.implicit=(this.implicit||[]).concat(t),c.explicit=(this.explicit||[]).concat(s),c.compiledImplicit=i(c,`implicit`),c.compiledExplicit=i(c,`explicit`),c.compiledTypeMap=a(c.compiledImplicit,c.compiledExplicit),c},t.exports=o})),h=s(((e,t)=>{t.exports=new(p())(`tag:yaml.org,2002:str`,{kind:`scalar`,construct:function(e){return e===null?``:e}})})),g=s(((e,t)=>{t.exports=new(p())(`tag:yaml.org,2002:seq`,{kind:`sequence`,construct:function(e){return e===null?[]:e}})})),_=s(((e,t)=>{t.exports=new(p())(`tag:yaml.org,2002:map`,{kind:`mapping`,construct:function(e){return e===null?{}:e}})})),v=s(((e,t)=>{t.exports=new(m())({explicit:[h(),g(),_()]})})),y=s(((e,t)=>{var n=p();function r(e){if(e===null)return!0;let t=e.length;return t===1&&e===`~`||t===4&&(e===`null`||e===`Null`||e===`NULL`)}function i(){return null}function a(e){return e===null}t.exports=new n(`tag:yaml.org,2002:null`,{kind:`scalar`,resolve:r,construct:i,predicate:a,represent:{canonical:function(){return`~`},lowercase:function(){return`null`},uppercase:function(){return`NULL`},camelcase:function(){return`Null`},empty:function(){return``}},defaultStyle:`lowercase`})})),b=s(((e,t)=>{var n=p();function r(e){if(e===null)return!1;let t=e.length;return t===4&&(e===`true`||e===`True`||e===`TRUE`)||t===5&&(e===`false`||e===`False`||e===`FALSE`)}function i(e){return e===`true`||e===`True`||e===`TRUE`}function a(e){return Object.prototype.toString.call(e)===`[object Boolean]`}t.exports=new n(`tag:yaml.org,2002:bool`,{kind:`scalar`,resolve:r,construct:i,predicate:a,represent:{lowercase:function(e){return e?`true`:`false`},uppercase:function(e){return e?`TRUE`:`FALSE`},camelcase:function(e){return e?`True`:`False`}},defaultStyle:`lowercase`})})),x=s(((e,t)=>{var n=u(),r=p();function i(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function a(e){return e>=48&&e<=55}function o(e){return e>=48&&e<=57}function s(e){if(e===null)return!1;let t=e.length,n=0,r=!1;if(!t)return!1;let s=e[n];if((s===`-`||s===`+`)&&(s=e[++n]),s===`0`){if(n+1===t)return!0;if(s=e[++n],s===`b`){for(n++;n<t;n++){if(s=e[n],s!==`0`&&s!==`1`)return!1;r=!0}return r&&Number.isFinite(c(e))}if(s===`x`){for(n++;n<t;n++){if(!i(e.charCodeAt(n)))return!1;r=!0}return r&&Number.isFinite(c(e))}if(s===`o`){for(n++;n<t;n++){if(!a(e.charCodeAt(n)))return!1;r=!0}return r&&Number.isFinite(c(e))}}for(;n<t;n++){if(!o(e.charCodeAt(n)))return!1;r=!0}return r?Number.isFinite(c(e)):!1}function c(e){let t=e,n=1,r=t[0];if((r===`-`||r===`+`)&&(r===`-`&&(n=-1),t=t.slice(1),r=t[0]),t===`0`)return 0;if(r===`0`){if(t[1]===`b`)return n*parseInt(t.slice(2),2);if(t[1]===`x`)return n*parseInt(t.slice(2),16);if(t[1]===`o`)return n*parseInt(t.slice(2),8)}return n*parseInt(t,10)}function l(e){return c(e)}function d(e){return Object.prototype.toString.call(e)===`[object Number]`&&e%1==0&&!n.isNegativeZero(e)}t.exports=new r(`tag:yaml.org,2002:int`,{kind:`scalar`,resolve:s,construct:l,predicate:d,represent:{binary:function(e){return e>=0?`0b`+e.toString(2):`-0b`+e.toString(2).slice(1)},octal:function(e){return e>=0?`0o`+e.toString(8):`-0o`+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?`0x`+e.toString(16).toUpperCase():`-0x`+e.toString(16).toUpperCase().slice(1)}},defaultStyle:`decimal`,styleAliases:{binary:[2,`bin`],octal:[8,`oct`],decimal:[10,`dec`],hexadecimal:[16,`hex`]}})})),S=s(((e,t)=>{var n=u(),r=p(),i=RegExp(`^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$`),a=RegExp(`^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$`);function o(e){return e===null||!i.test(e)?!1:Number.isFinite(parseFloat(e,10))?!0:a.test(e)}function s(e){let t=e.toLowerCase(),n=t[0]===`-`?-1:1;return`+-`.indexOf(t[0])>=0&&(t=t.slice(1)),t===`.inf`?n===1?1/0:-1/0:t===`.nan`?NaN:n*parseFloat(t,10)}var c=/^[-+]?[0-9]+e/;function l(e,t){if(isNaN(e))switch(t){case`lowercase`:return`.nan`;case`uppercase`:return`.NAN`;case`camelcase`:return`.NaN`}else if(e===1/0)switch(t){case`lowercase`:return`.inf`;case`uppercase`:return`.INF`;case`camelcase`:return`.Inf`}else if(e===-1/0)switch(t){case`lowercase`:return`-.inf`;case`uppercase`:return`-.INF`;case`camelcase`:return`-.Inf`}else if(n.isNegativeZero(e))return`-0.0`;let r=e.toString(10);return c.test(r)?r.replace(`e`,`.e`):r}function d(e){return Object.prototype.toString.call(e)===`[object Number]`&&(e%1!=0||n.isNegativeZero(e))}t.exports=new r(`tag:yaml.org,2002:float`,{kind:`scalar`,resolve:o,construct:s,predicate:d,represent:l,defaultStyle:`lowercase`})})),C=s(((e,t)=>{t.exports=v().extend({implicit:[y(),b(),x(),S()]})})),w=s(((e,t)=>{t.exports=C()})),T=s(((e,t)=>{var n=p(),r=RegExp(`^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$`),i=RegExp(`^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$`);function a(e){return e===null?!1:r.exec(e)!==null||i.exec(e)!==null}function o(e){let t=0,n=null,a=r.exec(e);if(a===null&&(a=i.exec(e)),a===null)throw Error(`Date resolve error`);let o=+a[1],s=a[2]-1,c=+a[3];if(!a[4])return new Date(Date.UTC(o,s,c));let l=+a[4],u=+a[5],d=+a[6];if(a[7]){for(t=a[7].slice(0,3);t.length<3;)t+=`0`;t=+t}if(a[9]){let e=+a[10],t=+(a[11]||0);n=(e*60+t)*6e4,a[9]===`-`&&(n=-n)}let f=new Date(Date.UTC(o,s,c,l,u,d,t));return n&&f.setTime(f.getTime()-n),f}function s(e){return e.toISOString()}t.exports=new n(`tag:yaml.org,2002:timestamp`,{kind:`scalar`,resolve:a,construct:o,instanceOf:Date,represent:s})})),E=s(((e,t)=>{var n=p();function r(e){return e===`<<`||e===null}t.exports=new n(`tag:yaml.org,2002:merge`,{kind:`scalar`,resolve:r})})),D=s(((e,t)=>{var n=p(),r=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= | ||
| \r`;function i(e){if(e===null)return!1;let t=0,n=e.length,i=r;for(let r=0;r<n;r++){let n=i.indexOf(e.charAt(r));if(!(n>64)){if(n<0)return!1;t+=6}}return t%8==0}function a(e){let t=e.replace(/[\r\n=]/g,``),n=t.length,i=r,a=0,o=[];for(let e=0;e<n;e++)e%4==0&&e&&(o.push(a>>16&255),o.push(a>>8&255),o.push(a&255)),a=a<<6|i.indexOf(t.charAt(e));let s=n%4*6;return s===0?(o.push(a>>16&255),o.push(a>>8&255),o.push(a&255)):s===18?(o.push(a>>10&255),o.push(a>>2&255)):s===12&&o.push(a>>4&255),new Uint8Array(o)}function o(e){let t=``,n=0,i=e.length,a=r;for(let r=0;r<i;r++)r%3==0&&r&&(t+=a[n>>18&63],t+=a[n>>12&63],t+=a[n>>6&63],t+=a[n&63]),n=(n<<8)+e[r];let o=i%3;return o===0?(t+=a[n>>18&63],t+=a[n>>12&63],t+=a[n>>6&63],t+=a[n&63]):o===2?(t+=a[n>>10&63],t+=a[n>>4&63],t+=a[n<<2&63],t+=a[64]):o===1&&(t+=a[n>>2&63],t+=a[n<<4&63],t+=a[64],t+=a[64]),t}function s(e){return Object.prototype.toString.call(e)===`[object Uint8Array]`}t.exports=new n(`tag:yaml.org,2002:binary`,{kind:`scalar`,resolve:i,construct:a,predicate:s,represent:o})})),O=s(((e,t)=>{var n=p(),r=Object.prototype.hasOwnProperty,i=Object.prototype.toString;function a(e){if(e===null)return!0;let t=[],n=e;for(let e=0,a=n.length;e<a;e+=1){let a=n[e],o=!1;if(i.call(a)!==`[object Object]`)return!1;let s;for(s in a)if(r.call(a,s))if(!o)o=!0;else return!1;if(!o)return!1;if(t.indexOf(s)===-1)t.push(s);else return!1}return!0}function o(e){return e===null?[]:e}t.exports=new n(`tag:yaml.org,2002:omap`,{kind:`sequence`,resolve:a,construct:o})})),k=s(((e,t)=>{var n=p(),r=Object.prototype.toString;function i(e){if(e===null)return!0;let t=e,n=Array(t.length);for(let e=0,i=t.length;e<i;e+=1){let i=t[e];if(r.call(i)!==`[object Object]`)return!1;let a=Object.keys(i);if(a.length!==1)return!1;n[e]=[a[0],i[a[0]]]}return!0}function a(e){if(e===null)return[];let t=e,n=Array(t.length);for(let e=0,r=t.length;e<r;e+=1){let r=t[e],i=Object.keys(r);n[e]=[i[0],r[i[0]]]}return n}t.exports=new n(`tag:yaml.org,2002:pairs`,{kind:`sequence`,resolve:i,construct:a})})),A=s(((e,t)=>{var n=p(),r=Object.prototype.hasOwnProperty;function i(e){if(e===null)return!0;let t=e;for(let e in t)if(r.call(t,e)&&t[e]!==null)return!1;return!0}function a(e){return e===null?{}:e}t.exports=new n(`tag:yaml.org,2002:set`,{kind:`mapping`,resolve:i,construct:a})})),ee=s(((e,t)=>{t.exports=w().extend({implicit:[T(),E()],explicit:[D(),O(),k(),A()]})})),j=s(((e,t)=>{var n=u(),r=d(),i=f(),a=ee(),o=Object.prototype.hasOwnProperty,s=1,c=2,l=3,p=4,m=1,h=2,g=3,_=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,v=/[\x85\u2028\u2029]/,y=/[,\[\]{}]/,b=/^(?:!|!!|![0-9A-Za-z-]+!)$/,x=/^(?:!|[^,\[\]{}])(?:%[0-9a-f]{2}|[0-9a-z\-#;/?:@&=+$,_.!~*'()\[\]])*$/i;function S(e){return Object.prototype.toString.call(e)}function C(e){return e===10||e===13}function w(e){return e===9||e===32}function T(e){return e===9||e===32||e===10||e===13}function E(e){return e===44||e===91||e===93||e===123||e===125}function D(e){if(e>=48&&e<=57)return e-48;let t=e|32;return t>=97&&t<=102?t-97+10:-1}function O(e){return e===120?2:e===117?4:e===85?8:0}function k(e){return e>=48&&e<=57?e-48:-1}function A(e){switch(e){case 48:return`\0`;case 97:return`\x07`;case 98:return`\b`;case 116:return` `;case 9:return` `;case 110:return` | ||
| `;case 118:return`\v`;case 102:return`\f`;case 114:return`\r`;case 101:return`\x1B`;case 32:return` `;case 34:return`"`;case 47:return`/`;case 92:return`\\`;case 78:return` `;case 95:return`\xA0`;case 76:return`\u2028`;case 80:return`\u2029`;default:return``}}function j(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function te(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:n}):e[t]=n}var M=Array(256),N=Array(256);for(let e=0;e<256;e++)M[e]=+!!A(e),N[e]=A(e);function ne(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||a,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.maxDepth=typeof t.maxDepth==`number`?t.maxDepth:100,this.maxMergeSeqLength=typeof t.maxMergeSeqLength==`number`?t.maxMergeSeqLength:20,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function P(e,t){let n={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return n.snippet=i(n),new r(t,n)}function F(e,t){throw P(e,t)}function I(e,t){e.onWarning&&e.onWarning.call(null,P(e,t))}function L(e,t,n){let r=e.anchorMapTransactions;if(r.length!==0){let n=r[r.length-1];o.call(n,t)||(n[t]={existed:o.call(e.anchorMap,t),value:e.anchorMap[t]})}e.anchorMap[t]=n}function R(e){e.anchorMapTransactions.push(Object.create(null))}function re(e){let t=e.anchorMapTransactions.pop(),n=e.anchorMapTransactions;if(n.length===0)return;let r=n[n.length-1],i=Object.keys(t);for(let e=0,n=i.length;e<n;e+=1){let n=i[e];o.call(r,n)||(r[n]=t[n])}}function z(e){let t=e.anchorMapTransactions.pop(),n=Object.keys(t);for(let r=n.length-1;r>=0;--r){let i=t[n[r]];i.existed?e.anchorMap[n[r]]=i.value:delete e.anchorMap[n[r]]}}function B(e){return{position:e.position,line:e.line,lineStart:e.lineStart,lineIndent:e.lineIndent,firstTabInLine:e.firstTabInLine,tag:e.tag,anchor:e.anchor,kind:e.kind,result:e.result}}function V(e,t){e.position=t.position,e.line=t.line,e.lineStart=t.lineStart,e.lineIndent=t.lineIndent,e.firstTabInLine=t.firstTabInLine,e.tag=t.tag,e.anchor=t.anchor,e.kind=t.kind,e.result=t.result}var H={YAML:function(e,t,n){e.version!==null&&F(e,`duplication of %YAML directive`),n.length!==1&&F(e,`YAML directive accepts exactly one argument`);let r=/^([0-9]+)\.([0-9]+)$/.exec(n[0]);r===null&&F(e,`ill-formed argument of the YAML directive`);let i=parseInt(r[1],10),a=parseInt(r[2],10);i!==1&&F(e,`unacceptable YAML version of the document`),e.version=n[0],e.checkLineBreaks=a<2,a!==1&&a!==2&&I(e,`unsupported YAML version of the document`)},TAG:function(e,t,n){let r;n.length!==2&&F(e,`TAG directive accepts exactly two arguments`);let i=n[0];r=n[1],b.test(i)||F(e,`ill-formed tag handle (first argument) of the TAG directive`),o.call(e.tagMap,i)&&F(e,`there is a previously declared suffix for "`+i+`" tag handle`),x.test(r)||F(e,`ill-formed tag prefix (second argument) of the TAG directive`);try{r=decodeURIComponent(r)}catch(t){F(e,`tag prefix is malformed: `+r)}e.tagMap[i]=r}};function U(e,t,n,r){if(t<n){let i=e.input.slice(t,n);if(r)for(let t=0,n=i.length;t<n;t+=1){let n=i.charCodeAt(t);n===9||n>=32&&n<=1114111||F(e,`expected valid JSON character`)}else _.test(i)&&F(e,`the stream contains non-printable characters`);e.result+=i}}function W(e,t,r,i){n.isObject(r)||F(e,`cannot merge mappings; the provided source object is unacceptable`);let a=Object.keys(r);for(let e=0,n=a.length;e<n;e+=1){let n=a[e];o.call(t,n)||(te(t,n,r[n]),i[n]=!0)}}function G(e,t,n,r,i,a,s,c,l){if(Array.isArray(i)){i=Array.prototype.slice.call(i);for(let t=0,n=i.length;t<n;t+=1)Array.isArray(i[t])&&F(e,`nested arrays are not supported inside keys`),typeof i==`object`&&S(i[t])===`[object Object]`&&(i[t]=`[object Object]`)}if(typeof i==`object`&&S(i)===`[object Object]`&&(i=`[object Object]`),i=String(i),t===null&&(t={}),r===`tag:yaml.org,2002:merge`)if(Array.isArray(a)){a.length>e.maxMergeSeqLength&&F(e,`merge sequence length exceeded maxMergeSeqLength (`+e.maxMergeSeqLength+`)`);let r=new Set;for(let i=0,o=a.length;i<o;i+=1){let o=a[i];r.has(o)||(r.add(o),W(e,t,o,n))}}else W(e,t,a,n);else !e.json&&!o.call(n,i)&&o.call(t,i)&&(e.line=s||e.line,e.lineStart=c||e.lineStart,e.position=l||e.position,F(e,`duplicated mapping key`)),te(t,i,a),delete n[i];return t}function K(e){let t=e.input.charCodeAt(e.position);t===10?e.position++:t===13?(e.position++,e.input.charCodeAt(e.position)===10&&e.position++):F(e,`a line break is expected`),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function q(e,t,n){let r=0,i=e.input.charCodeAt(e.position);for(;i!==0;){for(;w(i);)i===9&&e.firstTabInLine===-1&&(e.firstTabInLine=e.position),i=e.input.charCodeAt(++e.position);if(t&&i===35)do i=e.input.charCodeAt(++e.position);while(i!==10&&i!==13&&i!==0);if(C(i))for(K(e),i=e.input.charCodeAt(e.position),r++,e.lineIndent=0;i===32;)e.lineIndent++,i=e.input.charCodeAt(++e.position);else break}return n!==-1&&r!==0&&e.lineIndent<n&&I(e,`deficient indentation`),r}function J(e){let t=e.position,n=e.input.charCodeAt(t);return!!((n===45||n===46)&&n===e.input.charCodeAt(t+1)&&n===e.input.charCodeAt(t+2)&&(t+=3,n=e.input.charCodeAt(t),n===0||T(n)))}function Y(e,t){t===1?e.result+=` `:t>1&&(e.result+=n.repeat(` | ||
| `,t-1))}function ie(e,t,n){let r,i,a,o,s,c,l=e.kind,u=e.result,d=e.input.charCodeAt(e.position);if(T(d)||E(d)||d===35||d===38||d===42||d===33||d===124||d===62||d===39||d===34||d===37||d===64||d===96)return!1;if(d===63||d===45){let t=e.input.charCodeAt(e.position+1);if(T(t)||n&&E(t))return!1}for(e.kind=`scalar`,e.result=``,r=i=e.position,a=!1;d!==0;){if(d===58){let t=e.input.charCodeAt(e.position+1);if(T(t)||n&&E(t))break}else if(d===35){if(T(e.input.charCodeAt(e.position-1)))break}else if(e.position===e.lineStart&&J(e)||n&&E(d))break;else if(C(d))if(o=e.line,s=e.lineStart,c=e.lineIndent,q(e,!1,-1),e.lineIndent>=t){a=!0,d=e.input.charCodeAt(e.position);continue}else{e.position=i,e.line=o,e.lineStart=s,e.lineIndent=c;break}a&&(U(e,r,i,!1),Y(e,e.line-o),r=i=e.position,a=!1),w(d)||(i=e.position+1),d=e.input.charCodeAt(++e.position)}return U(e,r,i,!1),e.result?!0:(e.kind=l,e.result=u,!1)}function X(e,t){let n,r,i=e.input.charCodeAt(e.position);if(i!==39)return!1;for(e.kind=`scalar`,e.result=``,e.position++,n=r=e.position;(i=e.input.charCodeAt(e.position))!==0;)if(i===39)if(U(e,n,e.position,!0),i=e.input.charCodeAt(++e.position),i===39)n=e.position,e.position++,r=e.position;else return!0;else C(i)?(U(e,n,r,!0),Y(e,q(e,!1,t)),n=r=e.position):e.position===e.lineStart&&J(e)?F(e,`unexpected end of the document within a single quoted scalar`):(e.position++,w(i)||(r=e.position));F(e,`unexpected end of the stream within a single quoted scalar`)}function ae(e,t){let n,r,i,a=e.input.charCodeAt(e.position);if(a!==34)return!1;for(e.kind=`scalar`,e.result=``,e.position++,n=r=e.position;(a=e.input.charCodeAt(e.position))!==0;)if(a===34)return U(e,n,e.position,!0),e.position++,!0;else if(a===92){if(U(e,n,e.position,!0),a=e.input.charCodeAt(++e.position),C(a))q(e,!1,t);else if(a<256&&M[a])e.result+=N[a],e.position++;else if((i=O(a))>0){let t=i,n=0;for(;t>0;t--)a=e.input.charCodeAt(++e.position),(i=D(a))>=0?n=(n<<4)+i:F(e,`expected hexadecimal character`);e.result+=j(n),e.position++}else F(e,`unknown escape sequence`);n=r=e.position}else C(a)?(U(e,n,r,!0),Y(e,q(e,!1,t)),n=r=e.position):e.position===e.lineStart&&J(e)?F(e,`unexpected end of the document within a double quoted scalar`):(e.position++,w(a)||(r=e.position));F(e,`unexpected end of the stream within a double quoted scalar`)}function oe(e,t){let n=!0,r,i,a,o=e.tag,c,l=e.anchor,u,d,f,p,m=Object.create(null),h,g,_,v=e.input.charCodeAt(e.position);if(v===91)u=93,p=!1,c=[];else if(v===123)u=125,p=!0,c={};else return!1;for(e.anchor!==null&&L(e,e.anchor,c),v=e.input.charCodeAt(++e.position);v!==0;){if(q(e,!0,t),v=e.input.charCodeAt(e.position),v===u)return e.position++,e.tag=o,e.anchor=l,e.kind=p?`mapping`:`sequence`,e.result=c,!0;n?v===44&&F(e,`expected the node content, but found ','`):F(e,`missed comma between flow collection entries`),g=h=_=null,d=f=!1,v===63&&T(e.input.charCodeAt(e.position+1))&&(d=f=!0,e.position++,q(e,!0,t)),r=e.line,i=e.lineStart,a=e.position,Q(e,t,s,!1,!0),g=e.tag,h=e.result,q(e,!0,t),v=e.input.charCodeAt(e.position),(f||e.line===r)&&v===58&&(d=!0,v=e.input.charCodeAt(++e.position),q(e,!0,t),Q(e,t,s,!1,!0),_=e.result),p?G(e,c,m,g,h,_,r,i,a):d?c.push(G(e,null,m,g,h,_,r,i,a)):c.push(h),q(e,!0,t),v=e.input.charCodeAt(e.position),v===44?(n=!0,v=e.input.charCodeAt(++e.position)):n=!1}F(e,`unexpected end of the stream within a flow collection`)}function Z(e,t){let r,i=m,a=!1,o=!1,s=t,c=0,l=!1,u,d=e.input.charCodeAt(e.position);if(d===124)r=!1;else if(d===62)r=!0;else return!1;for(e.kind=`scalar`,e.result=``;d!==0;)if(d=e.input.charCodeAt(++e.position),d===43||d===45)m===i?i=d===43?g:h:F(e,`repeat of a chomping mode identifier`);else if((u=k(d))>=0)u===0?F(e,`bad explicit indentation width of a block scalar; it cannot be less than one`):o?F(e,`repeat of an indentation width identifier`):(s=t+u-1,o=!0);else break;if(w(d)){do d=e.input.charCodeAt(++e.position);while(w(d));if(d===35)do d=e.input.charCodeAt(++e.position);while(!C(d)&&d!==0)}for(;d!==0;){for(K(e),e.lineIndent=0,d=e.input.charCodeAt(e.position);(!o||e.lineIndent<s)&&d===32;)e.lineIndent++,d=e.input.charCodeAt(++e.position);if(!o&&e.lineIndent>s&&(s=e.lineIndent),C(d)){c++;continue}if(!o&&s===0&&F(e,`missing indentation for block scalar`),e.lineIndent<s){i===g?e.result+=n.repeat(` | ||
| `,a?1+c:c):i===m&&a&&(e.result+=` | ||
| `);break}r?w(d)?(l=!0,e.result+=n.repeat(` | ||
| `,a?1+c:c)):l?(l=!1,e.result+=n.repeat(` | ||
| `,c+1)):c===0?a&&(e.result+=` `):e.result+=n.repeat(` | ||
| `,c):e.result+=n.repeat(` | ||
| `,a?1+c:c),a=!0,o=!0,c=0;let t=e.position;for(;!C(d)&&d!==0;)d=e.input.charCodeAt(++e.position);U(e,t,e.position,!1)}return!0}function se(e,t){let n=e.tag,r=e.anchor,i=[],a=!1;if(e.firstTabInLine!==-1)return!1;e.anchor!==null&&L(e,e.anchor,i);let o=e.input.charCodeAt(e.position);for(;o!==0&&(e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,F(e,`tab characters must not be used in indentation`)),!(o!==45||!T(e.input.charCodeAt(e.position+1))));){if(a=!0,e.position++,q(e,!0,-1)&&e.lineIndent<=t){i.push(null),o=e.input.charCodeAt(e.position);continue}let n=e.line;if(Q(e,t,l,!1,!0),i.push(e.result),q(e,!0,-1),o=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&o!==0)F(e,`bad indentation of a sequence entry`);else if(e.lineIndent<t)break}return a?(e.tag=n,e.anchor=r,e.kind=`sequence`,e.result=i,!0):!1}function ce(e,t,n){let r,i,a,o,s=e.tag,l=e.anchor,u={},d=Object.create(null),f=null,m=null,h=null,g=!1,_=!1;if(e.firstTabInLine!==-1)return!1;e.anchor!==null&&L(e,e.anchor,u);let v=e.input.charCodeAt(e.position);for(;v!==0;){!g&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,F(e,`tab characters must not be used in indentation`));let y=e.input.charCodeAt(e.position+1),b=e.line;if((v===63||v===58)&&T(y))v===63?(g&&(G(e,u,d,f,m,null,i,a,o),f=m=h=null),_=!0,g=!0,r=!0):g?(g=!1,r=!0):F(e,`incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line`),e.position+=1,v=y;else{if(i=e.line,a=e.lineStart,o=e.position,!Q(e,n,c,!1,!0))break;if(e.line===b){for(v=e.input.charCodeAt(e.position);w(v);)v=e.input.charCodeAt(++e.position);if(v===58)v=e.input.charCodeAt(++e.position),T(v)||F(e,`a whitespace character is expected after the key-value separator within a block mapping`),g&&(G(e,u,d,f,m,null,i,a,o),f=m=h=null),_=!0,g=!1,r=!1,f=e.tag,m=e.result;else if(_)F(e,`can not read an implicit mapping pair; a colon is missed`);else return e.tag=s,e.anchor=l,!0}else if(_)F(e,`can not read a block mapping entry; a multiline key may not be an implicit key`);else return e.tag=s,e.anchor=l,!0}if((e.line===b||e.lineIndent>t)&&(g&&(i=e.line,a=e.lineStart,o=e.position),Q(e,t,p,!0,r)&&(g?m=e.result:h=e.result),g||(G(e,u,d,f,m,h,i,a,o),f=m=h=null),q(e,!0,-1),v=e.input.charCodeAt(e.position)),(e.line===b||e.lineIndent>t)&&v!==0)F(e,`bad indentation of a mapping entry`);else if(e.lineIndent<t)break}return g&&G(e,u,d,f,m,null,i,a,o),_&&(e.tag=s,e.anchor=l,e.kind=`mapping`,e.result=u),_}function le(e){let t=!1,n=!1,r,i,a=e.input.charCodeAt(e.position);if(a!==33)return!1;e.tag!==null&&F(e,`duplication of a tag property`),a=e.input.charCodeAt(++e.position),a===60?(t=!0,a=e.input.charCodeAt(++e.position)):a===33?(n=!0,r=`!!`,a=e.input.charCodeAt(++e.position)):r=`!`;let s=e.position;if(t){do a=e.input.charCodeAt(++e.position);while(a!==0&&a!==62);e.position<e.length?(i=e.input.slice(s,e.position),a=e.input.charCodeAt(++e.position)):F(e,`unexpected end of the stream within a verbatim tag`)}else{for(;a!==0&&!T(a);)a===33&&(n?F(e,`tag suffix cannot contain exclamation marks`):(r=e.input.slice(s-1,e.position+1),b.test(r)||F(e,`named tag handle cannot contain such characters`),n=!0,s=e.position+1)),a=e.input.charCodeAt(++e.position);i=e.input.slice(s,e.position),y.test(i)&&F(e,`tag suffix cannot contain flow indicator characters`)}i&&!x.test(i)&&F(e,`tag name cannot contain such characters: `+i);try{i=decodeURIComponent(i)}catch(t){F(e,`tag name is malformed: `+i)}return t?e.tag=i:o.call(e.tagMap,r)?e.tag=e.tagMap[r]+i:r===`!`?e.tag=`!`+i:r===`!!`?e.tag=`tag:yaml.org,2002:`+i:F(e,`undeclared tag handle "`+r+`"`),!0}function ue(e){let t=e.input.charCodeAt(e.position);if(t!==38)return!1;e.anchor!==null&&F(e,`duplication of an anchor property`),t=e.input.charCodeAt(++e.position);let n=e.position;for(;t!==0&&!T(t)&&!E(t);)t=e.input.charCodeAt(++e.position);return e.position===n&&F(e,`name of an anchor node must contain at least one character`),e.anchor=e.input.slice(n,e.position),!0}function de(e){let t=e.input.charCodeAt(e.position);if(t!==42)return!1;t=e.input.charCodeAt(++e.position);let n=e.position;for(;t!==0&&!T(t)&&!E(t);)t=e.input.charCodeAt(++e.position);e.position===n&&F(e,`name of an alias node must contain at least one character`);let r=e.input.slice(n,e.position);return o.call(e.anchorMap,r)||F(e,`unidentified alias "`+r+`"`),e.result=e.anchorMap[r],q(e,!0,-1),!0}function fe(e,t,n,r){let i=B(e);return R(e),V(e,t),e.tag=null,e.anchor=null,e.kind=null,e.result=null,ce(e,n,r)&&e.kind===`mapping`?(re(e),!0):(z(e),V(e,i),!1)}function Q(e,t,n,r,i){let a,u,d=1,f=!1,m=!1,h=null,g,_,v;e.depth>=e.maxDepth&&F(e,`nesting exceeded maxDepth (`+e.maxDepth+`)`),e.depth+=1,e.listener!==null&&e.listener(`open`,e),e.tag=null,e.anchor=null,e.kind=null,e.result=null;let y=a=u=p===n||l===n;if(r&&q(e,!0,-1)&&(f=!0,e.lineIndent>t?d=1:e.lineIndent===t?d=0:e.lineIndent<t&&(d=-1)),d===1)for(;;){let n=e.input.charCodeAt(e.position),r=B(e);if(f&&(n===33&&e.tag!==null||n===38&&e.anchor!==null)||!le(e)&&!ue(e))break;h===null&&(h=r),q(e,!0,-1)?(f=!0,u=y,e.lineIndent>t?d=1:e.lineIndent===t?d=0:e.lineIndent<t&&(d=-1)):u=!1}if(u&&(u=f||i),d===1||p===n)if(_=s===n||c===n?t:t+1,v=e.position-e.lineStart,d===1)if(u&&(se(e,v)||ce(e,v,_))||oe(e,_))m=!0;else{let t=e.input.charCodeAt(e.position);h!==null&&y&&!u&&t!==124&&t!==62&&fe(e,h,h.position-h.lineStart,_)||a&&Z(e,_)||X(e,_)||ae(e,_)?m=!0:de(e)?(m=!0,(e.tag!==null||e.anchor!==null)&&F(e,`alias node should not have any properties`)):ie(e,_,s===n)&&(m=!0,e.tag===null&&(e.tag=`?`)),e.anchor!==null&&L(e,e.anchor,e.result)}else d===0&&(m=u&&se(e,v));if(e.tag===null)e.anchor!==null&&L(e,e.anchor,e.result);else if(e.tag===`?`){e.result!==null&&e.kind!==`scalar`&&F(e,`unacceptable node kind for !<?> tag; it should be "scalar", not "`+e.kind+`"`);for(let t=0,n=e.implicitTypes.length;t<n;t+=1)if(g=e.implicitTypes[t],g.resolve(e.result)){e.result=g.construct(e.result),e.tag=g.tag,e.anchor!==null&&L(e,e.anchor,e.result);break}}else if(e.tag!==`!`){if(o.call(e.typeMap[e.kind||`fallback`],e.tag))g=e.typeMap[e.kind||`fallback`][e.tag];else{g=null;let t=e.typeMap.multi[e.kind||`fallback`];for(let n=0,r=t.length;n<r;n+=1)if(e.tag.slice(0,t[n].tag.length)===t[n].tag){g=t[n];break}}g||F(e,`unknown tag !<`+e.tag+`>`),e.result!==null&&g.kind!==e.kind&&F(e,`unacceptable node kind for !<`+e.tag+`> tag; it should be "`+g.kind+`", not "`+e.kind+`"`),g.resolve(e.result,e.tag)?(e.result=g.construct(e.result,e.tag),e.anchor!==null&&L(e,e.anchor,e.result)):F(e,`cannot resolve a node with !<`+e.tag+`> explicit tag`)}return e.listener!==null&&e.listener(`close`,e),--e.depth,e.tag!==null||e.anchor!==null||m}function pe(e){let t=e.position,n=!1,r;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);(r=e.input.charCodeAt(e.position))!==0&&(q(e,!0,-1),r=e.input.charCodeAt(e.position),!(e.lineIndent>0||r!==37));){n=!0,r=e.input.charCodeAt(++e.position);let t=e.position;for(;r!==0&&!T(r);)r=e.input.charCodeAt(++e.position);let i=e.input.slice(t,e.position),a=[];for(i.length<1&&F(e,`directive name must not be less than one character in length`);r!==0;){for(;w(r);)r=e.input.charCodeAt(++e.position);if(r===35){do r=e.input.charCodeAt(++e.position);while(r!==0&&!C(r));break}if(C(r))break;for(t=e.position;r!==0&&!T(r);)r=e.input.charCodeAt(++e.position);a.push(e.input.slice(t,e.position))}r!==0&&K(e),o.call(H,i)?H[i](e,i,a):I(e,`unknown document directive "`+i+`"`)}if(q(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,q(e,!0,-1)):n&&F(e,`directives end mark is expected`),Q(e,e.lineIndent-1,p,!1,!0),q(e,!0,-1),e.checkLineBreaks&&v.test(e.input.slice(t,e.position))&&I(e,`non-ASCII line breaks are interpreted as content`),e.documents.push(e.result),e.position===e.lineStart&&J(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,q(e,!0,-1));return}e.position<e.length-1&&F(e,`end of the stream or a document separator is expected`)}function me(e,t){e=String(e),t=t||{},e.length!==0&&(e.charCodeAt(e.length-1)!==10&&e.charCodeAt(e.length-1)!==13&&(e+=` | ||
| `),e.charCodeAt(0)===65279&&(e=e.slice(1)));let n=new ne(e,t),r=e.indexOf(`\0`);for(r!==-1&&(n.position=r,F(n,`null byte is not allowed in input`)),n.input+=`\0`;n.input.charCodeAt(n.position)===32;)n.lineIndent+=1,n.position+=1;for(;n.position<n.length-1;)pe(n);return n.documents}function he(e,t,n){typeof t==`object`&&t&&n===void 0&&(n=t,t=null);let r=me(e,n);if(typeof t!=`function`)return r;for(let e=0,n=r.length;e<n;e+=1)t(r[e])}function ge(e,t){let n=me(e,t);if(n.length!==0){if(n.length===1)return n[0];throw new r(`expected a single document in the stream, but found more`)}}t.exports.loadAll=he,t.exports.load=ge})),te=s(((e,t)=>{var n=u(),r=d(),i=ee(),a=Object.prototype.toString,o=Object.prototype.hasOwnProperty,s=65279,c=9,l=10,f=13,p=32,m=33,h=34,g=35,_=37,v=38,y=39,b=42,x=44,S=45,C=58,w=61,T=62,E=63,D=64,O=91,k=93,A=96,j=123,te=124,M=125,N={};N[0]=`\\0`,N[7]=`\\a`,N[8]=`\\b`,N[9]=`\\t`,N[10]=`\\n`,N[11]=`\\v`,N[12]=`\\f`,N[13]=`\\r`,N[27]=`\\e`,N[34]=`\\"`,N[92]=`\\\\`,N[133]=`\\N`,N[160]=`\\_`,N[8232]=`\\L`,N[8233]=`\\P`;var ne=[`y`,`Y`,`yes`,`Yes`,`YES`,`on`,`On`,`ON`,`n`,`N`,`no`,`No`,`NO`,`off`,`Off`,`OFF`],P=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function F(e,t){if(t===null)return{};let n={},r=Object.keys(t);for(let i=0,a=r.length;i<a;i+=1){let a=r[i],s=String(t[a]);a.slice(0,2)===`!!`&&(a=`tag:yaml.org,2002:`+a.slice(2));let c=e.compiledTypeMap.fallback[a];c&&o.call(c.styleAliases,s)&&(s=c.styleAliases[s]),n[a]=s}return n}function I(e){let t,i,a=e.toString(16).toUpperCase();if(e<=255)t=`x`,i=2;else if(e<=65535)t=`u`,i=4;else if(e<=4294967295)t=`U`,i=8;else throw new r(`code point within a string may not be greater than 0xFFFFFFFF`);return`\\`+t+n.repeat(`0`,i-a.length)+a}var L=1,R=2;function re(e){this.schema=e.schema||i,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=n.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=F(this.schema,e.styles||null),this.sortKeys=e.sortKeys||!1,this.lineWidth=e.lineWidth||80,this.noRefs=e.noRefs||!1,this.noCompatMode=e.noCompatMode||!1,this.condenseFlow=e.condenseFlow||!1,this.quotingType=e.quotingType===`"`?R:L,this.forceQuotes=e.forceQuotes||!1,this.replacer=typeof e.replacer==`function`?e.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result=``,this.duplicates=[],this.usedDuplicates=null}function z(e,t){let r=n.repeat(` `,t),i=0,a=``,o=e.length;for(;i<o;){let t,n=e.indexOf(` | ||
| `,i);n===-1?(t=e.slice(i),i=o):(t=e.slice(i,n+1),i=n+1),t.length&&t!==` | ||
| `&&(a+=r),a+=t}return a}function B(e,t){return` | ||
| `+n.repeat(` `,e.indent*t)}function V(e,t){for(let n=0,r=e.implicitTypes.length;n<r;n+=1)if(e.implicitTypes[n].resolve(t))return!0;return!1}function H(e){return e===p||e===c}function U(e){return e>=32&&e<=126||e>=161&&e<=55295&&e!==8232&&e!==8233||e>=57344&&e<=65533&&e!==s||e>=65536&&e<=1114111}function W(e){return U(e)&&e!==s&&e!==f&&e!==l}function G(e,t,n){let r=W(e),i=r&&!H(e);return(n?r:r&&e!==x&&e!==O&&e!==k&&e!==j&&e!==M)&&e!==g&&!(t===C&&!i)||W(t)&&!H(t)&&e===g||t===C&&i}function K(e){return U(e)&&e!==s&&!H(e)&&e!==S&&e!==E&&e!==C&&e!==x&&e!==O&&e!==k&&e!==j&&e!==M&&e!==g&&e!==v&&e!==b&&e!==m&&e!==te&&e!==w&&e!==T&&e!==y&&e!==h&&e!==_&&e!==D&&e!==A}function q(e){return!H(e)&&e!==C}function J(e,t){let n=e.charCodeAt(t),r;return n>=55296&&n<=56319&&t+1<e.length&&(r=e.charCodeAt(t+1),r>=56320&&r<=57343)?(n-55296)*1024+r-56320+65536:n}function Y(e){return/^\n* /.test(e)}var ie=1,X=2,ae=3,oe=4,Z=5;function se(e,t,n,r,i,a,o,s){let c,u=0,d=null,f=!1,p=!1,m=r!==-1,h=-1,g=K(J(e,0))&&q(J(e,e.length-1));if(t||o)for(c=0;c<e.length;u>=65536?c+=2:c++){if(u=J(e,c),!U(u))return Z;g=g&&G(u,d,s),d=u}else{for(c=0;c<e.length;u>=65536?c+=2:c++){if(u=J(e,c),u===l)f=!0,m&&(p=p||c-h-1>r&&e[h+1]!==` `,h=c);else if(!U(u))return Z;g=g&&G(u,d,s),d=u}p=p||m&&c-h-1>r&&e[h+1]!==` `}return!f&&!p?g&&!o&&!i(e)?ie:a===R?Z:X:n>9&&Y(e)?Z:o?a===R?Z:X:p?oe:ae}function ce(e,t,n,i,a){e.dump=function(){if(t.length===0)return e.quotingType===R?`""`:`''`;if(!e.noCompatMode&&(ne.indexOf(t)!==-1||P.test(t)))return e.quotingType===R?`"`+t+`"`:`'`+t+`'`;let o=e.indent*Math.max(1,n),s=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-o),c=i||e.flowLevel>-1&&n>=e.flowLevel;function l(t){return V(e,t)}switch(se(t,c,e.indent,s,l,e.quotingType,e.forceQuotes&&!i,a)){case ie:return t;case X:return`'`+t.replace(/'/g,`''`)+`'`;case ae:return`|`+le(t,e.indent)+ue(z(t,o));case oe:return`>`+le(t,e.indent)+ue(z(de(t,s),o));case Z:return`"`+Q(t,s)+`"`;default:throw new r(`impossible error: invalid scalar style`)}}()}function le(e,t){let n=Y(e)?String(t):``,r=e[e.length-1]===` | ||
| `;return n+(r&&(e[e.length-2]===` | ||
| `||e===` | ||
| `)?`+`:r?``:`-`)+` | ||
| `}function ue(e){return e[e.length-1]===` | ||
| `?e.slice(0,-1):e}function de(e,t){let n=/(\n+)([^\n]*)/g,r=function(){let r=e.indexOf(` | ||
| `);return r=r===-1?e.length:r,n.lastIndex=r,fe(e.slice(0,r),t)}(),i=e[0]===` | ||
| `||e[0]===` `,a,o;for(;o=n.exec(e);){let e=o[1],n=o[2];a=n[0]===` `,r+=e+(!i&&!a&&n!==``?` | ||
| `:``)+fe(n,t),i=a}return r}function fe(e,t){if(e===``||e[0]===` `)return e;let n=/ [^ ]/g,r,i=0,a,o=0,s=0,c=``;for(;r=n.exec(e);)s=r.index,s-i>t&&(a=o>i?o:s,c+=` | ||
| `+e.slice(i,a),i=a+1),o=s;return c+=` | ||
| `,e.length-i>t&&o>i?c+=e.slice(i,o)+` | ||
| `+e.slice(o+1):c+=e.slice(i),c.slice(1)}function Q(e){let t=``,n=0;for(let r=0;r<e.length;n>=65536?r+=2:r++){n=J(e,r);let i=N[n];!i&&U(n)?(t+=e[r],n>=65536&&(t+=e[r+1])):t+=i||I(n)}return t}function pe(e,t,n){let r=``,i=e.tag;for(let i=0,a=n.length;i<a;i+=1){let a=n[i];e.replacer&&(a=e.replacer.call(n,String(i),a)),($(e,t,a,!1,!1)||a===void 0&&$(e,t,null,!1,!1))&&(r!==``&&(r+=`,`+(e.condenseFlow?``:` `)),r+=e.dump)}e.tag=i,e.dump=`[`+r+`]`}function me(e,t,n,r){let i=``,a=e.tag;for(let a=0,o=n.length;a<o;a+=1){let o=n[a];e.replacer&&(o=e.replacer.call(n,String(a),o)),($(e,t+1,o,!0,!0,!1,!0)||o===void 0&&$(e,t+1,null,!0,!0,!1,!0))&&((!r||i!==``)&&(i+=B(e,t)),e.dump&&l===e.dump.charCodeAt(0)?i+=`-`:i+=`- `,i+=e.dump)}e.tag=a,e.dump=i||`[]`}function he(e,t,n){let r=``,i=e.tag,a=Object.keys(n);for(let i=0,o=a.length;i<o;i+=1){let o=``;r!==``&&(o+=`, `),e.condenseFlow&&(o+=`"`);let s=a[i],c=n[s];e.replacer&&(c=e.replacer.call(n,s,c)),$(e,t,s,!1,!1)&&(e.dump.length>1024&&(o+=`? `),o+=e.dump+(e.condenseFlow?`"`:``)+`:`+(e.condenseFlow?``:` `),$(e,t,c,!1,!1)&&(o+=e.dump,r+=o))}e.tag=i,e.dump=`{`+r+`}`}function ge(e,t,n,i){let a=``,o=e.tag,s=Object.keys(n);if(e.sortKeys===!0)s.sort();else if(typeof e.sortKeys==`function`)s.sort(e.sortKeys);else if(e.sortKeys)throw new r(`sortKeys must be a boolean or a function`);for(let r=0,o=s.length;r<o;r+=1){let o=``;(!i||a!==``)&&(o+=B(e,t));let c=s[r],u=n[c];if(e.replacer&&(u=e.replacer.call(n,c,u)),!$(e,t+1,c,!0,!0,!0))continue;let d=e.tag!==null&&e.tag!==`?`||e.dump&&e.dump.length>1024;d&&(e.dump&&l===e.dump.charCodeAt(0)?o+=`?`:o+=`? `),o+=e.dump,d&&(o+=B(e,t)),$(e,t+1,u,!0,d)&&(e.dump&&l===e.dump.charCodeAt(0)?o+=`:`:o+=`: `,o+=e.dump,a+=o)}e.tag=o,e.dump=a||`{}`}function _e(e,t,n){let i=n?e.explicitTypes:e.implicitTypes;for(let s=0,c=i.length;s<c;s+=1){let c=i[s];if((c.instanceOf||c.predicate)&&(!c.instanceOf||typeof t==`object`&&t instanceof c.instanceOf)&&(!c.predicate||c.predicate(t))){if(n?c.multi&&c.representName?e.tag=c.representName(t):e.tag=c.tag:e.tag=`?`,c.represent){let n=e.styleMap[c.tag]||c.defaultStyle,i;if(a.call(c.represent)===`[object Function]`)i=c.represent(t,n);else if(o.call(c.represent,n))i=c.represent[n](t,n);else throw new r(`!<`+c.tag+`> tag resolver accepts not "`+n+`" style`);e.dump=i}return!0}}return!1}function $(e,t,n,i,o,s,c){e.tag=null,e.dump=n,_e(e,n,!1)||_e(e,n,!0);let l=a.call(e.dump),u=i;i&&(i=e.flowLevel<0||e.flowLevel>t);let d=l===`[object Object]`||l===`[object Array]`,f,p;if(d&&(f=e.duplicates.indexOf(n),p=f!==-1),(e.tag!==null&&e.tag!==`?`||p||e.indent!==2&&t>0)&&(o=!1),p&&e.usedDuplicates[f])e.dump=`*ref_`+f;else{if(d&&p&&!e.usedDuplicates[f]&&(e.usedDuplicates[f]=!0),l===`[object Object]`)i&&Object.keys(e.dump).length!==0?(ge(e,t,e.dump,o),p&&(e.dump=`&ref_`+f+e.dump)):(he(e,t,e.dump),p&&(e.dump=`&ref_`+f+` `+e.dump));else if(l===`[object Array]`)i&&e.dump.length!==0?(e.noArrayIndent&&!c&&t>0?me(e,t-1,e.dump,o):me(e,t,e.dump,o),p&&(e.dump=`&ref_`+f+e.dump)):(pe(e,t,e.dump),p&&(e.dump=`&ref_`+f+` `+e.dump));else if(l===`[object String]`)e.tag!==`?`&&ce(e,e.dump,t,s,u);else if(l===`[object Undefined]`)return!1;else{if(e.skipInvalid)return!1;throw new r(`unacceptable kind of an object to dump `+l)}if(e.tag!==null&&e.tag!==`?`){let t=encodeURI(e.tag[0]===`!`?e.tag.slice(1):e.tag).replace(/!/g,`%21`);t=e.tag[0]===`!`?`!`+t:t.slice(0,18)===`tag:yaml.org,2002:`?`!!`+t.slice(18):`!<`+t+`>`,e.dump=t+` `+e.dump}}return!0}function ve(e,t){let n=[],r=[];ye(e,n,r);let i=r.length;for(let e=0;e<i;e+=1)t.duplicates.push(n[r[e]]);t.usedDuplicates=Array(i)}function ye(e,t,n){if(typeof e==`object`&&e){let r=t.indexOf(e);if(r!==-1)n.indexOf(r)===-1&&n.push(r);else if(t.push(e),Array.isArray(e))for(let r=0,i=e.length;r<i;r+=1)ye(e[r],t,n);else{let r=Object.keys(e);for(let i=0,a=r.length;i<a;i+=1)ye(e[r[i]],t,n)}}}function be(e,t){t=t||{};let n=new re(t);n.noRefs||ve(e,n);let r=e;return n.replacer&&(r=n.replacer.call({"":r},``,r)),$(n,0,r,!0,!0)?n.dump+` | ||
| `:``}t.exports.dump=be})),M=l(s(((e,t)=>{var n=j(),r=te();function i(e,t){return function(){throw Error(`Function yaml.`+e+` is removed in js-yaml 4. Use yaml.`+t+` instead, which is now safe by default.`)}}t.exports.Type=p(),t.exports.Schema=m(),t.exports.FAILSAFE_SCHEMA=v(),t.exports.JSON_SCHEMA=C(),t.exports.CORE_SCHEMA=w(),t.exports.DEFAULT_SCHEMA=ee(),t.exports.load=n.load,t.exports.loadAll=n.loadAll,t.exports.dump=r.dump,t.exports.YAMLException=d(),t.exports.types={binary:D(),float:S(),map:_(),null:y(),pairs:k(),set:A(),timestamp:T(),bool:b(),int:x(),merge:E(),omap:O(),seq:g(),str:h()},t.exports.safeLoad=i(`safeLoad`,`load`),t.exports.safeLoadAll=i(`safeLoadAll`,`loadAll`),t.exports.safeDump=i(`safeDump`,`dump`)}))(),1),{Type:N,Schema:ne,FAILSAFE_SCHEMA:P,JSON_SCHEMA:F,CORE_SCHEMA:I,DEFAULT_SCHEMA:L,load:R,loadAll:re,dump:z,YAMLException:B,types:V,safeLoad:H,safeLoadAll:U,safeDump:W}=M.default,G=M.default;e.CORE_SCHEMA=I,e.DEFAULT_SCHEMA=L,e.FAILSAFE_SCHEMA=P,e.JSON_SCHEMA=F,e.Schema=ne,e.Type=N,e.YAMLException=B,e.default=G,e.dump=z,e.load=R,e.loadAll=re,e.safeDump=W,e.safeLoad=H,e.safeLoadAll=U,e.types=V}); | ||
| //# sourceMappingURL=js-yaml.min.js.map |
Sorry, the diff of this file is too big to display
-44
| 'use strict' | ||
| const loader = require('./lib/loader') | ||
| const dumper = require('./lib/dumper') | ||
| function renamed (from, to) { | ||
| return function () { | ||
| throw new Error('Function yaml.' + from + ' is removed in js-yaml 4. ' + | ||
| 'Use yaml.' + to + ' instead, which is now safe by default.') | ||
| } | ||
| } | ||
| module.exports.Type = require('./lib/type') | ||
| module.exports.Schema = require('./lib/schema') | ||
| module.exports.FAILSAFE_SCHEMA = require('./lib/schema/failsafe') | ||
| module.exports.JSON_SCHEMA = require('./lib/schema/json') | ||
| module.exports.CORE_SCHEMA = require('./lib/schema/core') | ||
| module.exports.DEFAULT_SCHEMA = require('./lib/schema/default') | ||
| module.exports.load = loader.load | ||
| module.exports.loadAll = loader.loadAll | ||
| module.exports.dump = dumper.dump | ||
| module.exports.YAMLException = require('./lib/exception') | ||
| // Re-export all types in case user wants to create custom schema | ||
| module.exports.types = { | ||
| binary: require('./lib/type/binary'), | ||
| float: require('./lib/type/float'), | ||
| map: require('./lib/type/map'), | ||
| null: require('./lib/type/null'), | ||
| pairs: require('./lib/type/pairs'), | ||
| set: require('./lib/type/set'), | ||
| timestamp: require('./lib/type/timestamp'), | ||
| bool: require('./lib/type/bool'), | ||
| int: require('./lib/type/int'), | ||
| merge: require('./lib/type/merge'), | ||
| omap: require('./lib/type/omap'), | ||
| seq: require('./lib/type/seq'), | ||
| str: require('./lib/type/str') | ||
| } | ||
| // Removed functions from JS-YAML 3.0.x | ||
| module.exports.safeLoad = renamed('safeLoad', 'load') | ||
| module.exports.safeLoadAll = renamed('safeLoadAll', 'loadAll') | ||
| module.exports.safeDump = renamed('safeDump', 'dump') |
| 'use strict' | ||
| function isNothing (subject) { | ||
| return (typeof subject === 'undefined') || (subject === null) | ||
| } | ||
| function isObject (subject) { | ||
| return (typeof subject === 'object') && (subject !== null) | ||
| } | ||
| function toArray (sequence) { | ||
| if (Array.isArray(sequence)) return sequence | ||
| else if (isNothing(sequence)) return [] | ||
| return [sequence] | ||
| } | ||
| function extend (target, source) { | ||
| if (source) { | ||
| const sourceKeys = Object.keys(source) | ||
| for (let index = 0, length = sourceKeys.length; index < length; index += 1) { | ||
| const key = sourceKeys[index] | ||
| target[key] = source[key] | ||
| } | ||
| } | ||
| return target | ||
| } | ||
| function repeat (string, count) { | ||
| let result = '' | ||
| for (let cycle = 0; cycle < count; cycle += 1) { | ||
| result += string | ||
| } | ||
| return result | ||
| } | ||
| function isNegativeZero (number) { | ||
| return (number === 0) && (Number.NEGATIVE_INFINITY === 1 / number) | ||
| } | ||
| module.exports.isNothing = isNothing | ||
| module.exports.isObject = isObject | ||
| module.exports.toArray = toArray | ||
| module.exports.repeat = repeat | ||
| module.exports.isNegativeZero = isNegativeZero | ||
| module.exports.extend = extend |
-937
| 'use strict' | ||
| const common = require('./common') | ||
| const YAMLException = require('./exception') | ||
| const DEFAULT_SCHEMA = require('./schema/default') | ||
| const _toString = Object.prototype.toString | ||
| const _hasOwnProperty = Object.prototype.hasOwnProperty | ||
| const CHAR_BOM = 0xFEFF | ||
| const CHAR_TAB = 0x09 /* Tab */ | ||
| const CHAR_LINE_FEED = 0x0A /* LF */ | ||
| const CHAR_CARRIAGE_RETURN = 0x0D /* CR */ | ||
| const CHAR_SPACE = 0x20 /* Space */ | ||
| const CHAR_EXCLAMATION = 0x21 /* ! */ | ||
| const CHAR_DOUBLE_QUOTE = 0x22 /* " */ | ||
| const CHAR_SHARP = 0x23 /* # */ | ||
| const CHAR_PERCENT = 0x25 /* % */ | ||
| const CHAR_AMPERSAND = 0x26 /* & */ | ||
| const CHAR_SINGLE_QUOTE = 0x27 /* ' */ | ||
| const CHAR_ASTERISK = 0x2A /* * */ | ||
| const CHAR_COMMA = 0x2C /* , */ | ||
| const CHAR_MINUS = 0x2D /* - */ | ||
| const CHAR_COLON = 0x3A /* : */ | ||
| const CHAR_EQUALS = 0x3D /* = */ | ||
| const CHAR_GREATER_THAN = 0x3E /* > */ | ||
| const CHAR_QUESTION = 0x3F /* ? */ | ||
| const CHAR_COMMERCIAL_AT = 0x40 /* @ */ | ||
| const CHAR_LEFT_SQUARE_BRACKET = 0x5B /* [ */ | ||
| const CHAR_RIGHT_SQUARE_BRACKET = 0x5D /* ] */ | ||
| const CHAR_GRAVE_ACCENT = 0x60 /* ` */ | ||
| const CHAR_LEFT_CURLY_BRACKET = 0x7B /* { */ | ||
| const CHAR_VERTICAL_LINE = 0x7C /* | */ | ||
| const CHAR_RIGHT_CURLY_BRACKET = 0x7D /* } */ | ||
| const ESCAPE_SEQUENCES = {} | ||
| ESCAPE_SEQUENCES[0x00] = '\\0' | ||
| ESCAPE_SEQUENCES[0x07] = '\\a' | ||
| ESCAPE_SEQUENCES[0x08] = '\\b' | ||
| ESCAPE_SEQUENCES[0x09] = '\\t' | ||
| ESCAPE_SEQUENCES[0x0A] = '\\n' | ||
| ESCAPE_SEQUENCES[0x0B] = '\\v' | ||
| ESCAPE_SEQUENCES[0x0C] = '\\f' | ||
| ESCAPE_SEQUENCES[0x0D] = '\\r' | ||
| ESCAPE_SEQUENCES[0x1B] = '\\e' | ||
| ESCAPE_SEQUENCES[0x22] = '\\"' | ||
| ESCAPE_SEQUENCES[0x5C] = '\\\\' | ||
| ESCAPE_SEQUENCES[0x85] = '\\N' | ||
| ESCAPE_SEQUENCES[0xA0] = '\\_' | ||
| ESCAPE_SEQUENCES[0x2028] = '\\L' | ||
| ESCAPE_SEQUENCES[0x2029] = '\\P' | ||
| const DEPRECATED_BOOLEANS_SYNTAX = [ | ||
| 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON', | ||
| 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF' | ||
| ] | ||
| const DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/ | ||
| function compileStyleMap (schema, map) { | ||
| if (map === null) return {} | ||
| const result = {} | ||
| const keys = Object.keys(map) | ||
| for (let index = 0, length = keys.length; index < length; index += 1) { | ||
| let tag = keys[index] | ||
| let style = String(map[tag]) | ||
| if (tag.slice(0, 2) === '!!') { | ||
| tag = 'tag:yaml.org,2002:' + tag.slice(2) | ||
| } | ||
| const type = schema.compiledTypeMap['fallback'][tag] | ||
| if (type && _hasOwnProperty.call(type.styleAliases, style)) { | ||
| style = type.styleAliases[style] | ||
| } | ||
| result[tag] = style | ||
| } | ||
| return result | ||
| } | ||
| function encodeHex (character) { | ||
| let handle | ||
| let length | ||
| const string = character.toString(16).toUpperCase() | ||
| if (character <= 0xFF) { | ||
| handle = 'x' | ||
| length = 2 | ||
| } else if (character <= 0xFFFF) { | ||
| handle = 'u' | ||
| length = 4 | ||
| } else if (character <= 0xFFFFFFFF) { | ||
| handle = 'U' | ||
| length = 8 | ||
| } else { | ||
| throw new YAMLException('code point within a string may not be greater than 0xFFFFFFFF') | ||
| } | ||
| return '\\' + handle + common.repeat('0', length - string.length) + string | ||
| } | ||
| const QUOTING_TYPE_SINGLE = 1 | ||
| const QUOTING_TYPE_DOUBLE = 2 | ||
| function State (options) { | ||
| this.schema = options['schema'] || DEFAULT_SCHEMA | ||
| this.indent = Math.max(1, (options['indent'] || 2)) | ||
| this.noArrayIndent = options['noArrayIndent'] || false | ||
| this.skipInvalid = options['skipInvalid'] || false | ||
| this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']) | ||
| this.styleMap = compileStyleMap(this.schema, options['styles'] || null) | ||
| this.sortKeys = options['sortKeys'] || false | ||
| this.lineWidth = options['lineWidth'] || 80 | ||
| this.noRefs = options['noRefs'] || false | ||
| this.noCompatMode = options['noCompatMode'] || false | ||
| this.condenseFlow = options['condenseFlow'] || false | ||
| this.quotingType = options['quotingType'] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE | ||
| this.forceQuotes = options['forceQuotes'] || false | ||
| this.replacer = typeof options['replacer'] === 'function' ? options['replacer'] : null | ||
| this.implicitTypes = this.schema.compiledImplicit | ||
| this.explicitTypes = this.schema.compiledExplicit | ||
| this.tag = null | ||
| this.result = '' | ||
| this.duplicates = [] | ||
| this.usedDuplicates = null | ||
| } | ||
| // Indents every line in a string. Empty lines (\n only) are not indented. | ||
| function indentString (string, spaces) { | ||
| const ind = common.repeat(' ', spaces) | ||
| let position = 0 | ||
| let result = '' | ||
| const length = string.length | ||
| while (position < length) { | ||
| let line | ||
| const next = string.indexOf('\n', position) | ||
| if (next === -1) { | ||
| line = string.slice(position) | ||
| position = length | ||
| } else { | ||
| line = string.slice(position, next + 1) | ||
| position = next + 1 | ||
| } | ||
| if (line.length && line !== '\n') result += ind | ||
| result += line | ||
| } | ||
| return result | ||
| } | ||
| function generateNextLine (state, level) { | ||
| return '\n' + common.repeat(' ', state.indent * level) | ||
| } | ||
| function testImplicitResolving (state, str) { | ||
| for (let index = 0, length = state.implicitTypes.length; index < length; index += 1) { | ||
| const type = state.implicitTypes[index] | ||
| if (type.resolve(str)) { | ||
| return true | ||
| } | ||
| } | ||
| return false | ||
| } | ||
| // [33] s-white ::= s-space | s-tab | ||
| function isWhitespace (c) { | ||
| return c === CHAR_SPACE || c === CHAR_TAB | ||
| } | ||
| // Returns true if the character can be printed without escaping. | ||
| // From YAML 1.2: "any allowed characters known to be non-printable | ||
| // should also be escaped. [However,] This isn’t mandatory" | ||
| // Derived from nb-char - \t - #x85 - #xA0 - #x2028 - #x2029. | ||
| function isPrintable (c) { | ||
| return (c >= 0x00020 && c <= 0x00007E) || | ||
| ((c >= 0x000A1 && c <= 0x00D7FF) && c !== 0x2028 && c !== 0x2029) || | ||
| ((c >= 0x0E000 && c <= 0x00FFFD) && c !== CHAR_BOM) || | ||
| (c >= 0x10000 && c <= 0x10FFFF) | ||
| } | ||
| // [34] ns-char ::= nb-char - s-white | ||
| // [27] nb-char ::= c-printable - b-char - c-byte-order-mark | ||
| // [26] b-char ::= b-line-feed | b-carriage-return | ||
| // Including s-white (for some reason, examples doesn't match specs in this aspect) | ||
| // ns-char ::= c-printable - b-line-feed - b-carriage-return - c-byte-order-mark | ||
| function isNsCharOrWhitespace (c) { | ||
| return isPrintable(c) && | ||
| c !== CHAR_BOM && | ||
| // - b-char | ||
| c !== CHAR_CARRIAGE_RETURN && | ||
| c !== CHAR_LINE_FEED | ||
| } | ||
| // [127] ns-plain-safe(c) ::= c = flow-out ⇒ ns-plain-safe-out | ||
| // c = flow-in ⇒ ns-plain-safe-in | ||
| // c = block-key ⇒ ns-plain-safe-out | ||
| // c = flow-key ⇒ ns-plain-safe-in | ||
| // [128] ns-plain-safe-out ::= ns-char | ||
| // [129] ns-plain-safe-in ::= ns-char - c-flow-indicator | ||
| // [130] ns-plain-char(c) ::= ( ns-plain-safe(c) - “:” - “#” ) | ||
| // | ( /* An ns-char preceding */ “#” ) | ||
| // | ( “:” /* Followed by an ns-plain-safe(c) */ ) | ||
| function isPlainSafe (c, prev, inblock) { | ||
| const cIsNsCharOrWhitespace = isNsCharOrWhitespace(c) | ||
| const cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c) | ||
| return ( | ||
| ( | ||
| // ns-plain-safe | ||
| inblock // c = flow-in | ||
| ? cIsNsCharOrWhitespace | ||
| : cIsNsCharOrWhitespace && | ||
| // - c-flow-indicator | ||
| c !== CHAR_COMMA && | ||
| c !== CHAR_LEFT_SQUARE_BRACKET && | ||
| c !== CHAR_RIGHT_SQUARE_BRACKET && | ||
| c !== CHAR_LEFT_CURLY_BRACKET && | ||
| c !== CHAR_RIGHT_CURLY_BRACKET | ||
| ) && | ||
| // ns-plain-char | ||
| c !== CHAR_SHARP && // false on '#' | ||
| !(prev === CHAR_COLON && !cIsNsChar) | ||
| ) || // false on ': ' | ||
| (isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP) || // change to true on '[^ ]#' | ||
| (prev === CHAR_COLON && cIsNsChar) // change to true on ':[^ ]' | ||
| } | ||
| // Simplified test for values allowed as the first character in plain style. | ||
| function isPlainSafeFirst (c) { | ||
| // Uses a subset of ns-char - c-indicator | ||
| // where ns-char = nb-char - s-white. | ||
| // No support of ( ( “?” | “:” | “-” ) /* Followed by an ns-plain-safe(c)) */ ) part | ||
| return isPrintable(c) && | ||
| c !== CHAR_BOM && | ||
| !isWhitespace(c) && // - s-white | ||
| // - (c-indicator ::= | ||
| // “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}” | ||
| c !== CHAR_MINUS && | ||
| c !== CHAR_QUESTION && | ||
| c !== CHAR_COLON && | ||
| c !== CHAR_COMMA && | ||
| c !== CHAR_LEFT_SQUARE_BRACKET && | ||
| c !== CHAR_RIGHT_SQUARE_BRACKET && | ||
| c !== CHAR_LEFT_CURLY_BRACKET && | ||
| c !== CHAR_RIGHT_CURLY_BRACKET && | ||
| // | “#” | “&” | “*” | “!” | “|” | “=” | “>” | “'” | “"” | ||
| c !== CHAR_SHARP && | ||
| c !== CHAR_AMPERSAND && | ||
| c !== CHAR_ASTERISK && | ||
| c !== CHAR_EXCLAMATION && | ||
| c !== CHAR_VERTICAL_LINE && | ||
| c !== CHAR_EQUALS && | ||
| c !== CHAR_GREATER_THAN && | ||
| c !== CHAR_SINGLE_QUOTE && | ||
| c !== CHAR_DOUBLE_QUOTE && | ||
| // | “%” | “@” | “`”) | ||
| c !== CHAR_PERCENT && | ||
| c !== CHAR_COMMERCIAL_AT && | ||
| c !== CHAR_GRAVE_ACCENT | ||
| } | ||
| // Simplified test for values allowed as the last character in plain style. | ||
| function isPlainSafeLast (c) { | ||
| // just not whitespace or colon, it will be checked to be plain character later | ||
| return !isWhitespace(c) && c !== CHAR_COLON | ||
| } | ||
| // Same as 'string'.codePointAt(pos), but works in older browsers. | ||
| function codePointAt (string, pos) { | ||
| const first = string.charCodeAt(pos) | ||
| let second | ||
| if (first >= 0xD800 && first <= 0xDBFF && pos + 1 < string.length) { | ||
| second = string.charCodeAt(pos + 1) | ||
| if (second >= 0xDC00 && second <= 0xDFFF) { | ||
| // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae | ||
| return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000 | ||
| } | ||
| } | ||
| return first | ||
| } | ||
| // Determines whether block indentation indicator is required. | ||
| function needIndentIndicator (string) { | ||
| const leadingSpaceRe = /^\n* / | ||
| return leadingSpaceRe.test(string) | ||
| } | ||
| const STYLE_PLAIN = 1 | ||
| const STYLE_SINGLE = 2 | ||
| const STYLE_LITERAL = 3 | ||
| const STYLE_FOLDED = 4 | ||
| const STYLE_DOUBLE = 5 | ||
| // Determines which scalar styles are possible and returns the preferred style. | ||
| // lineWidth = -1 => no limit. | ||
| // Pre-conditions: str.length > 0. | ||
| // Post-conditions: | ||
| // STYLE_PLAIN or STYLE_SINGLE => no \n are in the string. | ||
| // STYLE_LITERAL => no lines are suitable for folding (or lineWidth is -1). | ||
| // STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1). | ||
| function chooseScalarStyle (string, singleLineOnly, indentPerLevel, lineWidth, | ||
| testAmbiguousType, quotingType, forceQuotes, inblock) { | ||
| let i | ||
| let char = 0 | ||
| let prevChar = null | ||
| let hasLineBreak = false | ||
| let hasFoldableLine = false // only checked if shouldTrackWidth | ||
| const shouldTrackWidth = lineWidth !== -1 | ||
| let previousLineBreak = -1 // count the first line correctly | ||
| let plain = isPlainSafeFirst(codePointAt(string, 0)) && | ||
| isPlainSafeLast(codePointAt(string, string.length - 1)) | ||
| if (singleLineOnly || forceQuotes) { | ||
| // Case: no block styles. | ||
| // Check for disallowed characters to rule out plain and single. | ||
| for (i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { | ||
| char = codePointAt(string, i) | ||
| if (!isPrintable(char)) { | ||
| return STYLE_DOUBLE | ||
| } | ||
| plain = plain && isPlainSafe(char, prevChar, inblock) | ||
| prevChar = char | ||
| } | ||
| } else { | ||
| // Case: block styles permitted. | ||
| for (i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { | ||
| char = codePointAt(string, i) | ||
| if (char === CHAR_LINE_FEED) { | ||
| hasLineBreak = true | ||
| // Check if any line can be folded. | ||
| if (shouldTrackWidth) { | ||
| hasFoldableLine = hasFoldableLine || | ||
| // Foldable line = too long, and not more-indented. | ||
| (i - previousLineBreak - 1 > lineWidth && | ||
| string[previousLineBreak + 1] !== ' ') | ||
| previousLineBreak = i | ||
| } | ||
| } else if (!isPrintable(char)) { | ||
| return STYLE_DOUBLE | ||
| } | ||
| plain = plain && isPlainSafe(char, prevChar, inblock) | ||
| prevChar = char | ||
| } | ||
| // in case the end is missing a \n | ||
| hasFoldableLine = hasFoldableLine || (shouldTrackWidth && | ||
| (i - previousLineBreak - 1 > lineWidth && | ||
| string[previousLineBreak + 1] !== ' ')) | ||
| } | ||
| // Although every style can represent \n without escaping, prefer block styles | ||
| // for multiline, since they're more readable and they don't add empty lines. | ||
| // Also prefer folding a super-long line. | ||
| if (!hasLineBreak && !hasFoldableLine) { | ||
| // Strings interpretable as another type have to be quoted; | ||
| // e.g. the string 'true' vs. the boolean true. | ||
| if (plain && !forceQuotes && !testAmbiguousType(string)) { | ||
| return STYLE_PLAIN | ||
| } | ||
| return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE | ||
| } | ||
| // Edge case: block indentation indicator can only have one digit. | ||
| if (indentPerLevel > 9 && needIndentIndicator(string)) { | ||
| return STYLE_DOUBLE | ||
| } | ||
| // At this point we know block styles are valid. | ||
| // Prefer literal style unless we want to fold. | ||
| if (!forceQuotes) { | ||
| return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL | ||
| } | ||
| return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE | ||
| } | ||
| // Note: line breaking/folding is implemented for only the folded style. | ||
| // NB. We drop the last trailing newline (if any) of a returned block scalar | ||
| // since the dumper adds its own newline. This always works: | ||
| // • No ending newline => unaffected; already using strip "-" chomping. | ||
| // • Ending newline => removed then restored. | ||
| // Importantly, this keeps the "+" chomp indicator from gaining an extra line. | ||
| function writeScalar (state, string, level, iskey, inblock) { | ||
| state.dump = (function () { | ||
| if (string.length === 0) { | ||
| return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''" | ||
| } | ||
| if (!state.noCompatMode) { | ||
| if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) { | ||
| return state.quotingType === QUOTING_TYPE_DOUBLE ? ('"' + string + '"') : ("'" + string + "'") | ||
| } | ||
| } | ||
| const indent = state.indent * Math.max(1, level) // no 0-indent scalars | ||
| // As indentation gets deeper, let the width decrease monotonically | ||
| // to the lower bound min(state.lineWidth, 40). | ||
| // Note that this implies | ||
| // state.lineWidth ≤ 40 + state.indent: width is fixed at the lower bound. | ||
| // state.lineWidth > 40 + state.indent: width decreases until the lower bound. | ||
| // This behaves better than a constant minimum width which disallows narrower options, | ||
| // or an indent threshold which causes the width to suddenly increase. | ||
| const lineWidth = (state.lineWidth === -1) | ||
| ? -1 | ||
| : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent) | ||
| // Without knowing if keys are implicit/explicit, assume implicit for safety. | ||
| const singleLineOnly = iskey || | ||
| // No block styles in flow mode. | ||
| (state.flowLevel > -1 && level >= state.flowLevel) | ||
| function testAmbiguity (string) { | ||
| return testImplicitResolving(state, string) | ||
| } | ||
| switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, | ||
| testAmbiguity, state.quotingType, state.forceQuotes && !iskey, inblock)) { | ||
| case STYLE_PLAIN: | ||
| return string | ||
| case STYLE_SINGLE: | ||
| return "'" + string.replace(/'/g, "''") + "'" | ||
| case STYLE_LITERAL: | ||
| return '|' + blockHeader(string, state.indent) + | ||
| dropEndingNewline(indentString(string, indent)) | ||
| case STYLE_FOLDED: | ||
| return '>' + blockHeader(string, state.indent) + | ||
| dropEndingNewline(indentString(foldString(string, lineWidth), indent)) | ||
| case STYLE_DOUBLE: | ||
| return '"' + escapeString(string, lineWidth) + '"' | ||
| default: | ||
| throw new YAMLException('impossible error: invalid scalar style') | ||
| } | ||
| }()) | ||
| } | ||
| // Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9. | ||
| function blockHeader (string, indentPerLevel) { | ||
| const indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : '' | ||
| // note the special case: the string '\n' counts as a "trailing" empty line. | ||
| const clip = string[string.length - 1] === '\n' | ||
| const keep = clip && (string[string.length - 2] === '\n' || string === '\n') | ||
| const chomp = keep ? '+' : (clip ? '' : '-') | ||
| return indentIndicator + chomp + '\n' | ||
| } | ||
| // (See the note for writeScalar.) | ||
| function dropEndingNewline (string) { | ||
| return string[string.length - 1] === '\n' ? string.slice(0, -1) : string | ||
| } | ||
| // Note: a long line without a suitable break point will exceed the width limit. | ||
| // Pre-conditions: every char in str isPrintable, str.length > 0, width > 0. | ||
| function foldString (string, width) { | ||
| // In folded style, $k$ consecutive newlines output as $k+1$ newlines— | ||
| // unless they're before or after a more-indented line, or at the very | ||
| // beginning or end, in which case $k$ maps to $k$. | ||
| // Therefore, parse each chunk as newline(s) followed by a content line. | ||
| const lineRe = /(\n+)([^\n]*)/g | ||
| // first line (possibly an empty line) | ||
| let result = (function () { | ||
| let nextLF = string.indexOf('\n') | ||
| nextLF = nextLF !== -1 ? nextLF : string.length | ||
| lineRe.lastIndex = nextLF | ||
| return foldLine(string.slice(0, nextLF), width) | ||
| }()) | ||
| // If we haven't reached the first content line yet, don't add an extra \n. | ||
| let prevMoreIndented = string[0] === '\n' || string[0] === ' ' | ||
| let moreIndented | ||
| // rest of the lines | ||
| let match | ||
| while ((match = lineRe.exec(string))) { | ||
| const prefix = match[1] | ||
| const line = match[2] | ||
| moreIndented = (line[0] === ' ') | ||
| result += prefix + | ||
| ((!prevMoreIndented && !moreIndented && line !== '') ? '\n' : '') + | ||
| foldLine(line, width) | ||
| prevMoreIndented = moreIndented | ||
| } | ||
| return result | ||
| } | ||
| // Greedy line breaking. | ||
| // Picks the longest line under the limit each time, | ||
| // otherwise settles for the shortest line over the limit. | ||
| // NB. More-indented lines *cannot* be folded, as that would add an extra \n. | ||
| function foldLine (line, width) { | ||
| if (line === '' || line[0] === ' ') return line | ||
| // Since a more-indented line adds a \n, breaks can't be followed by a space. | ||
| const breakRe = / [^ ]/g // note: the match index will always be <= length-2. | ||
| let match | ||
| // start is an inclusive index. end, curr, and next are exclusive. | ||
| let start = 0 | ||
| let end | ||
| let curr = 0 | ||
| let next = 0 | ||
| let result = '' | ||
| // Invariants: 0 <= start <= length-1. | ||
| // 0 <= curr <= next <= max(0, length-2). curr - start <= width. | ||
| // Inside the loop: | ||
| // A match implies length >= 2, so curr and next are <= length-2. | ||
| while ((match = breakRe.exec(line))) { | ||
| next = match.index | ||
| // maintain invariant: curr - start <= width | ||
| if (next - start > width) { | ||
| end = (curr > start) ? curr : next // derive end <= length-2 | ||
| result += '\n' + line.slice(start, end) | ||
| // skip the space that was output as \n | ||
| start = end + 1 // derive start <= length-1 | ||
| } | ||
| curr = next | ||
| } | ||
| // By the invariants, start <= length-1, so there is something left over. | ||
| // It is either the whole string or a part starting from non-whitespace. | ||
| result += '\n' | ||
| // Insert a break if the remainder is too long and there is a break available. | ||
| if (line.length - start > width && curr > start) { | ||
| result += line.slice(start, curr) + '\n' + line.slice(curr + 1) | ||
| } else { | ||
| result += line.slice(start) | ||
| } | ||
| return result.slice(1) // drop extra \n joiner | ||
| } | ||
| // Escapes a double-quoted string. | ||
| function escapeString (string) { | ||
| let result = '' | ||
| let char = 0 | ||
| for (let i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { | ||
| char = codePointAt(string, i) | ||
| const escapeSeq = ESCAPE_SEQUENCES[char] | ||
| if (!escapeSeq && isPrintable(char)) { | ||
| result += string[i] | ||
| if (char >= 0x10000) result += string[i + 1] | ||
| } else { | ||
| result += escapeSeq || encodeHex(char) | ||
| } | ||
| } | ||
| return result | ||
| } | ||
| function writeFlowSequence (state, level, object) { | ||
| let _result = '' | ||
| const _tag = state.tag | ||
| for (let index = 0, length = object.length; index < length; index += 1) { | ||
| let value = object[index] | ||
| if (state.replacer) { | ||
| value = state.replacer.call(object, String(index), value) | ||
| } | ||
| // Write only valid elements, put null instead of invalid elements. | ||
| if (writeNode(state, level, value, false, false) || | ||
| (typeof value === 'undefined' && | ||
| writeNode(state, level, null, false, false))) { | ||
| if (_result !== '') _result += ',' + (!state.condenseFlow ? ' ' : '') | ||
| _result += state.dump | ||
| } | ||
| } | ||
| state.tag = _tag | ||
| state.dump = '[' + _result + ']' | ||
| } | ||
| function writeBlockSequence (state, level, object, compact) { | ||
| let _result = '' | ||
| const _tag = state.tag | ||
| for (let index = 0, length = object.length; index < length; index += 1) { | ||
| let value = object[index] | ||
| if (state.replacer) { | ||
| value = state.replacer.call(object, String(index), value) | ||
| } | ||
| // Write only valid elements, put null instead of invalid elements. | ||
| if (writeNode(state, level + 1, value, true, true, false, true) || | ||
| (typeof value === 'undefined' && | ||
| writeNode(state, level + 1, null, true, true, false, true))) { | ||
| if (!compact || _result !== '') { | ||
| _result += generateNextLine(state, level) | ||
| } | ||
| if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { | ||
| _result += '-' | ||
| } else { | ||
| _result += '- ' | ||
| } | ||
| _result += state.dump | ||
| } | ||
| } | ||
| state.tag = _tag | ||
| state.dump = _result || '[]' // Empty sequence if no valid values. | ||
| } | ||
| function writeFlowMapping (state, level, object) { | ||
| let _result = '' | ||
| const _tag = state.tag | ||
| const objectKeyList = Object.keys(object) | ||
| for (let index = 0, length = objectKeyList.length; index < length; index += 1) { | ||
| let pairBuffer = '' | ||
| if (_result !== '') pairBuffer += ', ' | ||
| if (state.condenseFlow) pairBuffer += '"' | ||
| const objectKey = objectKeyList[index] | ||
| let objectValue = object[objectKey] | ||
| if (state.replacer) { | ||
| objectValue = state.replacer.call(object, objectKey, objectValue) | ||
| } | ||
| if (!writeNode(state, level, objectKey, false, false)) { | ||
| continue // Skip this pair because of invalid key; | ||
| } | ||
| if (state.dump.length > 1024) pairBuffer += '? ' | ||
| pairBuffer += state.dump + (state.condenseFlow ? '"' : '') + ':' + (state.condenseFlow ? '' : ' ') | ||
| if (!writeNode(state, level, objectValue, false, false)) { | ||
| continue // Skip this pair because of invalid value. | ||
| } | ||
| pairBuffer += state.dump | ||
| // Both key and value are valid. | ||
| _result += pairBuffer | ||
| } | ||
| state.tag = _tag | ||
| state.dump = '{' + _result + '}' | ||
| } | ||
| function writeBlockMapping (state, level, object, compact) { | ||
| let _result = '' | ||
| const _tag = state.tag | ||
| const objectKeyList = Object.keys(object) | ||
| // Allow sorting keys so that the output file is deterministic | ||
| if (state.sortKeys === true) { | ||
| // Default sorting | ||
| objectKeyList.sort() | ||
| } else if (typeof state.sortKeys === 'function') { | ||
| // Custom sort function | ||
| objectKeyList.sort(state.sortKeys) | ||
| } else if (state.sortKeys) { | ||
| // Something is wrong | ||
| throw new YAMLException('sortKeys must be a boolean or a function') | ||
| } | ||
| for (let index = 0, length = objectKeyList.length; index < length; index += 1) { | ||
| let pairBuffer = '' | ||
| if (!compact || _result !== '') { | ||
| pairBuffer += generateNextLine(state, level) | ||
| } | ||
| const objectKey = objectKeyList[index] | ||
| let objectValue = object[objectKey] | ||
| if (state.replacer) { | ||
| objectValue = state.replacer.call(object, objectKey, objectValue) | ||
| } | ||
| if (!writeNode(state, level + 1, objectKey, true, true, true)) { | ||
| continue // Skip this pair because of invalid key. | ||
| } | ||
| const explicitPair = (state.tag !== null && state.tag !== '?') || | ||
| (state.dump && state.dump.length > 1024) | ||
| if (explicitPair) { | ||
| if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { | ||
| pairBuffer += '?' | ||
| } else { | ||
| pairBuffer += '? ' | ||
| } | ||
| } | ||
| pairBuffer += state.dump | ||
| if (explicitPair) { | ||
| pairBuffer += generateNextLine(state, level) | ||
| } | ||
| if (!writeNode(state, level + 1, objectValue, true, explicitPair)) { | ||
| continue // Skip this pair because of invalid value. | ||
| } | ||
| if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { | ||
| pairBuffer += ':' | ||
| } else { | ||
| pairBuffer += ': ' | ||
| } | ||
| pairBuffer += state.dump | ||
| // Both key and value are valid. | ||
| _result += pairBuffer | ||
| } | ||
| state.tag = _tag | ||
| state.dump = _result || '{}' // Empty mapping if no valid pairs. | ||
| } | ||
| function detectType (state, object, explicit) { | ||
| const typeList = explicit ? state.explicitTypes : state.implicitTypes | ||
| for (let index = 0, length = typeList.length; index < length; index += 1) { | ||
| const type = typeList[index] | ||
| if ((type.instanceOf || type.predicate) && | ||
| (!type.instanceOf || ((typeof object === 'object') && (object instanceof type.instanceOf))) && | ||
| (!type.predicate || type.predicate(object))) { | ||
| if (explicit) { | ||
| if (type.multi && type.representName) { | ||
| state.tag = type.representName(object) | ||
| } else { | ||
| state.tag = type.tag | ||
| } | ||
| } else { | ||
| state.tag = '?' | ||
| } | ||
| if (type.represent) { | ||
| const style = state.styleMap[type.tag] || type.defaultStyle | ||
| let _result | ||
| if (_toString.call(type.represent) === '[object Function]') { | ||
| _result = type.represent(object, style) | ||
| } else if (_hasOwnProperty.call(type.represent, style)) { | ||
| _result = type.represent[style](object, style) | ||
| } else { | ||
| throw new YAMLException('!<' + type.tag + '> tag resolver accepts not "' + style + '" style') | ||
| } | ||
| state.dump = _result | ||
| } | ||
| return true | ||
| } | ||
| } | ||
| return false | ||
| } | ||
| // Serializes `object` and writes it to global `result`. | ||
| // Returns true on success, or false on invalid object. | ||
| // | ||
| function writeNode (state, level, object, block, compact, iskey, isblockseq) { | ||
| state.tag = null | ||
| state.dump = object | ||
| if (!detectType(state, object, false)) { | ||
| detectType(state, object, true) | ||
| } | ||
| const type = _toString.call(state.dump) | ||
| const inblock = block | ||
| if (block) { | ||
| block = (state.flowLevel < 0 || state.flowLevel > level) | ||
| } | ||
| const objectOrArray = type === '[object Object]' || type === '[object Array]' | ||
| let duplicateIndex | ||
| let duplicate | ||
| if (objectOrArray) { | ||
| duplicateIndex = state.duplicates.indexOf(object) | ||
| duplicate = duplicateIndex !== -1 | ||
| } | ||
| if ((state.tag !== null && state.tag !== '?') || duplicate || (state.indent !== 2 && level > 0)) { | ||
| compact = false | ||
| } | ||
| if (duplicate && state.usedDuplicates[duplicateIndex]) { | ||
| state.dump = '*ref_' + duplicateIndex | ||
| } else { | ||
| if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) { | ||
| state.usedDuplicates[duplicateIndex] = true | ||
| } | ||
| if (type === '[object Object]') { | ||
| if (block && (Object.keys(state.dump).length !== 0)) { | ||
| writeBlockMapping(state, level, state.dump, compact) | ||
| if (duplicate) { | ||
| state.dump = '&ref_' + duplicateIndex + state.dump | ||
| } | ||
| } else { | ||
| writeFlowMapping(state, level, state.dump) | ||
| if (duplicate) { | ||
| state.dump = '&ref_' + duplicateIndex + ' ' + state.dump | ||
| } | ||
| } | ||
| } else if (type === '[object Array]') { | ||
| if (block && (state.dump.length !== 0)) { | ||
| if (state.noArrayIndent && !isblockseq && level > 0) { | ||
| writeBlockSequence(state, level - 1, state.dump, compact) | ||
| } else { | ||
| writeBlockSequence(state, level, state.dump, compact) | ||
| } | ||
| if (duplicate) { | ||
| state.dump = '&ref_' + duplicateIndex + state.dump | ||
| } | ||
| } else { | ||
| writeFlowSequence(state, level, state.dump) | ||
| if (duplicate) { | ||
| state.dump = '&ref_' + duplicateIndex + ' ' + state.dump | ||
| } | ||
| } | ||
| } else if (type === '[object String]') { | ||
| if (state.tag !== '?') { | ||
| writeScalar(state, state.dump, level, iskey, inblock) | ||
| } | ||
| } else if (type === '[object Undefined]') { | ||
| return false | ||
| } else { | ||
| if (state.skipInvalid) return false | ||
| throw new YAMLException('unacceptable kind of an object to dump ' + type) | ||
| } | ||
| if (state.tag !== null && state.tag !== '?') { | ||
| // Need to encode all characters except those allowed by the spec: | ||
| // | ||
| // [35] ns-dec-digit ::= [#x30-#x39] /* 0-9 */ | ||
| // [36] ns-hex-digit ::= ns-dec-digit | ||
| // | [#x41-#x46] /* A-F */ | [#x61-#x66] /* a-f */ | ||
| // [37] ns-ascii-letter ::= [#x41-#x5A] /* A-Z */ | [#x61-#x7A] /* a-z */ | ||
| // [38] ns-word-char ::= ns-dec-digit | ns-ascii-letter | “-” | ||
| // [39] ns-uri-char ::= “%” ns-hex-digit ns-hex-digit | ns-word-char | “#” | ||
| // | “;” | “/” | “?” | “:” | “@” | “&” | “=” | “+” | “$” | “,” | ||
| // | “_” | “.” | “!” | “~” | “*” | “'” | “(” | “)” | “[” | “]” | ||
| // | ||
| // Also need to encode '!' because it has special meaning (end of tag prefix). | ||
| // | ||
| let tagStr = encodeURI( | ||
| state.tag[0] === '!' ? state.tag.slice(1) : state.tag | ||
| ).replace(/!/g, '%21') | ||
| if (state.tag[0] === '!') { | ||
| tagStr = '!' + tagStr | ||
| } else if (tagStr.slice(0, 18) === 'tag:yaml.org,2002:') { | ||
| tagStr = '!!' + tagStr.slice(18) | ||
| } else { | ||
| tagStr = '!<' + tagStr + '>' | ||
| } | ||
| state.dump = tagStr + ' ' + state.dump | ||
| } | ||
| } | ||
| return true | ||
| } | ||
| function getDuplicateReferences (object, state) { | ||
| const objects = [] | ||
| const duplicatesIndexes = [] | ||
| inspectNode(object, objects, duplicatesIndexes) | ||
| const length = duplicatesIndexes.length | ||
| for (let index = 0; index < length; index += 1) { | ||
| state.duplicates.push(objects[duplicatesIndexes[index]]) | ||
| } | ||
| state.usedDuplicates = new Array(length) | ||
| } | ||
| function inspectNode (object, objects, duplicatesIndexes) { | ||
| if (object !== null && typeof object === 'object') { | ||
| const index = objects.indexOf(object) | ||
| if (index !== -1) { | ||
| if (duplicatesIndexes.indexOf(index) === -1) { | ||
| duplicatesIndexes.push(index) | ||
| } | ||
| } else { | ||
| objects.push(object) | ||
| if (Array.isArray(object)) { | ||
| for (let i = 0, length = object.length; i < length; i += 1) { | ||
| inspectNode(object[i], objects, duplicatesIndexes) | ||
| } | ||
| } else { | ||
| const objectKeyList = Object.keys(object) | ||
| for (let i = 0, length = objectKeyList.length; i < length; i += 1) { | ||
| inspectNode(object[objectKeyList[i]], objects, duplicatesIndexes) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| function dump (input, options) { | ||
| options = options || {} | ||
| const state = new State(options) | ||
| if (!state.noRefs) getDuplicateReferences(input, state) | ||
| let value = input | ||
| if (state.replacer) { | ||
| value = state.replacer.call({ '': value }, '', value) | ||
| } | ||
| if (writeNode(state, 0, value, true, true)) return state.dump + '\n' | ||
| return '' | ||
| } | ||
| module.exports.dump = dump |
| // YAML error class. http://stackoverflow.com/questions/8458984 | ||
| // | ||
| 'use strict' | ||
| function formatError (exception, compact) { | ||
| let where = '' | ||
| const message = exception.reason || '(unknown reason)' | ||
| if (!exception.mark) return message | ||
| if (exception.mark.name) { | ||
| where += 'in "' + exception.mark.name + '" ' | ||
| } | ||
| where += '(' + (exception.mark.line + 1) + ':' + (exception.mark.column + 1) + ')' | ||
| if (!compact && exception.mark.snippet) { | ||
| where += '\n\n' + exception.mark.snippet | ||
| } | ||
| return message + ' ' + where | ||
| } | ||
| function YAMLException (reason, mark) { | ||
| // Super constructor | ||
| Error.call(this) | ||
| this.name = 'YAMLException' | ||
| this.reason = reason | ||
| this.mark = mark | ||
| this.message = formatError(this, false) | ||
| // Include stack trace in error object | ||
| if (Error.captureStackTrace) { | ||
| // Chrome and NodeJS | ||
| Error.captureStackTrace(this, this.constructor) | ||
| } else { | ||
| // FF, IE 10+ and Safari 6+. Fallback for others | ||
| this.stack = (new Error()).stack || '' | ||
| } | ||
| } | ||
| // Inherit from Error | ||
| YAMLException.prototype = Object.create(Error.prototype) | ||
| YAMLException.prototype.constructor = YAMLException | ||
| YAMLException.prototype.toString = function toString (compact) { | ||
| return this.name + ': ' + formatError(this, compact) | ||
| } | ||
| module.exports = YAMLException |
| import yaml from '../index.js' | ||
| const { | ||
| Type, | ||
| Schema, | ||
| FAILSAFE_SCHEMA, | ||
| JSON_SCHEMA, | ||
| CORE_SCHEMA, | ||
| DEFAULT_SCHEMA, | ||
| load, | ||
| loadAll, | ||
| dump, | ||
| YAMLException, | ||
| types, | ||
| safeLoad, | ||
| safeLoadAll, | ||
| safeDump | ||
| } = yaml | ||
| export { | ||
| Type, | ||
| Schema, | ||
| FAILSAFE_SCHEMA, | ||
| JSON_SCHEMA, | ||
| CORE_SCHEMA, | ||
| DEFAULT_SCHEMA, | ||
| load, | ||
| loadAll, | ||
| dump, | ||
| YAMLException, | ||
| types, | ||
| safeLoad, | ||
| safeLoadAll, | ||
| safeDump | ||
| } | ||
| export default yaml |
-1794
| 'use strict' | ||
| const common = require('./common') | ||
| const YAMLException = require('./exception') | ||
| const makeSnippet = require('./snippet') | ||
| const DEFAULT_SCHEMA = require('./schema/default') | ||
| const _hasOwnProperty = Object.prototype.hasOwnProperty | ||
| const CONTEXT_FLOW_IN = 1 | ||
| const CONTEXT_FLOW_OUT = 2 | ||
| const CONTEXT_BLOCK_IN = 3 | ||
| const CONTEXT_BLOCK_OUT = 4 | ||
| const CHOMPING_CLIP = 1 | ||
| const CHOMPING_STRIP = 2 | ||
| const CHOMPING_KEEP = 3 | ||
| // eslint-disable-next-line no-control-regex | ||
| const PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/ | ||
| const PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/ | ||
| // eslint-disable-next-line no-useless-escape | ||
| const PATTERN_FLOW_INDICATORS = /[,\[\]{}]/ | ||
| // eslint-disable-next-line no-useless-escape | ||
| const PATTERN_TAG_HANDLE = /^(?:!|!!|![0-9A-Za-z-]+!)$/ | ||
| // eslint-disable-next-line no-useless-escape | ||
| const PATTERN_TAG_URI = /^(?:!|[^,\[\]{}])(?:%[0-9a-f]{2}|[0-9a-z\-#;/?:@&=+$,_.!~*'()\[\]])*$/i | ||
| function _class (obj) { return Object.prototype.toString.call(obj) } | ||
| function isEol (c) { | ||
| return (c === 0x0A/* LF */) || (c === 0x0D/* CR */) | ||
| } | ||
| function isWhiteSpace (c) { | ||
| return (c === 0x09/* Tab */) || (c === 0x20/* Space */) | ||
| } | ||
| function isWsOrEol (c) { | ||
| return (c === 0x09/* Tab */) || | ||
| (c === 0x20/* Space */) || | ||
| (c === 0x0A/* LF */) || | ||
| (c === 0x0D/* CR */) | ||
| } | ||
| function isFlowIndicator (c) { | ||
| return c === 0x2C/* , */ || | ||
| c === 0x5B/* [ */ || | ||
| c === 0x5D/* ] */ || | ||
| c === 0x7B/* { */ || | ||
| c === 0x7D/* } */ | ||
| } | ||
| function fromHexCode (c) { | ||
| if ((c >= 0x30/* 0 */) && (c <= 0x39/* 9 */)) { | ||
| return c - 0x30 | ||
| } | ||
| const lc = c | 0x20 | ||
| if ((lc >= 0x61/* a */) && (lc <= 0x66/* f */)) { | ||
| return lc - 0x61 + 10 | ||
| } | ||
| return -1 | ||
| } | ||
| function escapedHexLen (c) { | ||
| if (c === 0x78/* x */) { return 2 } | ||
| if (c === 0x75/* u */) { return 4 } | ||
| if (c === 0x55/* U */) { return 8 } | ||
| return 0 | ||
| } | ||
| function fromDecimalCode (c) { | ||
| if ((c >= 0x30/* 0 */) && (c <= 0x39/* 9 */)) { | ||
| return c - 0x30 | ||
| } | ||
| return -1 | ||
| } | ||
| function simpleEscapeSequence (c) { | ||
| switch (c) { | ||
| case 0x30/* 0 */: return '\x00' | ||
| case 0x61/* a */: return '\x07' | ||
| case 0x62/* b */: return '\x08' | ||
| case 0x74/* t */: return '\x09' | ||
| case 0x09/* Tab */: return '\x09' | ||
| case 0x6E/* n */: return '\x0A' | ||
| case 0x76/* v */: return '\x0B' | ||
| case 0x66/* f */: return '\x0C' | ||
| case 0x72/* r */: return '\x0D' | ||
| case 0x65/* e */: return '\x1B' | ||
| case 0x20/* Space */: return ' ' | ||
| case 0x22/* " */: return '\x22' | ||
| case 0x2F/* / */: return '/' | ||
| case 0x5C/* \ */: return '\x5C' | ||
| case 0x4E/* N */: return '\x85' | ||
| case 0x5F/* _ */: return '\xA0' | ||
| case 0x4C/* L */: return '\u2028' | ||
| case 0x50/* P */: return '\u2029' | ||
| default: return '' | ||
| } | ||
| } | ||
| function charFromCodepoint (c) { | ||
| if (c <= 0xFFFF) { | ||
| return String.fromCharCode(c) | ||
| } | ||
| // Encode UTF-16 surrogate pair | ||
| // https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF | ||
| return String.fromCharCode( | ||
| ((c - 0x010000) >> 10) + 0xD800, | ||
| ((c - 0x010000) & 0x03FF) + 0xDC00 | ||
| ) | ||
| } | ||
| // set a property of a literal object, while protecting against prototype pollution, | ||
| // see https://github.com/nodeca/js-yaml/issues/164 for more details | ||
| function setProperty (object, key, value) { | ||
| // used for this specific key only because Object.defineProperty is slow | ||
| if (key === '__proto__') { | ||
| Object.defineProperty(object, key, { | ||
| configurable: true, | ||
| enumerable: true, | ||
| writable: true, | ||
| value: value | ||
| }) | ||
| } else { | ||
| object[key] = value | ||
| } | ||
| } | ||
| const simpleEscapeCheck = new Array(256) // integer, for fast access | ||
| const simpleEscapeMap = new Array(256) | ||
| for (let i = 0; i < 256; i++) { | ||
| simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0 | ||
| simpleEscapeMap[i] = simpleEscapeSequence(i) | ||
| } | ||
| function State (input, options) { | ||
| this.input = input | ||
| this.filename = options['filename'] || null | ||
| this.schema = options['schema'] || DEFAULT_SCHEMA | ||
| this.onWarning = options['onWarning'] || null | ||
| // (Hidden) Remove? makes the loader to expect YAML 1.1 documents | ||
| // if such documents have no explicit %YAML directive | ||
| this.legacy = options['legacy'] || false | ||
| this.json = options['json'] || false | ||
| this.listener = options['listener'] || null | ||
| this.maxDepth = typeof options['maxDepth'] === 'number' ? options['maxDepth'] : 100 | ||
| this.maxMergeSeqLength = typeof options['maxMergeSeqLength'] === 'number' ? options['maxMergeSeqLength'] : 20 | ||
| this.implicitTypes = this.schema.compiledImplicit | ||
| this.typeMap = this.schema.compiledTypeMap | ||
| this.length = input.length | ||
| this.position = 0 | ||
| this.line = 0 | ||
| this.lineStart = 0 | ||
| this.lineIndent = 0 | ||
| this.depth = 0 | ||
| // position of first leading tab in the current line, | ||
| // used to make sure there are no tabs in the indentation | ||
| this.firstTabInLine = -1 | ||
| this.documents = [] | ||
| this.anchorMapTransactions = [] | ||
| /* | ||
| this.version; | ||
| this.checkLineBreaks; | ||
| this.tagMap; | ||
| this.anchorMap; | ||
| this.tag; | ||
| this.anchor; | ||
| this.kind; | ||
| this.result; */ | ||
| } | ||
| function generateError (state, message) { | ||
| const mark = { | ||
| name: state.filename, | ||
| buffer: state.input.slice(0, -1), // omit trailing \0 | ||
| position: state.position, | ||
| line: state.line, | ||
| column: state.position - state.lineStart | ||
| } | ||
| mark.snippet = makeSnippet(mark) | ||
| return new YAMLException(message, mark) | ||
| } | ||
| function throwError (state, message) { | ||
| throw generateError(state, message) | ||
| } | ||
| function throwWarning (state, message) { | ||
| if (state.onWarning) { | ||
| state.onWarning.call(null, generateError(state, message)) | ||
| } | ||
| } | ||
| function storeAnchor (state, name, value) { | ||
| const transactions = state.anchorMapTransactions | ||
| if (transactions.length !== 0) { | ||
| const transaction = transactions[transactions.length - 1] | ||
| if (!_hasOwnProperty.call(transaction, name)) { | ||
| transaction[name] = { | ||
| existed: _hasOwnProperty.call(state.anchorMap, name), | ||
| value: state.anchorMap[name] | ||
| } | ||
| } | ||
| } | ||
| state.anchorMap[name] = value | ||
| } | ||
| function beginAnchorTransaction (state) { | ||
| state.anchorMapTransactions.push(Object.create(null)) | ||
| } | ||
| function commitAnchorTransaction (state) { | ||
| const transaction = state.anchorMapTransactions.pop() | ||
| const transactions = state.anchorMapTransactions | ||
| if (transactions.length === 0) return | ||
| const parent = transactions[transactions.length - 1] | ||
| const names = Object.keys(transaction) | ||
| for (let index = 0, length = names.length; index < length; index += 1) { | ||
| const name = names[index] | ||
| if (!_hasOwnProperty.call(parent, name)) { | ||
| parent[name] = transaction[name] | ||
| } | ||
| } | ||
| } | ||
| function rollbackAnchorTransaction (state) { | ||
| const transaction = state.anchorMapTransactions.pop() | ||
| const names = Object.keys(transaction) | ||
| for (let index = names.length - 1; index >= 0; index -= 1) { | ||
| const entry = transaction[names[index]] | ||
| if (entry.existed) { | ||
| state.anchorMap[names[index]] = entry.value | ||
| } else { | ||
| delete state.anchorMap[names[index]] | ||
| } | ||
| } | ||
| } | ||
| function snapshotState (state) { | ||
| return { | ||
| position: state.position, | ||
| line: state.line, | ||
| lineStart: state.lineStart, | ||
| lineIndent: state.lineIndent, | ||
| firstTabInLine: state.firstTabInLine, | ||
| tag: state.tag, | ||
| anchor: state.anchor, | ||
| kind: state.kind, | ||
| result: state.result | ||
| } | ||
| } | ||
| function restoreState (state, snapshot) { | ||
| state.position = snapshot.position | ||
| state.line = snapshot.line | ||
| state.lineStart = snapshot.lineStart | ||
| state.lineIndent = snapshot.lineIndent | ||
| state.firstTabInLine = snapshot.firstTabInLine | ||
| state.tag = snapshot.tag | ||
| state.anchor = snapshot.anchor | ||
| state.kind = snapshot.kind | ||
| state.result = snapshot.result | ||
| } | ||
| const directiveHandlers = { | ||
| YAML: function handleYamlDirective (state, name, args) { | ||
| if (state.version !== null) { | ||
| throwError(state, 'duplication of %YAML directive') | ||
| } | ||
| if (args.length !== 1) { | ||
| throwError(state, 'YAML directive accepts exactly one argument') | ||
| } | ||
| const match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]) | ||
| if (match === null) { | ||
| throwError(state, 'ill-formed argument of the YAML directive') | ||
| } | ||
| const major = parseInt(match[1], 10) | ||
| const minor = parseInt(match[2], 10) | ||
| if (major !== 1) { | ||
| throwError(state, 'unacceptable YAML version of the document') | ||
| } | ||
| state.version = args[0] | ||
| state.checkLineBreaks = (minor < 2) | ||
| if (minor !== 1 && minor !== 2) { | ||
| throwWarning(state, 'unsupported YAML version of the document') | ||
| } | ||
| }, | ||
| TAG: function handleTagDirective (state, name, args) { | ||
| let prefix | ||
| if (args.length !== 2) { | ||
| throwError(state, 'TAG directive accepts exactly two arguments') | ||
| } | ||
| const handle = args[0] | ||
| prefix = args[1] | ||
| if (!PATTERN_TAG_HANDLE.test(handle)) { | ||
| throwError(state, 'ill-formed tag handle (first argument) of the TAG directive') | ||
| } | ||
| if (_hasOwnProperty.call(state.tagMap, handle)) { | ||
| throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle') | ||
| } | ||
| if (!PATTERN_TAG_URI.test(prefix)) { | ||
| throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive') | ||
| } | ||
| try { | ||
| prefix = decodeURIComponent(prefix) | ||
| } catch (err) { | ||
| throwError(state, 'tag prefix is malformed: ' + prefix) | ||
| } | ||
| state.tagMap[handle] = prefix | ||
| } | ||
| } | ||
| function captureSegment (state, start, end, checkJson) { | ||
| if (start < end) { | ||
| const _result = state.input.slice(start, end) | ||
| if (checkJson) { | ||
| for (let _position = 0, _length = _result.length; _position < _length; _position += 1) { | ||
| const _character = _result.charCodeAt(_position) | ||
| if (!(_character === 0x09 || | ||
| (_character >= 0x20 && _character <= 0x10FFFF))) { | ||
| throwError(state, 'expected valid JSON character') | ||
| } | ||
| } | ||
| } else if (PATTERN_NON_PRINTABLE.test(_result)) { | ||
| throwError(state, 'the stream contains non-printable characters') | ||
| } | ||
| state.result += _result | ||
| } | ||
| } | ||
| function mergeMappings (state, destination, source, overridableKeys) { | ||
| if (!common.isObject(source)) { | ||
| throwError(state, 'cannot merge mappings; the provided source object is unacceptable') | ||
| } | ||
| const sourceKeys = Object.keys(source) | ||
| for (let index = 0, quantity = sourceKeys.length; index < quantity; index += 1) { | ||
| const key = sourceKeys[index] | ||
| if (!_hasOwnProperty.call(destination, key)) { | ||
| setProperty(destination, key, source[key]) | ||
| overridableKeys[key] = true | ||
| } | ||
| } | ||
| } | ||
| function storeMappingPair (state, _result, overridableKeys, keyTag, keyNode, valueNode, | ||
| startLine, startLineStart, startPos) { | ||
| // The output is a plain object here, so keys can only be strings. | ||
| // We need to convert keyNode to a string, but doing so can hang the process | ||
| // (deeply nested arrays that explode exponentially using aliases). | ||
| if (Array.isArray(keyNode)) { | ||
| keyNode = Array.prototype.slice.call(keyNode) | ||
| for (let index = 0, quantity = keyNode.length; index < quantity; index += 1) { | ||
| if (Array.isArray(keyNode[index])) { | ||
| throwError(state, 'nested arrays are not supported inside keys') | ||
| } | ||
| if (typeof keyNode === 'object' && _class(keyNode[index]) === '[object Object]') { | ||
| keyNode[index] = '[object Object]' | ||
| } | ||
| } | ||
| } | ||
| // Avoid code execution in load() via toString property | ||
| // (still use its own toString for arrays, timestamps, | ||
| // and whatever user schema extensions happen to have @@toStringTag) | ||
| if (typeof keyNode === 'object' && _class(keyNode) === '[object Object]') { | ||
| keyNode = '[object Object]' | ||
| } | ||
| keyNode = String(keyNode) | ||
| if (_result === null) { | ||
| _result = {} | ||
| } | ||
| if (keyTag === 'tag:yaml.org,2002:merge') { | ||
| if (Array.isArray(valueNode)) { | ||
| if (valueNode.length > state.maxMergeSeqLength) { | ||
| throwError(state, 'merge sequence length exceeded maxMergeSeqLength (' + state.maxMergeSeqLength + ')') | ||
| } | ||
| const seen = new Set() | ||
| for (let index = 0, quantity = valueNode.length; index < quantity; index += 1) { | ||
| const src = valueNode[index] | ||
| // Existing keys are not overridden on merge, so dedupe sources to | ||
| // avoid redundant work on repeated aliases. | ||
| if (seen.has(src)) continue | ||
| seen.add(src) | ||
| mergeMappings(state, _result, src, overridableKeys) | ||
| } | ||
| } else { | ||
| mergeMappings(state, _result, valueNode, overridableKeys) | ||
| } | ||
| } else { | ||
| if (!state.json && | ||
| !_hasOwnProperty.call(overridableKeys, keyNode) && | ||
| _hasOwnProperty.call(_result, keyNode)) { | ||
| state.line = startLine || state.line | ||
| state.lineStart = startLineStart || state.lineStart | ||
| state.position = startPos || state.position | ||
| throwError(state, 'duplicated mapping key') | ||
| } | ||
| setProperty(_result, keyNode, valueNode) | ||
| delete overridableKeys[keyNode] | ||
| } | ||
| return _result | ||
| } | ||
| function readLineBreak (state) { | ||
| const ch = state.input.charCodeAt(state.position) | ||
| if (ch === 0x0A/* LF */) { | ||
| state.position++ | ||
| } else if (ch === 0x0D/* CR */) { | ||
| state.position++ | ||
| if (state.input.charCodeAt(state.position) === 0x0A/* LF */) { | ||
| state.position++ | ||
| } | ||
| } else { | ||
| throwError(state, 'a line break is expected') | ||
| } | ||
| state.line += 1 | ||
| state.lineStart = state.position | ||
| state.firstTabInLine = -1 | ||
| } | ||
| function skipSeparationSpace (state, allowComments, checkIndent) { | ||
| let lineBreaks = 0 | ||
| let ch = state.input.charCodeAt(state.position) | ||
| while (ch !== 0) { | ||
| while (isWhiteSpace(ch)) { | ||
| if (ch === 0x09/* Tab */ && state.firstTabInLine === -1) { | ||
| state.firstTabInLine = state.position | ||
| } | ||
| ch = state.input.charCodeAt(++state.position) | ||
| } | ||
| if (allowComments && ch === 0x23/* # */) { | ||
| do { | ||
| ch = state.input.charCodeAt(++state.position) | ||
| } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && ch !== 0) | ||
| } | ||
| if (isEol(ch)) { | ||
| readLineBreak(state) | ||
| ch = state.input.charCodeAt(state.position) | ||
| lineBreaks++ | ||
| state.lineIndent = 0 | ||
| while (ch === 0x20/* Space */) { | ||
| state.lineIndent++ | ||
| ch = state.input.charCodeAt(++state.position) | ||
| } | ||
| } else { | ||
| break | ||
| } | ||
| } | ||
| if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) { | ||
| throwWarning(state, 'deficient indentation') | ||
| } | ||
| return lineBreaks | ||
| } | ||
| function testDocumentSeparator (state) { | ||
| let _position = state.position | ||
| let ch = state.input.charCodeAt(_position) | ||
| // Condition state.position === state.lineStart is tested | ||
| // in parent on each call, for efficiency. No needs to test here again. | ||
| if ((ch === 0x2D/* - */ || ch === 0x2E/* . */) && | ||
| ch === state.input.charCodeAt(_position + 1) && | ||
| ch === state.input.charCodeAt(_position + 2)) { | ||
| _position += 3 | ||
| ch = state.input.charCodeAt(_position) | ||
| if (ch === 0 || isWsOrEol(ch)) { | ||
| return true | ||
| } | ||
| } | ||
| return false | ||
| } | ||
| function writeFoldedLines (state, count) { | ||
| if (count === 1) { | ||
| state.result += ' ' | ||
| } else if (count > 1) { | ||
| state.result += common.repeat('\n', count - 1) | ||
| } | ||
| } | ||
| function readPlainScalar (state, nodeIndent, withinFlowCollection) { | ||
| let captureStart | ||
| let captureEnd | ||
| let hasPendingContent | ||
| let _line | ||
| let _lineStart | ||
| let _lineIndent | ||
| const _kind = state.kind | ||
| const _result = state.result | ||
| let ch = state.input.charCodeAt(state.position) | ||
| if (isWsOrEol(ch) || | ||
| isFlowIndicator(ch) || | ||
| ch === 0x23/* # */ || | ||
| ch === 0x26/* & */ || | ||
| ch === 0x2A/* * */ || | ||
| ch === 0x21/* ! */ || | ||
| ch === 0x7C/* | */ || | ||
| ch === 0x3E/* > */ || | ||
| ch === 0x27/* ' */ || | ||
| ch === 0x22/* " */ || | ||
| ch === 0x25/* % */ || | ||
| ch === 0x40/* @ */ || | ||
| ch === 0x60/* ` */) { | ||
| return false | ||
| } | ||
| if (ch === 0x3F/* ? */ || ch === 0x2D/* - */) { | ||
| const following = state.input.charCodeAt(state.position + 1) | ||
| if (isWsOrEol(following) || | ||
| (withinFlowCollection && isFlowIndicator(following))) { | ||
| return false | ||
| } | ||
| } | ||
| state.kind = 'scalar' | ||
| state.result = '' | ||
| captureStart = captureEnd = state.position | ||
| hasPendingContent = false | ||
| while (ch !== 0) { | ||
| if (ch === 0x3A/* : */) { | ||
| const following = state.input.charCodeAt(state.position + 1) | ||
| if (isWsOrEol(following) || | ||
| (withinFlowCollection && isFlowIndicator(following))) { | ||
| break | ||
| } | ||
| } else if (ch === 0x23/* # */) { | ||
| const preceding = state.input.charCodeAt(state.position - 1) | ||
| if (isWsOrEol(preceding)) { | ||
| break | ||
| } | ||
| } else if ((state.position === state.lineStart && testDocumentSeparator(state)) || | ||
| (withinFlowCollection && isFlowIndicator(ch))) { | ||
| break | ||
| } else if (isEol(ch)) { | ||
| _line = state.line | ||
| _lineStart = state.lineStart | ||
| _lineIndent = state.lineIndent | ||
| skipSeparationSpace(state, false, -1) | ||
| if (state.lineIndent >= nodeIndent) { | ||
| hasPendingContent = true | ||
| ch = state.input.charCodeAt(state.position) | ||
| continue | ||
| } else { | ||
| state.position = captureEnd | ||
| state.line = _line | ||
| state.lineStart = _lineStart | ||
| state.lineIndent = _lineIndent | ||
| break | ||
| } | ||
| } | ||
| if (hasPendingContent) { | ||
| captureSegment(state, captureStart, captureEnd, false) | ||
| writeFoldedLines(state, state.line - _line) | ||
| captureStart = captureEnd = state.position | ||
| hasPendingContent = false | ||
| } | ||
| if (!isWhiteSpace(ch)) { | ||
| captureEnd = state.position + 1 | ||
| } | ||
| ch = state.input.charCodeAt(++state.position) | ||
| } | ||
| captureSegment(state, captureStart, captureEnd, false) | ||
| if (state.result) { | ||
| return true | ||
| } | ||
| state.kind = _kind | ||
| state.result = _result | ||
| return false | ||
| } | ||
| function readSingleQuotedScalar (state, nodeIndent) { | ||
| let captureStart | ||
| let captureEnd | ||
| let ch = state.input.charCodeAt(state.position) | ||
| if (ch !== 0x27/* ' */) { | ||
| return false | ||
| } | ||
| state.kind = 'scalar' | ||
| state.result = '' | ||
| state.position++ | ||
| captureStart = captureEnd = state.position | ||
| while ((ch = state.input.charCodeAt(state.position)) !== 0) { | ||
| if (ch === 0x27/* ' */) { | ||
| captureSegment(state, captureStart, state.position, true) | ||
| ch = state.input.charCodeAt(++state.position) | ||
| if (ch === 0x27/* ' */) { | ||
| captureStart = state.position | ||
| state.position++ | ||
| captureEnd = state.position | ||
| } else { | ||
| return true | ||
| } | ||
| } else if (isEol(ch)) { | ||
| captureSegment(state, captureStart, captureEnd, true) | ||
| writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)) | ||
| captureStart = captureEnd = state.position | ||
| } else if (state.position === state.lineStart && testDocumentSeparator(state)) { | ||
| throwError(state, 'unexpected end of the document within a single quoted scalar') | ||
| } else { | ||
| state.position++ | ||
| if (!isWhiteSpace(ch)) { | ||
| captureEnd = state.position | ||
| } | ||
| } | ||
| } | ||
| throwError(state, 'unexpected end of the stream within a single quoted scalar') | ||
| } | ||
| function readDoubleQuotedScalar (state, nodeIndent) { | ||
| let captureStart | ||
| let captureEnd | ||
| let tmp | ||
| let ch = state.input.charCodeAt(state.position) | ||
| if (ch !== 0x22/* " */) { | ||
| return false | ||
| } | ||
| state.kind = 'scalar' | ||
| state.result = '' | ||
| state.position++ | ||
| captureStart = captureEnd = state.position | ||
| while ((ch = state.input.charCodeAt(state.position)) !== 0) { | ||
| if (ch === 0x22/* " */) { | ||
| captureSegment(state, captureStart, state.position, true) | ||
| state.position++ | ||
| return true | ||
| } else if (ch === 0x5C/* \ */) { | ||
| captureSegment(state, captureStart, state.position, true) | ||
| ch = state.input.charCodeAt(++state.position) | ||
| if (isEol(ch)) { | ||
| skipSeparationSpace(state, false, nodeIndent) | ||
| // TODO: rework to inline fn with no type cast? | ||
| } else if (ch < 256 && simpleEscapeCheck[ch]) { | ||
| state.result += simpleEscapeMap[ch] | ||
| state.position++ | ||
| } else if ((tmp = escapedHexLen(ch)) > 0) { | ||
| let hexLength = tmp | ||
| let hexResult = 0 | ||
| for (; hexLength > 0; hexLength--) { | ||
| ch = state.input.charCodeAt(++state.position) | ||
| if ((tmp = fromHexCode(ch)) >= 0) { | ||
| hexResult = (hexResult << 4) + tmp | ||
| } else { | ||
| throwError(state, 'expected hexadecimal character') | ||
| } | ||
| } | ||
| state.result += charFromCodepoint(hexResult) | ||
| state.position++ | ||
| } else { | ||
| throwError(state, 'unknown escape sequence') | ||
| } | ||
| captureStart = captureEnd = state.position | ||
| } else if (isEol(ch)) { | ||
| captureSegment(state, captureStart, captureEnd, true) | ||
| writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)) | ||
| captureStart = captureEnd = state.position | ||
| } else if (state.position === state.lineStart && testDocumentSeparator(state)) { | ||
| throwError(state, 'unexpected end of the document within a double quoted scalar') | ||
| } else { | ||
| state.position++ | ||
| if (!isWhiteSpace(ch)) { | ||
| captureEnd = state.position | ||
| } | ||
| } | ||
| } | ||
| throwError(state, 'unexpected end of the stream within a double quoted scalar') | ||
| } | ||
| function readFlowCollection (state, nodeIndent) { | ||
| let readNext = true | ||
| let _line | ||
| let _lineStart | ||
| let _pos | ||
| const _tag = state.tag | ||
| let _result | ||
| const _anchor = state.anchor | ||
| let terminator | ||
| let isPair | ||
| let isExplicitPair | ||
| let isMapping | ||
| const overridableKeys = Object.create(null) | ||
| let keyNode | ||
| let keyTag | ||
| let valueNode | ||
| let ch = state.input.charCodeAt(state.position) | ||
| if (ch === 0x5B/* [ */) { | ||
| terminator = 0x5D/* ] */ | ||
| isMapping = false | ||
| _result = [] | ||
| } else if (ch === 0x7B/* { */) { | ||
| terminator = 0x7D/* } */ | ||
| isMapping = true | ||
| _result = {} | ||
| } else { | ||
| return false | ||
| } | ||
| if (state.anchor !== null) { | ||
| storeAnchor(state, state.anchor, _result) | ||
| } | ||
| ch = state.input.charCodeAt(++state.position) | ||
| while (ch !== 0) { | ||
| skipSeparationSpace(state, true, nodeIndent) | ||
| ch = state.input.charCodeAt(state.position) | ||
| if (ch === terminator) { | ||
| state.position++ | ||
| state.tag = _tag | ||
| state.anchor = _anchor | ||
| state.kind = isMapping ? 'mapping' : 'sequence' | ||
| state.result = _result | ||
| return true | ||
| } else if (!readNext) { | ||
| throwError(state, 'missed comma between flow collection entries') | ||
| } else if (ch === 0x2C/* , */) { | ||
| // "flow collection entries can never be completely empty", as per YAML 1.2, section 7.4 | ||
| throwError(state, "expected the node content, but found ','") | ||
| } | ||
| keyTag = keyNode = valueNode = null | ||
| isPair = isExplicitPair = false | ||
| if (ch === 0x3F/* ? */) { | ||
| const following = state.input.charCodeAt(state.position + 1) | ||
| if (isWsOrEol(following)) { | ||
| isPair = isExplicitPair = true | ||
| state.position++ | ||
| skipSeparationSpace(state, true, nodeIndent) | ||
| } | ||
| } | ||
| _line = state.line // Save the current line. | ||
| _lineStart = state.lineStart | ||
| _pos = state.position | ||
| composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true) | ||
| keyTag = state.tag | ||
| keyNode = state.result | ||
| skipSeparationSpace(state, true, nodeIndent) | ||
| ch = state.input.charCodeAt(state.position) | ||
| if ((isExplicitPair || state.line === _line) && ch === 0x3A/* : */) { | ||
| isPair = true | ||
| ch = state.input.charCodeAt(++state.position) | ||
| skipSeparationSpace(state, true, nodeIndent) | ||
| composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true) | ||
| valueNode = state.result | ||
| } | ||
| if (isMapping) { | ||
| storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos) | ||
| } else if (isPair) { | ||
| _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos)) | ||
| } else { | ||
| _result.push(keyNode) | ||
| } | ||
| skipSeparationSpace(state, true, nodeIndent) | ||
| ch = state.input.charCodeAt(state.position) | ||
| if (ch === 0x2C/* , */) { | ||
| readNext = true | ||
| ch = state.input.charCodeAt(++state.position) | ||
| } else { | ||
| readNext = false | ||
| } | ||
| } | ||
| throwError(state, 'unexpected end of the stream within a flow collection') | ||
| } | ||
| function readBlockScalar (state, nodeIndent) { | ||
| let folding | ||
| let chomping = CHOMPING_CLIP | ||
| let didReadContent = false | ||
| let detectedIndent = false | ||
| let textIndent = nodeIndent | ||
| let emptyLines = 0 | ||
| let atMoreIndented = false | ||
| let tmp | ||
| let ch = state.input.charCodeAt(state.position) | ||
| if (ch === 0x7C/* | */) { | ||
| folding = false | ||
| } else if (ch === 0x3E/* > */) { | ||
| folding = true | ||
| } else { | ||
| return false | ||
| } | ||
| state.kind = 'scalar' | ||
| state.result = '' | ||
| while (ch !== 0) { | ||
| ch = state.input.charCodeAt(++state.position) | ||
| if (ch === 0x2B/* + */ || ch === 0x2D/* - */) { | ||
| if (CHOMPING_CLIP === chomping) { | ||
| chomping = (ch === 0x2B/* + */) ? CHOMPING_KEEP : CHOMPING_STRIP | ||
| } else { | ||
| throwError(state, 'repeat of a chomping mode identifier') | ||
| } | ||
| } else if ((tmp = fromDecimalCode(ch)) >= 0) { | ||
| if (tmp === 0) { | ||
| throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one') | ||
| } else if (!detectedIndent) { | ||
| textIndent = nodeIndent + tmp - 1 | ||
| detectedIndent = true | ||
| } else { | ||
| throwError(state, 'repeat of an indentation width identifier') | ||
| } | ||
| } else { | ||
| break | ||
| } | ||
| } | ||
| if (isWhiteSpace(ch)) { | ||
| do { ch = state.input.charCodeAt(++state.position) } | ||
| while (isWhiteSpace(ch)) | ||
| if (ch === 0x23/* # */) { | ||
| do { ch = state.input.charCodeAt(++state.position) } | ||
| while (!isEol(ch) && (ch !== 0)) | ||
| } | ||
| } | ||
| while (ch !== 0) { | ||
| readLineBreak(state) | ||
| state.lineIndent = 0 | ||
| ch = state.input.charCodeAt(state.position) | ||
| // eslint-disable-next-line no-unmodified-loop-condition | ||
| while ((!detectedIndent || state.lineIndent < textIndent) && | ||
| (ch === 0x20/* Space */)) { | ||
| state.lineIndent++ | ||
| ch = state.input.charCodeAt(++state.position) | ||
| } | ||
| if (!detectedIndent && state.lineIndent > textIndent) { | ||
| textIndent = state.lineIndent | ||
| } | ||
| if (isEol(ch)) { | ||
| emptyLines++ | ||
| continue | ||
| } | ||
| if (!detectedIndent && textIndent === 0) { | ||
| throwError(state, 'missing indentation for block scalar') | ||
| } | ||
| // End of the scalar. | ||
| if (state.lineIndent < textIndent) { | ||
| // Perform the chomping. | ||
| if (chomping === CHOMPING_KEEP) { | ||
| state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines) | ||
| } else if (chomping === CHOMPING_CLIP) { | ||
| if (didReadContent) { // i.e. only if the scalar is not empty. | ||
| state.result += '\n' | ||
| } | ||
| } | ||
| // Break this `while` cycle and go to the funciton's epilogue. | ||
| break | ||
| } | ||
| // Folded style: use fancy rules to handle line breaks. | ||
| if (folding) { | ||
| // Lines starting with white space characters (more-indented lines) are not folded. | ||
| if (isWhiteSpace(ch)) { | ||
| atMoreIndented = true | ||
| // except for the first content line (cf. Example 8.1) | ||
| state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines) | ||
| // End of more-indented block. | ||
| } else if (atMoreIndented) { | ||
| atMoreIndented = false | ||
| state.result += common.repeat('\n', emptyLines + 1) | ||
| // Just one line break - perceive as the same line. | ||
| } else if (emptyLines === 0) { | ||
| if (didReadContent) { // i.e. only if we have already read some scalar content. | ||
| state.result += ' ' | ||
| } | ||
| // Several line breaks - perceive as different lines. | ||
| } else { | ||
| state.result += common.repeat('\n', emptyLines) | ||
| } | ||
| // Literal style: just add exact number of line breaks between content lines. | ||
| } else { | ||
| // Keep all line breaks except the header line break. | ||
| state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines) | ||
| } | ||
| didReadContent = true | ||
| detectedIndent = true | ||
| emptyLines = 0 | ||
| const captureStart = state.position | ||
| while (!isEol(ch) && (ch !== 0)) { | ||
| ch = state.input.charCodeAt(++state.position) | ||
| } | ||
| captureSegment(state, captureStart, state.position, false) | ||
| } | ||
| return true | ||
| } | ||
| function readBlockSequence (state, nodeIndent) { | ||
| const _tag = state.tag | ||
| const _anchor = state.anchor | ||
| const _result = [] | ||
| let detected = false | ||
| // there is a leading tab before this token, so it can't be a block sequence/mapping; | ||
| // it can still be flow sequence/mapping or a scalar | ||
| if (state.firstTabInLine !== -1) return false | ||
| if (state.anchor !== null) { | ||
| storeAnchor(state, state.anchor, _result) | ||
| } | ||
| let ch = state.input.charCodeAt(state.position) | ||
| while (ch !== 0) { | ||
| if (state.firstTabInLine !== -1) { | ||
| state.position = state.firstTabInLine | ||
| throwError(state, 'tab characters must not be used in indentation') | ||
| } | ||
| if (ch !== 0x2D/* - */) { | ||
| break | ||
| } | ||
| const following = state.input.charCodeAt(state.position + 1) | ||
| if (!isWsOrEol(following)) { | ||
| break | ||
| } | ||
| detected = true | ||
| state.position++ | ||
| if (skipSeparationSpace(state, true, -1)) { | ||
| if (state.lineIndent <= nodeIndent) { | ||
| _result.push(null) | ||
| ch = state.input.charCodeAt(state.position) | ||
| continue | ||
| } | ||
| } | ||
| const _line = state.line | ||
| composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true) | ||
| _result.push(state.result) | ||
| skipSeparationSpace(state, true, -1) | ||
| ch = state.input.charCodeAt(state.position) | ||
| if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) { | ||
| throwError(state, 'bad indentation of a sequence entry') | ||
| } else if (state.lineIndent < nodeIndent) { | ||
| break | ||
| } | ||
| } | ||
| if (detected) { | ||
| state.tag = _tag | ||
| state.anchor = _anchor | ||
| state.kind = 'sequence' | ||
| state.result = _result | ||
| return true | ||
| } | ||
| return false | ||
| } | ||
| function readBlockMapping (state, nodeIndent, flowIndent) { | ||
| let allowCompact | ||
| let _keyLine | ||
| let _keyLineStart | ||
| let _keyPos | ||
| const _tag = state.tag | ||
| const _anchor = state.anchor | ||
| const _result = {} | ||
| const overridableKeys = Object.create(null) | ||
| let keyTag = null | ||
| let keyNode = null | ||
| let valueNode = null | ||
| let atExplicitKey = false | ||
| let detected = false | ||
| // there is a leading tab before this token, so it can't be a block sequence/mapping; | ||
| // it can still be flow sequence/mapping or a scalar | ||
| if (state.firstTabInLine !== -1) return false | ||
| if (state.anchor !== null) { | ||
| storeAnchor(state, state.anchor, _result) | ||
| } | ||
| let ch = state.input.charCodeAt(state.position) | ||
| while (ch !== 0) { | ||
| if (!atExplicitKey && state.firstTabInLine !== -1) { | ||
| state.position = state.firstTabInLine | ||
| throwError(state, 'tab characters must not be used in indentation') | ||
| } | ||
| const following = state.input.charCodeAt(state.position + 1) | ||
| const _line = state.line // Save the current line. | ||
| // | ||
| // Explicit notation case. There are two separate blocks: | ||
| // first for the key (denoted by "?") and second for the value (denoted by ":") | ||
| // | ||
| if ((ch === 0x3F/* ? */ || ch === 0x3A/* : */) && isWsOrEol(following)) { | ||
| if (ch === 0x3F/* ? */) { | ||
| if (atExplicitKey) { | ||
| storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos) | ||
| keyTag = keyNode = valueNode = null | ||
| } | ||
| detected = true | ||
| atExplicitKey = true | ||
| allowCompact = true | ||
| } else if (atExplicitKey) { | ||
| // i.e. 0x3A/* : */ === character after the explicit key. | ||
| atExplicitKey = false | ||
| allowCompact = true | ||
| } else { | ||
| throwError(state, 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line') | ||
| } | ||
| state.position += 1 | ||
| ch = following | ||
| // | ||
| // Implicit notation case. Flow-style node as the key first, then ":", and the value. | ||
| // | ||
| } else { | ||
| _keyLine = state.line | ||
| _keyLineStart = state.lineStart | ||
| _keyPos = state.position | ||
| if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) { | ||
| // Neither implicit nor explicit notation. | ||
| // Reading is done. Go to the epilogue. | ||
| break | ||
| } | ||
| if (state.line === _line) { | ||
| ch = state.input.charCodeAt(state.position) | ||
| while (isWhiteSpace(ch)) { | ||
| ch = state.input.charCodeAt(++state.position) | ||
| } | ||
| if (ch === 0x3A/* : */) { | ||
| ch = state.input.charCodeAt(++state.position) | ||
| if (!isWsOrEol(ch)) { | ||
| throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping') | ||
| } | ||
| if (atExplicitKey) { | ||
| storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos) | ||
| keyTag = keyNode = valueNode = null | ||
| } | ||
| detected = true | ||
| atExplicitKey = false | ||
| allowCompact = false | ||
| keyTag = state.tag | ||
| keyNode = state.result | ||
| } else if (detected) { | ||
| throwError(state, 'can not read an implicit mapping pair; a colon is missed') | ||
| } else { | ||
| state.tag = _tag | ||
| state.anchor = _anchor | ||
| return true // Keep the result of `composeNode`. | ||
| } | ||
| } else if (detected) { | ||
| throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key') | ||
| } else { | ||
| state.tag = _tag | ||
| state.anchor = _anchor | ||
| return true // Keep the result of `composeNode`. | ||
| } | ||
| } | ||
| // | ||
| // Common reading code for both explicit and implicit notations. | ||
| // | ||
| if (state.line === _line || state.lineIndent > nodeIndent) { | ||
| if (atExplicitKey) { | ||
| _keyLine = state.line | ||
| _keyLineStart = state.lineStart | ||
| _keyPos = state.position | ||
| } | ||
| if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) { | ||
| if (atExplicitKey) { | ||
| keyNode = state.result | ||
| } else { | ||
| valueNode = state.result | ||
| } | ||
| } | ||
| if (!atExplicitKey) { | ||
| storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos) | ||
| keyTag = keyNode = valueNode = null | ||
| } | ||
| skipSeparationSpace(state, true, -1) | ||
| ch = state.input.charCodeAt(state.position) | ||
| } | ||
| if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) { | ||
| throwError(state, 'bad indentation of a mapping entry') | ||
| } else if (state.lineIndent < nodeIndent) { | ||
| break | ||
| } | ||
| } | ||
| // | ||
| // Epilogue. | ||
| // | ||
| // Special case: last mapping's node contains only the key in explicit notation. | ||
| if (atExplicitKey) { | ||
| storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos) | ||
| } | ||
| // Expose the resulting mapping. | ||
| if (detected) { | ||
| state.tag = _tag | ||
| state.anchor = _anchor | ||
| state.kind = 'mapping' | ||
| state.result = _result | ||
| } | ||
| return detected | ||
| } | ||
| function readTagProperty (state) { | ||
| let isVerbatim = false | ||
| let isNamed = false | ||
| let tagHandle | ||
| let tagName | ||
| let ch = state.input.charCodeAt(state.position) | ||
| if (ch !== 0x21/* ! */) return false | ||
| if (state.tag !== null) { | ||
| throwError(state, 'duplication of a tag property') | ||
| } | ||
| ch = state.input.charCodeAt(++state.position) | ||
| if (ch === 0x3C/* < */) { | ||
| isVerbatim = true | ||
| ch = state.input.charCodeAt(++state.position) | ||
| } else if (ch === 0x21/* ! */) { | ||
| isNamed = true | ||
| tagHandle = '!!' | ||
| ch = state.input.charCodeAt(++state.position) | ||
| } else { | ||
| tagHandle = '!' | ||
| } | ||
| let _position = state.position | ||
| if (isVerbatim) { | ||
| do { ch = state.input.charCodeAt(++state.position) } | ||
| while (ch !== 0 && ch !== 0x3E/* > */) | ||
| if (state.position < state.length) { | ||
| tagName = state.input.slice(_position, state.position) | ||
| ch = state.input.charCodeAt(++state.position) | ||
| } else { | ||
| throwError(state, 'unexpected end of the stream within a verbatim tag') | ||
| } | ||
| } else { | ||
| while (ch !== 0 && !isWsOrEol(ch)) { | ||
| if (ch === 0x21/* ! */) { | ||
| if (!isNamed) { | ||
| tagHandle = state.input.slice(_position - 1, state.position + 1) | ||
| if (!PATTERN_TAG_HANDLE.test(tagHandle)) { | ||
| throwError(state, 'named tag handle cannot contain such characters') | ||
| } | ||
| isNamed = true | ||
| _position = state.position + 1 | ||
| } else { | ||
| throwError(state, 'tag suffix cannot contain exclamation marks') | ||
| } | ||
| } | ||
| ch = state.input.charCodeAt(++state.position) | ||
| } | ||
| tagName = state.input.slice(_position, state.position) | ||
| if (PATTERN_FLOW_INDICATORS.test(tagName)) { | ||
| throwError(state, 'tag suffix cannot contain flow indicator characters') | ||
| } | ||
| } | ||
| if (tagName && !PATTERN_TAG_URI.test(tagName)) { | ||
| throwError(state, 'tag name cannot contain such characters: ' + tagName) | ||
| } | ||
| try { | ||
| tagName = decodeURIComponent(tagName) | ||
| } catch (err) { | ||
| throwError(state, 'tag name is malformed: ' + tagName) | ||
| } | ||
| if (isVerbatim) { | ||
| state.tag = tagName | ||
| } else if (_hasOwnProperty.call(state.tagMap, tagHandle)) { | ||
| state.tag = state.tagMap[tagHandle] + tagName | ||
| } else if (tagHandle === '!') { | ||
| state.tag = '!' + tagName | ||
| } else if (tagHandle === '!!') { | ||
| state.tag = 'tag:yaml.org,2002:' + tagName | ||
| } else { | ||
| throwError(state, 'undeclared tag handle "' + tagHandle + '"') | ||
| } | ||
| return true | ||
| } | ||
| function readAnchorProperty (state) { | ||
| let ch = state.input.charCodeAt(state.position) | ||
| if (ch !== 0x26/* & */) return false | ||
| if (state.anchor !== null) { | ||
| throwError(state, 'duplication of an anchor property') | ||
| } | ||
| ch = state.input.charCodeAt(++state.position) | ||
| const _position = state.position | ||
| while (ch !== 0 && !isWsOrEol(ch) && !isFlowIndicator(ch)) { | ||
| ch = state.input.charCodeAt(++state.position) | ||
| } | ||
| if (state.position === _position) { | ||
| throwError(state, 'name of an anchor node must contain at least one character') | ||
| } | ||
| state.anchor = state.input.slice(_position, state.position) | ||
| return true | ||
| } | ||
| function readAlias (state) { | ||
| let ch = state.input.charCodeAt(state.position) | ||
| if (ch !== 0x2A/* * */) return false | ||
| ch = state.input.charCodeAt(++state.position) | ||
| const _position = state.position | ||
| while (ch !== 0 && !isWsOrEol(ch) && !isFlowIndicator(ch)) { | ||
| ch = state.input.charCodeAt(++state.position) | ||
| } | ||
| if (state.position === _position) { | ||
| throwError(state, 'name of an alias node must contain at least one character') | ||
| } | ||
| const alias = state.input.slice(_position, state.position) | ||
| if (!_hasOwnProperty.call(state.anchorMap, alias)) { | ||
| throwError(state, 'unidentified alias "' + alias + '"') | ||
| } | ||
| state.result = state.anchorMap[alias] | ||
| skipSeparationSpace(state, true, -1) | ||
| return true | ||
| } | ||
| function tryReadBlockMappingFromProperty (state, propertyStart, nodeIndent, flowIndent) { | ||
| const fallbackState = snapshotState(state) | ||
| beginAnchorTransaction(state) | ||
| restoreState(state, propertyStart) | ||
| // Re-read the leading properties as part of the first implicit key, not as | ||
| // properties of the current node. | ||
| state.tag = null | ||
| state.anchor = null | ||
| state.kind = null | ||
| state.result = null | ||
| if (readBlockMapping(state, nodeIndent, flowIndent) && state.kind === 'mapping') { | ||
| commitAnchorTransaction(state) | ||
| return true | ||
| } | ||
| rollbackAnchorTransaction(state) | ||
| restoreState(state, fallbackState) | ||
| return false | ||
| } | ||
| function composeNode (state, parentIndent, nodeContext, allowToSeek, allowCompact) { | ||
| let allowBlockScalars | ||
| let allowBlockCollections | ||
| let indentStatus = 1 // 1: this>parent, 0: this=parent, -1: this<parent | ||
| let atNewLine = false | ||
| let hasContent = false | ||
| let propertyStart = null | ||
| let type | ||
| let flowIndent | ||
| let blockIndent | ||
| if (state.depth >= state.maxDepth) { | ||
| throwError(state, 'nesting exceeded maxDepth (' + state.maxDepth + ')') | ||
| } | ||
| state.depth += 1 | ||
| if (state.listener !== null) { | ||
| state.listener('open', state) | ||
| } | ||
| state.tag = null | ||
| state.anchor = null | ||
| state.kind = null | ||
| state.result = null | ||
| const allowBlockStyles = allowBlockScalars = allowBlockCollections = | ||
| CONTEXT_BLOCK_OUT === nodeContext || | ||
| CONTEXT_BLOCK_IN === nodeContext | ||
| if (allowToSeek) { | ||
| if (skipSeparationSpace(state, true, -1)) { | ||
| atNewLine = true | ||
| if (state.lineIndent > parentIndent) { | ||
| indentStatus = 1 | ||
| } else if (state.lineIndent === parentIndent) { | ||
| indentStatus = 0 | ||
| } else if (state.lineIndent < parentIndent) { | ||
| indentStatus = -1 | ||
| } | ||
| } | ||
| } | ||
| if (indentStatus === 1) { | ||
| while (true) { | ||
| const ch = state.input.charCodeAt(state.position) | ||
| const propertyState = snapshotState(state) | ||
| // A duplicate property token after a line break can be the first key of | ||
| // a nested block mapping, e.g. `!!map\n !!str key: value`. | ||
| if (atNewLine && | ||
| ((ch === 0x21/* ! */ && state.tag !== null) || | ||
| (ch === 0x26/* & */ && state.anchor !== null))) { | ||
| break | ||
| } | ||
| if (!readTagProperty(state) && !readAnchorProperty(state)) { | ||
| break | ||
| } | ||
| if (propertyStart === null) { | ||
| propertyStart = propertyState | ||
| } | ||
| if (skipSeparationSpace(state, true, -1)) { | ||
| atNewLine = true | ||
| allowBlockCollections = allowBlockStyles | ||
| if (state.lineIndent > parentIndent) { | ||
| indentStatus = 1 | ||
| } else if (state.lineIndent === parentIndent) { | ||
| indentStatus = 0 | ||
| } else if (state.lineIndent < parentIndent) { | ||
| indentStatus = -1 | ||
| } | ||
| } else { | ||
| allowBlockCollections = false | ||
| } | ||
| } | ||
| } | ||
| if (allowBlockCollections) { | ||
| allowBlockCollections = atNewLine || allowCompact | ||
| } | ||
| if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) { | ||
| if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) { | ||
| flowIndent = parentIndent | ||
| } else { | ||
| flowIndent = parentIndent + 1 | ||
| } | ||
| blockIndent = state.position - state.lineStart | ||
| if (indentStatus === 1) { | ||
| if ((allowBlockCollections && | ||
| (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent))) || | ||
| readFlowCollection(state, flowIndent)) { | ||
| hasContent = true | ||
| } else { | ||
| const ch = state.input.charCodeAt(state.position) | ||
| if (propertyStart !== null && allowBlockStyles && !allowBlockCollections && | ||
| ch !== 0x7C/* | */ && ch !== 0x3E/* > */ && | ||
| tryReadBlockMappingFromProperty( | ||
| state, | ||
| propertyStart, | ||
| propertyStart.position - propertyStart.lineStart, | ||
| flowIndent | ||
| )) { | ||
| hasContent = true | ||
| } else if ((allowBlockScalars && readBlockScalar(state, flowIndent)) || | ||
| readSingleQuotedScalar(state, flowIndent) || | ||
| readDoubleQuotedScalar(state, flowIndent)) { | ||
| hasContent = true | ||
| } else if (readAlias(state)) { | ||
| hasContent = true | ||
| if (state.tag !== null || state.anchor !== null) { | ||
| throwError(state, 'alias node should not have any properties') | ||
| } | ||
| } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) { | ||
| hasContent = true | ||
| if (state.tag === null) { | ||
| state.tag = '?' | ||
| } | ||
| } | ||
| if (state.anchor !== null) { | ||
| storeAnchor(state, state.anchor, state.result) | ||
| } | ||
| } | ||
| } else if (indentStatus === 0) { | ||
| // Special case: block sequences are allowed to have same indentation level as the parent. | ||
| // http://www.yaml.org/spec/1.2/spec.html#id2799784 | ||
| hasContent = allowBlockCollections && readBlockSequence(state, blockIndent) | ||
| } | ||
| } | ||
| if (state.tag === null) { | ||
| if (state.anchor !== null) { | ||
| storeAnchor(state, state.anchor, state.result) | ||
| } | ||
| } else if (state.tag === '?') { | ||
| // Implicit resolving is not allowed for non-scalar types, and '?' | ||
| // non-specific tag is only automatically assigned to plain scalars. | ||
| // | ||
| // We only need to check kind conformity in case user explicitly assigns '?' | ||
| // tag, for example like this: "!<?> [0]" | ||
| // | ||
| if (state.result !== null && state.kind !== 'scalar') { | ||
| throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"') | ||
| } | ||
| for (let typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) { | ||
| type = state.implicitTypes[typeIndex] | ||
| if (type.resolve(state.result)) { // `state.result` updated in resolver if matched | ||
| state.result = type.construct(state.result) | ||
| state.tag = type.tag | ||
| if (state.anchor !== null) { | ||
| storeAnchor(state, state.anchor, state.result) | ||
| } | ||
| break | ||
| } | ||
| } | ||
| } else if (state.tag !== '!') { | ||
| if (_hasOwnProperty.call(state.typeMap[state.kind || 'fallback'], state.tag)) { | ||
| type = state.typeMap[state.kind || 'fallback'][state.tag] | ||
| } else { | ||
| // looking for multi type | ||
| type = null | ||
| const typeList = state.typeMap.multi[state.kind || 'fallback'] | ||
| for (let typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) { | ||
| if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) { | ||
| type = typeList[typeIndex] | ||
| break | ||
| } | ||
| } | ||
| } | ||
| if (!type) { | ||
| throwError(state, 'unknown tag !<' + state.tag + '>') | ||
| } | ||
| if (state.result !== null && type.kind !== state.kind) { | ||
| throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"') | ||
| } | ||
| if (!type.resolve(state.result, state.tag)) { // `state.result` updated in resolver if matched | ||
| throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag') | ||
| } else { | ||
| state.result = type.construct(state.result, state.tag) | ||
| if (state.anchor !== null) { | ||
| storeAnchor(state, state.anchor, state.result) | ||
| } | ||
| } | ||
| } | ||
| if (state.listener !== null) { | ||
| state.listener('close', state) | ||
| } | ||
| state.depth -= 1 | ||
| return state.tag !== null || state.anchor !== null || hasContent | ||
| } | ||
| function readDocument (state) { | ||
| const documentStart = state.position | ||
| let hasDirectives = false | ||
| let ch | ||
| state.version = null | ||
| state.checkLineBreaks = state.legacy | ||
| state.tagMap = Object.create(null) | ||
| state.anchorMap = Object.create(null) | ||
| while ((ch = state.input.charCodeAt(state.position)) !== 0) { | ||
| skipSeparationSpace(state, true, -1) | ||
| ch = state.input.charCodeAt(state.position) | ||
| if (state.lineIndent > 0 || ch !== 0x25/* % */) { | ||
| break | ||
| } | ||
| hasDirectives = true | ||
| ch = state.input.charCodeAt(++state.position) | ||
| let _position = state.position | ||
| while (ch !== 0 && !isWsOrEol(ch)) { | ||
| ch = state.input.charCodeAt(++state.position) | ||
| } | ||
| const directiveName = state.input.slice(_position, state.position) | ||
| const directiveArgs = [] | ||
| if (directiveName.length < 1) { | ||
| throwError(state, 'directive name must not be less than one character in length') | ||
| } | ||
| while (ch !== 0) { | ||
| while (isWhiteSpace(ch)) { | ||
| ch = state.input.charCodeAt(++state.position) | ||
| } | ||
| if (ch === 0x23/* # */) { | ||
| do { ch = state.input.charCodeAt(++state.position) } | ||
| while (ch !== 0 && !isEol(ch)) | ||
| break | ||
| } | ||
| if (isEol(ch)) break | ||
| _position = state.position | ||
| while (ch !== 0 && !isWsOrEol(ch)) { | ||
| ch = state.input.charCodeAt(++state.position) | ||
| } | ||
| directiveArgs.push(state.input.slice(_position, state.position)) | ||
| } | ||
| if (ch !== 0) readLineBreak(state) | ||
| if (_hasOwnProperty.call(directiveHandlers, directiveName)) { | ||
| directiveHandlers[directiveName](state, directiveName, directiveArgs) | ||
| } else { | ||
| throwWarning(state, 'unknown document directive "' + directiveName + '"') | ||
| } | ||
| } | ||
| skipSeparationSpace(state, true, -1) | ||
| if (state.lineIndent === 0 && | ||
| state.input.charCodeAt(state.position) === 0x2D/* - */ && | ||
| state.input.charCodeAt(state.position + 1) === 0x2D/* - */ && | ||
| state.input.charCodeAt(state.position + 2) === 0x2D/* - */) { | ||
| state.position += 3 | ||
| skipSeparationSpace(state, true, -1) | ||
| } else if (hasDirectives) { | ||
| throwError(state, 'directives end mark is expected') | ||
| } | ||
| composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true) | ||
| skipSeparationSpace(state, true, -1) | ||
| if (state.checkLineBreaks && | ||
| PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) { | ||
| throwWarning(state, 'non-ASCII line breaks are interpreted as content') | ||
| } | ||
| state.documents.push(state.result) | ||
| if (state.position === state.lineStart && testDocumentSeparator(state)) { | ||
| if (state.input.charCodeAt(state.position) === 0x2E/* . */) { | ||
| state.position += 3 | ||
| skipSeparationSpace(state, true, -1) | ||
| } | ||
| return | ||
| } | ||
| if (state.position < (state.length - 1)) { | ||
| throwError(state, 'end of the stream or a document separator is expected') | ||
| } | ||
| } | ||
| function loadDocuments (input, options) { | ||
| input = String(input) | ||
| options = options || {} | ||
| if (input.length !== 0) { | ||
| // Add tailing `\n` if not exists | ||
| if (input.charCodeAt(input.length - 1) !== 0x0A/* LF */ && | ||
| input.charCodeAt(input.length - 1) !== 0x0D/* CR */) { | ||
| input += '\n' | ||
| } | ||
| // Strip BOM | ||
| if (input.charCodeAt(0) === 0xFEFF) { | ||
| input = input.slice(1) | ||
| } | ||
| } | ||
| const state = new State(input, options) | ||
| const nullpos = input.indexOf('\0') | ||
| if (nullpos !== -1) { | ||
| state.position = nullpos | ||
| throwError(state, 'null byte is not allowed in input') | ||
| } | ||
| // Use 0 as string terminator. That significantly simplifies bounds check. | ||
| state.input += '\0' | ||
| while (state.input.charCodeAt(state.position) === 0x20/* Space */) { | ||
| state.lineIndent += 1 | ||
| state.position += 1 | ||
| } | ||
| while (state.position < (state.length - 1)) { | ||
| readDocument(state) | ||
| } | ||
| return state.documents | ||
| } | ||
| function loadAll (input, iterator, options) { | ||
| if (iterator !== null && typeof iterator === 'object' && typeof options === 'undefined') { | ||
| options = iterator | ||
| iterator = null | ||
| } | ||
| const documents = loadDocuments(input, options) | ||
| if (typeof iterator !== 'function') { | ||
| return documents | ||
| } | ||
| for (let index = 0, length = documents.length; index < length; index += 1) { | ||
| iterator(documents[index]) | ||
| } | ||
| } | ||
| function load (input, options) { | ||
| const documents = loadDocuments(input, options) | ||
| if (documents.length === 0) { | ||
| return undefined | ||
| } else if (documents.length === 1) { | ||
| return documents[0] | ||
| } | ||
| throw new YAMLException('expected a single document in the stream, but found more') | ||
| } | ||
| module.exports.loadAll = loadAll | ||
| module.exports.load = load |
-109
| 'use strict' | ||
| const YAMLException = require('./exception') | ||
| const Type = require('./type') | ||
| function compileList (schema, name) { | ||
| const result = [] | ||
| schema[name].forEach(function (currentType) { | ||
| let newIndex = result.length | ||
| result.forEach(function (previousType, previousIndex) { | ||
| if (previousType.tag === currentType.tag && | ||
| previousType.kind === currentType.kind && | ||
| previousType.multi === currentType.multi) { | ||
| newIndex = previousIndex | ||
| } | ||
| }) | ||
| result[newIndex] = currentType | ||
| }) | ||
| return result | ||
| } | ||
| function compileMap (/* lists... */) { | ||
| const result = { | ||
| scalar: {}, | ||
| sequence: {}, | ||
| mapping: {}, | ||
| fallback: {}, | ||
| multi: { | ||
| scalar: [], | ||
| sequence: [], | ||
| mapping: [], | ||
| fallback: [] | ||
| } | ||
| } | ||
| function collectType (type) { | ||
| if (type.multi) { | ||
| result.multi[type.kind].push(type) | ||
| result.multi['fallback'].push(type) | ||
| } else { | ||
| result[type.kind][type.tag] = result['fallback'][type.tag] = type | ||
| } | ||
| } | ||
| for (let index = 0, length = arguments.length; index < length; index += 1) { | ||
| arguments[index].forEach(collectType) | ||
| } | ||
| return result | ||
| } | ||
| function Schema (definition) { | ||
| return this.extend(definition) | ||
| } | ||
| Schema.prototype.extend = function extend (definition) { | ||
| let implicit = [] | ||
| let explicit = [] | ||
| if (definition instanceof Type) { | ||
| // Schema.extend(type) | ||
| explicit.push(definition) | ||
| } else if (Array.isArray(definition)) { | ||
| // Schema.extend([ type1, type2, ... ]) | ||
| explicit = explicit.concat(definition) | ||
| } else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) { | ||
| // Schema.extend({ explicit: [ type1, type2, ... ], implicit: [ type1, type2, ... ] }) | ||
| if (definition.implicit) implicit = implicit.concat(definition.implicit) | ||
| if (definition.explicit) explicit = explicit.concat(definition.explicit) | ||
| } else { | ||
| throw new YAMLException('Schema.extend argument should be a Type, [ Type ], ' + | ||
| 'or a schema definition ({ implicit: [...], explicit: [...] })') | ||
| } | ||
| implicit.forEach(function (type) { | ||
| if (!(type instanceof Type)) { | ||
| throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.') | ||
| } | ||
| if (type.loadKind && type.loadKind !== 'scalar') { | ||
| throw new YAMLException('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.') | ||
| } | ||
| if (type.multi) { | ||
| throw new YAMLException('There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.') | ||
| } | ||
| }) | ||
| explicit.forEach(function (type) { | ||
| if (!(type instanceof Type)) { | ||
| throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.') | ||
| } | ||
| }) | ||
| const result = Object.create(Schema.prototype) | ||
| result.implicit = (this.implicit || []).concat(implicit) | ||
| result.explicit = (this.explicit || []).concat(explicit) | ||
| result.compiledImplicit = compileList(result, 'implicit') | ||
| result.compiledExplicit = compileList(result, 'explicit') | ||
| result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit) | ||
| return result | ||
| } | ||
| module.exports = Schema |
| // Standard YAML's Core schema. | ||
| // http://www.yaml.org/spec/1.2/spec.html#id2804923 | ||
| // | ||
| // NOTE: JS-YAML does not support schema-specific tag resolution restrictions. | ||
| // So, Core schema has no distinctions from JSON schema is JS-YAML. | ||
| 'use strict' | ||
| module.exports = require('./json') |
| // JS-YAML's default schema for `safeLoad` function. | ||
| // It is not described in the YAML specification. | ||
| // | ||
| // This schema is based on standard YAML's Core schema and includes most of | ||
| // extra types described at YAML tag repository. (http://yaml.org/type/) | ||
| 'use strict' | ||
| module.exports = require('./core').extend({ | ||
| implicit: [ | ||
| require('../type/timestamp'), | ||
| require('../type/merge') | ||
| ], | ||
| explicit: [ | ||
| require('../type/binary'), | ||
| require('../type/omap'), | ||
| require('../type/pairs'), | ||
| require('../type/set') | ||
| ] | ||
| }) |
| // Standard YAML's Failsafe schema. | ||
| // http://www.yaml.org/spec/1.2/spec.html#id2802346 | ||
| 'use strict' | ||
| const Schema = require('../schema') | ||
| module.exports = new Schema({ | ||
| explicit: [ | ||
| require('../type/str'), | ||
| require('../type/seq'), | ||
| require('../type/map') | ||
| ] | ||
| }) |
| // Standard YAML's JSON schema. | ||
| // http://www.yaml.org/spec/1.2/spec.html#id2803231 | ||
| // | ||
| // NOTE: JS-YAML does not support schema-specific tag resolution restrictions. | ||
| // So, this schema is not such strict as defined in the YAML specification. | ||
| // It allows numbers in binary notaion, use `Null` and `NULL` as `null`, etc. | ||
| 'use strict' | ||
| module.exports = require('./failsafe').extend({ | ||
| implicit: [ | ||
| require('../type/null'), | ||
| require('../type/bool'), | ||
| require('../type/int'), | ||
| require('../type/float') | ||
| ] | ||
| }) |
| 'use strict' | ||
| const common = require('./common') | ||
| // get snippet for a single line, respecting maxLength | ||
| function getLine (buffer, lineStart, lineEnd, position, maxLineLength) { | ||
| let head = '' | ||
| let tail = '' | ||
| const maxHalfLength = Math.floor(maxLineLength / 2) - 1 | ||
| if (position - lineStart > maxHalfLength) { | ||
| head = ' ... ' | ||
| lineStart = position - maxHalfLength + head.length | ||
| } | ||
| if (lineEnd - position > maxHalfLength) { | ||
| tail = ' ...' | ||
| lineEnd = position + maxHalfLength - tail.length | ||
| } | ||
| return { | ||
| str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, '→') + tail, | ||
| pos: position - lineStart + head.length // relative position | ||
| } | ||
| } | ||
| function padStart (string, max) { | ||
| return common.repeat(' ', max - string.length) + string | ||
| } | ||
| function makeSnippet (mark, options) { | ||
| options = Object.create(options || null) | ||
| if (!mark.buffer) return null | ||
| if (!options.maxLength) options.maxLength = 79 | ||
| if (typeof options.indent !== 'number') options.indent = 1 | ||
| if (typeof options.linesBefore !== 'number') options.linesBefore = 3 | ||
| if (typeof options.linesAfter !== 'number') options.linesAfter = 2 | ||
| const re = /\r?\n|\r|\0/g | ||
| const lineStarts = [0] | ||
| const lineEnds = [] | ||
| let match | ||
| let foundLineNo = -1 | ||
| while ((match = re.exec(mark.buffer))) { | ||
| lineEnds.push(match.index) | ||
| lineStarts.push(match.index + match[0].length) | ||
| if (mark.position <= match.index && foundLineNo < 0) { | ||
| foundLineNo = lineStarts.length - 2 | ||
| } | ||
| } | ||
| if (foundLineNo < 0) foundLineNo = lineStarts.length - 1 | ||
| let result = '' | ||
| const lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length | ||
| const maxLineLength = options.maxLength - (options.indent + lineNoLength + 3) | ||
| for (let i = 1; i <= options.linesBefore; i++) { | ||
| if (foundLineNo - i < 0) break | ||
| const line = getLine( | ||
| mark.buffer, | ||
| lineStarts[foundLineNo - i], | ||
| lineEnds[foundLineNo - i], | ||
| mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]), | ||
| maxLineLength | ||
| ) | ||
| result = common.repeat(' ', options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + | ||
| ' | ' + line.str + '\n' + result | ||
| } | ||
| const line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength) | ||
| result += common.repeat(' ', options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + | ||
| ' | ' + line.str + '\n' | ||
| result += common.repeat('-', options.indent + lineNoLength + 3 + line.pos) + '^' + '\n' | ||
| for (let i = 1; i <= options.linesAfter; i++) { | ||
| if (foundLineNo + i >= lineEnds.length) break | ||
| const line = getLine( | ||
| mark.buffer, | ||
| lineStarts[foundLineNo + i], | ||
| lineEnds[foundLineNo + i], | ||
| mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]), | ||
| maxLineLength | ||
| ) | ||
| result += common.repeat(' ', options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + | ||
| ' | ' + line.str + '\n' | ||
| } | ||
| return result.replace(/\n$/, '') | ||
| } | ||
| module.exports = makeSnippet |
-66
| 'use strict' | ||
| const YAMLException = require('./exception') | ||
| const TYPE_CONSTRUCTOR_OPTIONS = [ | ||
| 'kind', | ||
| 'multi', | ||
| 'resolve', | ||
| 'construct', | ||
| 'instanceOf', | ||
| 'predicate', | ||
| 'represent', | ||
| 'representName', | ||
| 'defaultStyle', | ||
| 'styleAliases' | ||
| ] | ||
| const YAML_NODE_KINDS = [ | ||
| 'scalar', | ||
| 'sequence', | ||
| 'mapping' | ||
| ] | ||
| function compileStyleAliases (map) { | ||
| const result = {} | ||
| if (map !== null) { | ||
| Object.keys(map).forEach(function (style) { | ||
| map[style].forEach(function (alias) { | ||
| result[String(alias)] = style | ||
| }) | ||
| }) | ||
| } | ||
| return result | ||
| } | ||
| function Type (tag, options) { | ||
| options = options || {} | ||
| Object.keys(options).forEach(function (name) { | ||
| if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) { | ||
| throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.') | ||
| } | ||
| }) | ||
| // TODO: Add tag format check. | ||
| this.options = options // keep original options in case user wants to extend this type later | ||
| this.tag = tag | ||
| this.kind = options['kind'] || null | ||
| this.resolve = options['resolve'] || function () { return true } | ||
| this.construct = options['construct'] || function (data) { return data } | ||
| this.instanceOf = options['instanceOf'] || null | ||
| this.predicate = options['predicate'] || null | ||
| this.represent = options['represent'] || null | ||
| this.representName = options['representName'] || null | ||
| this.defaultStyle = options['defaultStyle'] || null | ||
| this.multi = options['multi'] || false | ||
| this.styleAliases = compileStyleAliases(options['styleAliases'] || null) | ||
| if (YAML_NODE_KINDS.indexOf(this.kind) === -1) { | ||
| throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.') | ||
| } | ||
| } | ||
| module.exports = Type |
| 'use strict' | ||
| const Type = require('../type') | ||
| // [ 64, 65, 66 ] -> [ padding, CR, LF ] | ||
| const BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r' | ||
| function resolveYamlBinary (data) { | ||
| if (data === null) return false | ||
| let bitlen = 0 | ||
| const max = data.length | ||
| const map = BASE64_MAP | ||
| // Convert one by one. | ||
| for (let idx = 0; idx < max; idx++) { | ||
| const code = map.indexOf(data.charAt(idx)) | ||
| // Skip CR/LF | ||
| if (code > 64) continue | ||
| // Fail on illegal characters | ||
| if (code < 0) return false | ||
| bitlen += 6 | ||
| } | ||
| // If there are any bits left, source was corrupted | ||
| return (bitlen % 8) === 0 | ||
| } | ||
| function constructYamlBinary (data) { | ||
| const input = data.replace(/[\r\n=]/g, '') // remove CR/LF & padding to simplify scan | ||
| const max = input.length | ||
| const map = BASE64_MAP | ||
| let bits = 0 | ||
| const result = [] | ||
| // Collect by 6*4 bits (3 bytes) | ||
| for (let idx = 0; idx < max; idx++) { | ||
| if ((idx % 4 === 0) && idx) { | ||
| result.push((bits >> 16) & 0xFF) | ||
| result.push((bits >> 8) & 0xFF) | ||
| result.push(bits & 0xFF) | ||
| } | ||
| bits = (bits << 6) | map.indexOf(input.charAt(idx)) | ||
| } | ||
| // Dump tail | ||
| const tailbits = (max % 4) * 6 | ||
| if (tailbits === 0) { | ||
| result.push((bits >> 16) & 0xFF) | ||
| result.push((bits >> 8) & 0xFF) | ||
| result.push(bits & 0xFF) | ||
| } else if (tailbits === 18) { | ||
| result.push((bits >> 10) & 0xFF) | ||
| result.push((bits >> 2) & 0xFF) | ||
| } else if (tailbits === 12) { | ||
| result.push((bits >> 4) & 0xFF) | ||
| } | ||
| return new Uint8Array(result) | ||
| } | ||
| function representYamlBinary (object /*, style */) { | ||
| let result = '' | ||
| let bits = 0 | ||
| const max = object.length | ||
| const map = BASE64_MAP | ||
| // Convert every three bytes to 4 ASCII characters. | ||
| for (let idx = 0; idx < max; idx++) { | ||
| if ((idx % 3 === 0) && idx) { | ||
| result += map[(bits >> 18) & 0x3F] | ||
| result += map[(bits >> 12) & 0x3F] | ||
| result += map[(bits >> 6) & 0x3F] | ||
| result += map[bits & 0x3F] | ||
| } | ||
| bits = (bits << 8) + object[idx] | ||
| } | ||
| // Dump tail | ||
| const tail = max % 3 | ||
| if (tail === 0) { | ||
| result += map[(bits >> 18) & 0x3F] | ||
| result += map[(bits >> 12) & 0x3F] | ||
| result += map[(bits >> 6) & 0x3F] | ||
| result += map[bits & 0x3F] | ||
| } else if (tail === 2) { | ||
| result += map[(bits >> 10) & 0x3F] | ||
| result += map[(bits >> 4) & 0x3F] | ||
| result += map[(bits << 2) & 0x3F] | ||
| result += map[64] | ||
| } else if (tail === 1) { | ||
| result += map[(bits >> 2) & 0x3F] | ||
| result += map[(bits << 4) & 0x3F] | ||
| result += map[64] | ||
| result += map[64] | ||
| } | ||
| return result | ||
| } | ||
| function isBinary (obj) { | ||
| return Object.prototype.toString.call(obj) === '[object Uint8Array]' | ||
| } | ||
| module.exports = new Type('tag:yaml.org,2002:binary', { | ||
| kind: 'scalar', | ||
| resolve: resolveYamlBinary, | ||
| construct: constructYamlBinary, | ||
| predicate: isBinary, | ||
| represent: representYamlBinary | ||
| }) |
| 'use strict' | ||
| const Type = require('../type') | ||
| function resolveYamlBoolean (data) { | ||
| if (data === null) return false | ||
| const max = data.length | ||
| return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) || | ||
| (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE')) | ||
| } | ||
| function constructYamlBoolean (data) { | ||
| return data === 'true' || | ||
| data === 'True' || | ||
| data === 'TRUE' | ||
| } | ||
| function isBoolean (object) { | ||
| return Object.prototype.toString.call(object) === '[object Boolean]' | ||
| } | ||
| module.exports = new Type('tag:yaml.org,2002:bool', { | ||
| kind: 'scalar', | ||
| resolve: resolveYamlBoolean, | ||
| construct: constructYamlBoolean, | ||
| predicate: isBoolean, | ||
| represent: { | ||
| lowercase: function (object) { return object ? 'true' : 'false' }, | ||
| uppercase: function (object) { return object ? 'TRUE' : 'FALSE' }, | ||
| camelcase: function (object) { return object ? 'True' : 'False' } | ||
| }, | ||
| defaultStyle: 'lowercase' | ||
| }) |
| 'use strict' | ||
| const common = require('../common') | ||
| const Type = require('../type') | ||
| const YAML_FLOAT_PATTERN = new RegExp( | ||
| // 2.5e4, 2.5 and integers | ||
| '^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?' + | ||
| // .2e4, .2 | ||
| // special case, seems not from spec | ||
| '|\\.[0-9]+(?:[eE][-+]?[0-9]+)?' + | ||
| // .inf | ||
| '|[-+]?\\.(?:inf|Inf|INF)' + | ||
| // .nan | ||
| '|\\.(?:nan|NaN|NAN))$') | ||
| const YAML_FLOAT_SPECIAL_PATTERN = new RegExp( | ||
| '^(?:' + | ||
| // .inf | ||
| '[-+]?\\.(?:inf|Inf|INF)' + | ||
| // .nan | ||
| '|\\.(?:nan|NaN|NAN))$') | ||
| function resolveYamlFloat (data) { | ||
| if (data === null) return false | ||
| if (!YAML_FLOAT_PATTERN.test(data)) { | ||
| return false | ||
| } | ||
| if (Number.isFinite(parseFloat(data, 10))) { | ||
| return true | ||
| } | ||
| return YAML_FLOAT_SPECIAL_PATTERN.test(data) | ||
| } | ||
| function constructYamlFloat (data) { | ||
| let value = data.toLowerCase() | ||
| const sign = value[0] === '-' ? -1 : 1 | ||
| if ('+-'.indexOf(value[0]) >= 0) { | ||
| value = value.slice(1) | ||
| } | ||
| if (value === '.inf') { | ||
| return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY | ||
| } else if (value === '.nan') { | ||
| return NaN | ||
| } | ||
| return sign * parseFloat(value, 10) | ||
| } | ||
| const SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/ | ||
| function representYamlFloat (object, style) { | ||
| if (isNaN(object)) { | ||
| switch (style) { | ||
| case 'lowercase': return '.nan' | ||
| case 'uppercase': return '.NAN' | ||
| case 'camelcase': return '.NaN' | ||
| } | ||
| } else if (Number.POSITIVE_INFINITY === object) { | ||
| switch (style) { | ||
| case 'lowercase': return '.inf' | ||
| case 'uppercase': return '.INF' | ||
| case 'camelcase': return '.Inf' | ||
| } | ||
| } else if (Number.NEGATIVE_INFINITY === object) { | ||
| switch (style) { | ||
| case 'lowercase': return '-.inf' | ||
| case 'uppercase': return '-.INF' | ||
| case 'camelcase': return '-.Inf' | ||
| } | ||
| } else if (common.isNegativeZero(object)) { | ||
| return '-0.0' | ||
| } | ||
| const res = object.toString(10) | ||
| // JS stringifier can build scientific format without dots: 5e-100, | ||
| // while YAML requres dot: 5.e-100. Fix it with simple hack | ||
| return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res | ||
| } | ||
| function isFloat (object) { | ||
| return (Object.prototype.toString.call(object) === '[object Number]') && | ||
| (object % 1 !== 0 || common.isNegativeZero(object)) | ||
| } | ||
| module.exports = new Type('tag:yaml.org,2002:float', { | ||
| kind: 'scalar', | ||
| resolve: resolveYamlFloat, | ||
| construct: constructYamlFloat, | ||
| predicate: isFloat, | ||
| represent: representYamlFloat, | ||
| defaultStyle: 'lowercase' | ||
| }) |
-142
| 'use strict' | ||
| const common = require('../common') | ||
| const Type = require('../type') | ||
| function isHexCode (c) { | ||
| return ((c >= 0x30/* 0 */) && (c <= 0x39/* 9 */)) || | ||
| ((c >= 0x41/* A */) && (c <= 0x46/* F */)) || | ||
| ((c >= 0x61/* a */) && (c <= 0x66/* f */)) | ||
| } | ||
| function isOctCode (c) { | ||
| return ((c >= 0x30/* 0 */) && (c <= 0x37/* 7 */)) | ||
| } | ||
| function isDecCode (c) { | ||
| return ((c >= 0x30/* 0 */) && (c <= 0x39/* 9 */)) | ||
| } | ||
| function resolveYamlInteger (data) { | ||
| if (data === null) return false | ||
| const max = data.length | ||
| let index = 0 | ||
| let hasDigits = false | ||
| if (!max) return false | ||
| let ch = data[index] | ||
| // sign | ||
| if (ch === '-' || ch === '+') { | ||
| ch = data[++index] | ||
| } | ||
| if (ch === '0') { | ||
| // 0 | ||
| if (index + 1 === max) return true | ||
| ch = data[++index] | ||
| // base 2, base 8, base 16 | ||
| if (ch === 'b') { | ||
| // base 2 | ||
| index++ | ||
| for (; index < max; index++) { | ||
| ch = data[index] | ||
| if (ch !== '0' && ch !== '1') return false | ||
| hasDigits = true | ||
| } | ||
| return hasDigits && Number.isFinite(parseYamlInteger(data)) | ||
| } | ||
| if (ch === 'x') { | ||
| // base 16 | ||
| index++ | ||
| for (; index < max; index++) { | ||
| if (!isHexCode(data.charCodeAt(index))) return false | ||
| hasDigits = true | ||
| } | ||
| return hasDigits && Number.isFinite(parseYamlInteger(data)) | ||
| } | ||
| if (ch === 'o') { | ||
| // base 8 | ||
| index++ | ||
| for (; index < max; index++) { | ||
| if (!isOctCode(data.charCodeAt(index))) return false | ||
| hasDigits = true | ||
| } | ||
| return hasDigits && Number.isFinite(parseYamlInteger(data)) | ||
| } | ||
| } | ||
| // base 10 (except 0) | ||
| for (; index < max; index++) { | ||
| if (!isDecCode(data.charCodeAt(index))) { | ||
| return false | ||
| } | ||
| hasDigits = true | ||
| } | ||
| if (!hasDigits) return false | ||
| return Number.isFinite(parseYamlInteger(data)) | ||
| } | ||
| function parseYamlInteger (data) { | ||
| let value = data | ||
| let sign = 1 | ||
| let ch = value[0] | ||
| if (ch === '-' || ch === '+') { | ||
| if (ch === '-') sign = -1 | ||
| value = value.slice(1) | ||
| ch = value[0] | ||
| } | ||
| if (value === '0') return 0 | ||
| if (ch === '0') { | ||
| if (value[1] === 'b') return sign * parseInt(value.slice(2), 2) | ||
| if (value[1] === 'x') return sign * parseInt(value.slice(2), 16) | ||
| if (value[1] === 'o') return sign * parseInt(value.slice(2), 8) | ||
| } | ||
| return sign * parseInt(value, 10) | ||
| } | ||
| function constructYamlInteger (data) { | ||
| return parseYamlInteger(data) | ||
| } | ||
| function isInteger (object) { | ||
| return (Object.prototype.toString.call(object)) === '[object Number]' && | ||
| (object % 1 === 0 && !common.isNegativeZero(object)) | ||
| } | ||
| module.exports = new Type('tag:yaml.org,2002:int', { | ||
| kind: 'scalar', | ||
| resolve: resolveYamlInteger, | ||
| construct: constructYamlInteger, | ||
| predicate: isInteger, | ||
| represent: { | ||
| binary: function (obj) { return obj >= 0 ? '0b' + obj.toString(2) : '-0b' + obj.toString(2).slice(1) }, | ||
| octal: function (obj) { return obj >= 0 ? '0o' + obj.toString(8) : '-0o' + obj.toString(8).slice(1) }, | ||
| decimal: function (obj) { return obj.toString(10) }, | ||
| hexadecimal: function (obj) { return obj >= 0 ? '0x' + obj.toString(16).toUpperCase() : '-0x' + obj.toString(16).toUpperCase().slice(1) } | ||
| }, | ||
| defaultStyle: 'decimal', | ||
| styleAliases: { | ||
| binary: [2, 'bin'], | ||
| octal: [8, 'oct'], | ||
| decimal: [10, 'dec'], | ||
| hexadecimal: [16, 'hex'] | ||
| } | ||
| }) |
| 'use strict' | ||
| const Type = require('../type') | ||
| module.exports = new Type('tag:yaml.org,2002:map', { | ||
| kind: 'mapping', | ||
| construct: function (data) { return data !== null ? data : {} } | ||
| }) |
| 'use strict' | ||
| const Type = require('../type') | ||
| function resolveYamlMerge (data) { | ||
| return data === '<<' || data === null | ||
| } | ||
| module.exports = new Type('tag:yaml.org,2002:merge', { | ||
| kind: 'scalar', | ||
| resolve: resolveYamlMerge | ||
| }) |
| 'use strict' | ||
| const Type = require('../type') | ||
| function resolveYamlNull (data) { | ||
| if (data === null) return true | ||
| const max = data.length | ||
| return (max === 1 && data === '~') || | ||
| (max === 4 && (data === 'null' || data === 'Null' || data === 'NULL')) | ||
| } | ||
| function constructYamlNull () { | ||
| return null | ||
| } | ||
| function isNull (object) { | ||
| return object === null | ||
| } | ||
| module.exports = new Type('tag:yaml.org,2002:null', { | ||
| kind: 'scalar', | ||
| resolve: resolveYamlNull, | ||
| construct: constructYamlNull, | ||
| predicate: isNull, | ||
| represent: { | ||
| canonical: function () { return '~' }, | ||
| lowercase: function () { return 'null' }, | ||
| uppercase: function () { return 'NULL' }, | ||
| camelcase: function () { return 'Null' }, | ||
| empty: function () { return '' } | ||
| }, | ||
| defaultStyle: 'lowercase' | ||
| }) |
| 'use strict' | ||
| const Type = require('../type') | ||
| const _hasOwnProperty = Object.prototype.hasOwnProperty | ||
| const _toString = Object.prototype.toString | ||
| function resolveYamlOmap (data) { | ||
| if (data === null) return true | ||
| const objectKeys = [] | ||
| const object = data | ||
| for (let index = 0, length = object.length; index < length; index += 1) { | ||
| const pair = object[index] | ||
| let pairHasKey = false | ||
| if (_toString.call(pair) !== '[object Object]') return false | ||
| let pairKey | ||
| for (pairKey in pair) { | ||
| if (_hasOwnProperty.call(pair, pairKey)) { | ||
| if (!pairHasKey) pairHasKey = true | ||
| else return false | ||
| } | ||
| } | ||
| if (!pairHasKey) return false | ||
| if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey) | ||
| else return false | ||
| } | ||
| return true | ||
| } | ||
| function constructYamlOmap (data) { | ||
| return data !== null ? data : [] | ||
| } | ||
| module.exports = new Type('tag:yaml.org,2002:omap', { | ||
| kind: 'sequence', | ||
| resolve: resolveYamlOmap, | ||
| construct: constructYamlOmap | ||
| }) |
| 'use strict' | ||
| const Type = require('../type') | ||
| const _toString = Object.prototype.toString | ||
| function resolveYamlPairs (data) { | ||
| if (data === null) return true | ||
| const object = data | ||
| const result = new Array(object.length) | ||
| for (let index = 0, length = object.length; index < length; index += 1) { | ||
| const pair = object[index] | ||
| if (_toString.call(pair) !== '[object Object]') return false | ||
| const keys = Object.keys(pair) | ||
| if (keys.length !== 1) return false | ||
| result[index] = [keys[0], pair[keys[0]]] | ||
| } | ||
| return true | ||
| } | ||
| function constructYamlPairs (data) { | ||
| if (data === null) return [] | ||
| const object = data | ||
| const result = new Array(object.length) | ||
| for (let index = 0, length = object.length; index < length; index += 1) { | ||
| const pair = object[index] | ||
| const keys = Object.keys(pair) | ||
| result[index] = [keys[0], pair[keys[0]]] | ||
| } | ||
| return result | ||
| } | ||
| module.exports = new Type('tag:yaml.org,2002:pairs', { | ||
| kind: 'sequence', | ||
| resolve: resolveYamlPairs, | ||
| construct: constructYamlPairs | ||
| }) |
| 'use strict' | ||
| const Type = require('../type') | ||
| module.exports = new Type('tag:yaml.org,2002:seq', { | ||
| kind: 'sequence', | ||
| construct: function (data) { return data !== null ? data : [] } | ||
| }) |
| 'use strict' | ||
| const Type = require('../type') | ||
| const _hasOwnProperty = Object.prototype.hasOwnProperty | ||
| function resolveYamlSet (data) { | ||
| if (data === null) return true | ||
| const object = data | ||
| for (const key in object) { | ||
| if (_hasOwnProperty.call(object, key)) { | ||
| if (object[key] !== null) return false | ||
| } | ||
| } | ||
| return true | ||
| } | ||
| function constructYamlSet (data) { | ||
| return data !== null ? data : {} | ||
| } | ||
| module.exports = new Type('tag:yaml.org,2002:set', { | ||
| kind: 'mapping', | ||
| resolve: resolveYamlSet, | ||
| construct: constructYamlSet | ||
| }) |
| 'use strict' | ||
| const Type = require('../type') | ||
| module.exports = new Type('tag:yaml.org,2002:str', { | ||
| kind: 'scalar', | ||
| construct: function (data) { return data !== null ? data : '' } | ||
| }) |
| 'use strict' | ||
| const Type = require('../type') | ||
| const YAML_DATE_REGEXP = new RegExp( | ||
| '^([0-9][0-9][0-9][0-9])' + // [1] year | ||
| '-([0-9][0-9])' + // [2] month | ||
| '-([0-9][0-9])$') // [3] day | ||
| const YAML_TIMESTAMP_REGEXP = new RegExp( | ||
| '^([0-9][0-9][0-9][0-9])' + // [1] year | ||
| '-([0-9][0-9]?)' + // [2] month | ||
| '-([0-9][0-9]?)' + // [3] day | ||
| '(?:[Tt]|[ \\t]+)' + // ... | ||
| '([0-9][0-9]?)' + // [4] hour | ||
| ':([0-9][0-9])' + // [5] minute | ||
| ':([0-9][0-9])' + // [6] second | ||
| '(?:\\.([0-9]*))?' + // [7] fraction | ||
| '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tzHour | ||
| '(?::([0-9][0-9]))?))?$') // [11] tzMinute | ||
| function resolveYamlTimestamp (data) { | ||
| if (data === null) return false | ||
| if (YAML_DATE_REGEXP.exec(data) !== null) return true | ||
| if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true | ||
| return false | ||
| } | ||
| function constructYamlTimestamp (data) { | ||
| let fraction = 0 | ||
| let delta = null | ||
| let match = YAML_DATE_REGEXP.exec(data) | ||
| if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data) | ||
| if (match === null) throw new Error('Date resolve error') | ||
| // match: [1] year [2] month [3] day | ||
| const year = +(match[1]) | ||
| const month = +(match[2]) - 1 // JS month starts with 0 | ||
| const day = +(match[3]) | ||
| if (!match[4]) { // no hour | ||
| return new Date(Date.UTC(year, month, day)) | ||
| } | ||
| // match: [4] hour [5] minute [6] second [7] fraction | ||
| const hour = +(match[4]) | ||
| const minute = +(match[5]) | ||
| const second = +(match[6]) | ||
| if (match[7]) { | ||
| fraction = match[7].slice(0, 3) | ||
| while (fraction.length < 3) { // milli-seconds | ||
| fraction += '0' | ||
| } | ||
| fraction = +fraction | ||
| } | ||
| // match: [8] tz [9] tz_sign [10] tzHour [11] tzMinute | ||
| if (match[9]) { | ||
| const tzHour = +(match[10]) | ||
| const tzMinute = +(match[11] || 0) | ||
| delta = (tzHour * 60 + tzMinute) * 60000 // delta in mili-seconds | ||
| if (match[9] === '-') delta = -delta | ||
| } | ||
| const date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction)) | ||
| if (delta) date.setTime(date.getTime() - delta) | ||
| return date | ||
| } | ||
| function representYamlTimestamp (object /*, style */) { | ||
| return object.toISOString() | ||
| } | ||
| module.exports = new Type('tag:yaml.org,2002:timestamp', { | ||
| kind: 'scalar', | ||
| resolve: resolveYamlTimestamp, | ||
| construct: constructYamlTimestamp, | ||
| instanceOf: Date, | ||
| represent: representYamlTimestamp | ||
| }) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 2 instances
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
1412499
61.62%9140
10.48%1
-50%16
45.45%13
-63.89%3
50%207
-10.78%1
Infinity%