3 Object.defineProperty(exports, '__esModule', { value: true });
5 function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
7 var os = _interopDefault(require('os'));
8 var path = _interopDefault(require('path'));
9 var module$1 = _interopDefault(require('module'));
10 var fs = _interopDefault(require('fs'));
11 var util = _interopDefault(require('util'));
12 var stream = _interopDefault(require('stream'));
14 function unwrapExports (x) {
15 return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
18 function createCommonjsModule(fn, module) {
19 return module = { exports: {} }, fn(module, module.exports), module.exports;
22 function getCjsExportFromNamespace (n) {
23 return n && n['default'] || n;
26 const resolveFrom = (fromDir, moduleId, silent) => {
27 if (typeof fromDir !== 'string') {
28 throw new TypeError(`Expected \`fromDir\` to be of type \`string\`, got \`${typeof fromDir}\``);
31 if (typeof moduleId !== 'string') {
32 throw new TypeError(`Expected \`moduleId\` to be of type \`string\`, got \`${typeof moduleId}\``);
36 fromDir = fs.realpathSync(fromDir);
38 if (err.code === 'ENOENT') {
39 fromDir = path.resolve(fromDir);
47 const fromFile = path.join(fromDir, 'noop.js');
49 const resolveFileName = () => module$1._resolveFilename(moduleId, {
52 paths: module$1._nodeModulePaths(fromDir)
57 return resolveFileName();
63 return resolveFileName();
66 var resolveFrom_1 = (fromDir, moduleId) => resolveFrom(fromDir, moduleId);
68 var silent = (fromDir, moduleId) => resolveFrom(fromDir, moduleId, true);
69 resolveFrom_1.silent = silent;
71 var importFresh = moduleId => {
72 if (typeof moduleId !== 'string') {
73 throw new TypeError('Expected a string');
76 const parentPath = __filename;
77 const filePath = resolveFrom_1(path.dirname(parentPath), moduleId);
78 const oldModule = eval('require').cache[filePath]; // Delete itself from module parent
80 if (oldModule && oldModule.parent) {
81 let i = oldModule.parent.children.length;
84 if (oldModule.parent.children[i].id === filePath) {
85 oldModule.parent.children.splice(i, 1);
90 delete eval('require').cache[filePath]; // Delete module from cache
92 const parent = eval('require').cache[parentPath]; // If `filePath` and `parentPath` are the same, cache will already be deleted so we won't get a memory leak in next step
94 return parent === undefined ? eval('require')(filePath) : parent.require(filePath); // In case cache doesn't have parent, fall back to normal require
97 var isArrayish = function isArrayish(obj) {
102 return obj instanceof Array || Array.isArray(obj) || obj.length >= 0 && obj.splice instanceof Function;
105 var errorEx = function errorEx(name, properties) {
106 if (!name || name.constructor !== String) {
107 properties = name || {};
111 var errorExError = function ErrorEXError(message) {
113 return new ErrorEXError(message);
116 message = message instanceof Error ? message.message : message || this.message;
117 Error.call(this, message);
118 Error.captureStackTrace(this, errorExError);
120 Object.defineProperty(this, 'message', {
124 var newMessage = message.split(/\r?\n/g);
126 for (var key in properties) {
127 if (!properties.hasOwnProperty(key)) {
131 var modifier = properties[key];
133 if ('message' in modifier) {
134 newMessage = modifier.message(this[key], newMessage) || newMessage;
136 if (!isArrayish(newMessage)) {
137 newMessage = [newMessage];
142 return newMessage.join('\n');
148 var overwrittenStack = null;
149 var stackDescriptor = Object.getOwnPropertyDescriptor(this, 'stack');
150 var stackGetter = stackDescriptor.get;
151 var stackValue = stackDescriptor.value;
152 delete stackDescriptor.value;
153 delete stackDescriptor.writable;
155 stackDescriptor.set = function (newstack) {
156 overwrittenStack = newstack;
159 stackDescriptor.get = function () {
160 var stack = (overwrittenStack || (stackGetter ? stackGetter.call(this) : stackValue)).split(/\r?\n+/g); // starting in Node 7, the stack builder caches the message.
163 if (!overwrittenStack) {
164 stack[0] = this.name + ': ' + this.message;
169 for (var key in properties) {
170 if (!properties.hasOwnProperty(key)) {
174 var modifier = properties[key];
176 if ('line' in modifier) {
177 var line = modifier.line(this[key]);
180 stack.splice(lineCount++, 0, ' ' + line);
184 if ('stack' in modifier) {
185 modifier.stack(this[key], stack);
189 return stack.join('\n');
192 Object.defineProperty(this, 'stack', stackDescriptor);
195 if (Object.setPrototypeOf) {
196 Object.setPrototypeOf(errorExError.prototype, Error.prototype);
197 Object.setPrototypeOf(errorExError, Error);
199 util.inherits(errorExError, Error);
205 errorEx.append = function (str, def) {
207 message: function (v, message) {
211 message[0] += ' ' + str.replace('%s', v.toString());
219 errorEx.line = function (str, def) {
225 return str.replace('%s', v.toString());
233 var errorEx_1 = errorEx;
235 var jsonParseBetterErrors = parseJson;
237 function parseJson(txt, reviver, context) {
238 context = context || 20;
241 return JSON.parse(txt, reviver);
243 if (typeof txt !== 'string') {
244 const isEmptyArray = Array.isArray(txt) && txt.length === 0;
245 const errorMessage = 'Cannot parse ' + (isEmptyArray ? 'an empty array' : String(txt));
246 throw new TypeError(errorMessage);
249 const syntaxErr = e.message.match(/^Unexpected token.*position\s+(\d+)/i);
250 const errIdx = syntaxErr ? +syntaxErr[1] : e.message.match(/^Unexpected end of JSON.*/i) ? txt.length - 1 : null;
252 if (errIdx != null) {
253 const start = errIdx <= context ? 0 : errIdx - context;
254 const end = errIdx + context >= txt.length ? txt.length : errIdx + context;
255 e.message += ` while parsing near '${start === 0 ? '' : '...'}${txt.slice(start, end)}${end === txt.length ? '' : '...'}'`;
257 e.message += ` while parsing '${txt.slice(0, context * 2)}'`;
267 var LinesAndColumns = function () {
268 function LinesAndColumns(string) {
269 this.string = string;
272 for (var offset = 0; offset < string.length;) {
273 switch (string[offset]) {
276 offsets.push(offset);
282 if (string[offset] === LF) {
286 offsets.push(offset);
295 this.offsets = offsets;
298 LinesAndColumns.prototype.locationForIndex = function (index) {
299 if (index < 0 || index > this.string.length) {
304 var offsets = this.offsets;
306 while (offsets[line + 1] <= index) {
310 var column = index - offsets[line];
317 LinesAndColumns.prototype.indexForLocation = function (location) {
318 var line = location.line,
319 column = location.column;
321 if (line < 0 || line >= this.offsets.length) {
325 if (column < 0 || column > this.lengthOfLine(line)) {
329 return this.offsets[line] + column;
332 LinesAndColumns.prototype.lengthOfLine = function (line) {
333 var offset = this.offsets[line];
334 var nextOffset = line === this.offsets.length - 1 ? this.string.length : this.offsets[line + 1];
335 return nextOffset - offset;
338 return LinesAndColumns;
341 var dist = /*#__PURE__*/Object.freeze({
343 'default': LinesAndColumns
346 var jsTokens = createCommonjsModule(function (module, exports) {
347 // Copyright 2014, 2015, 2016, 2017, 2018 Simon Lydell
348 // License: MIT. (See LICENSE.)
349 Object.defineProperty(exports, "__esModule", {
351 }); // This regex comes from regex.coffee, and is inserted here by generate-index.js
352 // (run `npm run build`).
354 exports.default = /((['"])(?:(?!\2|\\).|\\(?:\r\n|[\s\S]))*(\2)?|`(?:[^`\\$]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{[^}]*\}?)*\}?)*(`)?)|(\/\/.*)|(\/\*(?:[^*]|\*(?!\/))*(\*\/)?)|(\/(?!\*)(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\]\\]).|\\.)+\/(?:(?!\s*(?:\b|[\u0080-\uFFFF$\\'"~({]|[+\-!](?!=)|\.?\d))|[gmiyus]{1,6}\b(?![\u0080-\uFFFF$\\]|\s*(?:[+\-*%&|^<>!=?({]|\/(?![\/*])))))|(0[xX][\da-fA-F]+|0[oO][0-7]+|0[bB][01]+|(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?)|((?!\d)(?:(?!\s)[$\w\u0080-\uFFFF]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+)|(--|\+\+|&&|\|\||=>|\.{3}|(?:[+\-\/%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2})=?|[?~.,:;[\](){}])|(\s+)|(^$|[\s\S])/g;
356 exports.matchToToken = function (match) {
362 if (match[1]) token.type = "string", token.closed = !!(match[3] || match[4]);else if (match[5]) token.type = "comment";else if (match[6]) token.type = "comment", token.closed = !!match[7];else if (match[8]) token.type = "regex";else if (match[9]) token.type = "number";else if (match[10]) token.type = "name";else if (match[11]) token.type = "punctuator";else if (match[12]) token.type = "whitespace";
366 unwrapExports(jsTokens);
367 var jsTokens_1 = jsTokens.matchToToken;
369 var ast = createCommonjsModule(function (module) {
371 Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
373 Redistribution and use in source and binary forms, with or without
374 modification, are permitted provided that the following conditions are met:
376 * Redistributions of source code must retain the above copyright
377 notice, this list of conditions and the following disclaimer.
378 * Redistributions in binary form must reproduce the above copyright
379 notice, this list of conditions and the following disclaimer in the
380 documentation and/or other materials provided with the distribution.
382 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
383 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
384 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
385 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
386 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
387 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
388 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
389 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
390 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
391 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
395 function isExpression(node) {
401 case 'ArrayExpression':
402 case 'AssignmentExpression':
403 case 'BinaryExpression':
404 case 'CallExpression':
405 case 'ConditionalExpression':
406 case 'FunctionExpression':
409 case 'LogicalExpression':
410 case 'MemberExpression':
411 case 'NewExpression':
412 case 'ObjectExpression':
413 case 'SequenceExpression':
414 case 'ThisExpression':
415 case 'UnaryExpression':
416 case 'UpdateExpression':
423 function isIterationStatement(node) {
429 case 'DoWhileStatement':
430 case 'ForInStatement':
432 case 'WhileStatement':
439 function isStatement(node) {
445 case 'BlockStatement':
446 case 'BreakStatement':
447 case 'ContinueStatement':
448 case 'DebuggerStatement':
449 case 'DoWhileStatement':
450 case 'EmptyStatement':
451 case 'ExpressionStatement':
452 case 'ForInStatement':
455 case 'LabeledStatement':
456 case 'ReturnStatement':
457 case 'SwitchStatement':
458 case 'ThrowStatement':
460 case 'VariableDeclaration':
461 case 'WhileStatement':
462 case 'WithStatement':
469 function isSourceElement(node) {
470 return isStatement(node) || node != null && node.type === 'FunctionDeclaration';
473 function trailingStatement(node) {
476 if (node.alternate != null) {
477 return node.alternate;
480 return node.consequent;
482 case 'LabeledStatement':
484 case 'ForInStatement':
485 case 'WhileStatement':
486 case 'WithStatement':
493 function isProblematicIfStatement(node) {
496 if (node.type !== 'IfStatement') {
500 if (node.alternate == null) {
504 current = node.consequent;
507 if (current.type === 'IfStatement') {
508 if (current.alternate == null) {
513 current = trailingStatement(current);
520 isExpression: isExpression,
521 isStatement: isStatement,
522 isIterationStatement: isIterationStatement,
523 isSourceElement: isSourceElement,
524 isProblematicIfStatement: isProblematicIfStatement,
525 trailingStatement: trailingStatement
528 /* vim: set sw=4 ts=4 et tw=80 : */
531 var ast_1 = ast.isExpression;
532 var ast_2 = ast.isStatement;
533 var ast_3 = ast.isIterationStatement;
534 var ast_4 = ast.isSourceElement;
535 var ast_5 = ast.isProblematicIfStatement;
536 var ast_6 = ast.trailingStatement;
538 var code = createCommonjsModule(function (module) {
540 Copyright (C) 2013-2014 Yusuke Suzuki <utatane.tea@gmail.com>
541 Copyright (C) 2014 Ivan Nikulin <ifaaan@gmail.com>
543 Redistribution and use in source and binary forms, with or without
544 modification, are permitted provided that the following conditions are met:
546 * Redistributions of source code must retain the above copyright
547 notice, this list of conditions and the following disclaimer.
548 * Redistributions in binary form must reproduce the above copyright
549 notice, this list of conditions and the following disclaimer in the
550 documentation and/or other materials provided with the distribution.
552 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
553 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
554 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
555 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
556 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
557 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
558 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
559 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
560 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
561 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
565 var ES6Regex, ES5Regex, NON_ASCII_WHITESPACES, IDENTIFIER_START, IDENTIFIER_PART, ch; // See `tools/generate-identifier-regex.js`.
568 // ECMAScript 5.1/Unicode v9.0.0 NonAsciiIdentifierStart:
569 NonAsciiIdentifierStart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/,
570 // ECMAScript 5.1/Unicode v9.0.0 NonAsciiIdentifierPart:
571 NonAsciiIdentifierPart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/
574 // ECMAScript 6/Unicode v9.0.0 NonAsciiIdentifierStart:
575 NonAsciiIdentifierStart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]/,
576 // ECMAScript 6/Unicode v9.0.0 NonAsciiIdentifierPart:
577 NonAsciiIdentifierPart: /[\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/
580 function isDecimalDigit(ch) {
581 return 0x30 <= ch && ch <= 0x39; // 0..9
584 function isHexDigit(ch) {
585 return 0x30 <= ch && ch <= 0x39 || // 0..9
586 0x61 <= ch && ch <= 0x66 || // a..f
587 0x41 <= ch && ch <= 0x46; // A..F
590 function isOctalDigit(ch) {
591 return ch >= 0x30 && ch <= 0x37; // 0..7
595 NON_ASCII_WHITESPACES = [0x1680, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202F, 0x205F, 0x3000, 0xFEFF];
597 function isWhiteSpace(ch) {
598 return ch === 0x20 || ch === 0x09 || ch === 0x0B || ch === 0x0C || ch === 0xA0 || ch >= 0x1680 && NON_ASCII_WHITESPACES.indexOf(ch) >= 0;
599 } // 7.3 Line Terminators
602 function isLineTerminator(ch) {
603 return ch === 0x0A || ch === 0x0D || ch === 0x2028 || ch === 0x2029;
604 } // 7.6 Identifier Names and Identifiers
607 function fromCodePoint(cp) {
609 return String.fromCharCode(cp);
612 var cu1 = String.fromCharCode(Math.floor((cp - 0x10000) / 0x400) + 0xD800);
613 var cu2 = String.fromCharCode((cp - 0x10000) % 0x400 + 0xDC00);
617 IDENTIFIER_START = new Array(0x80);
619 for (ch = 0; ch < 0x80; ++ch) {
620 IDENTIFIER_START[ch] = ch >= 0x61 && ch <= 0x7A || // a..z
621 ch >= 0x41 && ch <= 0x5A || // A..Z
622 ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore)
625 IDENTIFIER_PART = new Array(0x80);
627 for (ch = 0; ch < 0x80; ++ch) {
628 IDENTIFIER_PART[ch] = ch >= 0x61 && ch <= 0x7A || // a..z
629 ch >= 0x41 && ch <= 0x5A || // A..Z
630 ch >= 0x30 && ch <= 0x39 || // 0..9
631 ch === 0x24 || ch === 0x5F; // $ (dollar) and _ (underscore)
634 function isIdentifierStartES5(ch) {
635 return ch < 0x80 ? IDENTIFIER_START[ch] : ES5Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch));
638 function isIdentifierPartES5(ch) {
639 return ch < 0x80 ? IDENTIFIER_PART[ch] : ES5Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch));
642 function isIdentifierStartES6(ch) {
643 return ch < 0x80 ? IDENTIFIER_START[ch] : ES6Regex.NonAsciiIdentifierStart.test(fromCodePoint(ch));
646 function isIdentifierPartES6(ch) {
647 return ch < 0x80 ? IDENTIFIER_PART[ch] : ES6Regex.NonAsciiIdentifierPart.test(fromCodePoint(ch));
651 isDecimalDigit: isDecimalDigit,
652 isHexDigit: isHexDigit,
653 isOctalDigit: isOctalDigit,
654 isWhiteSpace: isWhiteSpace,
655 isLineTerminator: isLineTerminator,
656 isIdentifierStartES5: isIdentifierStartES5,
657 isIdentifierPartES5: isIdentifierPartES5,
658 isIdentifierStartES6: isIdentifierStartES6,
659 isIdentifierPartES6: isIdentifierPartES6
662 /* vim: set sw=4 ts=4 et tw=80 : */
665 var code_1 = code.isDecimalDigit;
666 var code_2 = code.isHexDigit;
667 var code_3 = code.isOctalDigit;
668 var code_4 = code.isWhiteSpace;
669 var code_5 = code.isLineTerminator;
670 var code_6 = code.isIdentifierStartES5;
671 var code_7 = code.isIdentifierPartES5;
672 var code_8 = code.isIdentifierStartES6;
673 var code_9 = code.isIdentifierPartES6;
675 var keyword = createCommonjsModule(function (module) {
677 Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
679 Redistribution and use in source and binary forms, with or without
680 modification, are permitted provided that the following conditions are met:
682 * Redistributions of source code must retain the above copyright
683 notice, this list of conditions and the following disclaimer.
684 * Redistributions in binary form must reproduce the above copyright
685 notice, this list of conditions and the following disclaimer in the
686 documentation and/or other materials provided with the distribution.
688 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
689 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
690 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
691 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
692 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
693 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
694 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
695 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
696 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
697 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
703 function isStrictModeReservedWordES6(id) {
720 function isKeywordES5(id, strict) {
721 // yield should not be treated as keyword under non-strict mode.
722 if (!strict && id === 'yield') {
726 return isKeywordES6(id, strict);
729 function isKeywordES6(id, strict) {
730 if (strict && isStrictModeReservedWordES6(id)) {
736 return id === 'if' || id === 'in' || id === 'do';
739 return id === 'var' || id === 'for' || id === 'new' || id === 'try';
742 return id === 'this' || id === 'else' || id === 'case' || id === 'void' || id === 'with' || id === 'enum';
745 return id === 'while' || id === 'break' || id === 'catch' || id === 'throw' || id === 'const' || id === 'yield' || id === 'class' || id === 'super';
748 return id === 'return' || id === 'typeof' || id === 'delete' || id === 'switch' || id === 'export' || id === 'import';
751 return id === 'default' || id === 'finally' || id === 'extends';
754 return id === 'function' || id === 'continue' || id === 'debugger';
757 return id === 'instanceof';
764 function isReservedWordES5(id, strict) {
765 return id === 'null' || id === 'true' || id === 'false' || isKeywordES5(id, strict);
768 function isReservedWordES6(id, strict) {
769 return id === 'null' || id === 'true' || id === 'false' || isKeywordES6(id, strict);
772 function isRestrictedWord(id) {
773 return id === 'eval' || id === 'arguments';
776 function isIdentifierNameES5(id) {
779 if (id.length === 0) {
783 ch = id.charCodeAt(0);
785 if (!code$1.isIdentifierStartES5(ch)) {
789 for (i = 1, iz = id.length; i < iz; ++i) {
790 ch = id.charCodeAt(i);
792 if (!code$1.isIdentifierPartES5(ch)) {
800 function decodeUtf16(lead, trail) {
801 return (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
804 function isIdentifierNameES6(id) {
805 var i, iz, ch, lowCh, check;
807 if (id.length === 0) {
811 check = code$1.isIdentifierStartES6;
813 for (i = 0, iz = id.length; i < iz; ++i) {
814 ch = id.charCodeAt(i);
816 if (0xD800 <= ch && ch <= 0xDBFF) {
823 lowCh = id.charCodeAt(i);
825 if (!(0xDC00 <= lowCh && lowCh <= 0xDFFF)) {
829 ch = decodeUtf16(ch, lowCh);
836 check = code$1.isIdentifierPartES6;
842 function isIdentifierES5(id, strict) {
843 return isIdentifierNameES5(id) && !isReservedWordES5(id, strict);
846 function isIdentifierES6(id, strict) {
847 return isIdentifierNameES6(id) && !isReservedWordES6(id, strict);
851 isKeywordES5: isKeywordES5,
852 isKeywordES6: isKeywordES6,
853 isReservedWordES5: isReservedWordES5,
854 isReservedWordES6: isReservedWordES6,
855 isRestrictedWord: isRestrictedWord,
856 isIdentifierNameES5: isIdentifierNameES5,
857 isIdentifierNameES6: isIdentifierNameES6,
858 isIdentifierES5: isIdentifierES5,
859 isIdentifierES6: isIdentifierES6
862 /* vim: set sw=4 ts=4 et tw=80 : */
865 var keyword_1 = keyword.isKeywordES5;
866 var keyword_2 = keyword.isKeywordES6;
867 var keyword_3 = keyword.isReservedWordES5;
868 var keyword_4 = keyword.isReservedWordES6;
869 var keyword_5 = keyword.isRestrictedWord;
870 var keyword_6 = keyword.isIdentifierNameES5;
871 var keyword_7 = keyword.isIdentifierNameES6;
872 var keyword_8 = keyword.isIdentifierES5;
873 var keyword_9 = keyword.isIdentifierES6;
875 var utils = createCommonjsModule(function (module, exports) {
877 Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
879 Redistribution and use in source and binary forms, with or without
880 modification, are permitted provided that the following conditions are met:
882 * Redistributions of source code must retain the above copyright
883 notice, this list of conditions and the following disclaimer.
884 * Redistributions in binary form must reproduce the above copyright
885 notice, this list of conditions and the following disclaimer in the
886 documentation and/or other materials provided with the distribution.
888 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
889 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
890 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
891 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
892 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
893 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
894 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
895 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
896 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
897 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
903 exports.keyword = keyword;
905 /* vim: set sw=4 ts=4 et tw=80 : */
908 var utils_1 = utils.ast;
909 var utils_2 = utils.code;
910 var utils_3 = utils.keyword;
912 var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
914 var escapeStringRegexp = function (str) {
915 if (typeof str !== 'string') {
916 throw new TypeError('Expected a string');
919 return str.replace(matchOperatorsRe, '\\$&');
923 "aliceblue": [240, 248, 255],
924 "antiquewhite": [250, 235, 215],
925 "aqua": [0, 255, 255],
926 "aquamarine": [127, 255, 212],
927 "azure": [240, 255, 255],
928 "beige": [245, 245, 220],
929 "bisque": [255, 228, 196],
931 "blanchedalmond": [255, 235, 205],
933 "blueviolet": [138, 43, 226],
934 "brown": [165, 42, 42],
935 "burlywood": [222, 184, 135],
936 "cadetblue": [95, 158, 160],
937 "chartreuse": [127, 255, 0],
938 "chocolate": [210, 105, 30],
939 "coral": [255, 127, 80],
940 "cornflowerblue": [100, 149, 237],
941 "cornsilk": [255, 248, 220],
942 "crimson": [220, 20, 60],
943 "cyan": [0, 255, 255],
944 "darkblue": [0, 0, 139],
945 "darkcyan": [0, 139, 139],
946 "darkgoldenrod": [184, 134, 11],
947 "darkgray": [169, 169, 169],
948 "darkgreen": [0, 100, 0],
949 "darkgrey": [169, 169, 169],
950 "darkkhaki": [189, 183, 107],
951 "darkmagenta": [139, 0, 139],
952 "darkolivegreen": [85, 107, 47],
953 "darkorange": [255, 140, 0],
954 "darkorchid": [153, 50, 204],
955 "darkred": [139, 0, 0],
956 "darksalmon": [233, 150, 122],
957 "darkseagreen": [143, 188, 143],
958 "darkslateblue": [72, 61, 139],
959 "darkslategray": [47, 79, 79],
960 "darkslategrey": [47, 79, 79],
961 "darkturquoise": [0, 206, 209],
962 "darkviolet": [148, 0, 211],
963 "deeppink": [255, 20, 147],
964 "deepskyblue": [0, 191, 255],
965 "dimgray": [105, 105, 105],
966 "dimgrey": [105, 105, 105],
967 "dodgerblue": [30, 144, 255],
968 "firebrick": [178, 34, 34],
969 "floralwhite": [255, 250, 240],
970 "forestgreen": [34, 139, 34],
971 "fuchsia": [255, 0, 255],
972 "gainsboro": [220, 220, 220],
973 "ghostwhite": [248, 248, 255],
974 "gold": [255, 215, 0],
975 "goldenrod": [218, 165, 32],
976 "gray": [128, 128, 128],
977 "green": [0, 128, 0],
978 "greenyellow": [173, 255, 47],
979 "grey": [128, 128, 128],
980 "honeydew": [240, 255, 240],
981 "hotpink": [255, 105, 180],
982 "indianred": [205, 92, 92],
983 "indigo": [75, 0, 130],
984 "ivory": [255, 255, 240],
985 "khaki": [240, 230, 140],
986 "lavender": [230, 230, 250],
987 "lavenderblush": [255, 240, 245],
988 "lawngreen": [124, 252, 0],
989 "lemonchiffon": [255, 250, 205],
990 "lightblue": [173, 216, 230],
991 "lightcoral": [240, 128, 128],
992 "lightcyan": [224, 255, 255],
993 "lightgoldenrodyellow": [250, 250, 210],
994 "lightgray": [211, 211, 211],
995 "lightgreen": [144, 238, 144],
996 "lightgrey": [211, 211, 211],
997 "lightpink": [255, 182, 193],
998 "lightsalmon": [255, 160, 122],
999 "lightseagreen": [32, 178, 170],
1000 "lightskyblue": [135, 206, 250],
1001 "lightslategray": [119, 136, 153],
1002 "lightslategrey": [119, 136, 153],
1003 "lightsteelblue": [176, 196, 222],
1004 "lightyellow": [255, 255, 224],
1005 "lime": [0, 255, 0],
1006 "limegreen": [50, 205, 50],
1007 "linen": [250, 240, 230],
1008 "magenta": [255, 0, 255],
1009 "maroon": [128, 0, 0],
1010 "mediumaquamarine": [102, 205, 170],
1011 "mediumblue": [0, 0, 205],
1012 "mediumorchid": [186, 85, 211],
1013 "mediumpurple": [147, 112, 219],
1014 "mediumseagreen": [60, 179, 113],
1015 "mediumslateblue": [123, 104, 238],
1016 "mediumspringgreen": [0, 250, 154],
1017 "mediumturquoise": [72, 209, 204],
1018 "mediumvioletred": [199, 21, 133],
1019 "midnightblue": [25, 25, 112],
1020 "mintcream": [245, 255, 250],
1021 "mistyrose": [255, 228, 225],
1022 "moccasin": [255, 228, 181],
1023 "navajowhite": [255, 222, 173],
1024 "navy": [0, 0, 128],
1025 "oldlace": [253, 245, 230],
1026 "olive": [128, 128, 0],
1027 "olivedrab": [107, 142, 35],
1028 "orange": [255, 165, 0],
1029 "orangered": [255, 69, 0],
1030 "orchid": [218, 112, 214],
1031 "palegoldenrod": [238, 232, 170],
1032 "palegreen": [152, 251, 152],
1033 "paleturquoise": [175, 238, 238],
1034 "palevioletred": [219, 112, 147],
1035 "papayawhip": [255, 239, 213],
1036 "peachpuff": [255, 218, 185],
1037 "peru": [205, 133, 63],
1038 "pink": [255, 192, 203],
1039 "plum": [221, 160, 221],
1040 "powderblue": [176, 224, 230],
1041 "purple": [128, 0, 128],
1042 "rebeccapurple": [102, 51, 153],
1044 "rosybrown": [188, 143, 143],
1045 "royalblue": [65, 105, 225],
1046 "saddlebrown": [139, 69, 19],
1047 "salmon": [250, 128, 114],
1048 "sandybrown": [244, 164, 96],
1049 "seagreen": [46, 139, 87],
1050 "seashell": [255, 245, 238],
1051 "sienna": [160, 82, 45],
1052 "silver": [192, 192, 192],
1053 "skyblue": [135, 206, 235],
1054 "slateblue": [106, 90, 205],
1055 "slategray": [112, 128, 144],
1056 "slategrey": [112, 128, 144],
1057 "snow": [255, 250, 250],
1058 "springgreen": [0, 255, 127],
1059 "steelblue": [70, 130, 180],
1060 "tan": [210, 180, 140],
1061 "teal": [0, 128, 128],
1062 "thistle": [216, 191, 216],
1063 "tomato": [255, 99, 71],
1064 "turquoise": [64, 224, 208],
1065 "violet": [238, 130, 238],
1066 "wheat": [245, 222, 179],
1067 "white": [255, 255, 255],
1068 "whitesmoke": [245, 245, 245],
1069 "yellow": [255, 255, 0],
1070 "yellowgreen": [154, 205, 50]
1073 var conversions = createCommonjsModule(function (module) {
1075 // NOTE: conversions should only return primitive values (i.e. arrays, or
1076 // values that give correct `typeof` results).
1077 // do not use box values types (i.e. Number(), String(), etc.)
1078 var reverseKeywords = {};
1080 for (var key in colorName) {
1081 if (colorName.hasOwnProperty(key)) {
1082 reverseKeywords[colorName[key]] = key;
1086 var convert = module.exports = {
1137 labels: ['h', 'c', 'g']
1141 labels: ['r16', 'g16', 'b16']
1147 }; // hide .channels and .labels properties
1149 for (var model in convert) {
1150 if (convert.hasOwnProperty(model)) {
1151 if (!('channels' in convert[model])) {
1152 throw new Error('missing channels property: ' + model);
1155 if (!('labels' in convert[model])) {
1156 throw new Error('missing channel labels property: ' + model);
1159 if (convert[model].labels.length !== convert[model].channels) {
1160 throw new Error('channel and label counts mismatch: ' + model);
1163 var channels = convert[model].channels;
1164 var labels = convert[model].labels;
1165 delete convert[model].channels;
1166 delete convert[model].labels;
1167 Object.defineProperty(convert[model], 'channels', {
1170 Object.defineProperty(convert[model], 'labels', {
1176 convert.rgb.hsl = function (rgb) {
1177 var r = rgb[0] / 255;
1178 var g = rgb[1] / 255;
1179 var b = rgb[2] / 255;
1180 var min = Math.min(r, g, b);
1181 var max = Math.max(r, g, b);
1182 var delta = max - min;
1189 } else if (r === max) {
1190 h = (g - b) / delta;
1191 } else if (g === max) {
1192 h = 2 + (b - r) / delta;
1193 } else if (b === max) {
1194 h = 4 + (r - g) / delta;
1197 h = Math.min(h * 60, 360);
1203 l = (min + max) / 2;
1207 } else if (l <= 0.5) {
1208 s = delta / (max + min);
1210 s = delta / (2 - max - min);
1213 return [h, s * 100, l * 100];
1216 convert.rgb.hsv = function (rgb) {
1222 var r = rgb[0] / 255;
1223 var g = rgb[1] / 255;
1224 var b = rgb[2] / 255;
1225 var v = Math.max(r, g, b);
1226 var diff = v - Math.min(r, g, b);
1228 var diffc = function (c) {
1229 return (v - c) / 6 / diff + 1 / 2;
1242 } else if (g === v) {
1243 h = 1 / 3 + rdif - bdif;
1244 } else if (b === v) {
1245 h = 2 / 3 + gdif - rdif;
1255 return [h * 360, s * 100, v * 100];
1258 convert.rgb.hwb = function (rgb) {
1262 var h = convert.rgb.hsl(rgb)[0];
1263 var w = 1 / 255 * Math.min(r, Math.min(g, b));
1264 b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
1265 return [h, w * 100, b * 100];
1268 convert.rgb.cmyk = function (rgb) {
1269 var r = rgb[0] / 255;
1270 var g = rgb[1] / 255;
1271 var b = rgb[2] / 255;
1276 k = Math.min(1 - r, 1 - g, 1 - b);
1277 c = (1 - r - k) / (1 - k) || 0;
1278 m = (1 - g - k) / (1 - k) || 0;
1279 y = (1 - b - k) / (1 - k) || 0;
1280 return [c * 100, m * 100, y * 100, k * 100];
1283 * See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
1287 function comparativeDistance(x, y) {
1288 return Math.pow(x[0] - y[0], 2) + Math.pow(x[1] - y[1], 2) + Math.pow(x[2] - y[2], 2);
1291 convert.rgb.keyword = function (rgb) {
1292 var reversed = reverseKeywords[rgb];
1298 var currentClosestDistance = Infinity;
1299 var currentClosestKeyword;
1301 for (var keyword in colorName) {
1302 if (colorName.hasOwnProperty(keyword)) {
1303 var value = colorName[keyword]; // Compute comparative distance
1305 var distance = comparativeDistance(rgb, value); // Check if its less, if so set as closest
1307 if (distance < currentClosestDistance) {
1308 currentClosestDistance = distance;
1309 currentClosestKeyword = keyword;
1314 return currentClosestKeyword;
1317 convert.keyword.rgb = function (keyword) {
1318 return colorName[keyword];
1321 convert.rgb.xyz = function (rgb) {
1322 var r = rgb[0] / 255;
1323 var g = rgb[1] / 255;
1324 var b = rgb[2] / 255; // assume sRGB
1326 r = r > 0.04045 ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;
1327 g = g > 0.04045 ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;
1328 b = b > 0.04045 ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;
1329 var x = r * 0.4124 + g * 0.3576 + b * 0.1805;
1330 var y = r * 0.2126 + g * 0.7152 + b * 0.0722;
1331 var z = r * 0.0193 + g * 0.1192 + b * 0.9505;
1332 return [x * 100, y * 100, z * 100];
1335 convert.rgb.lab = function (rgb) {
1336 var xyz = convert.rgb.xyz(rgb);
1346 x = x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
1347 y = y > 0.008856 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
1348 z = z > 0.008856 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
1355 convert.hsl.rgb = function (hsl) {
1356 var h = hsl[0] / 360;
1357 var s = hsl[1] / 100;
1358 var l = hsl[2] / 100;
1367 return [val, val, val];
1379 for (var i = 0; i < 3; i++) {
1380 t3 = h + 1 / 3 * -(i - 1);
1391 val = t1 + (t2 - t1) * 6 * t3;
1392 } else if (2 * t3 < 1) {
1394 } else if (3 * t3 < 2) {
1395 val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
1406 convert.hsl.hsv = function (hsl) {
1408 var s = hsl[1] / 100;
1409 var l = hsl[2] / 100;
1411 var lmin = Math.max(l, 0.01);
1415 s *= l <= 1 ? l : 2 - l;
1416 smin *= lmin <= 1 ? lmin : 2 - lmin;
1418 sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
1419 return [h, sv * 100, v * 100];
1422 convert.hsv.rgb = function (hsv) {
1423 var h = hsv[0] / 60;
1424 var s = hsv[1] / 100;
1425 var v = hsv[2] / 100;
1426 var hi = Math.floor(h) % 6;
1427 var f = h - Math.floor(h);
1428 var p = 255 * v * (1 - s);
1429 var q = 255 * v * (1 - s * f);
1430 var t = 255 * v * (1 - s * (1 - f));
1454 convert.hsv.hsl = function (hsv) {
1456 var s = hsv[1] / 100;
1457 var v = hsv[2] / 100;
1458 var vmin = Math.max(v, 0.01);
1463 lmin = (2 - s) * vmin;
1465 sl /= lmin <= 1 ? lmin : 2 - lmin;
1468 return [h, sl * 100, l * 100];
1469 }; // http://dev.w3.org/csswg/css-color/#hwb-to-rgb
1472 convert.hwb.rgb = function (hwb) {
1473 var h = hwb[0] / 360;
1474 var wh = hwb[1] / 100;
1475 var bl = hwb[2] / 100;
1476 var ratio = wh + bl;
1480 var n; // wh + bl cant be > 1
1487 i = Math.floor(6 * h);
1491 if ((i & 0x01) !== 0) {
1495 n = wh + f * (v - wh); // linear interpolation
1541 return [r * 255, g * 255, b * 255];
1544 convert.cmyk.rgb = function (cmyk) {
1545 var c = cmyk[0] / 100;
1546 var m = cmyk[1] / 100;
1547 var y = cmyk[2] / 100;
1548 var k = cmyk[3] / 100;
1552 r = 1 - Math.min(1, c * (1 - k) + k);
1553 g = 1 - Math.min(1, m * (1 - k) + k);
1554 b = 1 - Math.min(1, y * (1 - k) + k);
1555 return [r * 255, g * 255, b * 255];
1558 convert.xyz.rgb = function (xyz) {
1559 var x = xyz[0] / 100;
1560 var y = xyz[1] / 100;
1561 var z = xyz[2] / 100;
1565 r = x * 3.2406 + y * -1.5372 + z * -0.4986;
1566 g = x * -0.9689 + y * 1.8758 + z * 0.0415;
1567 b = x * 0.0557 + y * -0.2040 + z * 1.0570; // assume sRGB
1569 r = r > 0.0031308 ? 1.055 * Math.pow(r, 1.0 / 2.4) - 0.055 : r * 12.92;
1570 g = g > 0.0031308 ? 1.055 * Math.pow(g, 1.0 / 2.4) - 0.055 : g * 12.92;
1571 b = b > 0.0031308 ? 1.055 * Math.pow(b, 1.0 / 2.4) - 0.055 : b * 12.92;
1572 r = Math.min(Math.max(0, r), 1);
1573 g = Math.min(Math.max(0, g), 1);
1574 b = Math.min(Math.max(0, b), 1);
1575 return [r * 255, g * 255, b * 255];
1578 convert.xyz.lab = function (xyz) {
1588 x = x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
1589 y = y > 0.008856 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
1590 z = z > 0.008856 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
1597 convert.lab.xyz = function (lab) {
1607 var y2 = Math.pow(y, 3);
1608 var x2 = Math.pow(x, 3);
1609 var z2 = Math.pow(z, 3);
1610 y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
1611 x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
1612 z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
1619 convert.lab.lch = function (lab) {
1626 hr = Math.atan2(b, a);
1627 h = hr * 360 / 2 / Math.PI;
1633 c = Math.sqrt(a * a + b * b);
1637 convert.lch.lab = function (lch) {
1644 hr = h / 360 * 2 * Math.PI;
1645 a = c * Math.cos(hr);
1646 b = c * Math.sin(hr);
1650 convert.rgb.ansi16 = function (args) {
1654 var value = 1 in arguments ? arguments[1] : convert.rgb.hsv(args)[2]; // hsv -> ansi16 optimization
1656 value = Math.round(value / 50);
1662 var ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
1671 convert.hsv.ansi16 = function (args) {
1672 // optimization here; we already know the value and don't need to get
1673 // it converted for us.
1674 return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
1677 convert.rgb.ansi256 = function (args) {
1680 var b = args[2]; // we use the extended greyscale palette here, with the exception of
1681 // black and white. normal palette only has 4 greyscale shades.
1683 if (r === g && g === b) {
1692 return Math.round((r - 8) / 247 * 24) + 232;
1695 var ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
1699 convert.ansi16.rgb = function (args) {
1700 var color = args % 10; // handle greyscale
1702 if (color === 0 || color === 7) {
1707 color = color / 10.5 * 255;
1708 return [color, color, color];
1711 var mult = (~~(args > 50) + 1) * 0.5;
1712 var r = (color & 1) * mult * 255;
1713 var g = (color >> 1 & 1) * mult * 255;
1714 var b = (color >> 2 & 1) * mult * 255;
1718 convert.ansi256.rgb = function (args) {
1721 var c = (args - 232) * 10 + 8;
1727 var r = Math.floor(args / 36) / 5 * 255;
1728 var g = Math.floor((rem = args % 36) / 6) / 5 * 255;
1729 var b = rem % 6 / 5 * 255;
1733 convert.rgb.hex = function (args) {
1734 var integer = ((Math.round(args[0]) & 0xFF) << 16) + ((Math.round(args[1]) & 0xFF) << 8) + (Math.round(args[2]) & 0xFF);
1735 var string = integer.toString(16).toUpperCase();
1736 return '000000'.substring(string.length) + string;
1739 convert.hex.rgb = function (args) {
1740 var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
1746 var colorString = match[0];
1748 if (match[0].length === 3) {
1749 colorString = colorString.split('').map(function (char) {
1754 var integer = parseInt(colorString, 16);
1755 var r = integer >> 16 & 0xFF;
1756 var g = integer >> 8 & 0xFF;
1757 var b = integer & 0xFF;
1761 convert.rgb.hcg = function (rgb) {
1762 var r = rgb[0] / 255;
1763 var g = rgb[1] / 255;
1764 var b = rgb[2] / 255;
1765 var max = Math.max(Math.max(r, g), b);
1766 var min = Math.min(Math.min(r, g), b);
1767 var chroma = max - min;
1772 grayscale = min / (1 - chroma);
1779 } else if (max === r) {
1780 hue = (g - b) / chroma % 6;
1781 } else if (max === g) {
1782 hue = 2 + (b - r) / chroma;
1784 hue = 4 + (r - g) / chroma + 4;
1789 return [hue * 360, chroma * 100, grayscale * 100];
1792 convert.hsl.hcg = function (hsl) {
1793 var s = hsl[1] / 100;
1794 var l = hsl[2] / 100;
1801 c = 2.0 * s * (1.0 - l);
1805 f = (l - 0.5 * c) / (1.0 - c);
1808 return [hsl[0], c * 100, f * 100];
1811 convert.hsv.hcg = function (hsv) {
1812 var s = hsv[1] / 100;
1813 var v = hsv[2] / 100;
1818 f = (v - c) / (1 - c);
1821 return [hsv[0], c * 100, f * 100];
1824 convert.hcg.rgb = function (hcg) {
1825 var h = hcg[0] / 360;
1826 var c = hcg[1] / 100;
1827 var g = hcg[2] / 100;
1830 return [g * 255, g * 255, g * 255];
1833 var pure = [0, 0, 0];
1839 switch (Math.floor(hi)) {
1877 return [(c * pure[0] + mg) * 255, (c * pure[1] + mg) * 255, (c * pure[2] + mg) * 255];
1880 convert.hcg.hsv = function (hcg) {
1881 var c = hcg[1] / 100;
1882 var g = hcg[2] / 100;
1883 var v = c + g * (1.0 - c);
1890 return [hcg[0], f * 100, v * 100];
1893 convert.hcg.hsl = function (hcg) {
1894 var c = hcg[1] / 100;
1895 var g = hcg[2] / 100;
1896 var l = g * (1.0 - c) + 0.5 * c;
1899 if (l > 0.0 && l < 0.5) {
1901 } else if (l >= 0.5 && l < 1.0) {
1902 s = c / (2 * (1 - l));
1905 return [hcg[0], s * 100, l * 100];
1908 convert.hcg.hwb = function (hcg) {
1909 var c = hcg[1] / 100;
1910 var g = hcg[2] / 100;
1911 var v = c + g * (1.0 - c);
1912 return [hcg[0], (v - c) * 100, (1 - v) * 100];
1915 convert.hwb.hcg = function (hwb) {
1916 var w = hwb[1] / 100;
1917 var b = hwb[2] / 100;
1923 g = (v - c) / (1 - c);
1926 return [hwb[0], c * 100, g * 100];
1929 convert.apple.rgb = function (apple) {
1930 return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
1933 convert.rgb.apple = function (rgb) {
1934 return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
1937 convert.gray.rgb = function (args) {
1938 return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
1941 convert.gray.hsl = convert.gray.hsv = function (args) {
1942 return [0, 0, args[0]];
1945 convert.gray.hwb = function (gray) {
1946 return [0, 100, gray[0]];
1949 convert.gray.cmyk = function (gray) {
1950 return [0, 0, 0, gray[0]];
1953 convert.gray.lab = function (gray) {
1954 return [gray[0], 0, 0];
1957 convert.gray.hex = function (gray) {
1958 var val = Math.round(gray[0] / 100 * 255) & 0xFF;
1959 var integer = (val << 16) + (val << 8) + val;
1960 var string = integer.toString(16).toUpperCase();
1961 return '000000'.substring(string.length) + string;
1964 convert.rgb.gray = function (rgb) {
1965 var val = (rgb[0] + rgb[1] + rgb[2]) / 3;
1966 return [val / 255 * 100];
1969 var conversions_1 = conversions.rgb;
1970 var conversions_2 = conversions.hsl;
1971 var conversions_3 = conversions.hsv;
1972 var conversions_4 = conversions.hwb;
1973 var conversions_5 = conversions.cmyk;
1974 var conversions_6 = conversions.xyz;
1975 var conversions_7 = conversions.lab;
1976 var conversions_8 = conversions.lch;
1977 var conversions_9 = conversions.hex;
1978 var conversions_10 = conversions.keyword;
1979 var conversions_11 = conversions.ansi16;
1980 var conversions_12 = conversions.ansi256;
1981 var conversions_13 = conversions.hcg;
1982 var conversions_14 = conversions.apple;
1983 var conversions_15 = conversions.gray;
1986 this function routes a model to all other models.
1988 all functions that are routed have a property `.conversion` attached
1989 to the returned synthetic function. This property is an array
1990 of strings, each with the steps in between the 'from' and 'to'
1991 color models (inclusive).
1993 conversions that are not possible simply are not included.
1996 function buildGraph() {
1997 var graph = {}; // https://jsperf.com/object-keys-vs-for-in-with-closure/3
1999 var models = Object.keys(conversions);
2001 for (var len = models.length, i = 0; i < len; i++) {
2002 graph[models[i]] = {
2003 // http://jsperf.com/1-vs-infinity
2004 // micro-opt, but this is simple.
2011 } // https://en.wikipedia.org/wiki/Breadth-first_search
2014 function deriveBFS(fromModel) {
2015 var graph = buildGraph();
2016 var queue = [fromModel]; // unshift -> queue -> pop
2018 graph[fromModel].distance = 0;
2020 while (queue.length) {
2021 var current = queue.pop();
2022 var adjacents = Object.keys(conversions[current]);
2024 for (var len = adjacents.length, i = 0; i < len; i++) {
2025 var adjacent = adjacents[i];
2026 var node = graph[adjacent];
2028 if (node.distance === -1) {
2029 node.distance = graph[current].distance + 1;
2030 node.parent = current;
2031 queue.unshift(adjacent);
2039 function link(from, to) {
2040 return function (args) {
2041 return to(from(args));
2045 function wrapConversion(toModel, graph) {
2046 var path = [graph[toModel].parent, toModel];
2047 var fn = conversions[graph[toModel].parent][toModel];
2048 var cur = graph[toModel].parent;
2050 while (graph[cur].parent) {
2051 path.unshift(graph[cur].parent);
2052 fn = link(conversions[graph[cur].parent][cur], fn);
2053 cur = graph[cur].parent;
2056 fn.conversion = path;
2060 var route = function (fromModel) {
2061 var graph = deriveBFS(fromModel);
2062 var conversion = {};
2063 var models = Object.keys(graph);
2065 for (var len = models.length, i = 0; i < len; i++) {
2066 var toModel = models[i];
2067 var node = graph[toModel];
2069 if (node.parent === null) {
2070 // no possible conversion, or this node is the source model.
2074 conversion[toModel] = wrapConversion(toModel, graph);
2081 var models = Object.keys(conversions);
2083 function wrapRaw(fn) {
2084 var wrappedFn = function (args) {
2085 if (args === undefined || args === null) {
2089 if (arguments.length > 1) {
2090 args = Array.prototype.slice.call(arguments);
2094 }; // preserve .conversion property if there is one
2097 if ('conversion' in fn) {
2098 wrappedFn.conversion = fn.conversion;
2104 function wrapRounded(fn) {
2105 var wrappedFn = function (args) {
2106 if (args === undefined || args === null) {
2110 if (arguments.length > 1) {
2111 args = Array.prototype.slice.call(arguments);
2114 var result = fn(args); // we're assuming the result is an array here.
2115 // see notice in conversions.js; don't use box types
2116 // in conversion functions.
2118 if (typeof result === 'object') {
2119 for (var len = result.length, i = 0; i < len; i++) {
2120 result[i] = Math.round(result[i]);
2125 }; // preserve .conversion property if there is one
2128 if ('conversion' in fn) {
2129 wrappedFn.conversion = fn.conversion;
2135 models.forEach(function (fromModel) {
2136 convert[fromModel] = {};
2137 Object.defineProperty(convert[fromModel], 'channels', {
2138 value: conversions[fromModel].channels
2140 Object.defineProperty(convert[fromModel], 'labels', {
2141 value: conversions[fromModel].labels
2143 var routes = route(fromModel);
2144 var routeModels = Object.keys(routes);
2145 routeModels.forEach(function (toModel) {
2146 var fn = routes[toModel];
2147 convert[fromModel][toModel] = wrapRounded(fn);
2148 convert[fromModel][toModel].raw = wrapRaw(fn);
2151 var colorConvert = convert;
2153 var ansiStyles = createCommonjsModule(function (module) {
2155 const wrapAnsi16 = (fn, offset) => function () {
2156 const code = fn.apply(colorConvert, arguments);
2157 return `\u001B[${code + offset}m`;
2160 const wrapAnsi256 = (fn, offset) => function () {
2161 const code = fn.apply(colorConvert, arguments);
2162 return `\u001B[${38 + offset};5;${code}m`;
2165 const wrapAnsi16m = (fn, offset) => function () {
2166 const rgb = fn.apply(colorConvert, arguments);
2167 return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
2170 function assembleStyles() {
2171 const codes = new Map();
2175 // 21 isn't widely supported and 22 does the same thing
2182 strikethrough: [9, 29]
2195 redBright: [91, 39],
2196 greenBright: [92, 39],
2197 yellowBright: [93, 39],
2198 blueBright: [94, 39],
2199 magentaBright: [95, 39],
2200 cyanBright: [96, 39],
2201 whiteBright: [97, 39]
2209 bgMagenta: [45, 49],
2213 bgBlackBright: [100, 49],
2214 bgRedBright: [101, 49],
2215 bgGreenBright: [102, 49],
2216 bgYellowBright: [103, 49],
2217 bgBlueBright: [104, 49],
2218 bgMagentaBright: [105, 49],
2219 bgCyanBright: [106, 49],
2220 bgWhiteBright: [107, 49]
2224 styles.color.grey = styles.color.gray;
2226 for (const groupName of Object.keys(styles)) {
2227 const group = styles[groupName];
2229 for (const styleName of Object.keys(group)) {
2230 const style = group[styleName];
2231 styles[styleName] = {
2232 open: `\u001B[${style[0]}m`,
2233 close: `\u001B[${style[1]}m`
2235 group[styleName] = styles[styleName];
2236 codes.set(style[0], style[1]);
2239 Object.defineProperty(styles, groupName, {
2243 Object.defineProperty(styles, 'codes', {
2249 const ansi2ansi = n => n;
2251 const rgb2rgb = (r, g, b) => [r, g, b];
2253 styles.color.close = '\u001B[39m';
2254 styles.bgColor.close = '\u001B[49m';
2255 styles.color.ansi = {
2256 ansi: wrapAnsi16(ansi2ansi, 0)
2258 styles.color.ansi256 = {
2259 ansi256: wrapAnsi256(ansi2ansi, 0)
2261 styles.color.ansi16m = {
2262 rgb: wrapAnsi16m(rgb2rgb, 0)
2264 styles.bgColor.ansi = {
2265 ansi: wrapAnsi16(ansi2ansi, 10)
2267 styles.bgColor.ansi256 = {
2268 ansi256: wrapAnsi256(ansi2ansi, 10)
2270 styles.bgColor.ansi16m = {
2271 rgb: wrapAnsi16m(rgb2rgb, 10)
2274 for (let key of Object.keys(colorConvert)) {
2275 if (typeof colorConvert[key] !== 'object') {
2279 const suite = colorConvert[key];
2281 if (key === 'ansi16') {
2285 if ('ansi16' in suite) {
2286 styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0);
2287 styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10);
2290 if ('ansi256' in suite) {
2291 styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0);
2292 styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10);
2295 if ('rgb' in suite) {
2296 styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0);
2297 styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10);
2302 } // Make the export immutable
2305 Object.defineProperty(module, 'exports', {
2311 var hasFlag = (flag, argv) => {
2312 argv = argv || process.argv;
2313 const prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--';
2314 const pos = argv.indexOf(prefix + flag);
2315 const terminatorPos = argv.indexOf('--');
2316 return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
2319 const env = process.env;
2322 if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false')) {
2324 } else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) {
2328 if ('FORCE_COLOR' in env) {
2329 forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0;
2332 function translateLevel(level) {
2345 function supportsColor(stream) {
2346 if (forceColor === false) {
2350 if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) {
2354 if (hasFlag('color=256')) {
2358 if (stream && !stream.isTTY && forceColor !== true) {
2362 const min = forceColor ? 1 : 0;
2364 if (process.platform === 'win32') {
2365 // Node.js 7.5.0 is the first version of Node.js to include a patch to
2366 // libuv that enables 256 color output on Windows. Anything earlier and it
2367 // won't work. However, here we target Node.js 8 at minimum as it is an LTS
2368 // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
2369 // release that supports 256 colors. Windows 10 build 14931 is the first release
2370 // that supports 16m/TrueColor.
2371 const osRelease = os.release().split('.');
2373 if (Number(process.versions.node.split('.')[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
2374 return Number(osRelease[2]) >= 14931 ? 3 : 2;
2381 if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
2388 if ('TEAMCITY_VERSION' in env) {
2389 return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
2392 if (env.COLORTERM === 'truecolor') {
2396 if ('TERM_PROGRAM' in env) {
2397 const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
2399 switch (env.TERM_PROGRAM) {
2401 return version >= 3 ? 3 : 2;
2403 case 'Apple_Terminal':
2409 if (/-256(color)?$/i.test(env.TERM)) {
2413 if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
2417 if ('COLORTERM' in env) {
2421 if (env.TERM === 'dumb') {
2428 function getSupportLevel(stream) {
2429 const level = supportsColor(stream);
2430 return translateLevel(level);
2433 var supportsColor_1 = {
2434 supportsColor: getSupportLevel,
2435 stdout: getSupportLevel(process.stdout),
2436 stderr: getSupportLevel(process.stderr)
2439 const TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
2440 const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
2441 const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
2442 const ESCAPE_REGEX = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi;
2443 const ESCAPES = new Map([['n', '\n'], ['r', '\r'], ['t', '\t'], ['b', '\b'], ['f', '\f'], ['v', '\v'], ['0', '\0'], ['\\', '\\'], ['e', '\u001B'], ['a', '\u0007']]);
2445 function unescape(c) {
2446 if (c[0] === 'u' && c.length === 5 || c[0] === 'x' && c.length === 3) {
2447 return String.fromCharCode(parseInt(c.slice(1), 16));
2450 return ESCAPES.get(c) || c;
2453 function parseArguments(name, args) {
2455 const chunks = args.trim().split(/\s*,\s*/g);
2458 for (const chunk of chunks) {
2459 if (!isNaN(chunk)) {
2460 results.push(Number(chunk));
2461 } else if (matches = chunk.match(STRING_REGEX)) {
2462 results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, chr) => escape ? unescape(escape) : chr));
2464 throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
2471 function parseStyle(style) {
2472 STYLE_REGEX.lastIndex = 0;
2476 while ((matches = STYLE_REGEX.exec(style)) !== null) {
2477 const name = matches[1];
2480 const args = parseArguments(name, matches[2]);
2481 results.push([name].concat(args));
2483 results.push([name]);
2490 function buildStyle(chalk, styles) {
2493 for (const layer of styles) {
2494 for (const style of layer.styles) {
2495 enabled[style[0]] = layer.inverse ? null : style.slice(1);
2499 let current = chalk;
2501 for (const styleName of Object.keys(enabled)) {
2502 if (Array.isArray(enabled[styleName])) {
2503 if (!(styleName in current)) {
2504 throw new Error(`Unknown Chalk style: ${styleName}`);
2507 if (enabled[styleName].length > 0) {
2508 current = current[styleName].apply(current, enabled[styleName]);
2510 current = current[styleName];
2518 var templates = (chalk, tmp) => {
2521 let chunk = []; // eslint-disable-next-line max-params
2523 tmp.replace(TEMPLATE_REGEX, (m, escapeChar, inverse, style, close, chr) => {
2525 chunk.push(unescape(escapeChar));
2527 const str = chunk.join('');
2529 chunks.push(styles.length === 0 ? str : buildStyle(chalk, styles)(str));
2532 styles: parseStyle(style)
2535 if (styles.length === 0) {
2536 throw new Error('Found extraneous } in Chalk template literal');
2539 chunks.push(buildStyle(chalk, styles)(chunk.join('')));
2546 chunks.push(chunk.join(''));
2548 if (styles.length > 0) {
2549 const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
2550 throw new Error(errMsg);
2553 return chunks.join('');
2556 var chalk = createCommonjsModule(function (module) {
2558 const stdoutColor = supportsColor_1.stdout;
2559 const isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm'); // `supportsColor.level` → `ansiStyles.color[name]` mapping
2561 const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m']; // `color-convert` models to exclude from the Chalk API due to conflicts and such
2563 const skipModels = new Set(['gray']);
2564 const styles = Object.create(null);
2566 function applyOptions(obj, options) {
2567 options = options || {}; // Detect level if not set manually
2569 const scLevel = stdoutColor ? stdoutColor.level : 0;
2570 obj.level = options.level === undefined ? scLevel : options.level;
2571 obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
2574 function Chalk(options) {
2575 // We check for this.template here since calling `chalk.constructor()`
2576 // by itself will have a `this` of a previously constructed chalk object
2577 if (!this || !(this instanceof Chalk) || this.template) {
2579 applyOptions(chalk, options);
2581 chalk.template = function () {
2582 const args = [].slice.call(arguments);
2583 return chalkTag.apply(null, [chalk.template].concat(args));
2586 Object.setPrototypeOf(chalk, Chalk.prototype);
2587 Object.setPrototypeOf(chalk.template, chalk);
2588 chalk.template.constructor = Chalk;
2589 return chalk.template;
2592 applyOptions(this, options);
2593 } // Use bright blue on Windows as the normal blue color is illegible
2596 if (isSimpleWindowsTerm) {
2597 ansiStyles.blue.open = '\u001B[94m';
2600 for (const key of Object.keys(ansiStyles)) {
2601 ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
2604 const codes = ansiStyles[key];
2605 return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key);
2613 return build.call(this, this._styles || [], true, 'visible');
2617 ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), 'g');
2619 for (const model of Object.keys(ansiStyles.color.ansi)) {
2620 if (skipModels.has(model)) {
2626 const level = this.level;
2627 return function () {
2628 const open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments);
2631 close: ansiStyles.color.close,
2632 closeRe: ansiStyles.color.closeRe
2634 return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
2641 ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles.bgColor.close), 'g');
2643 for (const model of Object.keys(ansiStyles.bgColor.ansi)) {
2644 if (skipModels.has(model)) {
2648 const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
2651 const level = this.level;
2652 return function () {
2653 const open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments);
2656 close: ansiStyles.bgColor.close,
2657 closeRe: ansiStyles.bgColor.closeRe
2659 return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
2666 const proto = Object.defineProperties(() => {}, styles);
2668 function build(_styles, _empty, key) {
2669 const builder = function () {
2670 return applyStyle.apply(builder, arguments);
2673 builder._styles = _styles;
2674 builder._empty = _empty;
2676 Object.defineProperty(builder, 'level', {
2688 Object.defineProperty(builder, 'enabled', {
2692 return self.enabled;
2696 self.enabled = enabled;
2699 }); // See below for fix regarding invisible grey/dim combination on Windows
2701 builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey'; // `__proto__` is used because we must return a function, but there is
2702 // no way to create a function with a different prototype
2704 builder.__proto__ = proto; // eslint-disable-line no-proto
2709 function applyStyle() {
2710 // Support varags, but simply cast to string in case there's only one arg
2711 const args = arguments;
2712 const argsLen = args.length;
2713 let str = String(arguments[0]);
2715 if (argsLen === 0) {
2720 // Don't slice `arguments`, it prevents V8 optimizations
2721 for (let a = 1; a < argsLen; a++) {
2722 str += ' ' + args[a];
2726 if (!this.enabled || this.level <= 0 || !str) {
2727 return this._empty ? '' : str;
2728 } // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
2729 // see https://github.com/chalk/chalk/issues/58
2730 // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.
2733 const originalDim = ansiStyles.dim.open;
2735 if (isSimpleWindowsTerm && this.hasGrey) {
2736 ansiStyles.dim.open = '';
2739 for (const code of this._styles.slice().reverse()) {
2740 // Replace any instances already present with a re-opening code
2741 // otherwise only the part of the string until said closing code
2742 // will be colored, and the rest will simply be 'plain'.
2743 str = code.open + str.replace(code.closeRe, code.open) + code.close; // Close the styling before a linebreak and reopen
2744 // after next line to fix a bleed issue on macOS
2745 // https://github.com/chalk/chalk/pull/92
2747 str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`);
2748 } // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue
2751 ansiStyles.dim.open = originalDim;
2755 function chalkTag(chalk, strings) {
2756 if (!Array.isArray(strings)) {
2757 // If chalk() was called by itself or with a string,
2758 // return the string itself as a string.
2759 return [].slice.call(arguments, 1).join(' ');
2762 const args = [].slice.call(arguments, 2);
2763 const parts = [strings.raw[0]];
2765 for (let i = 1; i < strings.length; i++) {
2766 parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&'));
2767 parts.push(String(strings.raw[i]));
2770 return templates(chalk, parts.join(''));
2773 Object.defineProperties(Chalk.prototype, styles);
2774 module.exports = Chalk(); // eslint-disable-line new-cap
2776 module.exports.supportsColor = stdoutColor;
2777 module.exports.default = module.exports; // For TypeScript
2779 var chalk_1 = chalk.supportsColor;
2781 var lib = createCommonjsModule(function (module, exports) {
2783 Object.defineProperty(exports, "__esModule", {
2786 exports.shouldHighlight = shouldHighlight;
2787 exports.getChalk = getChalk;
2788 exports.default = highlight;
2790 var _jsTokens = _interopRequireWildcard(jsTokens);
2792 var _esutils = _interopRequireDefault(utils);
2794 var _chalk = _interopRequireDefault(chalk);
2796 function _interopRequireDefault(obj) {
2797 return obj && obj.__esModule ? obj : {
2802 function _getRequireWildcardCache() {
2803 if (typeof WeakMap !== "function") return null;
2804 var cache = new WeakMap();
2806 _getRequireWildcardCache = function () {
2813 function _interopRequireWildcard(obj) {
2814 if (obj && obj.__esModule) {
2818 if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
2824 var cache = _getRequireWildcardCache();
2826 if (cache && cache.has(obj)) {
2827 return cache.get(obj);
2831 var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
2833 for (var key in obj) {
2834 if (Object.prototype.hasOwnProperty.call(obj, key)) {
2835 var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
2837 if (desc && (desc.get || desc.set)) {
2838 Object.defineProperty(newObj, key, desc);
2840 newObj[key] = obj[key];
2845 newObj.default = obj;
2848 cache.set(obj, newObj);
2854 function getDefs(chalk) {
2856 keyword: chalk.cyan,
2857 capitalized: chalk.yellow,
2858 jsx_tag: chalk.yellow,
2859 punctuator: chalk.yellow,
2860 number: chalk.magenta,
2861 string: chalk.green,
2862 regex: chalk.magenta,
2863 comment: chalk.grey,
2864 invalid: chalk.white.bgRed.bold
2868 const NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
2869 const JSX_TAG = /^[a-z][\w-]*$/i;
2870 const BRACKET = /^[()[\]{}]$/;
2872 function getTokenType(match) {
2873 const [offset, text] = match.slice(-2);
2874 const token = (0, _jsTokens.matchToToken)(match);
2876 if (token.type === "name") {
2877 if (_esutils.default.keyword.isReservedWordES6(token.value)) {
2881 if (JSX_TAG.test(token.value) && (text[offset - 1] === "<" || text.substr(offset - 2, 2) == "</")) {
2885 if (token.value[0] !== token.value[0].toLowerCase()) {
2886 return "capitalized";
2890 if (token.type === "punctuator" && BRACKET.test(token.value)) {
2894 if (token.type === "invalid" && (token.value === "@" || token.value === "#")) {
2895 return "punctuator";
2901 function highlightTokens(defs, text) {
2902 return text.replace(_jsTokens.default, function (...args) {
2903 const type = getTokenType(args);
2904 const colorize = defs[type];
2907 return args[0].split(NEWLINE).map(str => colorize(str)).join("\n");
2914 function shouldHighlight(options) {
2915 return _chalk.default.supportsColor || options.forceColor;
2918 function getChalk(options) {
2919 let chalk = _chalk.default;
2921 if (options.forceColor) {
2922 chalk = new _chalk.default.constructor({
2931 function highlight(code, options = {}) {
2932 if (shouldHighlight(options)) {
2933 const chalk = getChalk(options);
2934 const defs = getDefs(chalk);
2935 return highlightTokens(defs, code);
2942 var lib_1 = lib.shouldHighlight;
2943 var lib_2 = lib.getChalk;
2945 var lib$1 = createCommonjsModule(function (module, exports) {
2947 Object.defineProperty(exports, "__esModule", {
2950 exports.codeFrameColumns = codeFrameColumns;
2951 exports.default = _default;
2953 var _highlight = _interopRequireWildcard(lib);
2955 function _getRequireWildcardCache() {
2956 if (typeof WeakMap !== "function") return null;
2957 var cache = new WeakMap();
2959 _getRequireWildcardCache = function () {
2966 function _interopRequireWildcard(obj) {
2967 if (obj && obj.__esModule) {
2971 if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
2977 var cache = _getRequireWildcardCache();
2979 if (cache && cache.has(obj)) {
2980 return cache.get(obj);
2984 var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
2986 for (var key in obj) {
2987 if (Object.prototype.hasOwnProperty.call(obj, key)) {
2988 var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
2990 if (desc && (desc.get || desc.set)) {
2991 Object.defineProperty(newObj, key, desc);
2993 newObj[key] = obj[key];
2998 newObj.default = obj;
3001 cache.set(obj, newObj);
3007 let deprecationWarningShown = false;
3009 function getDefs(chalk) {
3012 marker: chalk.red.bold,
3013 message: chalk.red.bold
3017 const NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
3019 function getMarkerLines(loc, source, opts) {
3020 const startLoc = Object.assign({
3024 const endLoc = Object.assign({}, startLoc, {}, loc.end);
3029 const startLine = startLoc.line;
3030 const startColumn = startLoc.column;
3031 const endLine = endLoc.line;
3032 const endColumn = endLoc.column;
3033 let start = Math.max(startLine - (linesAbove + 1), 0);
3034 let end = Math.min(source.length, endLine + linesBelow);
3036 if (startLine === -1) {
3040 if (endLine === -1) {
3041 end = source.length;
3044 const lineDiff = endLine - startLine;
3045 const markerLines = {};
3048 for (let i = 0; i <= lineDiff; i++) {
3049 const lineNumber = i + startLine;
3052 markerLines[lineNumber] = true;
3053 } else if (i === 0) {
3054 const sourceLength = source[lineNumber - 1].length;
3055 markerLines[lineNumber] = [startColumn, sourceLength - startColumn + 1];
3056 } else if (i === lineDiff) {
3057 markerLines[lineNumber] = [0, endColumn];
3059 const sourceLength = source[lineNumber - i].length;
3060 markerLines[lineNumber] = [0, sourceLength];
3064 if (startColumn === endColumn) {
3066 markerLines[startLine] = [startColumn, 0];
3068 markerLines[startLine] = true;
3071 markerLines[startLine] = [startColumn, endColumn - startColumn];
3082 function codeFrameColumns(rawLines, loc, opts = {}) {
3083 const highlighted = (opts.highlightCode || opts.forceColor) && (0, _highlight.shouldHighlight)(opts);
3084 const chalk = (0, _highlight.getChalk)(opts);
3085 const defs = getDefs(chalk);
3087 const maybeHighlight = (chalkFn, string) => {
3088 return highlighted ? chalkFn(string) : string;
3091 const lines = rawLines.split(NEWLINE);
3096 } = getMarkerLines(loc, lines, opts);
3097 const hasColumns = loc.start && typeof loc.start.column === "number";
3098 const numberMaxWidth = String(end).length;
3099 const highlightedLines = highlighted ? (0, _highlight.default)(rawLines, opts) : rawLines;
3100 let frame = highlightedLines.split(NEWLINE).slice(start, end).map((line, index) => {
3101 const number = start + 1 + index;
3102 const paddedNumber = ` ${number}`.slice(-numberMaxWidth);
3103 const gutter = ` ${paddedNumber} | `;
3104 const hasMarker = markerLines[number];
3105 const lastMarkerLine = !markerLines[number + 1];
3108 let markerLine = "";
3110 if (Array.isArray(hasMarker)) {
3111 const markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " ");
3112 const numberOfMarkers = hasMarker[1] || 1;
3113 markerLine = ["\n ", maybeHighlight(defs.gutter, gutter.replace(/\d/g, " ")), markerSpacing, maybeHighlight(defs.marker, "^").repeat(numberOfMarkers)].join("");
3115 if (lastMarkerLine && opts.message) {
3116 markerLine += " " + maybeHighlight(defs.message, opts.message);
3120 return [maybeHighlight(defs.marker, ">"), maybeHighlight(defs.gutter, gutter), line, markerLine].join("");
3122 return ` ${maybeHighlight(defs.gutter, gutter)}${line}`;
3126 if (opts.message && !hasColumns) {
3127 frame = `${" ".repeat(numberMaxWidth + 1)}${opts.message}\n${frame}`;
3131 return chalk.reset(frame);
3137 function _default(rawLines, lineNumber, colNumber, opts = {}) {
3138 if (!deprecationWarningShown) {
3139 deprecationWarningShown = true;
3140 const message = "Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`.";
3142 if (process.emitWarning) {
3143 process.emitWarning(message, "DeprecationWarning");
3145 const deprecationError = new Error(message);
3146 deprecationError.name = "DeprecationWarning";
3147 console.warn(new Error(message));
3151 colNumber = Math.max(colNumber, 0);
3158 return codeFrameColumns(rawLines, location, opts);
3161 unwrapExports(lib$1);
3162 var lib_1$1 = lib$1.codeFrameColumns;
3164 var require$$0 = getCjsExportFromNamespace(dist);
3167 default: LinesAndColumns$1
3172 const JSONError = errorEx_1('JSONError', {
3173 fileName: errorEx_1.append('in %s'),
3174 codeFrame: errorEx_1.append('\n\n%s\n')
3177 var parseJson$1 = (string, reviver, filename) => {
3178 if (typeof reviver === 'string') {
3185 return JSON.parse(string, reviver);
3187 jsonParseBetterErrors(string, reviver);
3191 error.message = error.message.replace(/\n/g, '');
3192 const indexMatch = error.message.match(/in JSON at position (\d+) while parsing near/);
3193 const jsonError = new JSONError(error);
3196 jsonError.fileName = filename;
3199 if (indexMatch && indexMatch.length > 0) {
3200 const lines = new LinesAndColumns$1(string);
3201 const index = Number(indexMatch[1]);
3202 const location = lines.locationForIndex(index);
3203 const codeFrame = codeFrameColumns(string, {
3205 line: location.line + 1,
3206 column: location.column + 1
3211 jsonError.codeFrame = codeFrame;
3218 var constants = createCommonjsModule(function (module, exports) {
3220 Object.defineProperty(exports, "__esModule", {
3223 exports.Type = exports.Char = void 0;
3228 DIRECTIVES_END: '-',
3231 exports.Char = Char;
3234 BLANK_LINE: 'BLANK_LINE',
3235 BLOCK_FOLDED: 'BLOCK_FOLDED',
3236 BLOCK_LITERAL: 'BLOCK_LITERAL',
3238 DIRECTIVE: 'DIRECTIVE',
3239 DOCUMENT: 'DOCUMENT',
3240 FLOW_MAP: 'FLOW_MAP',
3241 FLOW_SEQ: 'FLOW_SEQ',
3244 MAP_VALUE: 'MAP_VALUE',
3246 QUOTE_DOUBLE: 'QUOTE_DOUBLE',
3247 QUOTE_SINGLE: 'QUOTE_SINGLE',
3249 SEQ_ITEM: 'SEQ_ITEM'
3251 exports.Type = Type;
3253 unwrapExports(constants);
3254 var constants_1 = constants.Type;
3255 var constants_2 = constants.Char;
3257 var sourceUtils = createCommonjsModule(function (module, exports) {
3259 Object.defineProperty(exports, "__esModule", {
3262 exports.getLinePos = getLinePos;
3263 exports.getLine = getLine;
3264 exports.getPrettyContext = getPrettyContext;
3266 function findLineStarts(src) {
3268 let offset = src.indexOf('\n');
3270 while (offset !== -1) {
3273 offset = src.indexOf('\n', offset);
3279 function getSrcInfo(cst) {
3280 let lineStarts, src;
3282 if (typeof cst === 'string') {
3283 lineStarts = findLineStarts(cst);
3286 if (Array.isArray(cst)) cst = cst[0];
3288 if (cst && cst.context) {
3289 if (!cst.lineStarts) cst.lineStarts = findLineStarts(cst.context.src);
3290 lineStarts = cst.lineStarts;
3291 src = cst.context.src;
3301 * @typedef {Object} LinePos - One-indexed position in the source
3302 * @property {number} line
3303 * @property {number} col
3307 * Determine the line/col position matching a character offset.
3309 * Accepts a source string or a CST document as the second parameter. With
3310 * the latter, starting indices for lines are cached in the document as
3311 * `lineStarts: number[]`.
3313 * Returns a one-indexed `{ line, col }` location if found, or
3314 * `undefined` otherwise.
3316 * @param {number} offset
3317 * @param {string|Document|Document[]} cst
3318 * @returns {?LinePos}
3322 function getLinePos(offset, cst) {
3323 if (typeof offset !== 'number' || offset < 0) return null;
3327 } = getSrcInfo(cst);
3328 if (!lineStarts || !src || offset > src.length) return null;
3330 for (let i = 0; i < lineStarts.length; ++i) {
3331 const start = lineStarts[i];
3333 if (offset < start) {
3336 col: offset - lineStarts[i - 1] + 1
3340 if (offset === start) return {
3346 const line = lineStarts.length;
3349 col: offset - lineStarts[line - 1] + 1
3353 * Get a specified line from the source.
3355 * Accepts a source string or a CST document as the second parameter. With
3356 * the latter, starting indices for lines are cached in the document as
3357 * `lineStarts: number[]`.
3359 * Returns the line as a string if found, or `null` otherwise.
3361 * @param {number} line One-indexed line number
3362 * @param {string|Document|Document[]} cst
3363 * @returns {?string}
3367 function getLine(line, cst) {
3371 } = getSrcInfo(cst);
3372 if (!lineStarts || !(line >= 1) || line > lineStarts.length) return null;
3373 const start = lineStarts[line - 1];
3374 let end = lineStarts[line]; // undefined for last line; that's ok for slice()
3376 while (end && end > start && src[end - 1] === '\n') --end;
3378 return src.slice(start, end);
3381 * Pretty-print the starting line from the source indicated by the range `pos`
3383 * Trims output to `maxWidth` chars while keeping the starting column visible,
3384 * using `…` at either end to indicate dropped characters.
3386 * Returns a two-line string (or `null`) with `\n` as separator; the second line
3387 * will hold appropriately indented `^` marks indicating the column range.
3389 * @param {Object} pos
3390 * @param {LinePos} pos.start
3391 * @param {LinePos} [pos.end]
3392 * @param {string|Document|Document[]*} cst
3393 * @param {number} [maxWidth=80]
3394 * @returns {?string}
3398 function getPrettyContext({
3401 }, cst, maxWidth = 80) {
3402 let src = getLine(start.line, cst);
3403 if (!src) return null;
3408 if (src.length > maxWidth) {
3409 if (col <= maxWidth - 10) {
3410 src = src.substr(0, maxWidth - 1) + '…';
3412 const halfWidth = Math.round(maxWidth / 2);
3413 if (src.length > col + halfWidth) src = src.substr(0, col + halfWidth - 1) + '…';
3414 col -= src.length - maxWidth;
3415 src = '…' + src.substr(1 - maxWidth);
3423 if (end.line === start.line && col + (end.col - start.col) <= maxWidth + 1) {
3424 errLen = end.col - start.col;
3426 errLen = Math.min(src.length + 1, maxWidth) - col;
3431 const offset = col > 1 ? ' '.repeat(col - 1) : '';
3432 const err = '^'.repeat(errLen);
3433 return `${src}\n${offset}${err}${errEnd}`;
3436 unwrapExports(sourceUtils);
3437 var sourceUtils_1 = sourceUtils.getLinePos;
3438 var sourceUtils_2 = sourceUtils.getLine;
3439 var sourceUtils_3 = sourceUtils.getPrettyContext;
3441 var Range_1 = createCommonjsModule(function (module, exports) {
3443 Object.defineProperty(exports, "__esModule", {
3446 exports.default = void 0;
3450 return new Range(orig.start, orig.end);
3453 constructor(start, end) {
3455 this.end = end || start;
3459 return typeof this.start !== 'number' || !this.end || this.end <= this.start;
3462 * Set `origStart` and `origEnd` to point to the original source range for
3463 * this node, which may differ due to dropped CR characters.
3465 * @param {number[]} cr - Positions of dropped CR characters
3466 * @param {number} offset - Starting index of `cr` from the last call
3467 * @returns {number} - The next offset, matching the one found for `origStart`
3471 setOrigRange(cr, offset) {
3477 if (cr.length === 0 || end <= cr[0]) {
3478 this.origStart = start;
3485 while (i < cr.length) {
3486 if (cr[i] > start) break;else ++i;
3489 this.origStart = start + i;
3490 const nextOffset = i;
3492 while (i < cr.length) {
3493 // if end was at \n, it should now be at \r
3494 if (cr[i] >= end) break;else ++i;
3497 this.origEnd = end + i;
3503 exports.default = Range;
3505 unwrapExports(Range_1);
3507 var Node_1 = createCommonjsModule(function (module, exports) {
3509 Object.defineProperty(exports, "__esModule", {
3512 exports.default = void 0;
3514 var _Range = _interopRequireDefault(Range_1);
3516 function _interopRequireDefault(obj) {
3517 return obj && obj.__esModule ? obj : {
3521 /** Root class of all nodes */
3525 static addStringTerminator(src, offset, str) {
3526 if (str[str.length - 1] === '\n') return str;
3527 const next = Node.endOfWhiteSpace(src, offset);
3528 return next >= src.length || src[next] === '\n' ? str + '\n' : str;
3532 static atDocumentBoundary(src, offset, sep) {
3533 const ch0 = src[offset];
3534 if (!ch0) return true;
3535 const prev = src[offset - 1];
3536 if (prev && prev !== '\n') return false;
3539 if (ch0 !== sep) return false;
3541 if (ch0 !== constants.Char.DIRECTIVES_END && ch0 !== constants.Char.DOCUMENT_END) return false;
3544 const ch1 = src[offset + 1];
3545 const ch2 = src[offset + 2];
3546 if (ch1 !== ch0 || ch2 !== ch0) return false;
3547 const ch3 = src[offset + 3];
3548 return !ch3 || ch3 === '\n' || ch3 === '\t' || ch3 === ' ';
3551 static endOfIdentifier(src, offset) {
3552 let ch = src[offset];
3553 const isVerbatim = ch === '<';
3554 const notOk = isVerbatim ? ['\n', '\t', ' ', '>'] : ['\n', '\t', ' ', '[', ']', '{', '}', ','];
3556 while (ch && notOk.indexOf(ch) === -1) ch = src[offset += 1];
3558 if (isVerbatim && ch === '>') offset += 1;
3562 static endOfIndent(src, offset) {
3563 let ch = src[offset];
3565 while (ch === ' ') ch = src[offset += 1];
3570 static endOfLine(src, offset) {
3571 let ch = src[offset];
3573 while (ch && ch !== '\n') ch = src[offset += 1];
3578 static endOfWhiteSpace(src, offset) {
3579 let ch = src[offset];
3581 while (ch === '\t' || ch === ' ') ch = src[offset += 1];
3586 static startOfLine(src, offset) {
3587 let ch = src[offset - 1];
3588 if (ch === '\n') return offset;
3590 while (ch && ch !== '\n') ch = src[offset -= 1];
3595 * End of indentation, or null if the line's indent level is not more
3598 * @param {string} src
3599 * @param {number} indent
3600 * @param {number} lineStart
3601 * @returns {?number}
3605 static endOfBlockIndent(src, indent, lineStart) {
3606 const inEnd = Node.endOfIndent(src, lineStart);
3608 if (inEnd > lineStart + indent) {
3611 const wsEnd = Node.endOfWhiteSpace(src, inEnd);
3612 const ch = src[wsEnd];
3613 if (!ch || ch === '\n') return wsEnd;
3619 static atBlank(src, offset, endAsBlank) {
3620 const ch = src[offset];
3621 return ch === '\n' || ch === '\t' || ch === ' ' || endAsBlank && !ch;
3624 static nextNodeIsIndented(ch, indentDiff, indicatorAsIndent) {
3625 if (!ch || indentDiff < 0) return false;
3626 if (indentDiff > 0) return true;
3627 return indicatorAsIndent && ch === '-';
3628 } // should be at line or string end, or at next non-whitespace char
3631 static normalizeOffset(src, offset) {
3632 const ch = src[offset];
3633 return !ch ? offset : ch !== '\n' && src[offset - 1] === '\n' ? offset - 1 : Node.endOfWhiteSpace(src, offset);
3634 } // fold single newline into space, multiple newlines to N - 1 newlines
3635 // presumes src[offset] === '\n'
3638 static foldNewline(src, offset, indent) {
3642 let ch = src[offset + 1];
3644 while (ch === ' ' || ch === '\t' || ch === '\n') {
3653 if (inCount <= indent) error = true;
3654 offset = Node.endOfWhiteSpace(src, offset + 2) - 1;
3663 ch = src[offset + 1];
3666 if (!fold) fold = ' ';
3667 if (ch && inCount <= indent) error = true;
3675 constructor(type, props, context) {
3676 Object.defineProperty(this, 'context', {
3677 value: context || null,
3682 this.valueRange = null;
3683 this.props = props || [];
3688 getPropValue(idx, key, skipKey) {
3689 if (!this.context) return null;
3693 const prop = this.props[idx];
3694 return prop && src[prop.start] === key ? src.slice(prop.start + (skipKey ? 1 : 0), prop.end) : null;
3698 for (let i = 0; i < this.props.length; ++i) {
3699 const anchor = this.getPropValue(i, constants.Char.ANCHOR, true);
3700 if (anchor != null) return anchor;
3707 const comments = [];
3709 for (let i = 0; i < this.props.length; ++i) {
3710 const comment = this.getPropValue(i, constants.Char.COMMENT, true);
3711 if (comment != null) comments.push(comment);
3714 return comments.length > 0 ? comments.join('\n') : null;
3717 commentHasRequiredWhitespace(start) {
3721 if (this.header && start === this.header.end) return false;
3722 if (!this.valueRange) return false;
3725 } = this.valueRange;
3726 return start !== end || Node.atBlank(src, end - 1);
3735 for (let i = 0; i < this.props.length; ++i) {
3736 if (src[this.props[i].start] === constants.Char.COMMENT) return true;
3749 for (let i = 0; i < this.props.length; ++i) {
3750 if (src[this.props[i].start] !== constants.Char.COMMENT) return true;
3757 get includesTrailingLines() {
3762 const jsonLikeTypes = [constants.Type.FLOW_MAP, constants.Type.FLOW_SEQ, constants.Type.QUOTE_DOUBLE, constants.Type.QUOTE_SINGLE];
3763 return jsonLikeTypes.indexOf(this.type) !== -1;
3766 get rangeAsLinePos() {
3767 if (!this.range || !this.context) return undefined;
3768 const start = (0, sourceUtils.getLinePos)(this.range.start, this.context.root);
3769 if (!start) return undefined;
3770 const end = (0, sourceUtils.getLinePos)(this.range.end, this.context.root);
3778 if (!this.valueRange || !this.context) return null;
3782 } = this.valueRange;
3783 return this.context.src.slice(start, end);
3787 for (let i = 0; i < this.props.length; ++i) {
3788 const tag = this.getPropValue(i, constants.Char.TAG, false);
3791 if (tag[1] === '<') {
3793 verbatim: tag.slice(2, -1)
3796 // eslint-disable-next-line no-unused-vars
3797 const [_, handle, suffix] = tag.match(/^(.*!)([^!]*)$/);
3809 get valueRangeContainsNewline() {
3810 if (!this.valueRange || !this.context) return false;
3814 } = this.valueRange;
3819 for (let i = start; i < end; ++i) {
3820 if (src[i] === '\n') return true;
3826 parseComment(start) {
3831 if (src[start] === constants.Char.COMMENT) {
3832 const end = Node.endOfLine(src, start + 1);
3833 const commentRange = new _Range.default(start, end);
3834 this.props.push(commentRange);
3841 * Populates the `origStart` and `origEnd` values of all ranges for this
3842 * node. Extended by child classes to handle descendant nodes.
3844 * @param {number[]} cr - Positions of dropped CR characters
3845 * @param {number} offset - Starting index of `cr` from the last call
3846 * @returns {number} - The next offset, matching the one found for `origStart`
3850 setOrigRanges(cr, offset) {
3851 if (this.range) offset = this.range.setOrigRange(cr, offset);
3852 if (this.valueRange) this.valueRange.setOrigRange(cr, offset);
3853 this.props.forEach(prop => prop.setOrigRange(cr, offset));
3865 if (value != null) return value;
3866 const str = src.slice(range.start, range.end);
3867 return Node.addStringTerminator(src, range.end, str);
3872 exports.default = Node;
3874 unwrapExports(Node_1);
3876 var errors = createCommonjsModule(function (module, exports) {
3878 Object.defineProperty(exports, "__esModule", {
3881 exports.YAMLWarning = exports.YAMLSyntaxError = exports.YAMLSemanticError = exports.YAMLReferenceError = exports.YAMLError = void 0;
3883 var _Node = _interopRequireDefault(Node_1);
3885 var _Range = _interopRequireDefault(Range_1);
3887 function _interopRequireDefault(obj) {
3888 return obj && obj.__esModule ? obj : {
3893 class YAMLError extends Error {
3894 constructor(name, source, message) {
3895 if (!message || !(source instanceof _Node.default)) throw new Error(`Invalid arguments for new ${name}`);
3898 this.message = message;
3899 this.source = source;
3903 if (!this.source) return;
3904 this.nodeType = this.source.type;
3905 const cst = this.source.context && this.source.context.root;
3907 if (typeof this.offset === 'number') {
3908 this.range = new _Range.default(this.offset, this.offset + 1);
3909 const start = cst && (0, sourceUtils.getLinePos)(this.offset, cst);
3924 this.range = this.source.range;
3925 this.linePos = this.source.rangeAsLinePos;
3932 } = this.linePos.start;
3933 this.message += ` at line ${line}, column ${col}`;
3934 const ctx = cst && (0, sourceUtils.getPrettyContext)(this.linePos, cst);
3935 if (ctx) this.message += `:\n\n${ctx}\n`;
3943 exports.YAMLError = YAMLError;
3945 class YAMLReferenceError extends YAMLError {
3946 constructor(source, message) {
3947 super('YAMLReferenceError', source, message);
3952 exports.YAMLReferenceError = YAMLReferenceError;
3954 class YAMLSemanticError extends YAMLError {
3955 constructor(source, message) {
3956 super('YAMLSemanticError', source, message);
3961 exports.YAMLSemanticError = YAMLSemanticError;
3963 class YAMLSyntaxError extends YAMLError {
3964 constructor(source, message) {
3965 super('YAMLSyntaxError', source, message);
3970 exports.YAMLSyntaxError = YAMLSyntaxError;
3972 class YAMLWarning extends YAMLError {
3973 constructor(source, message) {
3974 super('YAMLWarning', source, message);
3979 exports.YAMLWarning = YAMLWarning;
3981 unwrapExports(errors);
3982 var errors_1 = errors.YAMLWarning;
3983 var errors_2 = errors.YAMLSyntaxError;
3984 var errors_3 = errors.YAMLSemanticError;
3985 var errors_4 = errors.YAMLReferenceError;
3986 var errors_5 = errors.YAMLError;
3988 var BlankLine_1 = createCommonjsModule(function (module, exports) {
3990 Object.defineProperty(exports, "__esModule", {
3993 exports.default = void 0;
3995 var _Node = _interopRequireDefault(Node_1);
3997 var _Range = _interopRequireDefault(Range_1);
3999 function _interopRequireDefault(obj) {
4000 return obj && obj.__esModule ? obj : {
4005 class BlankLine extends _Node.default {
4007 super(constants.Type.BLANK_LINE);
4009 /* istanbul ignore next */
4012 get includesTrailingLines() {
4013 // This is never called from anywhere, but if it were,
4014 // this is the value it should return.
4018 * Parses blank lines from the source
4020 * @param {ParseContext} context
4021 * @param {number} start - Index of first \n character
4022 * @returns {number} - Index of the character after this
4026 parse(context, start) {
4027 this.context = context;
4031 let offset = start + 1;
4033 while (_Node.default.atBlank(src, offset)) {
4034 const lineEnd = _Node.default.endOfWhiteSpace(src, offset);
4036 if (lineEnd === '\n') offset = lineEnd + 1;else break;
4039 this.range = new _Range.default(start, offset);
4045 exports.default = BlankLine;
4047 unwrapExports(BlankLine_1);
4049 var CollectionItem_1 = createCommonjsModule(function (module, exports) {
4051 Object.defineProperty(exports, "__esModule", {
4054 exports.default = void 0;
4056 var _BlankLine = _interopRequireDefault(BlankLine_1);
4058 var _Node = _interopRequireDefault(Node_1);
4060 var _Range = _interopRequireDefault(Range_1);
4062 function _interopRequireDefault(obj) {
4063 return obj && obj.__esModule ? obj : {
4068 class CollectionItem extends _Node.default {
4069 constructor(type, props) {
4074 get includesTrailingLines() {
4075 return !!this.node && this.node.includesTrailingLines;
4078 * @param {ParseContext} context
4079 * @param {number} start - Index of first character
4080 * @returns {number} - Index of the character after this
4084 parse(context, start) {
4085 this.context = context;
4094 if (!atLineStart && this.type === constants.Type.SEQ_ITEM) this.error = new errors.YAMLSemanticError(this, 'Sequence items must not have preceding content on the same line');
4095 const indent = atLineStart ? start - lineStart : context.indent;
4097 let offset = _Node.default.endOfWhiteSpace(src, start + 1);
4099 let ch = src[offset];
4100 const inlineComment = ch === '#';
4101 const comments = [];
4102 let blankLine = null;
4104 while (ch === '\n' || ch === '#') {
4106 const end = _Node.default.endOfLine(src, offset + 1);
4108 comments.push(new _Range.default(offset, end));
4112 lineStart = offset + 1;
4114 const wsEnd = _Node.default.endOfWhiteSpace(src, lineStart);
4116 if (src[wsEnd] === '\n' && comments.length === 0) {
4117 blankLine = new _BlankLine.default();
4118 lineStart = blankLine.parse({
4123 offset = _Node.default.endOfIndent(src, lineStart);
4129 if (_Node.default.nextNodeIsIndented(ch, offset - (lineStart + indent), this.type !== constants.Type.SEQ_ITEM)) {
4130 this.node = parseNode({
4132 inCollection: false,
4137 } else if (ch && lineStart > start + 1) {
4138 offset = lineStart - 1;
4143 // Only blank lines preceding non-empty nodes are captured. Note that
4144 // this means that collection item range start indices do not always
4145 // increase monotonically. -- eemeli/yaml#126
4146 const items = context.parent.items || context.parent.contents;
4147 if (items) items.push(blankLine);
4150 if (comments.length) Array.prototype.push.apply(this.props, comments);
4151 offset = this.node.range.end;
4153 if (inlineComment) {
4154 const c = comments[0];
4158 offset = _Node.default.endOfLine(src, start + 1);
4162 const end = this.node ? this.node.valueRange.end : offset;
4163 this.valueRange = new _Range.default(start, end);
4167 setOrigRanges(cr, offset) {
4168 offset = super.setOrigRanges(cr, offset);
4169 return this.node ? this.node.setOrigRanges(cr, offset) : offset;
4181 if (value != null) return value;
4182 const str = node ? src.slice(range.start, node.range.start) + String(node) : src.slice(range.start, range.end);
4183 return _Node.default.addStringTerminator(src, range.end, str);
4188 exports.default = CollectionItem;
4190 unwrapExports(CollectionItem_1);
4192 var Comment_1 = createCommonjsModule(function (module, exports) {
4194 Object.defineProperty(exports, "__esModule", {
4197 exports.default = void 0;
4199 var _Node = _interopRequireDefault(Node_1);
4201 var _Range = _interopRequireDefault(Range_1);
4203 function _interopRequireDefault(obj) {
4204 return obj && obj.__esModule ? obj : {
4209 class Comment extends _Node.default {
4211 super(constants.Type.COMMENT);
4214 * Parses a comment line from the source
4216 * @param {ParseContext} context
4217 * @param {number} start - Index of first character
4218 * @returns {number} - Index of the character after this scalar
4222 parse(context, start) {
4223 this.context = context;
4224 const offset = this.parseComment(start);
4225 this.range = new _Range.default(start, offset);
4231 exports.default = Comment;
4233 unwrapExports(Comment_1);
4235 var Collection_1 = createCommonjsModule(function (module, exports) {
4237 Object.defineProperty(exports, "__esModule", {
4240 exports.grabCollectionEndComments = grabCollectionEndComments;
4241 exports.default = void 0;
4243 var _BlankLine = _interopRequireDefault(BlankLine_1);
4245 var _CollectionItem = _interopRequireDefault(CollectionItem_1);
4247 var _Comment = _interopRequireDefault(Comment_1);
4249 var _Node = _interopRequireDefault(Node_1);
4251 var _Range = _interopRequireDefault(Range_1);
4253 function _interopRequireDefault(obj) {
4254 return obj && obj.__esModule ? obj : {
4259 function grabCollectionEndComments(node) {
4262 while (cnode instanceof _CollectionItem.default) cnode = cnode.node;
4264 if (!(cnode instanceof Collection)) return null;
4265 const len = cnode.items.length;
4268 for (let i = len - 1; i >= 0; --i) {
4269 const n = cnode.items[i];
4271 if (n.type === constants.Type.COMMENT) {
4272 // Keep sufficiently indented comments with preceding node
4277 if (indent > 0 && n.range.start >= lineStart + indent) break;
4279 } else if (n.type === constants.Type.BLANK_LINE) ci = i;else break;
4282 if (ci === -1) return null;
4283 const ca = cnode.items.splice(ci, len - ci);
4284 const prevEnd = ca[0].range.start;
4287 cnode.range.end = prevEnd;
4288 if (cnode.valueRange && cnode.valueRange.end > prevEnd) cnode.valueRange.end = prevEnd;
4289 if (cnode === node) break;
4290 cnode = cnode.context.parent;
4296 class Collection extends _Node.default {
4297 static nextContentHasIndent(src, offset, indent) {
4298 const lineStart = _Node.default.endOfLine(src, offset) + 1;
4299 offset = _Node.default.endOfWhiteSpace(src, lineStart);
4300 const ch = src[offset];
4301 if (!ch) return false;
4302 if (offset >= lineStart + indent) return true;
4303 if (ch !== '#' && ch !== '\n') return false;
4304 return Collection.nextContentHasIndent(src, offset, indent);
4307 constructor(firstItem) {
4308 super(firstItem.type === constants.Type.SEQ_ITEM ? constants.Type.SEQ : constants.Type.MAP);
4310 for (let i = firstItem.props.length - 1; i >= 0; --i) {
4311 if (firstItem.props[i].start < firstItem.context.lineStart) {
4312 // props on previous line are assumed by the collection
4313 this.props = firstItem.props.slice(0, i + 1);
4314 firstItem.props = firstItem.props.slice(i + 1);
4315 const itemRange = firstItem.props[0] || firstItem.valueRange;
4316 firstItem.range.start = itemRange.start;
4321 this.items = [firstItem];
4322 const ec = grabCollectionEndComments(firstItem);
4323 if (ec) Array.prototype.push.apply(this.items, ec);
4326 get includesTrailingLines() {
4327 return this.items.length > 0;
4330 * @param {ParseContext} context
4331 * @param {number} start - Index of first character
4332 * @returns {number} - Index of the character after this
4336 parse(context, start) {
4337 this.context = context;
4341 } = context; // It's easier to recalculate lineStart here rather than tracking down the
4342 // last context from which to read it -- eemeli/yaml#2
4344 let lineStart = _Node.default.startOfLine(src, start);
4346 const firstItem = this.items[0]; // First-item context needs to be correct for later comment handling
4347 // -- eemeli/yaml#17
4349 firstItem.context.parent = this;
4350 this.valueRange = _Range.default.copy(firstItem.valueRange);
4351 const indent = firstItem.range.start - firstItem.context.lineStart;
4353 offset = _Node.default.normalizeOffset(src, offset);
4354 let ch = src[offset];
4355 let atLineStart = _Node.default.endOfWhiteSpace(src, lineStart) === offset;
4356 let prevIncludesTrailingLines = false;
4359 while (ch === '\n' || ch === '#') {
4360 if (atLineStart && ch === '\n' && !prevIncludesTrailingLines) {
4361 const blankLine = new _BlankLine.default();
4362 offset = blankLine.parse({
4365 this.valueRange.end = offset;
4367 if (offset >= src.length) {
4372 this.items.push(blankLine);
4373 offset -= 1; // blankLine.parse() consumes terminal newline
4374 } else if (ch === '#') {
4375 if (offset < lineStart + indent && !Collection.nextContentHasIndent(src, offset, indent)) {
4379 const comment = new _Comment.default();
4380 offset = comment.parse({
4385 this.items.push(comment);
4386 this.valueRange.end = offset;
4388 if (offset >= src.length) {
4394 lineStart = offset + 1;
4395 offset = _Node.default.endOfIndent(src, lineStart);
4397 if (_Node.default.atBlank(src, offset)) {
4398 const wsEnd = _Node.default.endOfWhiteSpace(src, offset);
4400 const next = src[wsEnd];
4402 if (!next || next === '\n' || next === '#') {
4415 if (offset !== lineStart + indent && (atLineStart || ch !== ':')) {
4416 if (lineStart > start) offset = lineStart;
4420 if (firstItem.type === constants.Type.SEQ_ITEM !== (ch === '-')) {
4421 let typeswitch = true;
4424 // map key may start with -, as long as it's followed by a non-whitespace char
4425 const next = src[offset + 1];
4426 typeswitch = !next || next === '\n' || next === '\t' || next === ' ';
4430 if (lineStart > start) offset = lineStart;
4435 const node = parseNode({
4442 if (!node) return offset; // at next document start
4444 this.items.push(node);
4445 this.valueRange.end = node.valueRange.end;
4446 offset = _Node.default.normalizeOffset(src, node.range.end);
4448 atLineStart = false;
4449 prevIncludesTrailingLines = node.includesTrailingLines; // Need to reset lineStart and atLineStart here if preceding node's range
4450 // has advanced to check the current line's indentation level
4451 // -- eemeli/yaml#10 & eemeli/yaml#38
4454 let ls = offset - 1;
4457 while (prev === ' ' || prev === '\t') prev = src[--ls];
4459 if (prev === '\n') {
4465 const ec = grabCollectionEndComments(node);
4466 if (ec) Array.prototype.push.apply(this.items, ec);
4472 setOrigRanges(cr, offset) {
4473 offset = super.setOrigRanges(cr, offset);
4474 this.items.forEach(node => {
4475 offset = node.setOrigRanges(cr, offset);
4489 if (value != null) return value;
4490 let str = src.slice(range.start, items[0].range.start) + String(items[0]);
4492 for (let i = 1; i < items.length; ++i) {
4493 const item = items[i];
4498 if (atLineStart) for (let i = 0; i < indent; ++i) str += ' ';
4499 str += String(item);
4502 return _Node.default.addStringTerminator(src, range.end, str);
4507 exports.default = Collection;
4509 unwrapExports(Collection_1);
4510 var Collection_2 = Collection_1.grabCollectionEndComments;
4512 var Directive_1 = createCommonjsModule(function (module, exports) {
4514 Object.defineProperty(exports, "__esModule", {
4517 exports.default = void 0;
4519 var _Node = _interopRequireDefault(Node_1);
4521 var _Range = _interopRequireDefault(Range_1);
4523 function _interopRequireDefault(obj) {
4524 return obj && obj.__esModule ? obj : {
4529 class Directive extends _Node.default {
4531 super(constants.Type.DIRECTIVE);
4536 const raw = this.rawValue;
4537 return raw ? raw.trim().split(/[ \t]+/) : [];
4545 let ch = src[offset];
4547 while (ch && ch !== '\n' && ch !== '\t' && ch !== ' ') ch = src[offset += 1];
4549 this.name = src.slice(start, offset);
4553 parseParameters(start) {
4558 let ch = src[offset];
4560 while (ch && ch !== '\n' && ch !== '#') ch = src[offset += 1];
4562 this.valueRange = new _Range.default(start, offset);
4566 parse(context, start) {
4567 this.context = context;
4568 let offset = this.parseName(start + 1);
4569 offset = this.parseParameters(offset);
4570 offset = this.parseComment(offset);
4571 this.range = new _Range.default(start, offset);
4577 exports.default = Directive;
4579 unwrapExports(Directive_1);
4581 var Document_1 = createCommonjsModule(function (module, exports) {
4583 Object.defineProperty(exports, "__esModule", {
4586 exports.default = void 0;
4588 var _BlankLine = _interopRequireDefault(BlankLine_1);
4590 var _Comment = _interopRequireDefault(Comment_1);
4592 var _Directive = _interopRequireDefault(Directive_1);
4594 var _Node = _interopRequireDefault(Node_1);
4596 var _Range = _interopRequireDefault(Range_1);
4598 function _interopRequireDefault(obj) {
4599 return obj && obj.__esModule ? obj : {
4604 class Document extends _Node.default {
4605 static startCommentOrEndBlankLine(src, start) {
4606 const offset = _Node.default.endOfWhiteSpace(src, start);
4608 const ch = src[offset];
4609 return ch === '#' || ch === '\n' ? offset : start;
4613 super(constants.Type.DOCUMENT);
4614 this.directives = null;
4615 this.contents = null;
4616 this.directivesEndMarker = null;
4617 this.documentEndMarker = null;
4620 parseDirectives(start) {
4624 this.directives = [];
4625 let atLineStart = true;
4626 let hasDirectives = false;
4629 while (!_Node.default.atDocumentBoundary(src, offset, constants.Char.DIRECTIVES_END)) {
4630 offset = Document.startCommentOrEndBlankLine(src, offset);
4632 switch (src[offset]) {
4635 const blankLine = new _BlankLine.default();
4636 offset = blankLine.parse({
4640 if (offset < src.length) {
4641 this.directives.push(blankLine);
4652 const comment = new _Comment.default();
4653 offset = comment.parse({
4656 this.directives.push(comment);
4657 atLineStart = false;
4663 const directive = new _Directive.default();
4664 offset = directive.parse({
4668 this.directives.push(directive);
4669 hasDirectives = true;
4670 atLineStart = false;
4675 if (hasDirectives) {
4676 this.error = new errors.YAMLSemanticError(this, 'Missing directives-end indicator line');
4677 } else if (this.directives.length > 0) {
4678 this.contents = this.directives;
4679 this.directives = [];
4687 this.directivesEndMarker = new _Range.default(offset, offset + 3);
4691 if (hasDirectives) {
4692 this.error = new errors.YAMLSemanticError(this, 'Missing directives-end indicator line');
4693 } else if (this.directives.length > 0) {
4694 this.contents = this.directives;
4695 this.directives = [];
4701 parseContents(start) {
4706 if (!this.contents) this.contents = [];
4707 let lineStart = start;
4709 while (src[lineStart - 1] === '-') lineStart -= 1;
4711 let offset = _Node.default.endOfWhiteSpace(src, start);
4713 let atLineStart = lineStart === start;
4714 this.valueRange = new _Range.default(offset);
4716 while (!_Node.default.atDocumentBoundary(src, offset, constants.Char.DOCUMENT_END)) {
4717 switch (src[offset]) {
4720 const blankLine = new _BlankLine.default();
4721 offset = blankLine.parse({
4725 if (offset < src.length) {
4726 this.contents.push(blankLine);
4738 const comment = new _Comment.default();
4739 offset = comment.parse({
4742 this.contents.push(comment);
4743 atLineStart = false;
4749 const iEnd = _Node.default.endOfIndent(src, offset);
4755 inCollection: false,
4759 const node = parseNode(context, iEnd);
4760 if (!node) return this.valueRange.end = iEnd; // at next document start
4762 this.contents.push(node);
4763 offset = node.range.end;
4764 atLineStart = false;
4765 const ec = (0, Collection_1.grabCollectionEndComments)(node);
4766 if (ec) Array.prototype.push.apply(this.contents, ec);
4770 offset = Document.startCommentOrEndBlankLine(src, offset);
4773 this.valueRange.end = offset;
4776 this.documentEndMarker = new _Range.default(offset, offset + 3);
4780 offset = _Node.default.endOfWhiteSpace(src, offset);
4782 if (src[offset] === '#') {
4783 const comment = new _Comment.default();
4784 offset = comment.parse({
4787 this.contents.push(comment);
4790 switch (src[offset]) {
4799 this.error = new errors.YAMLSyntaxError(this, 'Document end marker line cannot have a non-comment suffix');
4807 * @param {ParseContext} context
4808 * @param {number} start - Index of first character
4809 * @returns {number} - Index of the character after this
4813 parse(context, start) {
4814 context.root = this;
4815 this.context = context;
4819 let offset = src.charCodeAt(start) === 0xfeff ? start + 1 : start; // skip BOM
4821 offset = this.parseDirectives(offset);
4822 offset = this.parseContents(offset);
4826 setOrigRanges(cr, offset) {
4827 offset = super.setOrigRanges(cr, offset);
4828 this.directives.forEach(node => {
4829 offset = node.setOrigRanges(cr, offset);
4831 if (this.directivesEndMarker) offset = this.directivesEndMarker.setOrigRange(cr, offset);
4832 this.contents.forEach(node => {
4833 offset = node.setOrigRanges(cr, offset);
4835 if (this.documentEndMarker) offset = this.documentEndMarker.setOrigRange(cr, offset);
4845 if (value != null) return value;
4846 let str = directives.join('');
4848 if (contents.length > 0) {
4849 if (directives.length > 0 || contents[0].type === constants.Type.COMMENT) str += '---\n';
4850 str += contents.join('');
4853 if (str[str.length - 1] !== '\n') str += '\n';
4859 exports.default = Document;
4861 unwrapExports(Document_1);
4863 var Alias_1 = createCommonjsModule(function (module, exports) {
4865 Object.defineProperty(exports, "__esModule", {
4868 exports.default = void 0;
4870 var _Node = _interopRequireDefault(Node_1);
4872 var _Range = _interopRequireDefault(Range_1);
4874 function _interopRequireDefault(obj) {
4875 return obj && obj.__esModule ? obj : {
4880 class Alias extends _Node.default {
4882 * Parses an *alias from the source
4884 * @param {ParseContext} context
4885 * @param {number} start - Index of first character
4886 * @returns {number} - Index of the character after this scalar
4888 parse(context, start) {
4889 this.context = context;
4894 let offset = _Node.default.endOfIdentifier(src, start + 1);
4896 this.valueRange = new _Range.default(start + 1, offset);
4897 offset = _Node.default.endOfWhiteSpace(src, offset);
4898 offset = this.parseComment(offset);
4904 exports.default = Alias;
4906 unwrapExports(Alias_1);
4908 var BlockValue_1 = createCommonjsModule(function (module, exports) {
4910 Object.defineProperty(exports, "__esModule", {
4913 exports.default = exports.Chomp = void 0;
4915 var _Node = _interopRequireDefault(Node_1);
4917 var _Range = _interopRequireDefault(Range_1);
4919 function _interopRequireDefault(obj) {
4920 return obj && obj.__esModule ? obj : {
4930 exports.Chomp = Chomp;
4932 class BlockValue extends _Node.default {
4933 constructor(type, props) {
4935 this.blockIndent = null;
4936 this.chomping = Chomp.CLIP;
4940 get includesTrailingLines() {
4941 return this.chomping === Chomp.KEEP;
4945 if (!this.valueRange || !this.context) return null;
4949 } = this.valueRange;
4954 if (this.valueRange.isEmpty()) return '';
4955 let lastNewLine = null;
4956 let ch = src[end - 1];
4958 while (ch === '\n' || ch === '\t' || ch === ' ') {
4962 if (this.chomping === Chomp.KEEP) break;else return ''; // probably never happens
4965 if (ch === '\n') lastNewLine = end;
4969 let keepStart = end + 1;
4972 if (this.chomping === Chomp.KEEP) {
4973 keepStart = lastNewLine;
4974 end = this.valueRange.end;
4980 const bi = indent + this.blockIndent;
4981 const folded = this.type === constants.Type.BLOCK_FOLDED;
4985 let prevMoreIndented = false;
4987 for (let i = start; i < end; ++i) {
4988 for (let j = 0; j < bi; ++j) {
4989 if (src[i] !== ' ') break;
4996 if (sep === '\n') str += '\n';else sep = '\n';
4998 const lineEnd = _Node.default.endOfLine(src, i);
5000 const line = src.slice(i, lineEnd);
5003 if (folded && (ch === ' ' || ch === '\t') && i < keepStart) {
5004 if (sep === ' ') sep = '\n';else if (!prevMoreIndented && !atStart && sep === '\n') sep = '\n\n';
5005 str += sep + line; //+ ((lineEnd < end && src[lineEnd]) || '')
5007 sep = lineEnd < end && src[lineEnd] || '';
5008 prevMoreIndented = true;
5011 sep = folded && i < keepStart ? ' ' : '\n';
5012 prevMoreIndented = false;
5015 if (atStart && line !== '') atStart = false;
5019 return this.chomping === Chomp.STRIP ? str : str + '\n';
5022 parseBlockHeader(start) {
5026 let offset = start + 1;
5030 const ch = src[offset];
5034 this.chomping = Chomp.STRIP;
5038 this.chomping = Chomp.KEEP;
5055 this.blockIndent = Number(bi) || null;
5056 this.header = new _Range.default(start, offset);
5064 parseBlockValue(start) {
5070 let valueEnd = start;
5071 let bi = this.blockIndent ? indent + this.blockIndent - 1 : indent;
5072 let minBlockIndent = 1;
5074 for (let ch = src[offset]; ch === '\n'; ch = src[offset]) {
5076 if (_Node.default.atDocumentBoundary(src, offset)) break;
5078 const end = _Node.default.endOfBlockIndent(src, bi, offset); // should not include tab?
5081 if (end === null) break;
5083 if (!this.blockIndent) {
5084 // no explicit block indent, none yet detected
5085 const lineIndent = end - (offset + indent);
5087 if (src[end] !== '\n') {
5088 // first line with non-whitespace content
5089 if (lineIndent < minBlockIndent) {
5094 this.blockIndent = lineIndent;
5095 bi = indent + this.blockIndent - 1;
5096 } else if (lineIndent > minBlockIndent) {
5097 // empty line with more whitespace
5098 minBlockIndent = lineIndent;
5102 if (src[end] === '\n') {
5105 offset = valueEnd = _Node.default.endOfLine(src, end);
5109 if (this.chomping !== Chomp.KEEP) {
5110 offset = src[valueEnd] ? valueEnd + 1 : valueEnd;
5113 this.valueRange = new _Range.default(start + 1, offset);
5117 * Parses a block value from the source
5119 * Accepted forms are:
5129 * where the block style BS matches the regexp `[|>][-+1-9]*` and block lines
5130 * are empty or have an indent level greater than `indent`.
5132 * @param {ParseContext} context
5133 * @param {number} start - Index of first character
5134 * @returns {number} - Index of the character after this block
5138 parse(context, start) {
5139 this.context = context;
5143 let offset = this.parseBlockHeader(start);
5144 offset = _Node.default.endOfWhiteSpace(src, offset);
5145 offset = this.parseComment(offset);
5146 offset = this.parseBlockValue(offset);
5150 setOrigRanges(cr, offset) {
5151 offset = super.setOrigRanges(cr, offset);
5152 return this.header ? this.header.setOrigRange(cr, offset) : offset;
5157 exports.default = BlockValue;
5159 unwrapExports(BlockValue_1);
5160 var BlockValue_2 = BlockValue_1.Chomp;
5162 var FlowCollection_1 = createCommonjsModule(function (module, exports) {
5164 Object.defineProperty(exports, "__esModule", {
5167 exports.default = void 0;
5169 var _BlankLine = _interopRequireDefault(BlankLine_1);
5171 var _Comment = _interopRequireDefault(Comment_1);
5173 var _Node = _interopRequireDefault(Node_1);
5175 var _Range = _interopRequireDefault(Range_1);
5177 function _interopRequireDefault(obj) {
5178 return obj && obj.__esModule ? obj : {
5183 class FlowCollection extends _Node.default {
5184 constructor(type, props) {
5189 prevNodeIsJsonLike(idx = this.items.length) {
5190 const node = this.items[idx - 1];
5191 return !!node && (node.jsonLike || node.type === constants.Type.COMMENT && this.nodeIsJsonLike(idx - 1));
5194 * @param {ParseContext} context
5195 * @param {number} start - Index of first character
5196 * @returns {number} - Index of the character after this
5200 parse(context, start) {
5201 this.context = context;
5210 let char = src[start]; // { or [
5217 let offset = _Node.default.endOfWhiteSpace(src, start + 1);
5221 while (char && char !== ']' && char !== '}') {
5225 lineStart = offset + 1;
5227 const wsEnd = _Node.default.endOfWhiteSpace(src, lineStart);
5229 if (src[wsEnd] === '\n') {
5230 const blankLine = new _BlankLine.default();
5231 lineStart = blankLine.parse({
5234 this.items.push(blankLine);
5237 offset = _Node.default.endOfIndent(src, lineStart);
5239 if (offset <= lineStart + indent) {
5242 if (offset < lineStart + indent || char !== ']' && char !== '}') {
5243 const msg = 'Insufficient indentation in flow collection';
5244 this.error = new errors.YAMLSemanticError(this, msg);
5262 const comment = new _Comment.default();
5263 offset = comment.parse({
5266 this.items.push(comment);
5273 const next = src[offset + 1];
5275 if (next === '\n' || next === '\t' || next === ' ' || next === ',' || // in-flow : after JSON-like key does not need to be followed by whitespace
5276 char === ':' && this.prevNodeIsJsonLike()) {
5289 const node = parseNode({
5291 inCollection: false,
5299 // at next document start
5300 this.valueRange = new _Range.default(start, offset);
5304 this.items.push(node);
5305 offset = _Node.default.normalizeOffset(src, node.range.end);
5309 offset = _Node.default.endOfWhiteSpace(src, offset);
5313 this.valueRange = new _Range.default(start, offset + 1);
5320 offset = _Node.default.endOfWhiteSpace(src, offset + 1);
5321 offset = this.parseComment(offset);
5327 setOrigRanges(cr, offset) {
5328 offset = super.setOrigRanges(cr, offset);
5329 this.items.forEach(node => {
5330 if (node instanceof _Node.default) {
5331 offset = node.setOrigRanges(cr, offset);
5332 } else if (cr.length === 0) {
5333 node.origOffset = node.offset;
5337 while (i < cr.length) {
5338 if (cr[i] > node.offset) break;else ++i;
5341 node.origOffset = node.offset + i;
5357 if (value != null) return value;
5358 const nodes = items.filter(item => item instanceof _Node.default);
5360 let prevEnd = range.start;
5361 nodes.forEach(node => {
5362 const prefix = src.slice(prevEnd, node.range.start);
5363 prevEnd = node.range.end;
5364 str += prefix + String(node);
5366 if (str[str.length - 1] === '\n' && src[prevEnd - 1] !== '\n' && src[prevEnd] === '\n') {
5367 // Comment range does not include the terminal newline, but its
5368 // stringified value does. Without this fix, newlines at comment ends
5373 str += src.slice(prevEnd, range.end);
5374 return _Node.default.addStringTerminator(src, range.end, str);
5379 exports.default = FlowCollection;
5381 unwrapExports(FlowCollection_1);
5383 var PlainValue_1 = createCommonjsModule(function (module, exports) {
5385 Object.defineProperty(exports, "__esModule", {
5388 exports.default = void 0;
5390 var _Node = _interopRequireDefault(Node_1);
5392 var _Range = _interopRequireDefault(Range_1);
5394 function _interopRequireDefault(obj) {
5395 return obj && obj.__esModule ? obj : {
5400 class PlainValue extends _Node.default {
5401 static endOfLine(src, start, inFlow) {
5402 let ch = src[start];
5405 while (ch && ch !== '\n') {
5406 if (inFlow && (ch === '[' || ch === ']' || ch === '{' || ch === '}' || ch === ',')) break;
5407 const next = src[offset + 1];
5408 if (ch === ':' && (!next || next === '\n' || next === '\t' || next === ' ' || inFlow && next === ',')) break;
5409 if ((ch === ' ' || ch === '\t') && next === '#') break;
5418 if (!this.valueRange || !this.context) return null;
5422 } = this.valueRange;
5426 let ch = src[end - 1];
5428 while (start < end && (ch === '\n' || ch === '\t' || ch === ' ')) ch = src[--end - 1];
5432 while (start < end && (ch === '\n' || ch === '\t' || ch === ' ')) ch = src[++start];
5436 for (let i = start; i < end; ++i) {
5443 } = _Node.default.foldNewline(src, i, -1);
5447 } else if (ch === ' ' || ch === '\t') {
5448 // trim trailing whitespace
5450 let next = src[i + 1];
5452 while (i < end && (next === ' ' || next === '\t')) {
5457 if (next !== '\n') str += i > wsStart ? src.slice(wsStart, i + 1) : ch;
5466 parseBlockValue(start) {
5473 let valueEnd = start;
5475 for (let ch = src[offset]; ch === '\n'; ch = src[offset]) {
5476 if (_Node.default.atDocumentBoundary(src, offset + 1)) break;
5478 const end = _Node.default.endOfBlockIndent(src, indent, offset + 1);
5480 if (end === null || src[end] === '#') break;
5482 if (src[end] === '\n') {
5485 valueEnd = PlainValue.endOfLine(src, end, inFlow);
5490 if (this.valueRange.isEmpty()) this.valueRange.start = start;
5491 this.valueRange.end = valueEnd;
5495 * Parses a plain value from the source
5497 * Accepted forms are:
5503 * first line #comment
5513 * where block lines are empty or have an indent level greater than `indent`.
5515 * @param {ParseContext} context
5516 * @param {number} start - Index of first character
5517 * @returns {number} - Index of the character after this scalar, may be `\n`
5521 parse(context, start) {
5522 this.context = context;
5528 const ch = src[offset];
5530 if (ch && ch !== '#' && ch !== '\n') {
5531 offset = PlainValue.endOfLine(src, start, inFlow);
5534 this.valueRange = new _Range.default(start, offset);
5535 offset = _Node.default.endOfWhiteSpace(src, offset);
5536 offset = this.parseComment(offset);
5538 if (!this.hasComment || this.valueRange.isEmpty()) {
5539 offset = this.parseBlockValue(offset);
5547 exports.default = PlainValue;
5549 unwrapExports(PlainValue_1);
5551 var QuoteDouble_1 = createCommonjsModule(function (module, exports) {
5553 Object.defineProperty(exports, "__esModule", {
5556 exports.default = void 0;
5558 var _Node = _interopRequireDefault(Node_1);
5560 var _Range = _interopRequireDefault(Range_1);
5562 function _interopRequireDefault(obj) {
5563 return obj && obj.__esModule ? obj : {
5568 class QuoteDouble extends _Node.default {
5569 static endOfQuote(src, offset) {
5570 let ch = src[offset];
5572 while (ch && ch !== '"') {
5573 offset += ch === '\\' ? 2 : 1;
5580 * @returns {string | { str: string, errors: YAMLSyntaxError[] }}
5585 if (!this.valueRange || !this.context) return null;
5586 const errors$1 = [];
5590 } = this.valueRange;
5595 if (src[end - 1] !== '"') errors$1.push(new errors.YAMLSyntaxError(this, 'Missing closing "quote')); // Using String#replace is too painful with escaped newlines preceded by
5596 // escaped backslashes; also, this should be faster.
5600 for (let i = start + 1; i < end - 1; ++i) {
5604 if (_Node.default.atDocumentBoundary(src, i + 1)) errors$1.push(new errors.YAMLSemanticError(this, 'Document boundary indicators are not allowed within string values'));
5610 } = _Node.default.foldNewline(src, i, indent);
5614 if (error) errors$1.push(new errors.YAMLSemanticError(this, 'Multi-line double-quoted string needs to be sufficiently indented'));
5615 } else if (ch === '\\') {
5667 // Unicode next line
5672 // Unicode non-breaking space
5677 // Unicode line separator
5682 // Unicode paragraph separator
5705 str += this.parseCharCode(i + 1, 2, errors$1);
5710 str += this.parseCharCode(i + 1, 4, errors$1);
5715 str += this.parseCharCode(i + 1, 8, errors$1);
5720 // skip escaped newlines, but still trim the following line
5721 while (src[i + 1] === ' ' || src[i + 1] === '\t') i += 1;
5726 errors$1.push(new errors.YAMLSyntaxError(this, `Invalid escape sequence ${src.substr(i - 1, 2)}`));
5727 str += '\\' + src[i];
5729 } else if (ch === ' ' || ch === '\t') {
5730 // trim trailing whitespace
5732 let next = src[i + 1];
5734 while (next === ' ' || next === '\t') {
5739 if (next !== '\n') str += i > wsStart ? src.slice(wsStart, i + 1) : ch;
5745 return errors$1.length > 0 ? {
5751 parseCharCode(offset, length, errors$1) {
5755 const cc = src.substr(offset, length);
5756 const ok = cc.length === length && /^[0-9a-fA-F]+$/.test(cc);
5757 const code = ok ? parseInt(cc, 16) : NaN;
5760 errors$1.push(new errors.YAMLSyntaxError(this, `Invalid escape sequence ${src.substr(offset - 2, length + 2)}`));
5761 return src.substr(offset - 2, length + 2);
5764 return String.fromCodePoint(code);
5767 * Parses a "double quoted" value from the source
5769 * @param {ParseContext} context
5770 * @param {number} start - Index of first character
5771 * @returns {number} - Index of the character after this scalar
5775 parse(context, start) {
5776 this.context = context;
5780 let offset = QuoteDouble.endOfQuote(src, start + 1);
5781 this.valueRange = new _Range.default(start, offset);
5782 offset = _Node.default.endOfWhiteSpace(src, offset);
5783 offset = this.parseComment(offset);
5789 exports.default = QuoteDouble;
5791 unwrapExports(QuoteDouble_1);
5793 var QuoteSingle_1 = createCommonjsModule(function (module, exports) {
5795 Object.defineProperty(exports, "__esModule", {
5798 exports.default = void 0;
5800 var _Node = _interopRequireDefault(Node_1);
5802 var _Range = _interopRequireDefault(Range_1);
5804 function _interopRequireDefault(obj) {
5805 return obj && obj.__esModule ? obj : {
5810 class QuoteSingle extends _Node.default {
5811 static endOfQuote(src, offset) {
5812 let ch = src[offset];
5816 if (src[offset + 1] !== "'") break;
5817 ch = src[offset += 2];
5819 ch = src[offset += 1];
5826 * @returns {string | { str: string, errors: YAMLSyntaxError[] }}
5831 if (!this.valueRange || !this.context) return null;
5832 const errors$1 = [];
5836 } = this.valueRange;
5841 if (src[end - 1] !== "'") errors$1.push(new errors.YAMLSyntaxError(this, "Missing closing 'quote"));
5844 for (let i = start + 1; i < end - 1; ++i) {
5848 if (_Node.default.atDocumentBoundary(src, i + 1)) errors$1.push(new errors.YAMLSemanticError(this, 'Document boundary indicators are not allowed within string values'));
5854 } = _Node.default.foldNewline(src, i, indent);
5858 if (error) errors$1.push(new errors.YAMLSemanticError(this, 'Multi-line single-quoted string needs to be sufficiently indented'));
5859 } else if (ch === "'") {
5862 if (src[i] !== "'") errors$1.push(new errors.YAMLSyntaxError(this, 'Unescaped single quote? This should not happen.'));
5863 } else if (ch === ' ' || ch === '\t') {
5864 // trim trailing whitespace
5866 let next = src[i + 1];
5868 while (next === ' ' || next === '\t') {
5873 if (next !== '\n') str += i > wsStart ? src.slice(wsStart, i + 1) : ch;
5879 return errors$1.length > 0 ? {
5885 * Parses a 'single quoted' value from the source
5887 * @param {ParseContext} context
5888 * @param {number} start - Index of first character
5889 * @returns {number} - Index of the character after this scalar
5893 parse(context, start) {
5894 this.context = context;
5898 let offset = QuoteSingle.endOfQuote(src, start + 1);
5899 this.valueRange = new _Range.default(start, offset);
5900 offset = _Node.default.endOfWhiteSpace(src, offset);
5901 offset = this.parseComment(offset);
5907 exports.default = QuoteSingle;
5909 unwrapExports(QuoteSingle_1);
5911 var ParseContext_1 = createCommonjsModule(function (module, exports) {
5913 Object.defineProperty(exports, "__esModule", {
5916 exports.default = void 0;
5918 var _Alias = _interopRequireDefault(Alias_1);
5920 var _BlockValue = _interopRequireDefault(BlockValue_1);
5922 var _Collection = _interopRequireDefault(Collection_1);
5924 var _CollectionItem = _interopRequireDefault(CollectionItem_1);
5926 var _FlowCollection = _interopRequireDefault(FlowCollection_1);
5928 var _Node = _interopRequireDefault(Node_1);
5930 var _PlainValue = _interopRequireDefault(PlainValue_1);
5932 var _QuoteDouble = _interopRequireDefault(QuoteDouble_1);
5934 var _QuoteSingle = _interopRequireDefault(QuoteSingle_1);
5936 var _Range = _interopRequireDefault(Range_1);
5938 function _interopRequireDefault(obj) {
5939 return obj && obj.__esModule ? obj : {
5944 function _defineProperty(obj, key, value) {
5946 Object.defineProperty(obj, key, {
5959 function createNewNode(type, props) {
5961 case constants.Type.ALIAS:
5962 return new _Alias.default(type, props);
5964 case constants.Type.BLOCK_FOLDED:
5965 case constants.Type.BLOCK_LITERAL:
5966 return new _BlockValue.default(type, props);
5968 case constants.Type.FLOW_MAP:
5969 case constants.Type.FLOW_SEQ:
5970 return new _FlowCollection.default(type, props);
5972 case constants.Type.MAP_KEY:
5973 case constants.Type.MAP_VALUE:
5974 case constants.Type.SEQ_ITEM:
5975 return new _CollectionItem.default(type, props);
5977 case constants.Type.COMMENT:
5978 case constants.Type.PLAIN:
5979 return new _PlainValue.default(type, props);
5981 case constants.Type.QUOTE_DOUBLE:
5982 return new _QuoteDouble.default(type, props);
5984 case constants.Type.QUOTE_SINGLE:
5985 return new _QuoteSingle.default(type, props);
5987 /* istanbul ignore next */
5991 // should never happen
5995 * @param {boolean} atLineStart - Node starts at beginning of line
5996 * @param {boolean} inFlow - true if currently in a flow context
5997 * @param {boolean} inCollection - true if currently in a collection context
5998 * @param {number} indent - Current level of indentation
5999 * @param {number} lineStart - Start of the current line
6000 * @param {Node} parent - The parent of the node
6001 * @param {string} src - Source of the YAML document
6005 class ParseContext {
6006 static parseType(src, offset, inFlow) {
6007 switch (src[offset]) {
6009 return constants.Type.ALIAS;
6012 return constants.Type.BLOCK_FOLDED;
6015 return constants.Type.BLOCK_LITERAL;
6018 return constants.Type.FLOW_MAP;
6021 return constants.Type.FLOW_SEQ;
6024 return !inFlow && _Node.default.atBlank(src, offset + 1, true) ? constants.Type.MAP_KEY : constants.Type.PLAIN;
6027 return !inFlow && _Node.default.atBlank(src, offset + 1, true) ? constants.Type.MAP_VALUE : constants.Type.PLAIN;
6030 return !inFlow && _Node.default.atBlank(src, offset + 1, true) ? constants.Type.SEQ_ITEM : constants.Type.PLAIN;
6033 return constants.Type.QUOTE_DOUBLE;
6036 return constants.Type.QUOTE_SINGLE;
6039 return constants.Type.PLAIN;
6043 constructor(orig = {}, {
6051 _defineProperty(this, "parseNode", (overlay, start) => {
6052 if (_Node.default.atDocumentBoundary(this.src, start)) return null;
6053 const context = new ParseContext(this, overlay);
6058 } = context.parseProps(start);
6059 const node = createNewNode(type, props);
6060 let offset = node.parse(context, valueStart);
6061 node.range = new _Range.default(start, offset);
6062 /* istanbul ignore if */
6064 if (offset <= start) {
6065 // This should never happen, but if it does, let's make sure to at least
6066 // step one character forward to avoid a busy loop.
6067 node.error = new Error(`Node#parse consumed no characters`);
6068 node.error.parseEnd = offset;
6069 node.error.source = node;
6070 node.range.end = start + 1;
6073 if (context.nodeStartsCollection(node)) {
6074 if (!node.error && !context.atLineStart && context.parent.type === constants.Type.DOCUMENT) {
6075 node.error = new errors.YAMLSyntaxError(node, 'Block collection must not have preceding content here (e.g. directives-end indicator)');
6078 const collection = new _Collection.default(node);
6079 offset = collection.parse(new ParseContext(context), offset);
6080 collection.range = new _Range.default(start, offset);
6087 this.atLineStart = atLineStart != null ? atLineStart : orig.atLineStart || false;
6088 this.inCollection = inCollection != null ? inCollection : orig.inCollection || false;
6089 this.inFlow = inFlow != null ? inFlow : orig.inFlow || false;
6090 this.indent = indent != null ? indent : orig.indent;
6091 this.lineStart = lineStart != null ? lineStart : orig.lineStart;
6092 this.parent = parent != null ? parent : orig.parent || {};
6093 this.root = orig.root;
6094 this.src = orig.src;
6097 nodeStartsCollection(node) {
6103 if (inCollection || inFlow) return false;
6104 if (node instanceof _CollectionItem.default) return true; // check for implicit key
6106 let offset = node.range.end;
6107 if (src[offset] === '\n' || src[offset - 1] === '\n') return false;
6108 offset = _Node.default.endOfWhiteSpace(src, offset);
6109 return src[offset] === ':';
6110 } // Anchor and tag are before type, which determines the node implementation
6111 // class; hence this intermediate step.
6114 parseProps(offset) {
6121 let lineHasProps = false;
6122 offset = _Node.default.endOfWhiteSpace(src, offset);
6123 let ch = src[offset];
6125 while (ch === constants.Char.ANCHOR || ch === constants.Char.COMMENT || ch === constants.Char.TAG || ch === '\n') {
6127 const lineStart = offset + 1;
6129 const inEnd = _Node.default.endOfIndent(src, lineStart);
6131 const indentDiff = inEnd - (lineStart + this.indent);
6132 const noIndicatorAsIndent = parent.type === constants.Type.SEQ_ITEM && parent.context.atLineStart;
6133 if (!_Node.default.nextNodeIsIndented(src[inEnd], indentDiff, !noIndicatorAsIndent)) break;
6134 this.atLineStart = true;
6135 this.lineStart = lineStart;
6136 lineHasProps = false;
6138 } else if (ch === constants.Char.COMMENT) {
6139 const end = _Node.default.endOfLine(src, offset + 1);
6141 props.push(new _Range.default(offset, end));
6144 let end = _Node.default.endOfIdentifier(src, offset + 1);
6146 if (ch === constants.Char.TAG && src[end] === ',' && /^[a-zA-Z0-9-]+\.[a-zA-Z0-9-]+,\d\d\d\d(-\d\d){0,2}\/\S/.test(src.slice(offset + 1, end + 13))) {
6147 // Let's presume we're dealing with a YAML 1.0 domain tag here, rather
6148 // than an empty but 'foo.bar' private-tagged node in a flow collection
6149 // followed without whitespace by a plain string starting with a year
6150 // or date divided by something.
6151 end = _Node.default.endOfIdentifier(src, end + 5);
6154 props.push(new _Range.default(offset, end));
6155 lineHasProps = true;
6156 offset = _Node.default.endOfWhiteSpace(src, end);
6160 } // '- &a : b' has an anchor on an empty node
6163 if (lineHasProps && ch === ':' && _Node.default.atBlank(src, offset + 1, true)) offset -= 1;
6164 const type = ParseContext.parseType(src, offset, inFlow);
6172 * Parses a node from the source
6173 * @param {ParseContext} overlay
6174 * @param {number} start - Index of first non-whitespace character for the node
6175 * @returns {?Node} - null if at a document boundary
6181 exports.default = ParseContext;
6183 unwrapExports(ParseContext_1);
6185 var parse_1 = createCommonjsModule(function (module, exports) {
6187 Object.defineProperty(exports, "__esModule", {
6190 exports.default = parse;
6192 var _Document = _interopRequireDefault(Document_1);
6194 var _ParseContext = _interopRequireDefault(ParseContext_1);
6196 function _interopRequireDefault(obj) {
6197 return obj && obj.__esModule ? obj : {
6200 } // Published as 'yaml/parse-cst'
6203 function parse(src) {
6206 if (src.indexOf('\r') !== -1) {
6207 src = src.replace(/\r\n?/g, (match, offset) => {
6208 if (match.length > 1) cr.push(offset);
6213 const documents = [];
6217 const doc = new _Document.default();
6218 const context = new _ParseContext.default({
6221 offset = doc.parse(context, offset);
6222 documents.push(doc);
6223 } while (offset < src.length);
6225 documents.setOrigRanges = () => {
6226 if (cr.length === 0) return false;
6228 for (let i = 1; i < cr.length; ++i) cr[i] -= i;
6232 for (let i = 0; i < documents.length; ++i) {
6233 crOffset = documents[i].setOrigRanges(cr, crOffset);
6236 cr.splice(0, cr.length);
6240 documents.toString = () => documents.join('...\n');
6245 unwrapExports(parse_1);
6247 var addComment_1 = createCommonjsModule(function (module, exports) {
6249 Object.defineProperty(exports, "__esModule", {
6252 exports.addCommentBefore = addCommentBefore;
6253 exports.default = addComment;
6255 function addCommentBefore(str, indent, comment) {
6256 if (!comment) return str;
6257 const cc = comment.replace(/[\s\S]^/gm, `$&${indent}#`);
6258 return `#${cc}\n${indent}${str}`;
6261 function addComment(str, indent, comment) {
6262 return !comment ? str : comment.indexOf('\n') === -1 ? `${str} #${comment}` : `${str}\n` + comment.replace(/^/gm, `${indent || ''}#`);
6265 unwrapExports(addComment_1);
6266 var addComment_2 = addComment_1.addCommentBefore;
6268 var toJSON_1 = createCommonjsModule(function (module, exports) {
6270 Object.defineProperty(exports, "__esModule", {
6273 exports.default = toJSON;
6275 function toJSON(value, arg, ctx) {
6276 if (Array.isArray(value)) return value.map((v, i) => toJSON(v, String(i), ctx));
6278 if (value && typeof value.toJSON === 'function') {
6279 const anchor = ctx && ctx.anchors && ctx.anchors.find(a => a.node === value);
6280 if (anchor) ctx.onCreate = res => {
6282 delete ctx.onCreate;
6284 const res = value.toJSON(arg, ctx);
6285 if (anchor && ctx.onCreate) ctx.onCreate(res);
6292 unwrapExports(toJSON_1);
6294 var Node_1$1 = createCommonjsModule(function (module, exports) {
6296 Object.defineProperty(exports, "__esModule", {
6299 exports.default = void 0;
6303 exports.default = Node;
6305 unwrapExports(Node_1$1);
6307 var Scalar_1 = createCommonjsModule(function (module, exports) {
6309 Object.defineProperty(exports, "__esModule", {
6312 exports.default = void 0;
6314 var _toJSON = _interopRequireDefault(toJSON_1);
6316 var _Node = _interopRequireDefault(Node_1$1);
6318 function _interopRequireDefault(obj) {
6319 return obj && obj.__esModule ? obj : {
6322 } // Published as 'yaml/scalar'
6325 class Scalar extends _Node.default {
6326 constructor(value) {
6332 return ctx && ctx.keep ? this.value : (0, _toJSON.default)(this.value, arg, ctx);
6336 return String(this.value);
6341 exports.default = Scalar;
6343 unwrapExports(Scalar_1);
6345 var Pair_1 = createCommonjsModule(function (module, exports) {
6347 Object.defineProperty(exports, "__esModule", {
6350 exports.default = void 0;
6352 var _addComment = _interopRequireDefault(addComment_1);
6354 var _toJSON = _interopRequireDefault(toJSON_1);
6356 var _Collection = _interopRequireDefault(Collection_1$1);
6358 var _Node = _interopRequireDefault(Node_1$1);
6360 var _Scalar = _interopRequireDefault(Scalar_1);
6362 function _interopRequireDefault(obj) {
6363 return obj && obj.__esModule ? obj : {
6366 } // Published as 'yaml/pair'
6369 const stringifyKey = (key, jsKey, ctx) => {
6370 if (jsKey === null) return '';
6371 if (typeof jsKey !== 'object') return String(jsKey);
6372 if (key instanceof _Node.default && ctx && ctx.doc) return key.toString({
6377 inStringifyKey: true
6379 return JSON.stringify(jsKey);
6382 class Pair extends _Node.default {
6383 constructor(key, value = null) {
6390 get commentBefore() {
6391 return this.key && this.key.commentBefore;
6394 set commentBefore(cb) {
6395 if (this.key == null) this.key = new _Scalar.default(null);
6396 this.key.commentBefore = cb;
6399 addToJSMap(ctx, map) {
6400 const key = (0, _toJSON.default)(this.key, '', ctx);
6402 if (map instanceof Map) {
6403 const value = (0, _toJSON.default)(this.value, key, ctx);
6404 map.set(key, value);
6405 } else if (map instanceof Set) {
6408 const stringKey = stringifyKey(this.key, key, ctx);
6409 map[stringKey] = (0, _toJSON.default)(this.value, stringKey, ctx);
6416 const pair = ctx && ctx.mapAsMap ? new Map() : {};
6417 return this.addToJSMap(ctx, pair);
6420 toString(ctx, onComment, onChompKeep) {
6421 if (!ctx || !ctx.doc) return JSON.stringify(this);
6424 } = ctx.doc.options;
6429 let keyComment = key instanceof _Node.default && key.comment;
6433 throw new Error('With simple keys, key nodes cannot have comments');
6436 if (key instanceof _Collection.default) {
6437 const msg = 'With simple keys, collection cannot be used as a key value';
6438 throw new Error(msg);
6442 const explicitKey = !simpleKeys && (!key || keyComment || key instanceof _Collection.default || key.type === constants.Type.BLOCK_FOLDED || key.type === constants.Type.BLOCK_LITERAL);
6447 ctx = Object.assign({}, ctx, {
6448 implicitKey: !explicitKey,
6449 indent: indent + ' '
6451 let chompKeep = false;
6452 let str = doc.schema.stringify(key, ctx, () => keyComment = null, () => chompKeep = true);
6453 str = (0, _addComment.default)(str, ctx.indent, keyComment);
6455 if (ctx.allNullValues && !simpleKeys) {
6457 str = (0, _addComment.default)(str, ctx.indent, this.comment);
6458 if (onComment) onComment();
6459 } else if (chompKeep && !keyComment && onChompKeep) onChompKeep();
6461 return ctx.inFlow ? str : `? ${str}`;
6464 str = explicitKey ? `? ${str}\n${indent}:` : `${str}:`;
6467 // expected (but not strictly required) to be a single-line comment
6468 str = (0, _addComment.default)(str, ctx.indent, this.comment);
6469 if (onComment) onComment();
6473 let valueComment = null;
6475 if (value instanceof _Node.default) {
6476 if (value.spaceBefore) vcb = '\n';
6478 if (value.commentBefore) {
6479 const cs = value.commentBefore.replace(/^/gm, `${ctx.indent}#`);
6483 valueComment = value.comment;
6484 } else if (value && typeof value === 'object') {
6485 value = doc.schema.createNode(value, true);
6488 ctx.implicitKey = false;
6489 if (!explicitKey && !this.comment && value instanceof _Scalar.default) ctx.indentAtStart = str.length + 1;
6491 const valueStr = doc.schema.stringify(value, ctx, () => valueComment = null, () => chompKeep = true);
6494 if (vcb || this.comment) {
6495 ws = `${vcb}\n${ctx.indent}`;
6496 } else if (!explicitKey && value instanceof _Collection.default) {
6497 const flow = valueStr[0] === '[' || valueStr[0] === '{';
6498 if (!flow || valueStr.includes('\n')) ws = `\n${ctx.indent}`;
6501 if (chompKeep && !valueComment && onChompKeep) onChompKeep();
6502 return (0, _addComment.default)(str + ws + valueStr, ctx.indent, valueComment);
6507 exports.default = Pair;
6509 unwrapExports(Pair_1);
6511 var Collection_1$1 = createCommonjsModule(function (module, exports) {
6513 Object.defineProperty(exports, "__esModule", {
6516 exports.default = exports.isEmptyPath = void 0;
6518 var _addComment = _interopRequireDefault(addComment_1);
6520 var _Node = _interopRequireDefault(Node_1$1);
6522 var _Pair = _interopRequireDefault(Pair_1);
6524 var _Scalar = _interopRequireDefault(Scalar_1);
6526 function _interopRequireDefault(obj) {
6527 return obj && obj.__esModule ? obj : {
6532 function _defineProperty(obj, key, value) {
6534 Object.defineProperty(obj, key, {
6547 function collectionFromPath(schema, path, value) {
6550 for (let i = path.length - 1; i >= 0; --i) {
6552 const o = Number.isInteger(k) && k >= 0 ? [] : {};
6557 return schema.createNode(v, false);
6558 } // null, undefined, or an empty non-string iterable (e.g. [])
6561 const isEmptyPath = path => path == null || typeof path === 'object' && path[Symbol.iterator]().next().done;
6563 exports.isEmptyPath = isEmptyPath;
6565 class Collection extends _Node.default {
6566 constructor(schema) {
6569 _defineProperty(this, "items", []);
6571 this.schema = schema;
6574 addIn(path, value) {
6575 if (isEmptyPath(path)) this.add(value);else {
6576 const [key, ...rest] = path;
6577 const node = this.get(key, true);
6578 if (node instanceof Collection) node.addIn(rest, value);else if (node === undefined && this.schema) this.set(key, collectionFromPath(this.schema, rest, value));else throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`);
6582 deleteIn([key, ...rest]) {
6583 if (rest.length === 0) return this.delete(key);
6584 const node = this.get(key, true);
6585 if (node instanceof Collection) return node.deleteIn(rest);else throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`);
6588 getIn([key, ...rest], keepScalar) {
6589 const node = this.get(key, true);
6590 if (rest.length === 0) return !keepScalar && node instanceof _Scalar.default ? node.value : node;else return node instanceof Collection ? node.getIn(rest, keepScalar) : undefined;
6593 hasAllNullValues() {
6594 return this.items.every(node => {
6595 if (!(node instanceof _Pair.default)) return false;
6596 const n = node.value;
6597 return n == null || n instanceof _Scalar.default && n.value == null && !n.commentBefore && !n.comment && !n.tag;
6601 hasIn([key, ...rest]) {
6602 if (rest.length === 0) return this.has(key);
6603 const node = this.get(key, true);
6604 return node instanceof Collection ? node.hasIn(rest) : false;
6607 setIn([key, ...rest], value) {
6608 if (rest.length === 0) {
6609 this.set(key, value);
6611 const node = this.get(key, true);
6612 if (node instanceof Collection) node.setIn(rest, value);else if (node === undefined && this.schema) this.set(key, collectionFromPath(this.schema, rest, value));else throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`);
6614 } // overridden in implementations
6616 /* istanbul ignore next */
6628 }, onComment, onChompKeep) {
6633 const inFlow = this.type && this.type.substr(0, 4) === 'FLOW' || ctx.inFlow;
6634 if (inFlow) itemIndent += ' ';
6635 const allNullValues = isMap && this.hasAllNullValues();
6636 ctx = Object.assign({}, ctx, {
6642 let chompKeep = false;
6643 let hasItemWithNewLine = false;
6644 const nodes = this.items.reduce((nodes, item, i) => {
6648 if (!chompKeep && item.spaceBefore) nodes.push({
6652 if (item.commentBefore) item.commentBefore.match(/^.*$/gm).forEach(line => {
6658 if (item.comment) comment = item.comment;
6659 if (inFlow && (!chompKeep && item.spaceBefore || item.commentBefore || item.comment || item.key && (item.key.commentBefore || item.key.comment) || item.value && (item.value.commentBefore || item.value.comment))) hasItemWithNewLine = true;
6663 let str = doc.schema.stringify(item, ctx, () => comment = null, () => chompKeep = true);
6664 if (inFlow && !hasItemWithNewLine && str.includes('\n')) hasItemWithNewLine = true;
6665 if (inFlow && i < this.items.length - 1) str += ',';
6666 str = (0, _addComment.default)(str, itemIndent, comment);
6667 if (chompKeep && (comment || inFlow)) chompKeep = false;
6676 if (nodes.length === 0) {
6677 str = flowChars.start + flowChars.end;
6678 } else if (inFlow) {
6683 const strings = nodes.map(n => n.str);
6685 if (hasItemWithNewLine || strings.reduce((sum, str) => sum + str.length + 2, 2) > Collection.maxFlowStringSingleLineLength) {
6688 for (const s of strings) {
6689 str += s ? `\n ${indent}${s}` : '\n';
6692 str += `\n${indent}${end}`;
6694 str = `${start} ${strings.join(' ')} ${end}`;
6697 const strings = nodes.map(blockItem);
6698 str = strings.shift();
6700 for (const s of strings) str += s ? `\n${indent}${s}` : '\n';
6704 str += '\n' + this.comment.replace(/^/gm, `${indent}#`);
6705 if (onComment) onComment();
6706 } else if (chompKeep && onChompKeep) onChompKeep();
6713 exports.default = Collection;
6715 _defineProperty(Collection, "maxFlowStringSingleLineLength", 60);
6717 unwrapExports(Collection_1$1);
6718 var Collection_2$1 = Collection_1$1.isEmptyPath;
6720 var Alias_1$1 = createCommonjsModule(function (module, exports) {
6722 Object.defineProperty(exports, "__esModule", {
6725 exports.default = void 0;
6727 var _toJSON = _interopRequireDefault(toJSON_1);
6729 var _Collection = _interopRequireDefault(Collection_1$1);
6731 var _Node = _interopRequireDefault(Node_1$1);
6733 var _Pair = _interopRequireDefault(Pair_1);
6735 function _interopRequireDefault(obj) {
6736 return obj && obj.__esModule ? obj : {
6741 function _defineProperty(obj, key, value) {
6743 Object.defineProperty(obj, key, {
6756 const getAliasCount = (node, anchors) => {
6757 if (node instanceof Alias) {
6758 const anchor = anchors.find(a => a.node === node.source);
6759 return anchor.count * anchor.aliasCount;
6760 } else if (node instanceof _Collection.default) {
6763 for (const item of node.items) {
6764 const c = getAliasCount(item, anchors);
6765 if (c > count) count = c;
6769 } else if (node instanceof _Pair.default) {
6770 const kc = getAliasCount(node.key, anchors);
6771 const vc = getAliasCount(node.value, anchors);
6772 return Math.max(kc, vc);
6778 class Alias extends _Node.default {
6788 let anchor = Object.keys(anchors).find(a => anchors[a] === source);
6789 if (!anchor && inStringifyKey) anchor = doc.anchors.getName(source) || doc.anchors.newName();
6790 if (anchor) return `*${anchor}${implicitKey ? ' ' : ''}`;
6791 const msg = doc.anchors.getName(source) ? 'Alias node must be after source node' : 'Source node not found for alias node';
6792 throw new Error(`${msg} [${range}]`);
6795 constructor(source) {
6797 this.source = source;
6798 this.type = constants.Type.ALIAS;
6802 throw new Error('Alias nodes cannot have tags');
6806 if (!ctx) return (0, _toJSON.default)(this.source, arg, ctx);
6811 const anchor = anchors.find(a => a.node === this.source);
6812 /* istanbul ignore if */
6814 if (!anchor || anchor.res === undefined) {
6815 const msg = 'This should not happen: Alias anchor was not resolved?';
6816 if (this.cstNode) throw new errors.YAMLReferenceError(this.cstNode, msg);else throw new ReferenceError(msg);
6819 if (maxAliasCount >= 0) {
6821 if (anchor.aliasCount === 0) anchor.aliasCount = getAliasCount(this.source, anchors);
6823 if (anchor.count * anchor.aliasCount > maxAliasCount) {
6824 const msg = 'Excessive alias count indicates a resource exhaustion attack';
6825 if (this.cstNode) throw new errors.YAMLReferenceError(this.cstNode, msg);else throw new ReferenceError(msg);
6830 } // Only called when stringifying an alias mapping key while constructing
6835 return Alias.stringify(this, ctx);
6840 exports.default = Alias;
6842 _defineProperty(Alias, "default", true);
6844 unwrapExports(Alias_1$1);
6846 var _Map = createCommonjsModule(function (module, exports) {
6848 Object.defineProperty(exports, "__esModule", {
6851 exports.findPair = findPair;
6852 exports.default = void 0;
6854 var _Collection = _interopRequireDefault(Collection_1$1);
6856 var _Pair = _interopRequireDefault(Pair_1);
6858 var _Scalar = _interopRequireDefault(Scalar_1);
6860 function _interopRequireDefault(obj) {
6861 return obj && obj.__esModule ? obj : {
6866 function findPair(items, key) {
6867 const k = key instanceof _Scalar.default ? key.value : key;
6869 for (const it of items) {
6870 if (it instanceof _Pair.default) {
6871 if (it.key === key || it.key === k) return it;
6872 if (it.key && it.key.value === k) return it;
6879 class YAMLMap extends _Collection.default {
6880 add(pair, overwrite) {
6881 if (!pair) pair = new _Pair.default(pair);else if (!(pair instanceof _Pair.default)) pair = new _Pair.default(pair.key || pair, pair.value);
6882 const prev = findPair(this.items, pair.key);
6883 const sortEntries = this.schema && this.schema.sortMapEntries;
6886 if (overwrite) prev.value = pair.value;else throw new Error(`Key ${pair.key} already set`);
6887 } else if (sortEntries) {
6888 const i = this.items.findIndex(item => sortEntries(pair, item) < 0);
6889 if (i === -1) this.items.push(pair);else this.items.splice(i, 0, pair);
6891 this.items.push(pair);
6896 const it = findPair(this.items, key);
6897 if (!it) return false;
6898 const del = this.items.splice(this.items.indexOf(it), 1);
6899 return del.length > 0;
6902 get(key, keepScalar) {
6903 const it = findPair(this.items, key);
6904 const node = it && it.value;
6905 return !keepScalar && node instanceof _Scalar.default ? node.value : node;
6909 return !!findPair(this.items, key);
6913 this.add(new _Pair.default(key, value), true);
6916 * @param {*} arg ignored
6917 * @param {*} ctx Conversion context, originally set in Document#toJSON()
6918 * @param {Class} Type If set, forces the returned collection type
6919 * @returns {*} Instance of Type, Map, or Object
6923 toJSON(_, ctx, Type) {
6924 const map = Type ? new Type() : ctx && ctx.mapAsMap ? new Map() : {};
6925 if (ctx && ctx.onCreate) ctx.onCreate(map);
6927 for (const item of this.items) item.addToJSMap(ctx, map);
6932 toString(ctx, onComment, onChompKeep) {
6933 if (!ctx) return JSON.stringify(this);
6935 for (const item of this.items) {
6936 if (!(item instanceof _Pair.default)) throw new Error(`Map items must all be pairs; found ${JSON.stringify(item)} instead`);
6939 return super.toString(ctx, {
6940 blockItem: n => n.str,
6946 itemIndent: ctx.indent || ''
6947 }, onComment, onChompKeep);
6952 exports.default = YAMLMap;
6955 unwrapExports(_Map);
6956 var _Map_1 = _Map.findPair;
6958 var Seq = createCommonjsModule(function (module, exports) {
6960 Object.defineProperty(exports, "__esModule", {
6963 exports.default = void 0;
6965 var _toJSON = _interopRequireDefault(toJSON_1);
6967 var _Collection = _interopRequireDefault(Collection_1$1);
6969 var _Scalar = _interopRequireDefault(Scalar_1);
6971 function _interopRequireDefault(obj) {
6972 return obj && obj.__esModule ? obj : {
6975 } // Published as 'yaml/seq'
6978 function asItemIndex(key) {
6979 let idx = key instanceof _Scalar.default ? key.value : key;
6980 if (idx && typeof idx === 'string') idx = Number(idx);
6981 return Number.isInteger(idx) && idx >= 0 ? idx : null;
6984 class YAMLSeq extends _Collection.default {
6986 this.items.push(value);
6990 const idx = asItemIndex(key);
6991 if (typeof idx !== 'number') return false;
6992 const del = this.items.splice(idx, 1);
6993 return del.length > 0;
6996 get(key, keepScalar) {
6997 const idx = asItemIndex(key);
6998 if (typeof idx !== 'number') return undefined;
6999 const it = this.items[idx];
7000 return !keepScalar && it instanceof _Scalar.default ? it.value : it;
7004 const idx = asItemIndex(key);
7005 return typeof idx === 'number' && idx < this.items.length;
7009 const idx = asItemIndex(key);
7010 if (typeof idx !== 'number') throw new Error(`Expected a valid index, not ${key}.`);
7011 this.items[idx] = value;
7016 if (ctx && ctx.onCreate) ctx.onCreate(seq);
7019 for (const item of this.items) seq.push((0, _toJSON.default)(item, String(i++), ctx));
7024 toString(ctx, onComment, onChompKeep) {
7025 if (!ctx) return JSON.stringify(this);
7026 return super.toString(ctx, {
7027 blockItem: n => n.type === 'comment' ? n.str : `- ${n.str}`,
7033 itemIndent: (ctx.indent || '') + ' '
7034 }, onComment, onChompKeep);
7039 exports.default = YAMLSeq;
7043 var Merge_1 = createCommonjsModule(function (module, exports) {
7045 Object.defineProperty(exports, "__esModule", {
7048 exports.default = exports.MERGE_KEY = void 0;
7050 var _Map$1 = _interopRequireDefault(_Map);
7052 var _Pair = _interopRequireDefault(Pair_1);
7054 var _Scalar = _interopRequireDefault(Scalar_1);
7056 var _Seq = _interopRequireDefault(Seq);
7058 function _interopRequireDefault(obj) {
7059 return obj && obj.__esModule ? obj : {
7064 const MERGE_KEY = '<<';
7065 exports.MERGE_KEY = MERGE_KEY;
7067 class Merge extends _Pair.default {
7069 if (pair instanceof _Pair.default) {
7070 let seq = pair.value;
7072 if (!(seq instanceof _Seq.default)) {
7073 seq = new _Seq.default();
7074 seq.items.push(pair.value);
7075 seq.range = pair.value.range;
7078 super(pair.key, seq);
7079 this.range = pair.range;
7081 super(new _Scalar.default(MERGE_KEY), new _Seq.default());
7084 this.type = 'MERGE_PAIR';
7085 } // If the value associated with a merge key is a single mapping node, each of
7086 // its key/value pairs is inserted into the current mapping, unless the key
7087 // already exists in it. If the value associated with the merge key is a
7088 // sequence, then this sequence is expected to contain mapping nodes and each
7089 // of these nodes is merged in turn according to its order in the sequence.
7090 // Keys in mapping nodes earlier in the sequence override keys specified in
7091 // later mapping nodes. -- http://yaml.org/type/merge.html
7094 addToJSMap(ctx, map) {
7097 } of this.value.items) {
7098 if (!(source instanceof _Map$1.default)) throw new Error('Merge sources must be maps');
7099 const srcMap = source.toJSON(null, ctx, Map);
7101 for (const [key, value] of srcMap) {
7102 if (map instanceof Map) {
7103 if (!map.has(key)) map.set(key, value);
7104 } else if (map instanceof Set) {
7107 if (!Object.prototype.hasOwnProperty.call(map, key)) map[key] = value;
7115 toString(ctx, onComment) {
7116 const seq = this.value;
7117 if (seq.items.length > 1) return super.toString(ctx, onComment);
7118 this.value = seq.items[0];
7119 const str = super.toString(ctx, onComment);
7126 exports.default = Merge;
7128 unwrapExports(Merge_1);
7129 var Merge_2 = Merge_1.MERGE_KEY;
7131 var Anchors_1 = createCommonjsModule(function (module, exports) {
7133 Object.defineProperty(exports, "__esModule", {
7136 exports.default = void 0;
7138 var _Alias = _interopRequireDefault(Alias_1$1);
7140 var _Map$1 = _interopRequireDefault(_Map);
7142 var _Merge = _interopRequireDefault(Merge_1);
7144 var _Scalar = _interopRequireDefault(Scalar_1);
7146 var _Seq = _interopRequireDefault(Seq);
7148 function _interopRequireDefault(obj) {
7149 return obj && obj.__esModule ? obj : {
7154 function _defineProperty(obj, key, value) {
7156 Object.defineProperty(obj, key, {
7170 static validAnchorNode(node) {
7171 return node instanceof _Scalar.default || node instanceof _Seq.default || node instanceof _Map$1.default;
7174 constructor(prefix) {
7175 _defineProperty(this, "map", {});
7177 this.prefix = prefix;
7180 createAlias(node, name) {
7181 this.setAnchor(node, name);
7182 return new _Alias.default(node);
7185 createMergePair(...sources) {
7186 const merge = new _Merge.default();
7187 merge.value.items = sources.map(s => {
7188 if (s instanceof _Alias.default) {
7189 if (s.source instanceof _Map$1.default) return s;
7190 } else if (s instanceof _Map$1.default) {
7191 return this.createAlias(s);
7194 throw new Error('Merge sources must be Map nodes or their Aliases');
7203 return Object.keys(map).find(a => map[a] === node);
7207 return this.map[name];
7211 if (!prefix) prefix = this.prefix;
7212 const names = Object.keys(this.map);
7214 for (let i = 1; true; ++i) {
7215 const name = `${prefix}${i}`;
7216 if (!names.includes(name)) return name;
7218 } // During parsing, map & aliases contain CST nodes
7226 Object.keys(map).forEach(a => {
7227 map[a] = map[a].resolved;
7230 _cstAliases.forEach(a => {
7231 a.source = a.source.resolved;
7234 delete this._cstAliases;
7237 setAnchor(node, name) {
7238 if (node != null && !Anchors.validAnchorNode(node)) {
7239 throw new Error('Anchors may only be set for Scalar, Seq and Map nodes');
7242 if (name && /[\x00-\x19\s,[\]{}]/.test(name)) {
7243 throw new Error('Anchor names must not contain whitespace or control characters');
7249 const prev = node && Object.keys(map).find(a => map[a] === node);
7254 } else if (prev !== name) {
7260 if (!node) return null;
7261 name = this.newName();
7272 exports.default = Anchors;
7274 unwrapExports(Anchors_1);
7276 var listTagNames = createCommonjsModule(function (module, exports) {
7278 Object.defineProperty(exports, "__esModule", {
7281 exports.default = void 0;
7283 var _Collection = _interopRequireDefault(Collection_1$1);
7285 var _Pair = _interopRequireDefault(Pair_1);
7287 var _Scalar = _interopRequireDefault(Scalar_1);
7289 function _interopRequireDefault(obj) {
7290 return obj && obj.__esModule ? obj : {
7295 const visit = (node, tags) => {
7296 if (node && typeof node === 'object') {
7301 if (node instanceof _Collection.default) {
7302 if (tag) tags[tag] = true;
7303 node.items.forEach(n => visit(n, tags));
7304 } else if (node instanceof _Pair.default) {
7305 visit(node.key, tags);
7306 visit(node.value, tags);
7307 } else if (node instanceof _Scalar.default) {
7308 if (tag) tags[tag] = true;
7315 var _default = node => Object.keys(visit(node, {}));
7317 exports.default = _default;
7319 unwrapExports(listTagNames);
7321 var warnings = createCommonjsModule(function (module, exports) {
7323 Object.defineProperty(exports, "__esModule", {
7326 exports.warn = warn;
7327 exports.warnFileDeprecation = warnFileDeprecation;
7328 exports.warnOptionDeprecation = warnOptionDeprecation;
7329 /* global global, console */
7331 function warn(warning, type) {
7332 if (global && global._YAML_SILENCE_WARNINGS) return;
7335 } = global && global.process; // This will throw in Jest if `warning` is an Error instance due to
7336 // https://github.com/facebook/jest/issues/2549
7338 if (emitWarning) emitWarning(warning, type);else {
7339 // eslint-disable-next-line no-console
7340 console.warn(type ? `${type}: ${warning}` : warning);
7344 function warnFileDeprecation(filename) {
7345 if (global && global._YAML_SILENCE_DEPRECATION_WARNINGS) return;
7346 const path = filename.replace(/.*yaml[/\\]/i, '').replace(/\.js$/, '').replace(/\\/g, '/');
7347 warn(`The endpoint 'yaml/${path}' will be removed in a future release.`, 'DeprecationWarning');
7352 function warnOptionDeprecation(name, alternative) {
7353 if (global && global._YAML_SILENCE_DEPRECATION_WARNINGS) return;
7354 if (warned[name]) return;
7355 warned[name] = true;
7356 let msg = `The option '${name}' will be removed in a future release`;
7357 msg += alternative ? `, use '${alternative}' instead.` : '.';
7358 warn(msg, 'DeprecationWarning');
7361 unwrapExports(warnings);
7362 var warnings_1 = warnings.warn;
7363 var warnings_2 = warnings.warnFileDeprecation;
7364 var warnings_3 = warnings.warnOptionDeprecation;
7366 var foldFlowLines_1 = createCommonjsModule(function (module, exports) {
7368 Object.defineProperty(exports, "__esModule", {
7371 exports.default = foldFlowLines;
7372 exports.FOLD_QUOTED = exports.FOLD_BLOCK = exports.FOLD_FLOW = void 0;
7373 const FOLD_FLOW = 'flow';
7374 exports.FOLD_FLOW = FOLD_FLOW;
7375 const FOLD_BLOCK = 'block';
7376 exports.FOLD_BLOCK = FOLD_BLOCK;
7377 const FOLD_QUOTED = 'quoted'; // presumes i+1 is at the start of a line
7378 // returns index of last newline in more-indented block
7380 exports.FOLD_QUOTED = FOLD_QUOTED;
7382 const consumeMoreIndentedLines = (text, i) => {
7383 let ch = text[i + 1];
7385 while (ch === ' ' || ch === '\t') {
7388 } while (ch && ch !== '\n');
7396 * Tries to keep input at up to `lineWidth` characters, splitting only on spaces
7397 * not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are
7398 * terminated with `\n` and started with `indent`.
7400 * @param {string} text
7401 * @param {string} indent
7402 * @param {string} [mode='flow'] `'block'` prevents more-indented lines
7403 * from being folded; `'quoted'` allows for `\` escapes, including escaped
7405 * @param {Object} options
7406 * @param {number} [options.indentAtStart] Accounts for leading contents on
7407 * the first line, defaulting to `indent.length`
7408 * @param {number} [options.lineWidth=80]
7409 * @param {number} [options.minContentWidth=20] Allow highly indented lines to
7410 * stretch the line width
7411 * @param {function} options.onFold Called once if the text is folded
7412 * @param {function} options.onFold Called once if any line of text exceeds
7413 * lineWidth characters
7417 function foldFlowLines(text, indent, mode, {
7420 minContentWidth = 20,
7424 if (!lineWidth || lineWidth < 0) return text;
7425 const endStep = Math.max(1 + minContentWidth, 1 + lineWidth - indent.length);
7426 if (text.length <= endStep) return text;
7428 const escapedFolds = {};
7429 let end = lineWidth - (typeof indentAtStart === 'number' ? indentAtStart : indent.length);
7430 let split = undefined;
7431 let prev = undefined;
7432 let overflow = false;
7435 if (mode === FOLD_BLOCK) {
7436 i = consumeMoreIndentedLines(text, i);
7437 if (i !== -1) end = i + endStep;
7440 for (let ch; ch = text[i += 1];) {
7441 if (mode === FOLD_QUOTED && ch === '\\') {
7442 switch (text[i + 1]) {
7461 if (mode === FOLD_BLOCK) i = consumeMoreIndentedLines(text, i);
7465 if (ch === ' ' && prev && prev !== ' ' && prev !== '\n' && prev !== '\t') {
7466 // space surrounded by non-space can be replaced with newline + indent
7467 const next = text[i + 1];
7468 if (next && next !== ' ' && next !== '\n' && next !== '\t') split = i;
7474 end = split + endStep;
7476 } else if (mode === FOLD_QUOTED) {
7477 // white-space collected at end may stretch past lineWidth
7478 while (prev === ' ' || prev === '\t') {
7482 } // i - 2 accounts for not-dropped last char + newline-escaping \
7486 escapedFolds[i - 2] = true;
7487 end = i - 2 + endStep;
7498 if (overflow && onOverflow) onOverflow();
7499 if (folds.length === 0) return text;
7500 if (onFold) onFold();
7501 let res = text.slice(0, folds[0]);
7503 for (let i = 0; i < folds.length; ++i) {
7504 const fold = folds[i];
7505 const end = folds[i + 1] || text.length;
7506 if (mode === FOLD_QUOTED && escapedFolds[fold]) res += `${text[fold]}\\`;
7507 res += `\n${indent}${text.slice(fold + 1, end)}`;
7513 unwrapExports(foldFlowLines_1);
7514 var foldFlowLines_2 = foldFlowLines_1.FOLD_QUOTED;
7515 var foldFlowLines_3 = foldFlowLines_1.FOLD_BLOCK;
7516 var foldFlowLines_4 = foldFlowLines_1.FOLD_FLOW;
7518 var options = createCommonjsModule(function (module, exports) {
7520 Object.defineProperty(exports, "__esModule", {
7523 exports.strOptions = exports.nullOptions = exports.boolOptions = exports.binaryOptions = void 0;
7524 const binaryOptions = {
7525 defaultType: constants.Type.BLOCK_LITERAL,
7528 exports.binaryOptions = binaryOptions;
7529 const boolOptions = {
7533 exports.boolOptions = boolOptions;
7534 const nullOptions = {
7537 exports.nullOptions = nullOptions;
7538 const strOptions = {
7539 defaultType: constants.Type.PLAIN,
7541 jsonEncoding: false,
7542 minMultiLineLength: 40
7549 exports.strOptions = strOptions;
7551 unwrapExports(options);
7552 var options_1 = options.strOptions;
7553 var options_2 = options.nullOptions;
7554 var options_3 = options.boolOptions;
7555 var options_4 = options.binaryOptions;
7557 var stringify = createCommonjsModule(function (module, exports) {
7559 Object.defineProperty(exports, "__esModule", {
7562 exports.stringifyNumber = stringifyNumber;
7563 exports.stringifyString = stringifyString;
7565 var _foldFlowLines = _interopRequireWildcard(foldFlowLines_1);
7567 function _getRequireWildcardCache() {
7568 if (typeof WeakMap !== "function") return null;
7569 var cache = new WeakMap();
7571 _getRequireWildcardCache = function () {
7578 function _interopRequireWildcard(obj) {
7579 if (obj && obj.__esModule) {
7583 if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
7589 var cache = _getRequireWildcardCache();
7591 if (cache && cache.has(obj)) {
7592 return cache.get(obj);
7596 var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
7598 for (var key in obj) {
7599 if (Object.prototype.hasOwnProperty.call(obj, key)) {
7600 var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
7602 if (desc && (desc.get || desc.set)) {
7603 Object.defineProperty(newObj, key, desc);
7605 newObj[key] = obj[key];
7610 newObj.default = obj;
7613 cache.set(obj, newObj);
7619 const getFoldOptions = ({
7621 }) => indentAtStart ? Object.assign({
7623 }, options.strOptions.fold) : options.strOptions.fold;
7625 function stringifyNumber({
7631 if (!isFinite(value)) return isNaN(value) ? '.nan' : value < 0 ? '-.inf' : '.inf';
7632 let n = JSON.stringify(value);
7634 if (!format && minFractionDigits && (!tag || tag === 'tag:yaml.org,2002:float') && /^\d/.test(n)) {
7635 let i = n.indexOf('.');
7642 let d = minFractionDigits - (n.length - i - 1);
7644 while (d-- > 0) n += '0';
7650 function lineLengthOverLimit(str, limit) {
7651 const strLen = str.length;
7652 if (strLen <= limit) return false;
7654 for (let i = 0, start = 0; i < strLen; ++i) {
7655 if (str[i] === '\n') {
7656 if (i - start > limit) return true;
7658 if (strLen - start <= limit) return false;
7665 function doubleQuotedString(value, ctx) {
7673 } = options.strOptions.doubleQuoted;
7674 const json = JSON.stringify(value);
7675 if (jsonEncoding) return json;
7679 for (let i = 0, ch = json[i]; ch; ch = json[++i]) {
7680 if (ch === ' ' && json[i + 1] === '\\' && json[i + 2] === 'n') {
7681 // space before newline needs to be escaped to not be folded
7682 str += json.slice(start, i) + '\\ ';
7688 if (ch === '\\') switch (json[i + 1]) {
7691 str += json.slice(start, i);
7692 const code = json.substr(i + 2, 4);
7728 if (code.substr(0, 2) === '00') str += '\\x' + code.substr(2);else str += json.substr(i, 6);
7737 if (implicitKey || json[i + 2] === '"' || json.length < minMultiLineLength) {
7740 // folding will eat first newline
7741 str += json.slice(start, i) + '\n\n';
7743 while (json[i + 2] === '\\' && json[i + 3] === 'n' && json[i + 4] !== '"') {
7748 str += indent; // space after newline needs to be escaped to not be folded
7750 if (json[i + 2] === ' ') str += '\\';
7762 str = start ? str + json.slice(start) : json;
7763 return implicitKey ? str : (0, _foldFlowLines.default)(str, indent, _foldFlowLines.FOLD_QUOTED, getFoldOptions(ctx));
7766 function singleQuotedString(value, ctx) {
7773 if (/\n/.test(value)) return doubleQuotedString(value, ctx);
7775 // single quoted string can't have leading or trailing whitespace around newline
7776 if (/[ \t]\n|\n[ \t]/.test(value)) return doubleQuotedString(value, ctx);
7779 const res = "'" + value.replace(/'/g, "''").replace(/\n+/g, `$&\n${indent}`) + "'";
7780 return implicitKey ? res : (0, _foldFlowLines.default)(res, indent, _foldFlowLines.FOLD_FLOW, getFoldOptions(ctx));
7783 function blockString({
7787 }, ctx, onComment, onChompKeep) {
7788 // 1. Block can't end in whitespace unless the last line is non-empty.
7789 // 2. Strings consisting of only whitespace are best rendered explicitly.
7790 if (/\n[\t ]+$/.test(value) || /^\s*$/.test(value)) {
7791 return doubleQuotedString(value, ctx);
7794 const indent = ctx.indent || (ctx.forceBlockIndent ? ' ' : '');
7795 const indentSize = indent ? '2' : '1'; // root is at -1
7797 const literal = type === constants.Type.BLOCK_FOLDED ? false : type === constants.Type.BLOCK_LITERAL ? true : !lineLengthOverLimit(value, options.strOptions.fold.lineWidth - indent.length);
7798 let header = literal ? '|' : '>';
7799 if (!value) return header + '\n';
7802 value = value.replace(/[\n\t ]*$/, ws => {
7803 const n = ws.indexOf('\n');
7806 header += '-'; // strip
7807 } else if (value === ws || n !== ws.length - 1) {
7808 header += '+'; // keep
7810 if (onChompKeep) onChompKeep();
7813 wsEnd = ws.replace(/\n$/, '');
7815 }).replace(/^[\n ]*/, ws => {
7816 if (ws.indexOf(' ') !== -1) header += indentSize;
7817 const m = ws.match(/ +$/);
7820 wsStart = ws.slice(0, -m[0].length);
7827 if (wsEnd) wsEnd = wsEnd.replace(/\n+(?!\n|$)/g, `$&${indent}`);
7828 if (wsStart) wsStart = wsStart.replace(/\n+/g, `$&${indent}`);
7831 header += ' #' + comment.replace(/ ?[\r\n]+/g, ' ');
7832 if (onComment) onComment();
7835 if (!value) return `${header}${indentSize}\n${indent}${wsEnd}`;
7838 value = value.replace(/\n+/g, `$&${indent}`);
7839 return `${header}\n${indent}${wsStart}${value}${wsEnd}`;
7842 value = value.replace(/\n+/g, '\n$&').replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, '$1$2') // more-indented lines aren't folded
7843 // ^ ind.line ^ empty ^ capture next empty lines only at end of indent
7844 .replace(/\n+/g, `$&${indent}`);
7845 const body = (0, _foldFlowLines.default)(`${wsStart}${value}${wsEnd}`, indent, _foldFlowLines.FOLD_BLOCK, options.strOptions.fold);
7846 return `${header}\n${indent}${body}`;
7849 function plainString(item, ctx, onComment, onChompKeep) {
7863 if (implicitKey && /[\n[\]{},]/.test(value) || inFlow && /[[\]{},]/.test(value)) {
7864 return doubleQuotedString(value, ctx);
7867 if (!value || /^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(value)) {
7869 // - empty string, '-' or '?'
7870 // - start with an indicator character (except [?:-]) or /[?-] /
7871 // - '\n ', ': ' or ' \n' anywhere
7872 // - '#' not preceded by a non-space char
7873 // - end with ' ' or ':'
7874 return implicitKey || inFlow || value.indexOf('\n') === -1 ? value.indexOf('"') !== -1 && value.indexOf("'") === -1 ? singleQuotedString(value, ctx) : doubleQuotedString(value, ctx) : blockString(item, ctx, onComment, onChompKeep);
7877 if (!implicitKey && !inFlow && type !== constants.Type.PLAIN && value.indexOf('\n') !== -1) {
7878 // Where allowed & type not set explicitly, prefer block style for multiline strings
7879 return blockString(item, ctx, onComment, onChompKeep);
7882 const str = value.replace(/\n+/g, `$&\n${indent}`); // Verify that output will be parsed as a string, as e.g. plain numbers and
7883 // booleans get parsed with those types in v1.2 (e.g. '42', 'true' & '0.9e-3'),
7884 // and others in v1.1.
7886 if (actualString && typeof tags.resolveScalar(str).value !== 'string') {
7887 return doubleQuotedString(value, ctx);
7890 const body = implicitKey ? str : (0, _foldFlowLines.default)(str, indent, _foldFlowLines.FOLD_FLOW, getFoldOptions(ctx));
7892 if (comment && !inFlow && (body.indexOf('\n') !== -1 || comment.indexOf('\n') !== -1)) {
7893 if (onComment) onComment();
7894 return (0, addComment_1.addCommentBefore)(body, indent, comment);
7900 function stringifyString(item, ctx, onComment, onChompKeep) {
7903 } = options.strOptions;
7913 if (typeof value !== 'string') {
7914 value = String(value);
7915 item = Object.assign({}, item, {
7920 const _stringify = _type => {
7922 case constants.Type.BLOCK_FOLDED:
7923 case constants.Type.BLOCK_LITERAL:
7924 return blockString(item, ctx, onComment, onChompKeep);
7926 case constants.Type.QUOTE_DOUBLE:
7927 return doubleQuotedString(value, ctx);
7929 case constants.Type.QUOTE_SINGLE:
7930 return singleQuotedString(value, ctx);
7932 case constants.Type.PLAIN:
7933 return plainString(item, ctx, onComment, onChompKeep);
7940 if (type !== constants.Type.QUOTE_DOUBLE && /[\x00-\x08\x0b-\x1f\x7f-\x9f]/.test(value)) {
7941 // force double quotes on control characters
7942 type = constants.Type.QUOTE_DOUBLE;
7943 } else if ((implicitKey || inFlow) && (type === constants.Type.BLOCK_FOLDED || type === constants.Type.BLOCK_LITERAL)) {
7944 // should not happen; blocks are not valid inside flow containers
7945 type = constants.Type.QUOTE_DOUBLE;
7948 let res = _stringify(type);
7951 res = _stringify(defaultType);
7952 if (res === null) throw new Error(`Unsupported default string type ${defaultType}`);
7958 unwrapExports(stringify);
7959 var stringify_1 = stringify.stringifyNumber;
7960 var stringify_2 = stringify.stringifyString;
7962 var parseUtils = createCommonjsModule(function (module, exports) {
7964 Object.defineProperty(exports, "__esModule", {
7967 exports.checkFlowCollectionEnd = checkFlowCollectionEnd;
7968 exports.checkKeyLength = checkKeyLength;
7969 exports.resolveComments = resolveComments;
7971 function checkFlowCollectionEnd(errors$1, cst) {
7975 case constants.Type.FLOW_MAP:
7980 case constants.Type.FLOW_SEQ:
7982 name = 'flow sequence';
7986 errors$1.push(new errors.YAMLSemanticError(cst, 'Not a flow collection!?'));
7992 for (let i = cst.items.length - 1; i >= 0; --i) {
7993 const item = cst.items[i];
7995 if (!item || item.type !== constants.Type.COMMENT) {
8001 if (lastItem && lastItem.char !== char) {
8002 const msg = `Expected ${name} to end with ${char}`;
8005 if (typeof lastItem.offset === 'number') {
8006 err = new errors.YAMLSemanticError(cst, msg);
8007 err.offset = lastItem.offset + 1;
8009 err = new errors.YAMLSemanticError(lastItem, msg);
8010 if (lastItem.range && lastItem.range.end) err.offset = lastItem.range.end - lastItem.range.start;
8017 function checkKeyLength(errors$1, node, itemIdx, key, keyStart) {
8018 if (!key || typeof keyStart !== 'number') return;
8019 const item = node.items[itemIdx];
8020 let keyEnd = item && item.range && item.range.start;
8023 for (let i = itemIdx - 1; i >= 0; --i) {
8024 const it = node.items[i];
8026 if (it && it.range) {
8027 keyEnd = it.range.end + 2 * (itemIdx - i);
8033 if (keyEnd > keyStart + 1024) {
8034 const k = String(key).substr(0, 8) + '...' + String(key).substr(-8);
8035 errors$1.push(new errors.YAMLSemanticError(node, `The "${k}" key is too long`));
8039 function resolveComments(collection, comments) {
8045 let item = collection.items[before];
8048 if (comment !== undefined) {
8049 if (collection.comment) collection.comment += '\n' + comment;else collection.comment = comment;
8052 if (afterKey && item.value) item = item.value;
8054 if (comment === undefined) {
8055 if (afterKey || !item.commentBefore) item.spaceBefore = true;
8057 if (item.commentBefore) item.commentBefore += '\n' + comment;else item.commentBefore = comment;
8063 unwrapExports(parseUtils);
8064 var parseUtils_1 = parseUtils.checkFlowCollectionEnd;
8065 var parseUtils_2 = parseUtils.checkKeyLength;
8066 var parseUtils_3 = parseUtils.resolveComments;
8068 var parseMap_1 = createCommonjsModule(function (module, exports) {
8070 Object.defineProperty(exports, "__esModule", {
8073 exports.default = parseMap;
8075 var _PlainValue = _interopRequireDefault(PlainValue_1);
8077 var _Map$1 = _interopRequireDefault(_Map);
8079 var _Merge = _interopRequireWildcard(Merge_1);
8081 var _Pair = _interopRequireDefault(Pair_1);
8083 var _Alias = _interopRequireDefault(Alias_1$1);
8085 var _Collection = _interopRequireDefault(Collection_1$1);
8087 function _getRequireWildcardCache() {
8088 if (typeof WeakMap !== "function") return null;
8089 var cache = new WeakMap();
8091 _getRequireWildcardCache = function () {
8098 function _interopRequireWildcard(obj) {
8099 if (obj && obj.__esModule) {
8103 if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
8109 var cache = _getRequireWildcardCache();
8111 if (cache && cache.has(obj)) {
8112 return cache.get(obj);
8116 var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
8118 for (var key in obj) {
8119 if (Object.prototype.hasOwnProperty.call(obj, key)) {
8120 var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
8122 if (desc && (desc.get || desc.set)) {
8123 Object.defineProperty(newObj, key, desc);
8125 newObj[key] = obj[key];
8130 newObj.default = obj;
8133 cache.set(obj, newObj);
8139 function _interopRequireDefault(obj) {
8140 return obj && obj.__esModule ? obj : {
8145 function parseMap(doc, cst) {
8146 if (cst.type !== constants.Type.MAP && cst.type !== constants.Type.FLOW_MAP) {
8147 const msg = `A ${cst.type} node cannot be resolved as a mapping`;
8148 doc.errors.push(new errors.YAMLSyntaxError(cst, msg));
8155 } = cst.type === constants.Type.FLOW_MAP ? resolveFlowMapItems(doc, cst) : resolveBlockMapItems(doc, cst);
8156 const map = new _Map$1.default();
8158 (0, parseUtils.resolveComments)(map, comments);
8159 let hasCollectionKey = false;
8161 for (let i = 0; i < items.length; ++i) {
8165 if (iKey instanceof _Collection.default) hasCollectionKey = true;
8167 if (doc.schema.merge && iKey && iKey.value === _Merge.MERGE_KEY) {
8168 items[i] = new _Merge.default(items[i]);
8169 const sources = items[i].value.items;
8171 sources.some(node => {
8172 if (node instanceof _Alias.default) {
8173 // During parsing, alias sources are CST nodes; to account for
8174 // circular references their resolved values can't be used here.
8178 if (type === constants.Type.MAP || type === constants.Type.FLOW_MAP) return false;
8179 return error = 'Merge nodes aliases can only point to maps';
8182 return error = 'Merge nodes can only have Alias nodes as values';
8184 if (error) doc.errors.push(new errors.YAMLSemanticError(cst, error));
8186 for (let j = i + 1; j < items.length; ++j) {
8191 if (iKey === jKey || iKey && jKey && Object.prototype.hasOwnProperty.call(iKey, 'value') && iKey.value === jKey.value) {
8192 const msg = `Map keys must be unique; "${iKey}" is repeated`;
8193 doc.errors.push(new errors.YAMLSemanticError(cst, msg));
8200 if (hasCollectionKey && !doc.options.mapAsMap) {
8201 const warn = 'Keys with collection values will be stringified as YAML due to JS Object restrictions. Use mapAsMap: true to avoid this.';
8202 doc.warnings.push(new errors.YAMLWarning(cst, warn));
8209 const valueHasPairComment = ({
8217 if (props.length === 0) return false;
8221 if (node && start > node.valueRange.start) return false;
8222 if (src[start] !== constants.Char.COMMENT) return false;
8224 for (let i = lineStart; i < start; ++i) if (src[i] === '\n') return false;
8229 function resolvePairComment(item, pair) {
8230 if (!valueHasPairComment(item)) return;
8231 const comment = item.getPropValue(0, constants.Char.COMMENT, true);
8233 const cb = pair.value.commentBefore;
8235 if (cb && cb.startsWith(comment)) {
8236 pair.value.commentBefore = cb.substr(comment.length + 1);
8239 const cc = pair.value.comment;
8241 if (!item.node && cc && cc.startsWith(comment)) {
8242 pair.value.comment = cc.substr(comment.length + 1);
8247 if (found) pair.comment = comment;
8250 function resolveBlockMapItems(doc, cst) {
8251 const comments = [];
8253 let key = undefined;
8254 let keyStart = null;
8256 for (let i = 0; i < cst.items.length; ++i) {
8257 const item = cst.items[i];
8259 switch (item.type) {
8260 case constants.Type.BLANK_LINE:
8263 before: items.length
8267 case constants.Type.COMMENT:
8270 before: items.length,
8271 comment: item.comment
8275 case constants.Type.MAP_KEY:
8276 if (key !== undefined) items.push(new _Pair.default(key));
8277 if (item.error) doc.errors.push(item.error);
8278 key = doc.resolveNode(item.node);
8282 case constants.Type.MAP_VALUE:
8284 if (key === undefined) key = null;
8285 if (item.error) doc.errors.push(item.error);
8287 if (!item.context.atLineStart && item.node && item.node.type === constants.Type.MAP && !item.node.context.atLineStart) {
8288 const msg = 'Nested mappings are not allowed in compact mappings';
8289 doc.errors.push(new errors.YAMLSemanticError(item.node, msg));
8292 let valueNode = item.node;
8294 if (!valueNode && item.props.length > 0) {
8295 // Comments on an empty mapping value need to be preserved, so we
8296 // need to construct a minimal empty node here to use instead of the
8297 // missing `item.node`. -- eemeli/yaml#19
8298 valueNode = new _PlainValue.default(constants.Type.PLAIN, []);
8299 valueNode.context = {
8301 src: item.context.src
8303 const pos = item.range.start + 1;
8308 valueNode.valueRange = {
8313 if (typeof item.range.origStart === 'number') {
8314 const origPos = item.range.origStart + 1;
8315 valueNode.range.origStart = valueNode.range.origEnd = origPos;
8316 valueNode.valueRange.origStart = valueNode.valueRange.origEnd = origPos;
8320 const pair = new _Pair.default(key, doc.resolveNode(valueNode));
8321 resolvePairComment(item, pair);
8323 (0, parseUtils.checkKeyLength)(doc.errors, cst, i, key, keyStart);
8330 if (key !== undefined) items.push(new _Pair.default(key));
8331 key = doc.resolveNode(item);
8332 keyStart = item.range.start;
8333 if (item.error) doc.errors.push(item.error);
8335 next: for (let j = i + 1;; ++j) {
8336 const nextItem = cst.items[j];
8338 switch (nextItem && nextItem.type) {
8339 case constants.Type.BLANK_LINE:
8340 case constants.Type.COMMENT:
8343 case constants.Type.MAP_VALUE:
8347 doc.errors.push(new errors.YAMLSemanticError(item, 'Implicit map keys need to be followed by map values'));
8352 if (item.valueRangeContainsNewline) {
8353 const msg = 'Implicit map keys need to be on a single line';
8354 doc.errors.push(new errors.YAMLSemanticError(item, msg));
8360 if (key !== undefined) items.push(new _Pair.default(key));
8367 function resolveFlowMapItems(doc, cst) {
8368 const comments = [];
8370 let key = undefined;
8371 let keyStart = null;
8372 let explicitKey = false;
8375 for (let i = 0; i < cst.items.length; ++i) {
8376 (0, parseUtils.checkKeyLength)(doc.errors, cst, i, key, keyStart);
8377 const item = cst.items[i];
8379 if (typeof item.char === 'string') {
8385 if (char === '?' && key === undefined && !explicitKey) {
8392 if (key === undefined) key = null;
8400 if (key === undefined && char !== ',') key = null;
8401 explicitKey = false;
8404 if (key !== undefined) {
8405 items.push(new _Pair.default(key));
8417 if (i === cst.items.length - 1) continue;
8418 } else if (char === next) {
8423 const msg = `Flow map contains an unexpected ${char}`;
8424 const err = new errors.YAMLSyntaxError(cst, msg);
8425 err.offset = offset;
8426 doc.errors.push(err);
8427 } else if (item.type === constants.Type.BLANK_LINE) {
8430 before: items.length
8432 } else if (item.type === constants.Type.COMMENT) {
8435 before: items.length,
8436 comment: item.comment
8438 } else if (key === undefined) {
8439 if (next === ',') doc.errors.push(new errors.YAMLSemanticError(item, 'Separator , missing in flow map'));
8440 key = doc.resolveNode(item);
8441 keyStart = explicitKey ? null : item.range.start; // TODO: add error for non-explicit multiline plain key
8443 if (next !== ',') doc.errors.push(new errors.YAMLSemanticError(item, 'Indicator : missing in flow map entry'));
8444 items.push(new _Pair.default(key, doc.resolveNode(item)));
8446 explicitKey = false;
8450 (0, parseUtils.checkFlowCollectionEnd)(doc.errors, cst);
8451 if (key !== undefined) items.push(new _Pair.default(key));
8458 unwrapExports(parseMap_1);
8460 var map = createCommonjsModule(function (module, exports) {
8462 Object.defineProperty(exports, "__esModule", {
8465 exports.default = void 0;
8467 var _Map$1 = _interopRequireDefault(_Map);
8469 var _parseMap = _interopRequireDefault(parseMap_1);
8471 function _interopRequireDefault(obj) {
8472 return obj && obj.__esModule ? obj : {
8477 function createMap(schema, obj, ctx) {
8478 const map = new _Map$1.default(schema);
8480 if (obj instanceof Map) {
8481 for (const [key, value] of obj) map.items.push(schema.createPair(key, value, ctx));
8482 } else if (obj && typeof obj === 'object') {
8483 for (const key of Object.keys(obj)) map.items.push(schema.createPair(key, obj[key], ctx));
8486 if (typeof schema.sortMapEntries === 'function') {
8487 map.items.sort(schema.sortMapEntries);
8494 createNode: createMap,
8496 nodeClass: _Map$1.default,
8497 tag: 'tag:yaml.org,2002:map',
8498 resolve: _parseMap.default
8500 exports.default = _default;
8504 var parseSeq_1 = createCommonjsModule(function (module, exports) {
8506 Object.defineProperty(exports, "__esModule", {
8509 exports.default = parseSeq;
8511 var _Pair = _interopRequireDefault(Pair_1);
8513 var _Seq = _interopRequireDefault(Seq);
8515 var _Collection = _interopRequireDefault(Collection_1$1);
8517 function _interopRequireDefault(obj) {
8518 return obj && obj.__esModule ? obj : {
8523 function parseSeq(doc, cst) {
8524 if (cst.type !== constants.Type.SEQ && cst.type !== constants.Type.FLOW_SEQ) {
8525 const msg = `A ${cst.type} node cannot be resolved as a sequence`;
8526 doc.errors.push(new errors.YAMLSyntaxError(cst, msg));
8533 } = cst.type === constants.Type.FLOW_SEQ ? resolveFlowSeqItems(doc, cst) : resolveBlockSeqItems(doc, cst);
8534 const seq = new _Seq.default();
8536 (0, parseUtils.resolveComments)(seq, comments);
8538 if (!doc.options.mapAsMap && items.some(it => it instanceof _Pair.default && it.key instanceof _Collection.default)) {
8539 const warn = 'Keys with collection values will be stringified as YAML due to JS Object restrictions. Use mapAsMap: true to avoid this.';
8540 doc.warnings.push(new errors.YAMLWarning(cst, warn));
8547 function resolveBlockSeqItems(doc, cst) {
8548 const comments = [];
8551 for (let i = 0; i < cst.items.length; ++i) {
8552 const item = cst.items[i];
8554 switch (item.type) {
8555 case constants.Type.BLANK_LINE:
8557 before: items.length
8561 case constants.Type.COMMENT:
8563 comment: item.comment,
8564 before: items.length
8568 case constants.Type.SEQ_ITEM:
8569 if (item.error) doc.errors.push(item.error);
8570 items.push(doc.resolveNode(item.node));
8572 if (item.hasProps) {
8573 const msg = 'Sequence items cannot have tags or anchors before the - indicator';
8574 doc.errors.push(new errors.YAMLSemanticError(item, msg));
8580 if (item.error) doc.errors.push(item.error);
8581 doc.errors.push(new errors.YAMLSyntaxError(item, `Unexpected ${item.type} node in sequence`));
8591 function resolveFlowSeqItems(doc, cst) {
8592 const comments = [];
8594 let explicitKey = false;
8595 let key = undefined;
8596 let keyStart = null;
8599 for (let i = 0; i < cst.items.length; ++i) {
8600 const item = cst.items[i];
8602 if (typeof item.char === 'string') {
8608 if (char !== ':' && (explicitKey || key !== undefined)) {
8609 if (explicitKey && key === undefined) key = next ? items.pop() : null;
8610 items.push(new _Pair.default(key));
8611 explicitKey = false;
8616 if (char === next) {
8618 } else if (!next && char === '?') {
8620 } else if (next !== '[' && char === ':' && key === undefined) {
8624 if (key instanceof _Pair.default) {
8625 const msg = 'Chaining flow sequence pairs is invalid';
8626 const err = new errors.YAMLSemanticError(cst, msg);
8627 err.offset = offset;
8628 doc.errors.push(err);
8631 if (!explicitKey) (0, parseUtils.checkKeyLength)(doc.errors, cst, i, key, keyStart);
8637 explicitKey = false; // TODO: add error for non-explicit multiline plain key
8640 } else if (next === '[' || char !== ']' || i < cst.items.length - 1) {
8641 const msg = `Flow sequence contains an unexpected ${char}`;
8642 const err = new errors.YAMLSyntaxError(cst, msg);
8643 err.offset = offset;
8644 doc.errors.push(err);
8646 } else if (item.type === constants.Type.BLANK_LINE) {
8648 before: items.length
8650 } else if (item.type === constants.Type.COMMENT) {
8652 comment: item.comment,
8653 before: items.length
8657 const msg = `Expected a ${next} in flow sequence`;
8658 doc.errors.push(new errors.YAMLSemanticError(item, msg));
8661 const value = doc.resolveNode(item);
8663 if (key === undefined) {
8666 items.push(new _Pair.default(key, value));
8670 keyStart = item.range.start;
8675 (0, parseUtils.checkFlowCollectionEnd)(doc.errors, cst);
8676 if (key !== undefined) items.push(new _Pair.default(key));
8683 unwrapExports(parseSeq_1);
8685 var seq = createCommonjsModule(function (module, exports) {
8687 Object.defineProperty(exports, "__esModule", {
8690 exports.default = void 0;
8692 var _parseSeq = _interopRequireDefault(parseSeq_1);
8694 var _Seq = _interopRequireDefault(Seq);
8696 function _interopRequireDefault(obj) {
8697 return obj && obj.__esModule ? obj : {
8702 function createSeq(schema, obj, ctx) {
8703 const seq = new _Seq.default(schema);
8705 if (obj && obj[Symbol.iterator]) {
8706 for (const it of obj) {
8707 const v = schema.createNode(it, ctx.wrapScalars, null, ctx);
8716 createNode: createSeq,
8718 nodeClass: _Seq.default,
8719 tag: 'tag:yaml.org,2002:seq',
8720 resolve: _parseSeq.default
8722 exports.default = _default;
8726 var string = createCommonjsModule(function (module, exports) {
8728 Object.defineProperty(exports, "__esModule", {
8731 exports.default = exports.resolveString = void 0;
8733 const resolveString = (doc, node) => {
8734 // on error, will return { str: string, errors: Error[] }
8735 const res = node.strValue;
8736 if (!res) return '';
8737 if (typeof res === 'string') return res;
8738 res.errors.forEach(error => {
8739 if (!error.source) error.source = node;
8740 doc.errors.push(error);
8745 exports.resolveString = resolveString;
8747 identify: value => typeof value === 'string',
8749 tag: 'tag:yaml.org,2002:str',
8750 resolve: resolveString,
8752 stringify(item, ctx, onComment, onChompKeep) {
8753 ctx = Object.assign({
8756 return (0, stringify.stringifyString)(item, ctx, onComment, onChompKeep);
8759 options: options.strOptions
8761 exports.default = _default;
8763 unwrapExports(string);
8764 var string_1 = string.resolveString;
8766 var failsafe = createCommonjsModule(function (module, exports) {
8768 Object.defineProperty(exports, "__esModule", {
8771 exports.default = void 0;
8773 var _map = _interopRequireDefault(map);
8775 var _seq = _interopRequireDefault(seq);
8777 var _string = _interopRequireDefault(string);
8779 function _interopRequireDefault(obj) {
8780 return obj && obj.__esModule ? obj : {
8785 var _default = [_map.default, _seq.default, _string.default];
8786 exports.default = _default;
8788 unwrapExports(failsafe);
8790 var core = createCommonjsModule(function (module, exports) {
8792 Object.defineProperty(exports, "__esModule", {
8795 exports.default = exports.floatObj = exports.expObj = exports.nanObj = exports.hexObj = exports.intObj = exports.octObj = exports.boolObj = exports.nullObj = void 0;
8797 var _Scalar = _interopRequireDefault(Scalar_1);
8799 var _failsafe = _interopRequireDefault(failsafe);
8801 function _interopRequireDefault(obj) {
8802 return obj && obj.__esModule ? obj : {
8808 identify: value => value == null,
8809 createNode: (schema, value, ctx) => ctx.wrapScalars ? new _Scalar.default(null) : null,
8811 tag: 'tag:yaml.org,2002:null',
8812 test: /^(?:~|[Nn]ull|NULL)?$/,
8813 resolve: () => null,
8814 options: options.nullOptions,
8815 stringify: () => options.nullOptions.nullStr
8817 exports.nullObj = nullObj;
8819 identify: value => typeof value === 'boolean',
8821 tag: 'tag:yaml.org,2002:bool',
8822 test: /^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,
8823 resolve: str => str[0] === 't' || str[0] === 'T',
8824 options: options.boolOptions,
8827 }) => value ? options.boolOptions.trueStr : options.boolOptions.falseStr
8829 exports.boolObj = boolObj;
8831 identify: value => typeof value === 'number',
8833 tag: 'tag:yaml.org,2002:int',
8835 test: /^0o([0-7]+)$/,
8836 resolve: (str, oct) => parseInt(oct, 8),
8839 }) => '0o' + value.toString(8)
8841 exports.octObj = octObj;
8843 identify: value => typeof value === 'number',
8845 tag: 'tag:yaml.org,2002:int',
8846 test: /^[-+]?[0-9]+$/,
8847 resolve: str => parseInt(str, 10),
8848 stringify: stringify.stringifyNumber
8850 exports.intObj = intObj;
8852 identify: value => typeof value === 'number',
8854 tag: 'tag:yaml.org,2002:int',
8856 test: /^0x([0-9a-fA-F]+)$/,
8857 resolve: (str, hex) => parseInt(hex, 16),
8860 }) => '0x' + value.toString(16)
8862 exports.hexObj = hexObj;
8864 identify: value => typeof value === 'number',
8866 tag: 'tag:yaml.org,2002:float',
8867 test: /^(?:[-+]?\.inf|(\.nan))$/i,
8868 resolve: (str, nan) => nan ? NaN : str[0] === '-' ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
8869 stringify: stringify.stringifyNumber
8871 exports.nanObj = nanObj;
8873 identify: value => typeof value === 'number',
8875 tag: 'tag:yaml.org,2002:float',
8877 test: /^[-+]?(?:0|[1-9][0-9]*)(\.[0-9]*)?[eE][-+]?[0-9]+$/,
8878 resolve: str => parseFloat(str),
8881 }) => Number(value).toExponential()
8883 exports.expObj = expObj;
8885 identify: value => typeof value === 'number',
8887 tag: 'tag:yaml.org,2002:float',
8888 test: /^[-+]?(?:0|[1-9][0-9]*)\.([0-9]*)$/,
8890 resolve(str, frac) {
8891 const node = new _Scalar.default(parseFloat(str));
8892 if (frac && frac[frac.length - 1] === '0') node.minFractionDigits = frac.length;
8896 stringify: stringify.stringifyNumber
8898 exports.floatObj = floatObj;
8900 var _default = _failsafe.default.concat([nullObj, boolObj, octObj, intObj, hexObj, nanObj, expObj, floatObj]);
8902 exports.default = _default;
8904 unwrapExports(core);
8905 var core_1 = core.floatObj;
8906 var core_2 = core.expObj;
8907 var core_3 = core.nanObj;
8908 var core_4 = core.hexObj;
8909 var core_5 = core.intObj;
8910 var core_6 = core.octObj;
8911 var core_7 = core.boolObj;
8912 var core_8 = core.nullObj;
8914 var json = createCommonjsModule(function (module, exports) {
8916 Object.defineProperty(exports, "__esModule", {
8919 exports.default = void 0;
8921 var _map = _interopRequireDefault(map);
8923 var _seq = _interopRequireDefault(seq);
8925 var _Scalar = _interopRequireDefault(Scalar_1);
8927 function _interopRequireDefault(obj) {
8928 return obj && obj.__esModule ? obj : {
8933 const schema = [_map.default, _seq.default, {
8934 identify: value => typeof value === 'string',
8936 tag: 'tag:yaml.org,2002:str',
8937 resolve: string.resolveString,
8938 stringify: value => JSON.stringify(value)
8940 identify: value => value == null,
8941 createNode: (schema, value, ctx) => ctx.wrapScalars ? new _Scalar.default(null) : null,
8943 tag: 'tag:yaml.org,2002:null',
8945 resolve: () => null,
8946 stringify: value => JSON.stringify(value)
8948 identify: value => typeof value === 'boolean',
8950 tag: 'tag:yaml.org,2002:bool',
8951 test: /^true|false$/,
8952 resolve: str => str === 'true',
8953 stringify: value => JSON.stringify(value)
8955 identify: value => typeof value === 'number',
8957 tag: 'tag:yaml.org,2002:int',
8958 test: /^-?(?:0|[1-9][0-9]*)$/,
8959 resolve: str => parseInt(str, 10),
8960 stringify: value => JSON.stringify(value)
8962 identify: value => typeof value === 'number',
8964 tag: 'tag:yaml.org,2002:float',
8965 test: /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,
8966 resolve: str => parseFloat(str),
8967 stringify: value => JSON.stringify(value)
8970 schema.scalarFallback = str => {
8971 throw new SyntaxError(`Unresolved plain scalar ${JSON.stringify(str)}`);
8974 var _default = schema;
8975 exports.default = _default;
8977 unwrapExports(json);
8979 var binary = createCommonjsModule(function (module, exports) {
8981 Object.defineProperty(exports, "__esModule", {
8984 exports.default = void 0;
8985 /* global atob, btoa, Buffer */
8988 identify: value => value instanceof Uint8Array,
8989 // Buffer inherits from Uint8Array
8991 tag: 'tag:yaml.org,2002:binary',
8994 * Returns a Buffer in node and an Uint8Array in browsers
8996 * To use the resulting buffer as an image, you'll want to do something like:
8998 * const blob = new Blob([buffer], { type: 'image/jpeg' })
8999 * document.querySelector('#photo').src = URL.createObjectURL(blob)
9001 resolve: (doc, node) => {
9002 if (typeof Buffer === 'function') {
9003 const src = (0, string.resolveString)(doc, node);
9004 return Buffer.from(src, 'base64');
9005 } else if (typeof atob === 'function') {
9006 const src = atob((0, string.resolveString)(doc, node));
9007 const buffer = new Uint8Array(src.length);
9009 for (let i = 0; i < src.length; ++i) buffer[i] = src.charCodeAt(i);
9013 doc.errors.push(new errors.YAMLReferenceError(node, 'This environment does not support reading binary tags; either Buffer or atob is required'));
9017 options: options.binaryOptions,
9022 }, ctx, onComment, onChompKeep) => {
9025 if (typeof Buffer === 'function') {
9026 src = value instanceof Buffer ? value.toString('base64') : Buffer.from(value.buffer).toString('base64');
9027 } else if (typeof btoa === 'function') {
9030 for (let i = 0; i < value.length; ++i) s += String.fromCharCode(value[i]);
9034 throw new Error('This environment does not support writing binary tags; either Buffer or btoa is required');
9037 if (!type) type = options.binaryOptions.defaultType;
9039 if (type === constants.Type.QUOTE_DOUBLE) {
9044 } = options.binaryOptions;
9045 const n = Math.ceil(src.length / lineWidth);
9046 const lines = new Array(n);
9048 for (let i = 0, o = 0; i < n; ++i, o += lineWidth) {
9049 lines[i] = src.substr(o, lineWidth);
9052 value = lines.join(type === constants.Type.BLOCK_LITERAL ? '\n' : ' ');
9055 return (0, stringify.stringifyString)({
9059 }, ctx, onComment, onChompKeep);
9062 exports.default = _default;
9064 unwrapExports(binary);
9066 var pairs = createCommonjsModule(function (module, exports) {
9068 Object.defineProperty(exports, "__esModule", {
9071 exports.parsePairs = parsePairs;
9072 exports.createPairs = createPairs;
9073 exports.default = void 0;
9075 var _Map$1 = _interopRequireDefault(_Map);
9077 var _Pair = _interopRequireDefault(Pair_1);
9079 var _parseSeq = _interopRequireDefault(parseSeq_1);
9081 var _Seq = _interopRequireDefault(Seq);
9083 function _interopRequireDefault(obj) {
9084 return obj && obj.__esModule ? obj : {
9089 function parsePairs(doc, cst) {
9090 const seq = (0, _parseSeq.default)(doc, cst);
9092 for (let i = 0; i < seq.items.length; ++i) {
9093 let item = seq.items[i];
9094 if (item instanceof _Pair.default) continue;else if (item instanceof _Map$1.default) {
9095 if (item.items.length > 1) {
9096 const msg = 'Each pair must have its own sequence indicator';
9097 throw new errors.YAMLSemanticError(cst, msg);
9100 const pair = item.items[0] || new _Pair.default();
9101 if (item.commentBefore) pair.commentBefore = pair.commentBefore ? `${item.commentBefore}\n${pair.commentBefore}` : item.commentBefore;
9102 if (item.comment) pair.comment = pair.comment ? `${item.comment}\n${pair.comment}` : item.comment;
9105 seq.items[i] = item instanceof _Pair.default ? item : new _Pair.default(item);
9111 function createPairs(schema, iterable, ctx) {
9112 const pairs = new _Seq.default(schema);
9113 pairs.tag = 'tag:yaml.org,2002:pairs';
9115 for (const it of iterable) {
9118 if (Array.isArray(it)) {
9119 if (it.length === 2) {
9122 } else throw new TypeError(`Expected [key, value] tuple: ${it}`);
9123 } else if (it && it instanceof Object) {
9124 const keys = Object.keys(it);
9126 if (keys.length === 1) {
9129 } else throw new TypeError(`Expected { key: value } tuple: ${it}`);
9134 const pair = schema.createPair(key, value, ctx);
9135 pairs.items.push(pair);
9143 tag: 'tag:yaml.org,2002:pairs',
9144 resolve: parsePairs,
9145 createNode: createPairs
9147 exports.default = _default;
9149 unwrapExports(pairs);
9150 var pairs_1 = pairs.parsePairs;
9151 var pairs_2 = pairs.createPairs;
9153 var omap = createCommonjsModule(function (module, exports) {
9155 Object.defineProperty(exports, "__esModule", {
9158 exports.default = exports.YAMLOMap = void 0;
9160 var _toJSON = _interopRequireDefault(toJSON_1);
9162 var _Map$1 = _interopRequireDefault(_Map);
9164 var _Pair = _interopRequireDefault(Pair_1);
9166 var _Scalar = _interopRequireDefault(Scalar_1);
9168 var _Seq = _interopRequireDefault(Seq);
9170 function _interopRequireDefault(obj) {
9171 return obj && obj.__esModule ? obj : {
9176 function _defineProperty(obj, key, value) {
9178 Object.defineProperty(obj, key, {
9191 class YAMLOMap extends _Seq.default {
9195 _defineProperty(this, "add", _Map$1.default.prototype.add.bind(this));
9197 _defineProperty(this, "delete", _Map$1.default.prototype.delete.bind(this));
9199 _defineProperty(this, "get", _Map$1.default.prototype.get.bind(this));
9201 _defineProperty(this, "has", _Map$1.default.prototype.has.bind(this));
9203 _defineProperty(this, "set", _Map$1.default.prototype.set.bind(this));
9205 this.tag = YAMLOMap.tag;
9209 const map = new Map();
9210 if (ctx && ctx.onCreate) ctx.onCreate(map);
9212 for (const pair of this.items) {
9215 if (pair instanceof _Pair.default) {
9216 key = (0, _toJSON.default)(pair.key, '', ctx);
9217 value = (0, _toJSON.default)(pair.value, key, ctx);
9219 key = (0, _toJSON.default)(pair, '', ctx);
9222 if (map.has(key)) throw new Error('Ordered maps must not include duplicate keys');
9223 map.set(key, value);
9231 exports.YAMLOMap = YAMLOMap;
9233 _defineProperty(YAMLOMap, "tag", 'tag:yaml.org,2002:omap');
9235 function parseOMap(doc, cst) {
9236 const pairs$1 = (0, pairs.parsePairs)(doc, cst);
9237 const seenKeys = [];
9241 } of pairs$1.items) {
9242 if (key instanceof _Scalar.default) {
9243 if (seenKeys.includes(key.value)) {
9244 const msg = 'Ordered maps must not include duplicate keys';
9245 throw new errors.YAMLSemanticError(cst, msg);
9247 seenKeys.push(key.value);
9252 return Object.assign(new YAMLOMap(), pairs$1);
9255 function createOMap(schema, iterable, ctx) {
9256 const pairs$1 = (0, pairs.createPairs)(schema, iterable, ctx);
9257 const omap = new YAMLOMap();
9258 omap.items = pairs$1.items;
9263 identify: value => value instanceof Map,
9264 nodeClass: YAMLOMap,
9266 tag: 'tag:yaml.org,2002:omap',
9268 createNode: createOMap
9270 exports.default = _default;
9272 unwrapExports(omap);
9273 var omap_1 = omap.YAMLOMap;
9275 var set = createCommonjsModule(function (module, exports) {
9277 Object.defineProperty(exports, "__esModule", {
9280 exports.default = exports.YAMLSet = void 0;
9282 var _Map$1 = _interopRequireWildcard(_Map);
9284 var _Pair = _interopRequireDefault(Pair_1);
9286 var _parseMap = _interopRequireDefault(parseMap_1);
9288 var _Scalar = _interopRequireDefault(Scalar_1);
9290 function _interopRequireDefault(obj) {
9291 return obj && obj.__esModule ? obj : {
9296 function _getRequireWildcardCache() {
9297 if (typeof WeakMap !== "function") return null;
9298 var cache = new WeakMap();
9300 _getRequireWildcardCache = function () {
9307 function _interopRequireWildcard(obj) {
9308 if (obj && obj.__esModule) {
9312 if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
9318 var cache = _getRequireWildcardCache();
9320 if (cache && cache.has(obj)) {
9321 return cache.get(obj);
9325 var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
9327 for (var key in obj) {
9328 if (Object.prototype.hasOwnProperty.call(obj, key)) {
9329 var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
9331 if (desc && (desc.get || desc.set)) {
9332 Object.defineProperty(newObj, key, desc);
9334 newObj[key] = obj[key];
9339 newObj.default = obj;
9342 cache.set(obj, newObj);
9348 function _defineProperty(obj, key, value) {
9350 Object.defineProperty(obj, key, {
9363 class YAMLSet extends _Map$1.default {
9366 this.tag = YAMLSet.tag;
9370 const pair = key instanceof _Pair.default ? key : new _Pair.default(key);
9371 const prev = (0, _Map$1.findPair)(this.items, pair.key);
9372 if (!prev) this.items.push(pair);
9375 get(key, keepPair) {
9376 const pair = (0, _Map$1.findPair)(this.items, key);
9377 return !keepPair && pair instanceof _Pair.default ? pair.key instanceof _Scalar.default ? pair.key.value : pair.key : pair;
9381 if (typeof value !== 'boolean') throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof value}`);
9382 const prev = (0, _Map$1.findPair)(this.items, key);
9384 if (prev && !value) {
9385 this.items.splice(this.items.indexOf(prev), 1);
9386 } else if (!prev && value) {
9387 this.items.push(new _Pair.default(key));
9392 return super.toJSON(_, ctx, Set);
9395 toString(ctx, onComment, onChompKeep) {
9396 if (!ctx) return JSON.stringify(this);
9397 if (this.hasAllNullValues()) return super.toString(ctx, onComment, onChompKeep);else throw new Error('Set items must all have null values');
9402 exports.YAMLSet = YAMLSet;
9404 _defineProperty(YAMLSet, "tag", 'tag:yaml.org,2002:set');
9406 function parseSet(doc, cst) {
9407 const map = (0, _parseMap.default)(doc, cst);
9408 if (!map.hasAllNullValues()) throw new errors.YAMLSemanticError(cst, 'Set items must all have null values');
9409 return Object.assign(new YAMLSet(), map);
9412 function createSet(schema, iterable, ctx) {
9413 const set = new YAMLSet();
9415 for (const value of iterable) set.items.push(schema.createPair(value, null, ctx));
9421 identify: value => value instanceof Set,
9424 tag: 'tag:yaml.org,2002:set',
9426 createNode: createSet
9428 exports.default = _default;
9431 var set_1 = set.YAMLSet;
9433 var timestamp_1 = createCommonjsModule(function (module, exports) {
9435 Object.defineProperty(exports, "__esModule", {
9438 exports.timestamp = exports.floatTime = exports.intTime = void 0;
9440 const parseSexagesimal = (sign, parts) => {
9441 const n = parts.split(':').reduce((n, p) => n * 60 + Number(p), 0);
9442 return sign === '-' ? -n : n;
9443 }; // hhhh:mm:ss.sss
9446 const stringifySexagesimal = ({
9449 if (isNaN(value) || !isFinite(value)) return (0, stringify.stringifyNumber)(value);
9454 value = Math.abs(value);
9457 const parts = [value % 60]; // seconds, including ms
9460 parts.unshift(0); // at least one : is required
9462 value = Math.round((value - parts[0]) / 60);
9463 parts.unshift(value % 60); // minutes
9466 value = Math.round((value - parts[0]) / 60);
9467 parts.unshift(value); // hours
9471 return sign + parts.map(n => n < 10 ? '0' + String(n) : String(n)).join(':').replace(/000000\d*$/, '') // % 60 may introduce error
9476 identify: value => typeof value === 'number',
9478 tag: 'tag:yaml.org,2002:int',
9480 test: /^([-+]?)([0-9][0-9_]*(?::[0-5]?[0-9])+)$/,
9481 resolve: (str, sign, parts) => parseSexagesimal(sign, parts.replace(/_/g, '')),
9482 stringify: stringifySexagesimal
9484 exports.intTime = intTime;
9486 identify: value => typeof value === 'number',
9488 tag: 'tag:yaml.org,2002:float',
9490 test: /^([-+]?)([0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*)$/,
9491 resolve: (str, sign, parts) => parseSexagesimal(sign, parts.replace(/_/g, '')),
9492 stringify: stringifySexagesimal
9494 exports.floatTime = floatTime;
9496 identify: value => value instanceof Date,
9498 tag: 'tag:yaml.org,2002:timestamp',
9499 // If the time zone is omitted, the timestamp is assumed to be specified in UTC. The time part
9500 // may be omitted altogether, resulting in a date format. In such a case, the time part is
9501 // assumed to be 00:00:00Z (start of day, UTC).
9502 test: RegExp('^(?:' + '([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})' + // YYYY-Mm-Dd
9503 '(?:(?:t|T|[ \\t]+)' + // t | T | whitespace
9504 '([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)' + // Hh:Mm:Ss(.ss)?
9505 '(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?' + // Z | +5 | -03:30
9507 resolve: (str, year, month, day, hour, minute, second, millisec, tz) => {
9508 if (millisec) millisec = (millisec + '00').substr(1, 3);
9509 let date = Date.UTC(year, month - 1, day, hour || 0, minute || 0, second || 0, millisec || 0);
9511 if (tz && tz !== 'Z') {
9512 let d = parseSexagesimal(tz[0], tz.slice(1));
9513 if (Math.abs(d) < 30) d *= 60;
9517 return new Date(date);
9521 }) => value.toISOString().replace(/((T00:00)?:00)?\.000Z$/, '')
9523 exports.timestamp = timestamp;
9525 unwrapExports(timestamp_1);
9526 var timestamp_2 = timestamp_1.timestamp;
9527 var timestamp_3 = timestamp_1.floatTime;
9528 var timestamp_4 = timestamp_1.intTime;
9530 var yaml1_1 = createCommonjsModule(function (module, exports) {
9532 Object.defineProperty(exports, "__esModule", {
9535 exports.default = void 0;
9537 var _Scalar = _interopRequireDefault(Scalar_1);
9539 var _failsafe = _interopRequireDefault(failsafe);
9541 var _binary = _interopRequireDefault(binary);
9543 var _omap = _interopRequireDefault(omap);
9545 var _pairs = _interopRequireDefault(pairs);
9547 var _set = _interopRequireDefault(set);
9549 function _interopRequireDefault(obj) {
9550 return obj && obj.__esModule ? obj : {
9555 const boolStringify = ({
9557 }) => value ? options.boolOptions.trueStr : options.boolOptions.falseStr;
9559 var _default = _failsafe.default.concat([{
9560 identify: value => value == null,
9561 createNode: (schema, value, ctx) => ctx.wrapScalars ? new _Scalar.default(null) : null,
9563 tag: 'tag:yaml.org,2002:null',
9564 test: /^(?:~|[Nn]ull|NULL)?$/,
9565 resolve: () => null,
9566 options: options.nullOptions,
9567 stringify: () => options.nullOptions.nullStr
9569 identify: value => typeof value === 'boolean',
9571 tag: 'tag:yaml.org,2002:bool',
9572 test: /^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,
9573 resolve: () => true,
9574 options: options.boolOptions,
9575 stringify: boolStringify
9577 identify: value => typeof value === 'boolean',
9579 tag: 'tag:yaml.org,2002:bool',
9580 test: /^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/i,
9581 resolve: () => false,
9582 options: options.boolOptions,
9583 stringify: boolStringify
9585 identify: value => typeof value === 'number',
9587 tag: 'tag:yaml.org,2002:int',
9589 test: /^0b([0-1_]+)$/,
9590 resolve: (str, bin) => parseInt(bin.replace(/_/g, ''), 2),
9593 }) => '0b' + value.toString(2)
9595 identify: value => typeof value === 'number',
9597 tag: 'tag:yaml.org,2002:int',
9599 test: /^[-+]?0([0-7_]+)$/,
9600 resolve: (str, oct) => parseInt(oct.replace(/_/g, ''), 8),
9603 }) => (value < 0 ? '-0' : '0') + value.toString(8)
9605 identify: value => typeof value === 'number',
9607 tag: 'tag:yaml.org,2002:int',
9608 test: /^[-+]?[0-9][0-9_]*$/,
9609 resolve: str => parseInt(str.replace(/_/g, ''), 10),
9610 stringify: stringify.stringifyNumber
9612 identify: value => typeof value === 'number',
9614 tag: 'tag:yaml.org,2002:int',
9616 test: /^0x([0-9a-fA-F_]+)$/,
9617 resolve: (str, hex) => parseInt(hex.replace(/_/g, ''), 16),
9620 }) => (value < 0 ? '-0x' : '0x') + value.toString(16)
9622 identify: value => typeof value === 'number',
9624 tag: 'tag:yaml.org,2002:float',
9625 test: /^(?:[-+]?\.inf|(\.nan))$/i,
9626 resolve: (str, nan) => nan ? NaN : str[0] === '-' ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
9627 stringify: stringify.stringifyNumber
9629 identify: value => typeof value === 'number',
9631 tag: 'tag:yaml.org,2002:float',
9633 test: /^[-+]?([0-9][0-9_]*)?(\.[0-9_]*)?[eE][-+]?[0-9]+$/,
9634 resolve: str => parseFloat(str.replace(/_/g, '')),
9637 }) => Number(value).toExponential()
9639 identify: value => typeof value === 'number',
9641 tag: 'tag:yaml.org,2002:float',
9642 test: /^[-+]?(?:[0-9][0-9_]*)?\.([0-9_]*)$/,
9644 resolve(str, frac) {
9645 const node = new _Scalar.default(parseFloat(str.replace(/_/g, '')));
9648 const f = frac.replace(/_/g, '');
9649 if (f[f.length - 1] === '0') node.minFractionDigits = f.length;
9655 stringify: stringify.stringifyNumber
9656 }], _binary.default, _omap.default, _pairs.default, _set.default, timestamp_1.intTime, timestamp_1.floatTime, timestamp_1.timestamp);
9658 exports.default = _default;
9660 unwrapExports(yaml1_1);
9662 var tags_1 = createCommonjsModule(function (module, exports) {
9664 Object.defineProperty(exports, "__esModule", {
9667 exports.tags = exports.schemas = void 0;
9669 var _core = _interopRequireWildcard(core);
9671 var _failsafe = _interopRequireDefault(failsafe);
9673 var _json = _interopRequireDefault(json);
9675 var _yaml = _interopRequireDefault(yaml1_1);
9677 var _map = _interopRequireDefault(map);
9679 var _seq = _interopRequireDefault(seq);
9681 var _binary = _interopRequireDefault(binary);
9683 var _omap = _interopRequireDefault(omap);
9685 var _pairs = _interopRequireDefault(pairs);
9687 var _set = _interopRequireDefault(set);
9689 function _interopRequireDefault(obj) {
9690 return obj && obj.__esModule ? obj : {
9695 function _getRequireWildcardCache() {
9696 if (typeof WeakMap !== "function") return null;
9697 var cache = new WeakMap();
9699 _getRequireWildcardCache = function () {
9706 function _interopRequireWildcard(obj) {
9707 if (obj && obj.__esModule) {
9711 if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
9717 var cache = _getRequireWildcardCache();
9719 if (cache && cache.has(obj)) {
9720 return cache.get(obj);
9724 var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
9726 for (var key in obj) {
9727 if (Object.prototype.hasOwnProperty.call(obj, key)) {
9728 var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
9730 if (desc && (desc.get || desc.set)) {
9731 Object.defineProperty(newObj, key, desc);
9733 newObj[key] = obj[key];
9738 newObj.default = obj;
9741 cache.set(obj, newObj);
9748 core: _core.default,
9749 failsafe: _failsafe.default,
9750 json: _json.default,
9751 yaml11: _yaml.default
9753 exports.schemas = schemas;
9755 binary: _binary.default,
9756 bool: _core.boolObj,
9757 float: _core.floatObj,
9758 floatExp: _core.expObj,
9759 floatNaN: _core.nanObj,
9760 floatTime: timestamp_1.floatTime,
9762 intHex: _core.hexObj,
9763 intOct: _core.octObj,
9764 intTime: timestamp_1.intTime,
9766 null: _core.nullObj,
9767 omap: _omap.default,
9768 pairs: _pairs.default,
9771 timestamp: timestamp_1.timestamp
9773 exports.tags = tags;
9775 unwrapExports(tags_1);
9776 var tags_2 = tags_1.tags;
9777 var tags_3 = tags_1.schemas;
9779 var schema = createCommonjsModule(function (module, exports) {
9781 Object.defineProperty(exports, "__esModule", {
9784 exports.default = void 0;
9786 var _Alias = _interopRequireDefault(Alias_1$1);
9788 var _Collection = _interopRequireDefault(Collection_1$1);
9790 var _Node = _interopRequireDefault(Node_1$1);
9792 var _Pair = _interopRequireDefault(Pair_1);
9794 var _Scalar = _interopRequireDefault(Scalar_1);
9796 function _interopRequireDefault(obj) {
9797 return obj && obj.__esModule ? obj : {
9802 function _defineProperty(obj, key, value) {
9804 Object.defineProperty(obj, key, {
9819 }) => type === constants.Type.FLOW_MAP || type === constants.Type.MAP;
9823 }) => type === constants.Type.FLOW_SEQ || type === constants.Type.SEQ;
9831 tags: deprecatedCustomTags
9833 this.merge = !!merge;
9835 this.sortMapEntries = sortMapEntries === true ? (a, b) => a.key < b.key ? -1 : a.key > b.key ? 1 : 0 : sortMapEntries || null;
9836 this.tags = tags_1.schemas[schema.replace(/\W/g, '')]; // 'yaml-1.1' -> 'yaml11'
9839 const keys = Object.keys(tags_1.schemas).map(key => JSON.stringify(key)).join(', ');
9840 throw new Error(`Unknown schema "${schema}"; use one of ${keys}`);
9843 if (!customTags && deprecatedCustomTags) {
9844 customTags = deprecatedCustomTags;
9845 (0, warnings.warnOptionDeprecation)('tags', 'customTags');
9848 if (Array.isArray(customTags)) {
9849 for (const tag of customTags) this.tags = this.tags.concat(tag);
9850 } else if (typeof customTags === 'function') {
9851 this.tags = customTags(this.tags.slice());
9854 for (let i = 0; i < this.tags.length; ++i) {
9855 const tag = this.tags[i];
9857 if (typeof tag === 'string') {
9858 const tagObj = tags_1.tags[tag];
9861 const keys = Object.keys(tags_1.tags).map(key => JSON.stringify(key)).join(', ');
9862 throw new Error(`Unknown custom tag "${tag}"; use one of ${keys}`);
9865 this.tags[i] = tagObj;
9870 createNode(value, wrapScalars, tag, ctx) {
9871 if (value instanceof _Node.default) return value;
9875 if (tag.startsWith('!!')) tag = Schema.defaultPrefix + tag.slice(2);
9876 const match = this.tags.filter(t => t.tag === tag);
9877 tagObj = match.find(t => !t.format) || match[0];
9878 if (!tagObj) throw new Error(`Tag ${tag} not found`);
9880 // TODO: deprecate/remove class check
9881 tagObj = this.tags.find(t => (t.identify && t.identify(value) || t.class && value instanceof t.class) && !t.format);
9884 if (typeof value.toJSON === 'function') value = value.toJSON();
9885 if (typeof value !== 'object') return wrapScalars ? new _Scalar.default(value) : value;
9886 tagObj = value instanceof Map ? tags_1.tags.map : value[Symbol.iterator] ? tags_1.tags.seq : tags_1.tags.map;
9892 };else ctx.wrapScalars = wrapScalars;
9895 ctx.onTagObj(tagObj);
9896 delete ctx.onTagObj;
9901 if (value && typeof value === 'object' && ctx.prevObjects) {
9902 const prev = ctx.prevObjects.get(value);
9905 const alias = new _Alias.default(prev); // leaves source dirty; must be cleaned by caller
9907 ctx.aliasNodes.push(alias);
9912 ctx.prevObjects.set(value, obj);
9915 obj.node = tagObj.createNode ? tagObj.createNode(this, value, ctx) : wrapScalars ? new _Scalar.default(value) : value;
9916 if (tag && obj.node instanceof _Node.default) obj.node.tag = tag;
9920 createPair(key, value, ctx) {
9921 const k = this.createNode(key, ctx.wrapScalars, null, ctx);
9922 const v = this.createNode(value, ctx.wrapScalars, null, ctx);
9923 return new _Pair.default(k, v);
9924 } // falls back to string on no match
9927 resolveScalar(str, tags) {
9928 if (!tags) tags = this.tags;
9930 for (let i = 0; i < tags.length; ++i) {
9938 const match = str.match(test);
9941 let res = resolve.apply(null, match);
9942 if (!(res instanceof _Scalar.default)) res = new _Scalar.default(res);
9943 if (format) res.format = format;
9949 if (this.tags.scalarFallback) str = this.tags.scalarFallback(str);
9950 return new _Scalar.default(str);
9951 } // sets node.resolved on success
9954 resolveNode(doc, node, tagName) {
9955 const tags = this.tags.filter(({
9957 }) => tag === tagName);
9958 const generic = tags.find(({
9961 if (node.error) doc.errors.push(node.error);
9965 let res = generic.resolve(doc, node);
9966 if (!(res instanceof _Collection.default)) res = new _Scalar.default(res);
9967 node.resolved = res;
9969 const str = (0, string.resolveString)(doc, node);
9971 if (typeof str === 'string' && tags.length > 0) {
9972 node.resolved = this.resolveScalar(str, tags);
9976 /* istanbul ignore if */
9977 if (!error.source) error.source = node;
9978 doc.errors.push(error);
9979 node.resolved = null;
9982 if (!node.resolved) return null;
9983 if (tagName && node.tag) node.resolved.tag = tagName;
9984 return node.resolved;
9987 resolveNodeWithFallback(doc, node, tagName) {
9988 const res = this.resolveNode(doc, node, tagName);
9989 if (Object.prototype.hasOwnProperty.call(node, 'resolved')) return res;
9990 const fallback = isMap(node) ? Schema.defaultTags.MAP : isSeq(node) ? Schema.defaultTags.SEQ : Schema.defaultTags.STR;
9991 /* istanbul ignore else */
9994 doc.warnings.push(new errors.YAMLWarning(node, `The tag ${tagName} is unavailable, falling back to ${fallback}`));
9995 const res = this.resolveNode(doc, node, fallback);
9999 doc.errors.push(new errors.YAMLReferenceError(node, `The tag ${tagName} is unavailable`));
10004 getTagObject(item) {
10005 if (item instanceof _Alias.default) return _Alias.default;
10008 const match = this.tags.filter(t => t.tag === item.tag);
10009 if (match.length > 0) return match.find(t => t.format === item.format) || match[0];
10014 if (item instanceof _Scalar.default) {
10015 obj = item.value; // TODO: deprecate/remove class check
10017 const match = this.tags.filter(t => t.identify && t.identify(obj) || t.class && obj instanceof t.class);
10018 tagObj = match.find(t => t.format === item.format) || match.find(t => !t.format);
10021 tagObj = this.tags.find(t => t.nodeClass && obj instanceof t.nodeClass);
10025 const name = obj && obj.constructor ? obj.constructor.name : typeof obj;
10026 throw new Error(`Tag not resolved for ${name} value`);
10030 } // needs to be called before stringifier to allow for circular anchor refs
10033 stringifyProps(node, tagObj, {
10038 const anchor = doc.anchors.getName(node);
10041 anchors[anchor] = node;
10042 props.push(`&${anchor}`);
10046 props.push(doc.stringifyTag(node.tag));
10047 } else if (!tagObj.default) {
10048 props.push(doc.stringifyTag(tagObj.tag));
10051 return props.join(' ');
10054 stringify(item, ctx, onComment, onChompKeep) {
10057 if (!(item instanceof _Node.default)) {
10058 const createCtx = {
10060 onTagObj: o => tagObj = o,
10061 prevObjects: new Map()
10063 item = this.createNode(item, true, null, createCtx);
10068 for (const alias of createCtx.aliasNodes) {
10069 alias.source = alias.source.node;
10070 let name = anchors.getName(alias.source);
10073 name = anchors.newName();
10074 anchors.map[name] = alias.source;
10080 if (item instanceof _Pair.default) return item.toString(ctx, onComment, onChompKeep);
10081 if (!tagObj) tagObj = this.getTagObject(item);
10082 const props = this.stringifyProps(item, tagObj, ctx);
10083 if (props.length > 0) ctx.indentAtStart = (ctx.indentAtStart || 0) + props.length + 1;
10084 const str = typeof tagObj.stringify === 'function' ? tagObj.stringify(item, ctx, onComment, onChompKeep) : item instanceof _Collection.default ? item.toString(ctx, onComment, onChompKeep) : (0, stringify.stringifyString)(item, ctx, onComment, onChompKeep);
10085 return props ? item instanceof _Collection.default && str[0] !== '{' && str[0] !== '[' ? `${props}\n${ctx.indent}${str}` : `${props} ${str}` : str;
10090 exports.default = Schema;
10092 _defineProperty(Schema, "defaultPrefix", 'tag:yaml.org,2002:');
10094 _defineProperty(Schema, "defaultTags", {
10095 MAP: 'tag:yaml.org,2002:map',
10096 SEQ: 'tag:yaml.org,2002:seq',
10097 STR: 'tag:yaml.org,2002:str'
10100 unwrapExports(schema);
10102 var Document_1$1 = createCommonjsModule(function (module, exports) {
10104 Object.defineProperty(exports, "__esModule", {
10107 exports.default = void 0;
10109 var _addComment = _interopRequireDefault(addComment_1);
10111 var _Anchors = _interopRequireDefault(Anchors_1);
10113 var _listTagNames = _interopRequireDefault(listTagNames);
10115 var _schema = _interopRequireDefault(schema);
10117 var _Alias = _interopRequireDefault(Alias_1$1);
10119 var _Collection = _interopRequireWildcard(Collection_1$1);
10121 var _Node = _interopRequireDefault(Node_1$1);
10123 var _Scalar = _interopRequireDefault(Scalar_1);
10125 var _toJSON = _interopRequireDefault(toJSON_1);
10127 function _getRequireWildcardCache() {
10128 if (typeof WeakMap !== "function") return null;
10129 var cache = new WeakMap();
10131 _getRequireWildcardCache = function () {
10138 function _interopRequireWildcard(obj) {
10139 if (obj && obj.__esModule) {
10143 if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
10149 var cache = _getRequireWildcardCache();
10151 if (cache && cache.has(obj)) {
10152 return cache.get(obj);
10156 var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
10158 for (var key in obj) {
10159 if (Object.prototype.hasOwnProperty.call(obj, key)) {
10160 var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
10162 if (desc && (desc.get || desc.set)) {
10163 Object.defineProperty(newObj, key, desc);
10165 newObj[key] = obj[key];
10170 newObj.default = obj;
10173 cache.set(obj, newObj);
10179 function _interopRequireDefault(obj) {
10180 return obj && obj.__esModule ? obj : {
10185 function _defineProperty(obj, key, value) {
10187 Object.defineProperty(obj, key, {
10190 configurable: true,
10200 const isCollectionItem = node => node && [constants.Type.MAP_KEY, constants.Type.MAP_VALUE, constants.Type.SEQ_ITEM].includes(node.type);
10203 constructor(options) {
10204 this.anchors = new _Anchors.default(options.anchorPrefix);
10205 this.commentBefore = null;
10206 this.comment = null;
10207 this.contents = null;
10208 this.directivesEndMarker = null;
10210 this.options = options;
10211 this.schema = null;
10212 this.tagPrefixes = [];
10213 this.version = null;
10214 this.warnings = [];
10217 assertCollectionContents() {
10218 if (this.contents instanceof _Collection.default) return true;
10219 throw new Error('Expected a YAML collection as document contents');
10223 this.assertCollectionContents();
10224 return this.contents.add(value);
10227 addIn(path, value) {
10228 this.assertCollectionContents();
10229 this.contents.addIn(path, value);
10233 this.assertCollectionContents();
10234 return this.contents.delete(key);
10238 if ((0, _Collection.isEmptyPath)(path)) {
10239 if (this.contents == null) return false;
10240 this.contents = null;
10244 this.assertCollectionContents();
10245 return this.contents.deleteIn(path);
10249 return Document.defaults[this.version] || Document.defaults[this.options.version] || {};
10252 get(key, keepScalar) {
10253 return this.contents instanceof _Collection.default ? this.contents.get(key, keepScalar) : undefined;
10256 getIn(path, keepScalar) {
10257 if ((0, _Collection.isEmptyPath)(path)) return !keepScalar && this.contents instanceof _Scalar.default ? this.contents.value : this.contents;
10258 return this.contents instanceof _Collection.default ? this.contents.getIn(path, keepScalar) : undefined;
10262 return this.contents instanceof _Collection.default ? this.contents.has(key) : false;
10266 if ((0, _Collection.isEmptyPath)(path)) return this.contents !== undefined;
10267 return this.contents instanceof _Collection.default ? this.contents.hasIn(path) : false;
10271 this.assertCollectionContents();
10272 this.contents.set(key, value);
10275 setIn(path, value) {
10276 if ((0, _Collection.isEmptyPath)(path)) this.contents = value;else {
10277 this.assertCollectionContents();
10278 this.contents.setIn(path, value);
10282 setSchema(id, customTags) {
10283 if (!id && !customTags && this.schema) return;
10284 if (typeof id === 'number') id = id.toFixed(1);
10286 if (id === '1.0' || id === '1.1' || id === '1.2') {
10287 if (this.version) this.version = id;else this.options.version = id;
10288 delete this.options.schema;
10289 } else if (id && typeof id === 'string') {
10290 this.options.schema = id;
10293 if (Array.isArray(customTags)) this.options.customTags = customTags;
10294 const opt = Object.assign({}, this.getDefaults(), this.options);
10295 this.schema = new _schema.default(opt);
10298 parse(node, prevDoc) {
10299 if (this.options.keepCstNodes) this.cstNode = node;
10300 if (this.options.keepNodeTypes) this.type = 'DOCUMENT';
10304 directivesEndMarker,
10310 if (!error.source) error.source = this;
10311 this.errors.push(error);
10314 this.parseDirectives(directives, prevDoc);
10315 if (directivesEndMarker) this.directivesEndMarker = true;
10316 this.range = valueRange ? [valueRange.start, valueRange.end] : null;
10318 this.anchors._cstAliases = [];
10319 this.parseContents(contents);
10320 this.anchors.resolveNodes();
10322 if (this.options.prettyErrors) {
10323 for (const error of this.errors) if (error instanceof errors.YAMLError) error.makePretty();
10325 for (const warn of this.warnings) if (warn instanceof errors.YAMLError) warn.makePretty();
10331 parseDirectives(directives, prevDoc) {
10332 const directiveComments = [];
10333 let hasDirectives = false;
10334 directives.forEach(directive => {
10342 this.resolveTagDirective(directive);
10343 hasDirectives = true;
10348 this.resolveYamlDirective(directive);
10349 hasDirectives = true;
10354 const msg = `YAML only supports %TAG and %YAML directives, and not %${name}`;
10355 this.warnings.push(new errors.YAMLWarning(directive, msg));
10360 if (comment) directiveComments.push(comment);
10363 if (prevDoc && !hasDirectives && '1.1' === (this.version || prevDoc.version || this.options.version)) {
10364 const copyTagPrefix = ({
10372 this.tagPrefixes = prevDoc.tagPrefixes.map(copyTagPrefix);
10373 this.version = prevDoc.version;
10376 this.commentBefore = directiveComments.join('\n') || null;
10379 parseContents(contents) {
10384 const contentNodes = [];
10385 let spaceBefore = false;
10386 contents.forEach(node => {
10387 if (node.valueRange) {
10388 if (contentNodes.length === 1) {
10389 const msg = 'Document is not valid YAML (bad indentation?)';
10390 this.errors.push(new errors.YAMLSyntaxError(node, msg));
10393 const res = this.resolveNode(node);
10396 res.spaceBefore = true;
10397 spaceBefore = false;
10400 contentNodes.push(res);
10401 } else if (node.comment !== null) {
10402 const cc = contentNodes.length === 0 ? comments.before : comments.after;
10403 cc.push(node.comment);
10404 } else if (node.type === constants.Type.BLANK_LINE) {
10405 spaceBefore = true;
10407 if (contentNodes.length === 0 && comments.before.length > 0 && !this.commentBefore) {
10408 // space-separated comments at start are parsed as document comments
10409 this.commentBefore = comments.before.join('\n');
10410 comments.before = [];
10415 switch (contentNodes.length) {
10417 this.contents = null;
10418 comments.after = comments.before;
10422 this.contents = contentNodes[0];
10424 if (this.contents) {
10425 const cb = comments.before.join('\n') || null;
10428 const cbNode = this.contents instanceof _Collection.default && this.contents.items[0] ? this.contents.items[0] : this.contents;
10429 cbNode.commentBefore = cbNode.commentBefore ? `${cb}\n${cbNode.commentBefore}` : cb;
10432 comments.after = comments.before.concat(comments.after);
10438 this.contents = contentNodes;
10440 if (this.contents[0]) {
10441 this.contents[0].commentBefore = comments.before.join('\n') || null;
10443 comments.after = comments.before.concat(comments.after);
10448 this.comment = comments.after.join('\n') || null;
10451 resolveTagDirective(directive) {
10452 const [handle, prefix] = directive.parameters;
10454 if (handle && prefix) {
10455 if (this.tagPrefixes.every(p => p.handle !== handle)) {
10456 this.tagPrefixes.push({
10461 const msg = 'The %TAG directive must only be given at most once per handle in the same document.';
10462 this.errors.push(new errors.YAMLSemanticError(directive, msg));
10465 const msg = 'Insufficient parameters given for %TAG directive';
10466 this.errors.push(new errors.YAMLSemanticError(directive, msg));
10470 resolveYamlDirective(directive) {
10471 let [version] = directive.parameters;
10472 if (directive.name === 'YAML:1.0') version = '1.0';
10474 if (this.version) {
10475 const msg = 'The %YAML directive must only be given at most once per document.';
10476 this.errors.push(new errors.YAMLSemanticError(directive, msg));
10480 const msg = 'Insufficient parameters given for %YAML directive';
10481 this.errors.push(new errors.YAMLSemanticError(directive, msg));
10483 if (!Document.defaults[version]) {
10484 const v0 = this.version || this.options.version;
10485 const msg = `Document will be parsed as YAML ${v0} rather than YAML ${version}`;
10486 this.warnings.push(new errors.YAMLWarning(directive, msg));
10489 this.version = version;
10493 resolveTagName(node) {
10498 let nonSpecific = false;
10508 if (verbatim !== '!' && verbatim !== '!!') return verbatim;
10509 const msg = `Verbatim tags aren't resolved, so ${verbatim} is invalid.`;
10510 this.errors.push(new errors.YAMLSemanticError(node, msg));
10511 } else if (handle === '!' && !suffix) {
10512 nonSpecific = true;
10514 let prefix = this.tagPrefixes.find(p => p.handle === handle);
10517 const dtp = this.getDefaults().tagPrefixes;
10518 if (dtp) prefix = dtp.find(p => p.handle === handle);
10523 if (handle === '!' && (this.version || this.options.version) === '1.0') {
10524 if (suffix[0] === '^') return suffix;
10526 if (/[:/]/.test(suffix)) {
10527 // word/foo -> tag:word.yaml.org,2002:foo
10528 const vocab = suffix.match(/^([a-z0-9-]+)\/(.*)/i);
10529 return vocab ? `tag:${vocab[1]}.yaml.org,2002:${vocab[2]}` : `tag:${suffix}`;
10533 return prefix.prefix + decodeURIComponent(suffix);
10536 this.errors.push(new errors.YAMLSemanticError(node, `The ${handle} tag has no suffix.`));
10538 const msg = `The ${handle} tag handle is non-default and was not declared.`;
10539 this.errors.push(new errors.YAMLSemanticError(node, msg));
10545 case constants.Type.BLOCK_FOLDED:
10546 case constants.Type.BLOCK_LITERAL:
10547 case constants.Type.QUOTE_DOUBLE:
10548 case constants.Type.QUOTE_SINGLE:
10549 return _schema.default.defaultTags.STR;
10551 case constants.Type.FLOW_MAP:
10552 case constants.Type.MAP:
10553 return _schema.default.defaultTags.MAP;
10555 case constants.Type.FLOW_SEQ:
10556 case constants.Type.SEQ:
10557 return _schema.default.defaultTags.SEQ;
10559 case constants.Type.PLAIN:
10560 return nonSpecific ? _schema.default.defaultTags.STR : null;
10567 resolveNode(node) {
10568 if (!node) return null;
10574 let hasAnchor = false;
10575 let hasTag = false;
10580 const props = isCollectionItem(node.context.parent) ? node.context.parent.props.concat(node.props) : node.props;
10586 switch (node.context.src[start]) {
10587 case constants.Char.COMMENT:
10589 if (!node.commentHasRequiredWhitespace(start)) {
10590 const msg = 'Comments must be separated from other tokens by white space characters';
10591 errors$1.push(new errors.YAMLSemanticError(node, msg));
10594 const c = node.context.src.slice(start + 1, end);
10600 if (valueRange && (start > valueRange.start || header && start > header.start)) {
10601 comments.after.push(c);
10603 comments.before.push(c);
10608 case constants.Char.ANCHOR:
10610 const msg = 'A node can have at most one anchor';
10611 errors$1.push(new errors.YAMLSemanticError(node, msg));
10617 case constants.Char.TAG:
10619 const msg = 'A node can have at most one tag';
10620 errors$1.push(new errors.YAMLSemanticError(node, msg));
10629 const name = node.anchor;
10630 const prev = anchors.getNode(name); // At this point, aliases for any preceding node with the same anchor
10631 // name have already been resolved, so it may safely be renamed.
10633 if (prev) anchors.map[anchors.newName(name)] = prev; // During parsing, we need to store the CST node in anchors.map as
10634 // anchors need to be available during resolution to allow for
10635 // circular references.
10637 anchors.map[name] = node;
10642 if (node.type === constants.Type.ALIAS) {
10643 if (hasAnchor || hasTag) {
10644 const msg = 'An alias node must not specify any properties';
10645 errors$1.push(new errors.YAMLSemanticError(node, msg));
10648 const name = node.rawValue;
10649 const src = anchors.getNode(name);
10652 const msg = `Aliased anchor not found: ${name}`;
10653 errors$1.push(new errors.YAMLReferenceError(node, msg));
10655 } // Lazy resolution for circular references
10658 res = new _Alias.default(src);
10660 anchors._cstAliases.push(res);
10662 const tagName = this.resolveTagName(node);
10665 res = schema.resolveNodeWithFallback(this, node, tagName);
10667 if (node.type !== constants.Type.PLAIN) {
10668 const msg = `Failed to resolve ${node.type} node here`;
10669 errors$1.push(new errors.YAMLSyntaxError(node, msg));
10674 res = schema.resolveScalar(node.strValue || '');
10676 if (!error.source) error.source = node;
10677 errors$1.push(error);
10684 res.range = [node.range.start, node.range.end];
10685 if (this.options.keepCstNodes) res.cstNode = node;
10686 if (this.options.keepNodeTypes) res.type = node.type;
10687 const cb = comments.before.join('\n');
10690 res.commentBefore = res.commentBefore ? `${res.commentBefore}\n${cb}` : cb;
10693 const ca = comments.after.join('\n');
10694 if (ca) res.comment = res.comment ? `${res.comment}\n${ca}` : ca;
10697 return node.resolved = res;
10700 listNonDefaultTags() {
10701 return (0, _listTagNames.default)(this.contents).filter(t => t.indexOf(_schema.default.defaultPrefix) !== 0);
10704 setTagPrefix(handle, prefix) {
10705 if (handle[0] !== '!' || handle[handle.length - 1] !== '!') throw new Error('Handle must start and end with !');
10708 const prev = this.tagPrefixes.find(p => p.handle === handle);
10709 if (prev) prev.prefix = prefix;else this.tagPrefixes.push({
10714 this.tagPrefixes = this.tagPrefixes.filter(p => p.handle !== handle);
10718 stringifyTag(tag) {
10719 if ((this.version || this.options.version) === '1.0') {
10720 const priv = tag.match(/^tag:private\.yaml\.org,2002:([^:/]+)$/);
10721 if (priv) return '!' + priv[1];
10722 const vocab = tag.match(/^tag:([a-zA-Z0-9-]+)\.yaml\.org,2002:(.*)/);
10723 return vocab ? `!${vocab[1]}/${vocab[2]}` : `!${tag.replace(/^tag:/, '')}`;
10725 let p = this.tagPrefixes.find(p => tag.indexOf(p.prefix) === 0);
10728 const dtp = this.getDefaults().tagPrefixes;
10729 p = dtp && dtp.find(p => tag.indexOf(p.prefix) === 0);
10732 if (!p) return tag[0] === '!' ? tag : `!<${tag}>`;
10733 const suffix = tag.substr(p.prefix.length).replace(/[!,[\]{}]/g, ch => ({
10741 return p.handle + suffix;
10751 const keep = keepBlobsInJSON && (typeof arg !== 'string' || !(this.contents instanceof _Scalar.default));
10755 mapAsMap: keep && !!mapAsMap,
10758 const anchorNames = Object.keys(this.anchors.map);
10759 if (anchorNames.length > 0) ctx.anchors = anchorNames.map(name => ({
10763 node: this.anchors.map[name]
10765 return (0, _toJSON.default)(this.contents, arg, ctx);
10769 if (this.errors.length > 0) throw new Error('Document with errors cannot be stringified');
10772 let hasDirectives = false;
10774 if (this.version) {
10775 let vd = '%YAML 1.2';
10777 if (this.schema.name === 'yaml-1.1') {
10778 if (this.version === '1.0') vd = '%YAML:1.0';else if (this.version === '1.1') vd = '%YAML 1.1';
10782 hasDirectives = true;
10785 const tagNames = this.listNonDefaultTags();
10786 this.tagPrefixes.forEach(({
10790 if (tagNames.some(t => t.indexOf(prefix) === 0)) {
10791 lines.push(`%TAG ${handle} ${prefix}`);
10792 hasDirectives = true;
10795 if (hasDirectives || this.directivesEndMarker) lines.push('---');
10797 if (this.commentBefore) {
10798 if (hasDirectives || !this.directivesEndMarker) lines.unshift('');
10799 lines.unshift(this.commentBefore.replace(/^/gm, '#'));
10807 let chompKeep = false;
10808 let contentComment = null;
10810 if (this.contents) {
10811 if (this.contents instanceof _Node.default) {
10812 if (this.contents.spaceBefore && (hasDirectives || this.directivesEndMarker)) lines.push('');
10813 if (this.contents.commentBefore) lines.push(this.contents.commentBefore.replace(/^/gm, '#')); // top-level block scalars need to be indented if followed by a comment
10815 ctx.forceBlockIndent = !!this.comment;
10816 contentComment = this.contents.comment;
10819 const onChompKeep = contentComment ? null : () => chompKeep = true;
10820 const body = this.schema.stringify(this.contents, ctx, () => contentComment = null, onChompKeep);
10821 lines.push((0, _addComment.default)(body, '', contentComment));
10822 } else if (this.contents !== undefined) {
10823 lines.push(this.schema.stringify(this.contents, ctx));
10826 if (this.comment) {
10827 if ((!chompKeep || contentComment) && lines[lines.length - 1] !== '') lines.push('');
10828 lines.push(this.comment.replace(/^/gm, '#'));
10831 return lines.join('\n') + '\n';
10836 exports.default = Document;
10838 _defineProperty(Document, "defaults", {
10840 schema: 'yaml-1.1',
10844 prefix: _schema.default.defaultPrefix
10847 prefix: 'tag:private.yaml.org,2002:'
10851 schema: 'yaml-1.1',
10858 prefix: _schema.default.defaultPrefix
10869 prefix: _schema.default.defaultPrefix
10874 unwrapExports(Document_1$1);
10876 var dist$1 = createCommonjsModule(function (module, exports) {
10878 Object.defineProperty(exports, "__esModule", {
10881 exports.default = void 0;
10883 var _parse = _interopRequireDefault(parse_1);
10885 var _Document = _interopRequireDefault(Document_1$1);
10887 var _schema = _interopRequireDefault(schema);
10889 function _interopRequireDefault(obj) {
10890 return obj && obj.__esModule ? obj : {
10895 const defaultOptions = {
10898 keepCstNodes: false,
10899 keepNodeTypes: true,
10900 keepBlobsInJSON: true,
10902 maxAliasCount: 100,
10903 prettyErrors: false,
10904 // TODO Set true in v2
10909 function createNode(value, wrapScalars = true, tag) {
10910 if (tag === undefined && typeof wrapScalars === 'string') {
10912 wrapScalars = true;
10915 const options = Object.assign({}, _Document.default.defaults[defaultOptions.version], defaultOptions);
10916 const schema = new _schema.default(options);
10917 return schema.createNode(value, wrapScalars, tag);
10920 class Document extends _Document.default {
10921 constructor(options) {
10922 super(Object.assign({}, defaultOptions, options));
10927 function parseAllDocuments(src, options) {
10931 for (const cstDoc of (0, _parse.default)(src)) {
10932 const doc = new Document(options);
10933 doc.parse(cstDoc, prev);
10941 function parseDocument(src, options) {
10942 const cst = (0, _parse.default)(src);
10943 const doc = new Document(options).parse(cst[0]);
10945 if (cst.length > 1) {
10946 const errMsg = 'Source contains multiple documents; please use YAML.parseAllDocuments()';
10947 doc.errors.unshift(new errors.YAMLSemanticError(cst[1], errMsg));
10953 function parse(src, options) {
10954 const doc = parseDocument(src, options);
10955 doc.warnings.forEach(warning => (0, warnings.warn)(warning));
10956 if (doc.errors.length > 0) throw doc.errors[0];
10957 return doc.toJSON();
10960 function stringify(value, options) {
10961 const doc = new Document(options);
10962 doc.contents = value;
10963 return String(doc);
10972 parseCST: _parse.default,
10976 exports.default = _default;
10978 unwrapExports(dist$1);
10980 var yaml = dist$1.default;
10982 var loaders_1 = createCommonjsModule(function (module, exports) {
10984 Object.defineProperty(exports, "__esModule", {
10987 exports.loaders = void 0;
10988 /* eslint-disable @typescript-eslint/no-require-imports */
10992 const loadJs = function loadJs(filepath) {
10993 if (importFresh$1 === undefined) {
10994 importFresh$1 = importFresh;
10997 const result = importFresh$1(filepath);
11003 const loadJson = function loadJson(filepath, content) {
11004 if (parseJson === undefined) {
11005 parseJson = parseJson$1;
11009 const result = parseJson(content);
11012 error.message = `JSON Error in ${filepath}:\n${error.message}`;
11019 const loadYaml = function loadYaml(filepath, content) {
11020 if (yaml$1 === undefined) {
11025 const result = yaml$1.parse(content, {
11030 error.message = `YAML Error in ${filepath}:\n${error.message}`;
11040 exports.loaders = loaders;
11042 unwrapExports(loaders_1);
11043 var loaders_2 = loaders_1.loaders;
11045 var getPropertyByPath_1 = createCommonjsModule(function (module, exports) {
11047 Object.defineProperty(exports, "__esModule", {
11050 exports.getPropertyByPath = getPropertyByPath; // Resolves property names or property paths defined with period-delimited
11051 // strings or arrays of strings. Property names that are found on the source
11052 // object are used directly (even if they include a period).
11053 // Nested property names that include periods, within a path, are only
11054 // understood in array paths.
11056 function getPropertyByPath(source, path) {
11057 if (typeof path === 'string' && Object.prototype.hasOwnProperty.call(source, path)) {
11058 return source[path];
11061 const parsedPath = typeof path === 'string' ? path.split('.') : path; // eslint-disable-next-line @typescript-eslint/no-explicit-any
11063 return parsedPath.reduce((previous, key) => {
11064 if (previous === undefined) {
11068 return previous[key];
11072 unwrapExports(getPropertyByPath_1);
11073 var getPropertyByPath_2 = getPropertyByPath_1.getPropertyByPath;
11075 var ExplorerBase_1 = createCommonjsModule(function (module, exports) {
11077 Object.defineProperty(exports, "__esModule", {
11080 exports.getExtensionDescription = getExtensionDescription;
11081 exports.ExplorerBase = void 0;
11083 var _path = _interopRequireDefault(path);
11085 function _interopRequireDefault(obj) {
11086 return obj && obj.__esModule ? obj : {
11091 class ExplorerBase {
11092 constructor(options) {
11093 if (options.cache === true) {
11094 this.loadCache = new Map();
11095 this.searchCache = new Map();
11098 this.config = options;
11099 this.validateConfig();
11103 if (this.loadCache) {
11104 this.loadCache.clear();
11108 clearSearchCache() {
11109 if (this.searchCache) {
11110 this.searchCache.clear();
11115 this.clearLoadCache();
11116 this.clearSearchCache();
11120 const config = this.config;
11121 config.searchPlaces.forEach(place => {
11122 const loaderKey = _path.default.extname(place) || 'noExt';
11123 const loader = config.loaders[loaderKey];
11126 throw new Error(`No loader specified for ${getExtensionDescription(place)}, so searchPlaces item "${place}" is invalid`);
11129 if (typeof loader !== 'function') {
11130 throw new Error(`loader for ${getExtensionDescription(place)} is not a function (type provided: "${typeof loader}"), so searchPlaces item "${place}" is invalid`);
11135 shouldSearchStopWithResult(result) {
11136 if (result === null) return false;
11137 if (result.isEmpty && this.config.ignoreEmptySearchPlaces) return false;
11141 nextDirectoryToSearch(currentDir, currentResult) {
11142 if (this.shouldSearchStopWithResult(currentResult)) {
11146 const nextDir = nextDirUp(currentDir);
11148 if (nextDir === currentDir || currentDir === this.config.stopDir) {
11155 loadPackageProp(filepath, content) {
11156 const parsedContent = loaders_1.loaders.loadJson(filepath, content);
11158 const packagePropValue = (0, getPropertyByPath_1.getPropertyByPath)(parsedContent, this.config.packageProp);
11159 return packagePropValue || null;
11162 getLoaderEntryForFile(filepath) {
11163 if (_path.default.basename(filepath) === 'package.json') {
11164 const loader = this.loadPackageProp.bind(this);
11168 const loaderKey = _path.default.extname(filepath) || 'noExt';
11169 const loader = this.config.loaders[loaderKey];
11172 throw new Error(`No loader specified for ${getExtensionDescription(filepath)}`);
11178 loadedContentToCosmiconfigResult(filepath, loadedContent) {
11179 if (loadedContent === null) {
11183 if (loadedContent === undefined) {
11192 config: loadedContent,
11197 validateFilePath(filepath) {
11199 throw new Error('load must pass a non-empty string');
11205 exports.ExplorerBase = ExplorerBase;
11207 function nextDirUp(dir) {
11208 return _path.default.dirname(dir);
11211 function getExtensionDescription(filepath) {
11212 const ext = _path.default.extname(filepath);
11214 return ext ? `extension "${ext}"` : 'files without extensions';
11217 unwrapExports(ExplorerBase_1);
11218 var ExplorerBase_2 = ExplorerBase_1.getExtensionDescription;
11219 var ExplorerBase_3 = ExplorerBase_1.ExplorerBase;
11221 var readFile_1 = createCommonjsModule(function (module, exports) {
11223 Object.defineProperty(exports, "__esModule", {
11226 exports.readFile = readFile;
11227 exports.readFileSync = readFileSync;
11229 var _fs = _interopRequireDefault(fs);
11231 function _interopRequireDefault(obj) {
11232 return obj && obj.__esModule ? obj : {
11237 async function fsReadFileAsync(pathname, encoding) {
11238 return new Promise((resolve, reject) => {
11239 _fs.default.readFile(pathname, encoding, (error, contents) => {
11250 async function readFile(filepath, options = {}) {
11251 const throwNotFound = options.throwNotFound === true;
11254 const content = await fsReadFileAsync(filepath, 'utf8');
11257 if (throwNotFound === false && error.code === 'ENOENT') {
11265 function readFileSync(filepath, options = {}) {
11266 const throwNotFound = options.throwNotFound === true;
11269 const content = _fs.default.readFileSync(filepath, 'utf8');
11273 if (throwNotFound === false && error.code === 'ENOENT') {
11281 unwrapExports(readFile_1);
11282 var readFile_2 = readFile_1.readFile;
11283 var readFile_3 = readFile_1.readFileSync;
11285 var cacheWrapper_1 = createCommonjsModule(function (module, exports) {
11287 Object.defineProperty(exports, "__esModule", {
11290 exports.cacheWrapper = cacheWrapper;
11291 exports.cacheWrapperSync = cacheWrapperSync;
11293 async function cacheWrapper(cache, key, fn) {
11294 const cached = cache.get(key);
11296 if (cached !== undefined) {
11300 const result = await fn();
11301 cache.set(key, result);
11305 function cacheWrapperSync(cache, key, fn) {
11306 const cached = cache.get(key);
11308 if (cached !== undefined) {
11312 const result = fn();
11313 cache.set(key, result);
11317 unwrapExports(cacheWrapper_1);
11318 var cacheWrapper_2 = cacheWrapper_1.cacheWrapper;
11319 var cacheWrapper_3 = cacheWrapper_1.cacheWrapperSync;
11325 async function isType(fsStatType, statsMethodName, filePath) {
11326 if (typeof filePath !== 'string') {
11327 throw new TypeError(`Expected a string, got ${typeof filePath}`);
11331 const stats = await promisify(fs[fsStatType])(filePath);
11332 return stats[statsMethodName]();
11334 if (error.code === 'ENOENT') {
11342 function isTypeSync(fsStatType, statsMethodName, filePath) {
11343 if (typeof filePath !== 'string') {
11344 throw new TypeError(`Expected a string, got ${typeof filePath}`);
11348 return fs[fsStatType](filePath)[statsMethodName]();
11350 if (error.code === 'ENOENT') {
11358 var isFile = isType.bind(null, 'stat', 'isFile');
11359 var isDirectory = isType.bind(null, 'stat', 'isDirectory');
11360 var isSymlink = isType.bind(null, 'lstat', 'isSymbolicLink');
11361 var isFileSync = isTypeSync.bind(null, 'statSync', 'isFile');
11362 var isDirectorySync = isTypeSync.bind(null, 'statSync', 'isDirectory');
11363 var isSymlinkSync = isTypeSync.bind(null, 'lstatSync', 'isSymbolicLink');
11366 isDirectory: isDirectory,
11367 isSymlink: isSymlink,
11368 isFileSync: isFileSync,
11369 isDirectorySync: isDirectorySync,
11370 isSymlinkSync: isSymlinkSync
11373 var getDirectory_1 = createCommonjsModule(function (module, exports) {
11375 Object.defineProperty(exports, "__esModule", {
11378 exports.getDirectory = getDirectory;
11379 exports.getDirectorySync = getDirectorySync;
11381 var _path = _interopRequireDefault(path);
11383 function _interopRequireDefault(obj) {
11384 return obj && obj.__esModule ? obj : {
11389 async function getDirectory(filepath) {
11390 const filePathIsDirectory = await (0, pathType.isDirectory)(filepath);
11392 if (filePathIsDirectory === true) {
11396 const directory = _path.default.dirname(filepath);
11401 function getDirectorySync(filepath) {
11402 const filePathIsDirectory = (0, pathType.isDirectorySync)(filepath);
11404 if (filePathIsDirectory === true) {
11408 const directory = _path.default.dirname(filepath);
11413 unwrapExports(getDirectory_1);
11414 var getDirectory_2 = getDirectory_1.getDirectory;
11415 var getDirectory_3 = getDirectory_1.getDirectorySync;
11417 var Explorer_1 = createCommonjsModule(function (module, exports) {
11419 Object.defineProperty(exports, "__esModule", {
11422 exports.Explorer = void 0;
11424 var _path = _interopRequireDefault(path);
11426 function _interopRequireDefault(obj) {
11427 return obj && obj.__esModule ? obj : {
11432 function _asyncIterator(iterable) {
11435 if (typeof Symbol !== "undefined") {
11436 if (Symbol.asyncIterator) {
11437 method = iterable[Symbol.asyncIterator];
11438 if (method != null) return method.call(iterable);
11441 if (Symbol.iterator) {
11442 method = iterable[Symbol.iterator];
11443 if (method != null) return method.call(iterable);
11447 throw new TypeError("Object is not async iterable");
11450 class Explorer extends ExplorerBase_1.ExplorerBase {
11451 constructor(options) {
11455 async search(searchFrom = process.cwd()) {
11456 const startDirectory = await (0, getDirectory_1.getDirectory)(searchFrom);
11457 const result = await this.searchFromDirectory(startDirectory);
11461 async searchFromDirectory(dir) {
11462 const absoluteDir = _path.default.resolve(process.cwd(), dir);
11464 const run = async () => {
11465 const result = await this.searchDirectory(absoluteDir);
11466 const nextDir = this.nextDirectoryToSearch(absoluteDir, result);
11469 return this.searchFromDirectory(nextDir);
11472 const transformResult = await this.config.transform(result);
11473 return transformResult;
11476 if (this.searchCache) {
11477 return (0, cacheWrapper_1.cacheWrapper)(this.searchCache, absoluteDir, run);
11483 async searchDirectory(dir) {
11484 var _iteratorNormalCompletion = true;
11485 var _didIteratorError = false;
11487 var _iteratorError;
11490 for (var _iterator = _asyncIterator(this.config.searchPlaces), _step, _value; _step = await _iterator.next(), _iteratorNormalCompletion = _step.done, _value = await _step.value, !_iteratorNormalCompletion; _iteratorNormalCompletion = true) {
11491 const place = _value;
11492 const placeResult = await this.loadSearchPlace(dir, place);
11494 if (this.shouldSearchStopWithResult(placeResult) === true) {
11495 return placeResult;
11497 } // config not found
11500 _didIteratorError = true;
11501 _iteratorError = err;
11504 if (!_iteratorNormalCompletion && _iterator.return != null) {
11505 await _iterator.return();
11508 if (_didIteratorError) {
11509 throw _iteratorError;
11517 async loadSearchPlace(dir, place) {
11518 const filepath = _path.default.join(dir, place);
11520 const fileContents = await (0, readFile_1.readFile)(filepath);
11521 const result = await this.createCosmiconfigResult(filepath, fileContents);
11525 async loadFileContent(filepath, content) {
11526 if (content === null) {
11530 if (content.trim() === '') {
11534 const loader = this.getLoaderEntryForFile(filepath);
11535 const loaderResult = await loader(filepath, content);
11536 return loaderResult;
11539 async createCosmiconfigResult(filepath, content) {
11540 const fileContent = await this.loadFileContent(filepath, content);
11541 const result = this.loadedContentToCosmiconfigResult(filepath, fileContent);
11545 async load(filepath) {
11546 this.validateFilePath(filepath);
11548 const absoluteFilePath = _path.default.resolve(process.cwd(), filepath);
11550 const runLoad = async () => {
11551 const fileContents = await (0, readFile_1.readFile)(absoluteFilePath, {
11552 throwNotFound: true
11554 const result = await this.createCosmiconfigResult(absoluteFilePath, fileContents);
11555 const transformResult = await this.config.transform(result);
11556 return transformResult;
11559 if (this.loadCache) {
11560 return (0, cacheWrapper_1.cacheWrapper)(this.loadCache, absoluteFilePath, runLoad);
11568 exports.Explorer = Explorer;
11570 unwrapExports(Explorer_1);
11571 var Explorer_2 = Explorer_1.Explorer;
11573 var ExplorerSync_1 = createCommonjsModule(function (module, exports) {
11575 Object.defineProperty(exports, "__esModule", {
11578 exports.ExplorerSync = void 0;
11580 var _path = _interopRequireDefault(path);
11582 function _interopRequireDefault(obj) {
11583 return obj && obj.__esModule ? obj : {
11588 class ExplorerSync extends ExplorerBase_1.ExplorerBase {
11589 constructor(options) {
11593 searchSync(searchFrom = process.cwd()) {
11594 const startDirectory = (0, getDirectory_1.getDirectorySync)(searchFrom);
11595 const result = this.searchFromDirectorySync(startDirectory);
11599 searchFromDirectorySync(dir) {
11600 const absoluteDir = _path.default.resolve(process.cwd(), dir);
11602 const run = () => {
11603 const result = this.searchDirectorySync(absoluteDir);
11604 const nextDir = this.nextDirectoryToSearch(absoluteDir, result);
11607 return this.searchFromDirectorySync(nextDir);
11610 const transformResult = this.config.transform(result);
11611 return transformResult;
11614 if (this.searchCache) {
11615 return (0, cacheWrapper_1.cacheWrapperSync)(this.searchCache, absoluteDir, run);
11621 searchDirectorySync(dir) {
11622 for (const place of this.config.searchPlaces) {
11623 const placeResult = this.loadSearchPlaceSync(dir, place);
11625 if (this.shouldSearchStopWithResult(placeResult) === true) {
11626 return placeResult;
11628 } // config not found
11634 loadSearchPlaceSync(dir, place) {
11635 const filepath = _path.default.join(dir, place);
11637 const content = (0, readFile_1.readFileSync)(filepath);
11638 const result = this.createCosmiconfigResultSync(filepath, content);
11642 loadFileContentSync(filepath, content) {
11643 if (content === null) {
11647 if (content.trim() === '') {
11651 const loader = this.getLoaderEntryForFile(filepath);
11652 const loaderResult = loader(filepath, content);
11653 return loaderResult;
11656 createCosmiconfigResultSync(filepath, content) {
11657 const fileContent = this.loadFileContentSync(filepath, content);
11658 const result = this.loadedContentToCosmiconfigResult(filepath, fileContent);
11662 loadSync(filepath) {
11663 this.validateFilePath(filepath);
11665 const absoluteFilePath = _path.default.resolve(process.cwd(), filepath);
11667 const runLoadSync = () => {
11668 const content = (0, readFile_1.readFileSync)(absoluteFilePath, {
11669 throwNotFound: true
11671 const cosmiconfigResult = this.createCosmiconfigResultSync(absoluteFilePath, content);
11672 const transformResult = this.config.transform(cosmiconfigResult);
11673 return transformResult;
11676 if (this.loadCache) {
11677 return (0, cacheWrapper_1.cacheWrapperSync)(this.loadCache, absoluteFilePath, runLoadSync);
11680 return runLoadSync();
11685 exports.ExplorerSync = ExplorerSync;
11687 unwrapExports(ExplorerSync_1);
11688 var ExplorerSync_2 = ExplorerSync_1.ExplorerSync;
11690 var dist$2 = createCommonjsModule(function (module, exports) {
11692 Object.defineProperty(exports, "__esModule", {
11695 exports.cosmiconfig = cosmiconfig;
11696 exports.cosmiconfigSync = cosmiconfigSync;
11697 exports.defaultLoaders = void 0;
11699 var _os = _interopRequireDefault(os);
11701 function _interopRequireDefault(obj) {
11702 return obj && obj.__esModule ? obj : {
11705 } // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
11708 function cosmiconfig(moduleName, options = {}) {
11709 const normalizedOptions = normalizeOptions(moduleName, options);
11710 const explorer = new Explorer_1.Explorer(normalizedOptions);
11712 search: explorer.search.bind(explorer),
11713 load: explorer.load.bind(explorer),
11714 clearLoadCache: explorer.clearLoadCache.bind(explorer),
11715 clearSearchCache: explorer.clearSearchCache.bind(explorer),
11716 clearCaches: explorer.clearCaches.bind(explorer)
11718 } // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
11721 function cosmiconfigSync(moduleName, options = {}) {
11722 const normalizedOptions = normalizeOptions(moduleName, options);
11723 const explorerSync = new ExplorerSync_1.ExplorerSync(normalizedOptions);
11725 search: explorerSync.searchSync.bind(explorerSync),
11726 load: explorerSync.loadSync.bind(explorerSync),
11727 clearLoadCache: explorerSync.clearLoadCache.bind(explorerSync),
11728 clearSearchCache: explorerSync.clearSearchCache.bind(explorerSync),
11729 clearCaches: explorerSync.clearCaches.bind(explorerSync)
11731 } // do not allow mutation of default loaders. Make sure it is set inside options
11734 const defaultLoaders = Object.freeze({
11735 '.js': loaders_1.loaders.loadJs,
11736 '.json': loaders_1.loaders.loadJson,
11737 '.yaml': loaders_1.loaders.loadYaml,
11738 '.yml': loaders_1.loaders.loadYaml,
11739 noExt: loaders_1.loaders.loadYaml
11741 exports.defaultLoaders = defaultLoaders;
11743 function normalizeOptions(moduleName, options) {
11745 packageProp: moduleName,
11746 searchPlaces: ['package.json', `.${moduleName}rc`, `.${moduleName}rc.json`, `.${moduleName}rc.yaml`, `.${moduleName}rc.yml`, `.${moduleName}rc.js`, `${moduleName}.config.js`],
11747 ignoreEmptySearchPlaces: true,
11748 stopDir: _os.default.homedir(),
11750 transform: identity,
11751 loaders: defaultLoaders
11753 const normalizedOptions = Object.assign({}, defaults, {}, options, {
11754 loaders: Object.assign({}, defaults.loaders, {}, options.loaders)
11756 return normalizedOptions;
11759 const identity = function identity(x) {
11763 unwrapExports(dist$2);
11764 var dist_1 = dist$2.cosmiconfig;
11765 var dist_2 = dist$2.cosmiconfigSync;
11766 var dist_3 = dist$2.defaultLoaders;
11768 var findParentDir = createCommonjsModule(function (module, exports) {
11770 var exists = fs.exists || path.exists,
11771 existsSync = fs.existsSync || path.existsSync;
11773 function splitPath(path) {
11774 var parts = path.split(/(\/|\\)/);
11775 if (!parts.length) return parts; // when path starts with a slash, the first part is empty string
11777 return !parts[0].length ? parts.slice(1) : parts;
11780 exports = module.exports = function (currentFullPath, clue, cb) {
11781 function testDir(parts) {
11782 if (parts.length === 0) return cb(null, null);
11783 var p = parts.join('');
11784 exists(path.join(p, clue), function (itdoes) {
11785 if (itdoes) return cb(null, p);
11786 testDir(parts.slice(0, -1));
11790 testDir(splitPath(currentFullPath));
11793 exports.sync = function (currentFullPath, clue) {
11794 function testDir(parts) {
11795 if (parts.length === 0) return null;
11796 var p = parts.join('');
11797 var itdoes = existsSync(path.join(p, clue));
11798 return itdoes ? p : testDir(parts.slice(0, -1));
11801 return testDir(splitPath(currentFullPath));
11804 var findParentDir_1 = findParentDir.sync;
11806 // Returns a wrapper function that returns a wrapped callback
11807 // The wrapper function should do some stuff, and return a
11808 // presumably different callback function.
11809 // This makes sure that own properties are retained, so that
11810 // decorations and such are not lost along the way.
11811 var wrappy_1 = wrappy;
11813 function wrappy(fn, cb) {
11814 if (fn && cb) return wrappy(fn)(cb);
11815 if (typeof fn !== 'function') throw new TypeError('need wrapper function');
11816 Object.keys(fn).forEach(function (k) {
11817 wrapper[k] = fn[k];
11821 function wrapper() {
11822 var args = new Array(arguments.length);
11824 for (var i = 0; i < args.length; i++) {
11825 args[i] = arguments[i];
11828 var ret = fn.apply(this, args);
11829 var cb = args[args.length - 1];
11831 if (typeof ret === 'function' && ret !== cb) {
11832 Object.keys(cb).forEach(function (k) {
11841 var once_1 = wrappy_1(once);
11842 var strict = wrappy_1(onceStrict);
11843 once.proto = once(function () {
11844 Object.defineProperty(Function.prototype, 'once', {
11845 value: function () {
11850 Object.defineProperty(Function.prototype, 'onceStrict', {
11851 value: function () {
11852 return onceStrict(this);
11858 function once(fn) {
11859 var f = function () {
11860 if (f.called) return f.value;
11862 return f.value = fn.apply(this, arguments);
11869 function onceStrict(fn) {
11870 var f = function () {
11871 if (f.called) throw new Error(f.onceError);
11873 return f.value = fn.apply(this, arguments);
11876 var name = fn.name || 'Function wrapped with `once`';
11877 f.onceError = name + " shouldn't be called more than once";
11881 once_1.strict = strict;
11883 var noop = function () {};
11885 var isRequest = function (stream) {
11886 return stream.setHeader && typeof stream.abort === 'function';
11889 var isChildProcess = function (stream) {
11890 return stream.stdio && Array.isArray(stream.stdio) && stream.stdio.length === 3;
11893 var eos = function (stream, opts, callback) {
11894 if (typeof opts === 'function') return eos(stream, null, opts);
11895 if (!opts) opts = {};
11896 callback = once_1(callback || noop);
11897 var ws = stream._writableState;
11898 var rs = stream._readableState;
11899 var readable = opts.readable || opts.readable !== false && stream.readable;
11900 var writable = opts.writable || opts.writable !== false && stream.writable;
11901 var cancelled = false;
11903 var onlegacyfinish = function () {
11904 if (!stream.writable) onfinish();
11907 var onfinish = function () {
11909 if (!readable) callback.call(stream);
11912 var onend = function () {
11914 if (!writable) callback.call(stream);
11917 var onexit = function (exitCode) {
11918 callback.call(stream, exitCode ? new Error('exited with error code: ' + exitCode) : null);
11921 var onerror = function (err) {
11922 callback.call(stream, err);
11925 var onclose = function () {
11926 process.nextTick(onclosenexttick);
11929 var onclosenexttick = function () {
11930 if (cancelled) return;
11931 if (readable && !(rs && rs.ended && !rs.destroyed)) return callback.call(stream, new Error('premature close'));
11932 if (writable && !(ws && ws.ended && !ws.destroyed)) return callback.call(stream, new Error('premature close'));
11935 var onrequest = function () {
11936 stream.req.on('finish', onfinish);
11939 if (isRequest(stream)) {
11940 stream.on('complete', onfinish);
11941 stream.on('abort', onclose);
11942 if (stream.req) onrequest();else stream.on('request', onrequest);
11943 } else if (writable && !ws) {
11945 stream.on('end', onlegacyfinish);
11946 stream.on('close', onlegacyfinish);
11949 if (isChildProcess(stream)) stream.on('exit', onexit);
11950 stream.on('end', onend);
11951 stream.on('finish', onfinish);
11952 if (opts.error !== false) stream.on('error', onerror);
11953 stream.on('close', onclose);
11954 return function () {
11956 stream.removeListener('complete', onfinish);
11957 stream.removeListener('abort', onclose);
11958 stream.removeListener('request', onrequest);
11959 if (stream.req) stream.req.removeListener('finish', onfinish);
11960 stream.removeListener('end', onlegacyfinish);
11961 stream.removeListener('close', onlegacyfinish);
11962 stream.removeListener('finish', onfinish);
11963 stream.removeListener('exit', onexit);
11964 stream.removeListener('end', onend);
11965 stream.removeListener('error', onerror);
11966 stream.removeListener('close', onclose);
11970 var endOfStream = eos;
11972 var noop$1 = function () {};
11974 var ancient = /^v?\.0/.test(process.version);
11976 var isFn = function (fn) {
11977 return typeof fn === 'function';
11980 var isFS = function (stream) {
11981 if (!ancient) return false; // newer node version do not need to care about fs is a special way
11983 if (!fs) return false; // browser
11985 return (stream instanceof (fs.ReadStream || noop$1) || stream instanceof (fs.WriteStream || noop$1)) && isFn(stream.close);
11988 var isRequest$1 = function (stream) {
11989 return stream.setHeader && isFn(stream.abort);
11992 var destroyer = function (stream, reading, writing, callback) {
11993 callback = once_1(callback);
11994 var closed = false;
11995 stream.on('close', function () {
11998 endOfStream(stream, {
12001 }, function (err) {
12002 if (err) return callback(err);
12006 var destroyed = false;
12007 return function (err) {
12008 if (closed) return;
12009 if (destroyed) return;
12011 if (isFS(stream)) return stream.close(noop$1); // use close for fs streams to avoid fd leaks
12013 if (isRequest$1(stream)) return stream.abort(); // request.destroy just do .end - .abort is what we want
12015 if (isFn(stream.destroy)) return stream.destroy();
12016 callback(err || new Error('stream was destroyed'));
12020 var call = function (fn) {
12024 var pipe = function (from, to) {
12025 return from.pipe(to);
12028 var pump = function () {
12029 var streams = Array.prototype.slice.call(arguments);
12030 var callback = isFn(streams[streams.length - 1] || noop$1) && streams.pop() || noop$1;
12031 if (Array.isArray(streams[0])) streams = streams[0];
12032 if (streams.length < 2) throw new Error('pump requires two streams per minimum');
12034 var destroys = streams.map(function (stream, i) {
12035 var reading = i < streams.length - 1;
12036 var writing = i > 0;
12037 return destroyer(stream, reading, writing, function (err) {
12038 if (!error) error = err;
12039 if (err) destroys.forEach(call);
12040 if (reading) return;
12041 destroys.forEach(call);
12045 return streams.reduce(pipe);
12051 PassThrough: PassThroughStream
12054 var bufferStream = options => {
12055 options = Object.assign({}, options);
12062 const isBuffer = encoding === 'buffer';
12063 let objectMode = false;
12066 objectMode = !(encoding || isBuffer);
12068 encoding = encoding || 'utf8';
12075 const stream = new PassThroughStream({
12080 stream.setEncoding(encoding);
12085 stream.on('data', chunk => {
12086 chunks.push(chunk);
12089 length = chunks.length;
12091 length += chunk.length;
12095 stream.getBufferedValue = () => {
12100 return isBuffer ? Buffer.concat(chunks, length) : chunks.join('');
12103 stream.getBufferedLength = () => length;
12108 class MaxBufferError extends Error {
12110 super('maxBuffer exceeded');
12111 this.name = 'MaxBufferError';
12116 async function getStream(inputStream, options) {
12117 if (!inputStream) {
12118 return Promise.reject(new Error('Expected a stream'));
12121 options = Object.assign({
12122 maxBuffer: Infinity
12128 await new Promise((resolve, reject) => {
12129 const rejectPromise = error => {
12132 error.bufferedData = stream.getBufferedValue();
12138 stream = pump_1(inputStream, bufferStream(options), error => {
12140 rejectPromise(error);
12146 stream.on('data', () => {
12147 if (stream.getBufferedLength() > maxBuffer) {
12148 rejectPromise(new MaxBufferError());
12152 return stream.getBufferedValue();
12155 var getStream_1 = getStream; // TODO: Remove this for the next major release
12157 var default_1 = getStream;
12159 var buffer = (stream, options) => getStream(stream, Object.assign({}, options, {
12163 var array = (stream, options) => getStream(stream, Object.assign({}, options, {
12167 var MaxBufferError_1 = MaxBufferError;
12168 getStream_1.default = default_1;
12169 getStream_1.buffer = buffer;
12170 getStream_1.array = array;
12171 getStream_1.MaxBufferError = MaxBufferError_1;
12176 constant: "APPVEYOR",
12178 pr: "APPVEYOR_PULL_REQUEST_NUMBER"
12181 name: "Azure Pipelines",
12182 constant: "AZURE_PIPELINES",
12183 env: "SYSTEM_TEAMFOUNDATIONCOLLECTIONURI",
12184 pr: "SYSTEM_PULLREQUEST_PULLREQUESTID"
12188 constant: "BAMBOO",
12189 env: "bamboo_planKey"
12192 name: "Bitbucket Pipelines",
12193 constant: "BITBUCKET",
12194 env: "BITBUCKET_COMMIT",
12195 pr: "BITBUCKET_PR_ID"
12199 constant: "BITRISE",
12201 pr: "BITRISE_PULL_REQUEST"
12206 env: "BUDDY_WORKSPACE_ID",
12207 pr: "BUDDY_EXECUTION_PULL_REQUEST_ID"
12211 constant: "BUILDKITE",
12214 env: "BUILDKITE_PULL_REQUEST",
12220 constant: "CIRCLE",
12222 pr: "CIRCLE_PULL_REQUEST"
12226 constant: "CIRRUS",
12231 name: "AWS CodeBuild",
12232 constant: "CODEBUILD",
12233 env: "CODEBUILD_BUILD_ARN"
12237 constant: "CODESHIP",
12239 CI_NAME: "codeship"
12247 DRONE_BUILD_EVENT: "pull_request"
12256 name: "GitHub Actions",
12257 constant: "GITHUB_ACTIONS",
12258 env: "GITHUB_ACTIONS",
12260 GITHUB_EVENT_NAME: "pull_request"
12265 constant: "GITLAB",
12271 env: "GO_PIPELINE_LABEL"
12275 constant: "HUDSON",
12280 constant: "JENKINS",
12294 constant: "ZEIT_NOW",
12299 constant: "MAGNUM",
12303 name: "Netlify CI",
12304 constant: "NETLIFY",
12307 env: "PULL_REQUEST",
12313 constant: "NEVERCODE",
12316 env: "NEVERCODE_PULL_REQUEST",
12322 constant: "RENDER",
12325 IS_PULL_REQUEST: "true"
12332 pr: "SAIL_PULL_REQUEST_NUMBER"
12336 constant: "SEMAPHORE",
12338 pr: "PULL_REQUEST_NUMBER"
12342 constant: "SHIPPABLE",
12345 IS_PULL_REQUEST: "true"
12350 constant: "SOLANO",
12355 name: "Strider CD",
12356 constant: "STRIDER",
12360 name: "TaskCluster",
12361 constant: "TASKCLUSTER",
12369 constant: "TEAMCITY",
12370 env: "TEAMCITY_VERSION"
12374 constant: "TRAVIS",
12377 env: "TRAVIS_PULL_REQUEST",
12383 var vendors$1 = /*#__PURE__*/Object.freeze({
12388 var vendors$2 = getCjsExportFromNamespace(vendors$1);
12390 var ciInfo = createCommonjsModule(function (module, exports) {
12392 var env = process.env; // Used for testing only
12394 Object.defineProperty(exports, '_vendors', {
12395 value: vendors$2.map(function (v) {
12399 exports.name = null;
12400 exports.isPR = null;
12401 vendors$2.forEach(function (vendor) {
12402 var envs = Array.isArray(vendor.env) ? vendor.env : [vendor.env];
12403 var isCI = envs.every(function (obj) {
12404 return checkEnv(obj);
12406 exports[vendor.constant] = isCI;
12409 exports.name = vendor.name;
12411 switch (typeof vendor.pr) {
12413 // "pr": "CIRRUS_PR"
12414 exports.isPR = !!env[vendor.pr];
12418 if ('env' in vendor.pr) {
12419 // "pr": { "env": "BUILDKITE_PULL_REQUEST", "ne": "false" }
12420 exports.isPR = vendor.pr.env in env && env[vendor.pr.env] !== vendor.pr.ne;
12421 } else if ('any' in vendor.pr) {
12422 // "pr": { "any": ["ghprbPullId", "CHANGE_ID"] }
12423 exports.isPR = vendor.pr.any.some(function (key) {
12427 // "pr": { "DRONE_BUILD_EVENT": "pull_request" }
12428 exports.isPR = checkEnv(vendor.pr);
12434 // PR detection not supported for this vendor
12435 exports.isPR = null;
12439 exports.isCI = !!(env.CI || // Travis CI, CircleCI, Cirrus CI, Gitlab CI, Appveyor, CodeShip, dsari
12440 env.CONTINUOUS_INTEGRATION || // Travis CI, Cirrus CI
12441 env.BUILD_NUMBER || // Jenkins, TeamCity
12442 env.RUN_ID || // TaskCluster, dsari
12443 exports.name || false);
12445 function checkEnv(obj) {
12446 if (typeof obj === 'string') return !!env[obj];
12447 return Object.keys(obj).every(function (k) {
12448 return env[k] === obj[k];
12452 var ciInfo_1 = ciInfo.name;
12453 var ciInfo_2 = ciInfo.isPR;
12454 var ciInfo_3 = ciInfo.isCI;
12457 cosmiconfig: dist$2.cosmiconfig,
12458 cosmiconfigSync: dist$2.cosmiconfigSync,
12459 findParentDir: findParentDir.sync,
12460 getStream: getStream_1,
12461 isCI: () => ciInfo.isCI
12463 var thirdParty_1 = thirdParty.cosmiconfig;
12464 var thirdParty_2 = thirdParty.cosmiconfigSync;
12465 var thirdParty_3 = thirdParty.findParentDir;
12466 var thirdParty_4 = thirdParty.getStream;
12467 var thirdParty_5 = thirdParty.isCI;
12469 exports.cosmiconfig = thirdParty_1;
12470 exports.cosmiconfigSync = thirdParty_2;
12471 exports.default = thirdParty;
12472 exports.findParentDir = thirdParty_3;
12473 exports.getStream = thirdParty_4;
12474 exports.isCI = thirdParty_5;