/******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ /***/ "./node_modules/acorn-jsx/index.js": /*!*****************************************!*\ !*** ./node_modules/acorn-jsx/index.js ***! \*****************************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; const XHTMLEntities = __webpack_require__(/*! ./xhtml */ "./node_modules/acorn-jsx/xhtml.js"); const hexNumber = /^[\da-fA-F]+$/; const decimalNumber = /^\d+$/; // The map to `acorn-jsx` tokens from `acorn` namespace objects. const acornJsxMap = new WeakMap(); // Get the original tokens for the given `acorn` namespace object. function getJsxTokens(acorn) { acorn = acorn.Parser.acorn || acorn; let acornJsx = acornJsxMap.get(acorn); if (!acornJsx) { const tt = acorn.tokTypes; const TokContext = acorn.TokContext; const TokenType = acorn.TokenType; const tc_oTag = new TokContext('...', true, true); const tokContexts = { tc_oTag: tc_oTag, tc_cTag: tc_cTag, tc_expr: tc_expr }; const tokTypes = { jsxName: new TokenType('jsxName'), jsxText: new TokenType('jsxText', {beforeExpr: true}), jsxTagStart: new TokenType('jsxTagStart', {startsExpr: true}), jsxTagEnd: new TokenType('jsxTagEnd') }; tokTypes.jsxTagStart.updateContext = function() { this.context.push(tc_expr); // treat as beginning of JSX expression this.context.push(tc_oTag); // start opening tag context this.exprAllowed = false; }; tokTypes.jsxTagEnd.updateContext = function(prevType) { let out = this.context.pop(); if (out === tc_oTag && prevType === tt.slash || out === tc_cTag) { this.context.pop(); this.exprAllowed = this.curContext() === tc_expr; } else { this.exprAllowed = true; } }; acornJsx = { tokContexts: tokContexts, tokTypes: tokTypes }; acornJsxMap.set(acorn, acornJsx); } return acornJsx; } // Transforms JSX element name to string. function getQualifiedJSXName(object) { if (!object) return object; if (object.type === 'JSXIdentifier') return object.name; if (object.type === 'JSXNamespacedName') return object.namespace.name + ':' + object.name.name; if (object.type === 'JSXMemberExpression') return getQualifiedJSXName(object.object) + '.' + getQualifiedJSXName(object.property); } module.exports = function(options) { options = options || {}; return function(Parser) { return plugin({ allowNamespaces: options.allowNamespaces !== false, allowNamespacedObjects: !!options.allowNamespacedObjects }, Parser); }; }; // This is `tokTypes` of the peer dep. // This can be different instances from the actual `tokTypes` this plugin uses. Object.defineProperty(module.exports, "tokTypes", ({ get: function get_tokTypes() { return getJsxTokens(__webpack_require__(/*! acorn */ "./node_modules/acorn/dist/acorn.js")).tokTypes; }, configurable: true, enumerable: true })); function plugin(options, Parser) { const acorn = Parser.acorn || __webpack_require__(/*! acorn */ "./node_modules/acorn/dist/acorn.js"); const acornJsx = getJsxTokens(acorn); const tt = acorn.tokTypes; const tok = acornJsx.tokTypes; const tokContexts = acorn.tokContexts; const tc_oTag = acornJsx.tokContexts.tc_oTag; const tc_cTag = acornJsx.tokContexts.tc_cTag; const tc_expr = acornJsx.tokContexts.tc_expr; const isNewLine = acorn.isNewLine; const isIdentifierStart = acorn.isIdentifierStart; const isIdentifierChar = acorn.isIdentifierChar; return class extends Parser { // Expose actual `tokTypes` and `tokContexts` to other plugins. static get acornJsx() { return acornJsx; } // Reads inline JSX contents token. jsx_readToken() { let out = '', chunkStart = this.pos; for (;;) { if (this.pos >= this.input.length) this.raise(this.start, 'Unterminated JSX contents'); let ch = this.input.charCodeAt(this.pos); switch (ch) { case 60: // '<' case 123: // '{' if (this.pos === this.start) { if (ch === 60 && this.exprAllowed) { ++this.pos; return this.finishToken(tok.jsxTagStart); } return this.getTokenFromCode(ch); } out += this.input.slice(chunkStart, this.pos); return this.finishToken(tok.jsxText, out); case 38: // '&' out += this.input.slice(chunkStart, this.pos); out += this.jsx_readEntity(); chunkStart = this.pos; break; case 62: // '>' case 125: // '}' this.raise( this.pos, "Unexpected token `" + this.input[this.pos] + "`. Did you mean `" + (ch === 62 ? ">" : "}") + "` or " + "`{\"" + this.input[this.pos] + "\"}" + "`?" ); default: if (isNewLine(ch)) { out += this.input.slice(chunkStart, this.pos); out += this.jsx_readNewLine(true); chunkStart = this.pos; } else { ++this.pos; } } } } jsx_readNewLine(normalizeCRLF) { let ch = this.input.charCodeAt(this.pos); let out; ++this.pos; if (ch === 13 && this.input.charCodeAt(this.pos) === 10) { ++this.pos; out = normalizeCRLF ? '\n' : '\r\n'; } else { out = String.fromCharCode(ch); } if (this.options.locations) { ++this.curLine; this.lineStart = this.pos; } return out; } jsx_readString(quote) { let out = '', chunkStart = ++this.pos; for (;;) { if (this.pos >= this.input.length) this.raise(this.start, 'Unterminated string constant'); let ch = this.input.charCodeAt(this.pos); if (ch === quote) break; if (ch === 38) { // '&' out += this.input.slice(chunkStart, this.pos); out += this.jsx_readEntity(); chunkStart = this.pos; } else if (isNewLine(ch)) { out += this.input.slice(chunkStart, this.pos); out += this.jsx_readNewLine(false); chunkStart = this.pos; } else { ++this.pos; } } out += this.input.slice(chunkStart, this.pos++); return this.finishToken(tt.string, out); } jsx_readEntity() { let str = '', count = 0, entity; let ch = this.input[this.pos]; if (ch !== '&') this.raise(this.pos, 'Entity must start with an ampersand'); let startPos = ++this.pos; while (this.pos < this.input.length && count++ < 10) { ch = this.input[this.pos++]; if (ch === ';') { if (str[0] === '#') { if (str[1] === 'x') { str = str.substr(2); if (hexNumber.test(str)) entity = String.fromCharCode(parseInt(str, 16)); } else { str = str.substr(1); if (decimalNumber.test(str)) entity = String.fromCharCode(parseInt(str, 10)); } } else { entity = XHTMLEntities[str]; } break; } str += ch; } if (!entity) { this.pos = startPos; return '&'; } return entity; } // Read a JSX identifier (valid tag or attribute name). // // Optimized version since JSX identifiers can't contain // escape characters and so can be read as single slice. // Also assumes that first character was already checked // by isIdentifierStart in readToken. jsx_readWord() { let ch, start = this.pos; do { ch = this.input.charCodeAt(++this.pos); } while (isIdentifierChar(ch) || ch === 45); // '-' return this.finishToken(tok.jsxName, this.input.slice(start, this.pos)); } // Parse next token as JSX identifier jsx_parseIdentifier() { let node = this.startNode(); if (this.type === tok.jsxName) node.name = this.value; else if (this.type.keyword) node.name = this.type.keyword; else this.unexpected(); this.next(); return this.finishNode(node, 'JSXIdentifier'); } // Parse namespaced identifier. jsx_parseNamespacedName() { let startPos = this.start, startLoc = this.startLoc; let name = this.jsx_parseIdentifier(); if (!options.allowNamespaces || !this.eat(tt.colon)) return name; var node = this.startNodeAt(startPos, startLoc); node.namespace = name; node.name = this.jsx_parseIdentifier(); return this.finishNode(node, 'JSXNamespacedName'); } // Parses element name in any form - namespaced, member // or single identifier. jsx_parseElementName() { if (this.type === tok.jsxTagEnd) return ''; let startPos = this.start, startLoc = this.startLoc; let node = this.jsx_parseNamespacedName(); if (this.type === tt.dot && node.type === 'JSXNamespacedName' && !options.allowNamespacedObjects) { this.unexpected(); } while (this.eat(tt.dot)) { let newNode = this.startNodeAt(startPos, startLoc); newNode.object = node; newNode.property = this.jsx_parseIdentifier(); node = this.finishNode(newNode, 'JSXMemberExpression'); } return node; } // Parses any type of JSX attribute value. jsx_parseAttributeValue() { switch (this.type) { case tt.braceL: let node = this.jsx_parseExpressionContainer(); if (node.expression.type === 'JSXEmptyExpression') this.raise(node.start, 'JSX attributes must only be assigned a non-empty expression'); return node; case tok.jsxTagStart: case tt.string: return this.parseExprAtom(); default: this.raise(this.start, 'JSX value should be either an expression or a quoted JSX text'); } } // JSXEmptyExpression is unique type since it doesn't actually parse anything, // and so it should start at the end of last read token (left brace) and finish // at the beginning of the next one (right brace). jsx_parseEmptyExpression() { let node = this.startNodeAt(this.lastTokEnd, this.lastTokEndLoc); return this.finishNodeAt(node, 'JSXEmptyExpression', this.start, this.startLoc); } // Parses JSX expression enclosed into curly brackets. jsx_parseExpressionContainer() { let node = this.startNode(); this.next(); node.expression = this.type === tt.braceR ? this.jsx_parseEmptyExpression() : this.parseExpression(); this.expect(tt.braceR); return this.finishNode(node, 'JSXExpressionContainer'); } // Parses following JSX attribute name-value pair. jsx_parseAttribute() { let node = this.startNode(); if (this.eat(tt.braceL)) { this.expect(tt.ellipsis); node.argument = this.parseMaybeAssign(); this.expect(tt.braceR); return this.finishNode(node, 'JSXSpreadAttribute'); } node.name = this.jsx_parseNamespacedName(); node.value = this.eat(tt.eq) ? this.jsx_parseAttributeValue() : null; return this.finishNode(node, 'JSXAttribute'); } // Parses JSX opening tag starting after '<'. jsx_parseOpeningElementAt(startPos, startLoc) { let node = this.startNodeAt(startPos, startLoc); node.attributes = []; let nodeName = this.jsx_parseElementName(); if (nodeName) node.name = nodeName; while (this.type !== tt.slash && this.type !== tok.jsxTagEnd) node.attributes.push(this.jsx_parseAttribute()); node.selfClosing = this.eat(tt.slash); this.expect(tok.jsxTagEnd); return this.finishNode(node, nodeName ? 'JSXOpeningElement' : 'JSXOpeningFragment'); } // Parses JSX closing tag starting after ''); } } let fragmentOrElement = openingElement.name ? 'Element' : 'Fragment'; node['opening' + fragmentOrElement] = openingElement; node['closing' + fragmentOrElement] = closingElement; node.children = children; if (this.type === tt.relational && this.value === "<") { this.raise(this.start, "Adjacent JSX elements must be wrapped in an enclosing tag"); } return this.finishNode(node, 'JSX' + fragmentOrElement); } // Parse JSX text jsx_parseText() { let node = this.parseLiteral(this.value); node.type = "JSXText"; return node; } // Parses entire JSX element from current position. jsx_parseElement() { let startPos = this.start, startLoc = this.startLoc; this.next(); return this.jsx_parseElementAt(startPos, startLoc); } parseExprAtom(refShortHandDefaultPos) { if (this.type === tok.jsxText) return this.jsx_parseText(); else if (this.type === tok.jsxTagStart) return this.jsx_parseElement(); else return super.parseExprAtom(refShortHandDefaultPos); } readToken(code) { let context = this.curContext(); if (context === tc_expr) return this.jsx_readToken(); if (context === tc_oTag || context === tc_cTag) { if (isIdentifierStart(code)) return this.jsx_readWord(); if (code == 62) { ++this.pos; return this.finishToken(tok.jsxTagEnd); } if ((code === 34 || code === 39) && context == tc_oTag) return this.jsx_readString(code); } if (code === 60 && this.exprAllowed && this.input.charCodeAt(this.pos + 1) !== 33) { ++this.pos; return this.finishToken(tok.jsxTagStart); } return super.readToken(code); } updateContext(prevType) { if (this.type == tt.braceL) { var curContext = this.curContext(); if (curContext == tc_oTag) this.context.push(tokContexts.b_expr); else if (curContext == tc_expr) this.context.push(tokContexts.b_tmpl); else super.updateContext(prevType); this.exprAllowed = true; } else if (this.type === tt.slash && prevType === tok.jsxTagStart) { this.context.length -= 2; // do not consider JSX expr -> JSX open tag -> ... anymore this.context.push(tc_cTag); // reconsider as closing tag context this.exprAllowed = false; } else { return super.updateContext(prevType); } } }; } /***/ }), /***/ "./node_modules/acorn-jsx/xhtml.js": /*!*****************************************!*\ !*** ./node_modules/acorn-jsx/xhtml.js ***! \*****************************************/ /***/ ((module) => { module.exports = { quot: '\u0022', amp: '&', apos: '\u0027', lt: '<', gt: '>', nbsp: '\u00A0', iexcl: '\u00A1', cent: '\u00A2', pound: '\u00A3', curren: '\u00A4', yen: '\u00A5', brvbar: '\u00A6', sect: '\u00A7', uml: '\u00A8', copy: '\u00A9', ordf: '\u00AA', laquo: '\u00AB', not: '\u00AC', shy: '\u00AD', reg: '\u00AE', macr: '\u00AF', deg: '\u00B0', plusmn: '\u00B1', sup2: '\u00B2', sup3: '\u00B3', acute: '\u00B4', micro: '\u00B5', para: '\u00B6', middot: '\u00B7', cedil: '\u00B8', sup1: '\u00B9', ordm: '\u00BA', raquo: '\u00BB', frac14: '\u00BC', frac12: '\u00BD', frac34: '\u00BE', iquest: '\u00BF', Agrave: '\u00C0', Aacute: '\u00C1', Acirc: '\u00C2', Atilde: '\u00C3', Auml: '\u00C4', Aring: '\u00C5', AElig: '\u00C6', Ccedil: '\u00C7', Egrave: '\u00C8', Eacute: '\u00C9', Ecirc: '\u00CA', Euml: '\u00CB', Igrave: '\u00CC', Iacute: '\u00CD', Icirc: '\u00CE', Iuml: '\u00CF', ETH: '\u00D0', Ntilde: '\u00D1', Ograve: '\u00D2', Oacute: '\u00D3', Ocirc: '\u00D4', Otilde: '\u00D5', Ouml: '\u00D6', times: '\u00D7', Oslash: '\u00D8', Ugrave: '\u00D9', Uacute: '\u00DA', Ucirc: '\u00DB', Uuml: '\u00DC', Yacute: '\u00DD', THORN: '\u00DE', szlig: '\u00DF', agrave: '\u00E0', aacute: '\u00E1', acirc: '\u00E2', atilde: '\u00E3', auml: '\u00E4', aring: '\u00E5', aelig: '\u00E6', ccedil: '\u00E7', egrave: '\u00E8', eacute: '\u00E9', ecirc: '\u00EA', euml: '\u00EB', igrave: '\u00EC', iacute: '\u00ED', icirc: '\u00EE', iuml: '\u00EF', eth: '\u00F0', ntilde: '\u00F1', ograve: '\u00F2', oacute: '\u00F3', ocirc: '\u00F4', otilde: '\u00F5', ouml: '\u00F6', divide: '\u00F7', oslash: '\u00F8', ugrave: '\u00F9', uacute: '\u00FA', ucirc: '\u00FB', uuml: '\u00FC', yacute: '\u00FD', thorn: '\u00FE', yuml: '\u00FF', OElig: '\u0152', oelig: '\u0153', Scaron: '\u0160', scaron: '\u0161', Yuml: '\u0178', fnof: '\u0192', circ: '\u02C6', tilde: '\u02DC', Alpha: '\u0391', Beta: '\u0392', Gamma: '\u0393', Delta: '\u0394', Epsilon: '\u0395', Zeta: '\u0396', Eta: '\u0397', Theta: '\u0398', Iota: '\u0399', Kappa: '\u039A', Lambda: '\u039B', Mu: '\u039C', Nu: '\u039D', Xi: '\u039E', Omicron: '\u039F', Pi: '\u03A0', Rho: '\u03A1', Sigma: '\u03A3', Tau: '\u03A4', Upsilon: '\u03A5', Phi: '\u03A6', Chi: '\u03A7', Psi: '\u03A8', Omega: '\u03A9', alpha: '\u03B1', beta: '\u03B2', gamma: '\u03B3', delta: '\u03B4', epsilon: '\u03B5', zeta: '\u03B6', eta: '\u03B7', theta: '\u03B8', iota: '\u03B9', kappa: '\u03BA', lambda: '\u03BB', mu: '\u03BC', nu: '\u03BD', xi: '\u03BE', omicron: '\u03BF', pi: '\u03C0', rho: '\u03C1', sigmaf: '\u03C2', sigma: '\u03C3', tau: '\u03C4', upsilon: '\u03C5', phi: '\u03C6', chi: '\u03C7', psi: '\u03C8', omega: '\u03C9', thetasym: '\u03D1', upsih: '\u03D2', piv: '\u03D6', ensp: '\u2002', emsp: '\u2003', thinsp: '\u2009', zwnj: '\u200C', zwj: '\u200D', lrm: '\u200E', rlm: '\u200F', ndash: '\u2013', mdash: '\u2014', lsquo: '\u2018', rsquo: '\u2019', sbquo: '\u201A', ldquo: '\u201C', rdquo: '\u201D', bdquo: '\u201E', dagger: '\u2020', Dagger: '\u2021', bull: '\u2022', hellip: '\u2026', permil: '\u2030', prime: '\u2032', Prime: '\u2033', lsaquo: '\u2039', rsaquo: '\u203A', oline: '\u203E', frasl: '\u2044', euro: '\u20AC', image: '\u2111', weierp: '\u2118', real: '\u211C', trade: '\u2122', alefsym: '\u2135', larr: '\u2190', uarr: '\u2191', rarr: '\u2192', darr: '\u2193', harr: '\u2194', crarr: '\u21B5', lArr: '\u21D0', uArr: '\u21D1', rArr: '\u21D2', dArr: '\u21D3', hArr: '\u21D4', forall: '\u2200', part: '\u2202', exist: '\u2203', empty: '\u2205', nabla: '\u2207', isin: '\u2208', notin: '\u2209', ni: '\u220B', prod: '\u220F', sum: '\u2211', minus: '\u2212', lowast: '\u2217', radic: '\u221A', prop: '\u221D', infin: '\u221E', ang: '\u2220', and: '\u2227', or: '\u2228', cap: '\u2229', cup: '\u222A', 'int': '\u222B', there4: '\u2234', sim: '\u223C', cong: '\u2245', asymp: '\u2248', ne: '\u2260', equiv: '\u2261', le: '\u2264', ge: '\u2265', sub: '\u2282', sup: '\u2283', nsub: '\u2284', sube: '\u2286', supe: '\u2287', oplus: '\u2295', otimes: '\u2297', perp: '\u22A5', sdot: '\u22C5', lceil: '\u2308', rceil: '\u2309', lfloor: '\u230A', rfloor: '\u230B', lang: '\u2329', rang: '\u232A', loz: '\u25CA', spades: '\u2660', clubs: '\u2663', hearts: '\u2665', diams: '\u2666' }; /***/ }), /***/ "./node_modules/acorn/dist/acorn.js": /*!******************************************!*\ !*** ./node_modules/acorn/dist/acorn.js ***! \******************************************/ /***/ (function(__unused_webpack_module, exports) { (function (global, factory) { true ? factory(exports) : 0; })(this, (function (exports) { 'use strict'; // This file was generated. Do not modify manually! var astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 7, 9, 32, 4, 318, 1, 80, 3, 71, 10, 50, 3, 123, 2, 54, 14, 32, 10, 3, 1, 11, 3, 46, 10, 8, 0, 46, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 3, 0, 158, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 68, 8, 2, 0, 3, 0, 2, 3, 2, 4, 2, 0, 15, 1, 83, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 7, 19, 58, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 343, 9, 54, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 10, 1, 2, 0, 49, 6, 4, 4, 14, 10, 5350, 0, 7, 14, 11465, 27, 2343, 9, 87, 9, 39, 4, 60, 6, 26, 9, 535, 9, 470, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 4178, 9, 519, 45, 3, 22, 543, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 101, 0, 161, 6, 10, 9, 357, 0, 62, 13, 499, 13, 245, 1, 2, 9, 726, 6, 110, 6, 6, 9, 4759, 9, 787719, 239]; // This file was generated. Do not modify manually! var astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 13, 10, 2, 14, 2, 6, 2, 1, 2, 10, 2, 14, 2, 6, 2, 1, 4, 51, 13, 310, 10, 21, 11, 7, 25, 5, 2, 41, 2, 8, 70, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 39, 27, 10, 22, 251, 41, 7, 1, 17, 2, 60, 28, 11, 0, 9, 21, 43, 17, 47, 20, 28, 22, 13, 52, 58, 1, 3, 0, 14, 44, 33, 24, 27, 35, 30, 0, 3, 0, 9, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 20, 1, 64, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 31, 9, 2, 0, 3, 0, 2, 37, 2, 0, 26, 0, 2, 0, 45, 52, 19, 3, 21, 2, 31, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 14, 0, 72, 26, 38, 6, 186, 43, 117, 63, 32, 7, 3, 0, 3, 7, 2, 1, 2, 23, 16, 0, 2, 0, 95, 7, 3, 38, 17, 0, 2, 0, 29, 0, 11, 39, 8, 0, 22, 0, 12, 45, 20, 0, 19, 72, 200, 32, 32, 8, 2, 36, 18, 0, 50, 29, 113, 6, 2, 1, 2, 37, 22, 0, 26, 5, 2, 1, 2, 31, 15, 0, 328, 18, 16, 0, 2, 12, 2, 33, 125, 0, 80, 921, 103, 110, 18, 195, 2637, 96, 16, 1071, 18, 5, 26, 3994, 6, 582, 6842, 29, 1763, 568, 8, 30, 18, 78, 18, 29, 19, 47, 17, 3, 32, 20, 6, 18, 433, 44, 212, 63, 129, 74, 6, 0, 67, 12, 65, 1, 2, 0, 29, 6135, 9, 1237, 42, 9, 8936, 3, 2, 6, 2, 1, 2, 290, 16, 0, 30, 2, 3, 0, 15, 3, 9, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 1845, 30, 7, 5, 262, 61, 147, 44, 11, 6, 17, 0, 322, 29, 19, 43, 485, 27, 229, 29, 3, 0, 496, 6, 2, 3, 2, 1, 2, 14, 2, 196, 60, 67, 8, 0, 1205, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42719, 33, 4153, 7, 221, 3, 5761, 15, 7472, 16, 621, 2467, 541, 1507, 4938, 6, 4191]; // This file was generated. Do not modify manually! var nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u0897-\u089f\u08ca-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b55-\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3c\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0cf3\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d81-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ece\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u180f-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf-\u1ace\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1dff\u200c\u200d\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\u30fb\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua82c\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f\uff65"; // This file was generated. Do not modify manually! var nonASCIIidentifierStartChars = "\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\u0560-\u0588\u05d0-\u05ea\u05ef-\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\u0860-\u086a\u0870-\u0887\u0889-\u088e\u08a0-\u08c9\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\u09fc\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\u0c5d\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cdd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d04-\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\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\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-\u1711\u171f-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4c\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c8a\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\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-\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-\u312f\u3131-\u318e\u31a0-\u31bf\u31f0-\u31ff\u3400-\u4dbf\u4e00-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7cd\ua7d0\ua7d1\ua7d3\ua7d5-\ua7dc\ua7f2-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\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-\uab69\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"; // These are a run-length and offset encoded representation of the // >0xffff code points that are a valid part of identifiers. The // offset starts at 0x10000, and each pair of numbers represents an // offset to the next range, and then a size of the range. // Reserved word lists for various dialects of the language var reservedWords = { 3: "abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile", 5: "class enum extends super const export import", 6: "enum", strict: "implements interface let package private protected public static yield", strictBind: "eval arguments" }; // And the keywords var ecma5AndLessKeywords = "break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this"; var keywords$1 = { 5: ecma5AndLessKeywords, "5module": ecma5AndLessKeywords + " export import", 6: ecma5AndLessKeywords + " const class extends export import super" }; var keywordRelationalOperator = /^in(stanceof)?$/; // ## Character categories var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]"); var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]"); // This has a complexity linear to the value of the code. The // assumption is that looking up astral identifier characters is // rare. function isInAstralSet(code, set) { var pos = 0x10000; for (var i = 0; i < set.length; i += 2) { pos += set[i]; if (pos > code) { return false } pos += set[i + 1]; if (pos >= code) { return true } } return false } // Test whether a given character code starts an identifier. function isIdentifierStart(code, astral) { if (code < 65) { return code === 36 } if (code < 91) { return true } if (code < 97) { return code === 95 } if (code < 123) { return true } if (code <= 0xffff) { return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code)) } if (astral === false) { return false } return isInAstralSet(code, astralIdentifierStartCodes) } // Test whether a given character is part of an identifier. function isIdentifierChar(code, astral) { if (code < 48) { return code === 36 } if (code < 58) { return true } if (code < 65) { return false } if (code < 91) { return true } if (code < 97) { return code === 95 } if (code < 123) { return true } if (code <= 0xffff) { return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code)) } if (astral === false) { return false } return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes) } // ## Token types // The assignment of fine-grained, information-carrying type objects // allows the tokenizer to store the information it has about a // token in a way that is very cheap for the parser to look up. // All token type variables start with an underscore, to make them // easy to recognize. // The `beforeExpr` property is used to disambiguate between regular // expressions and divisions. It is set on all token types that can // be followed by an expression (thus, a slash after them would be a // regular expression). // // The `startsExpr` property is used to check if the token ends a // `yield` expression. It is set on all token types that either can // directly start an expression (like a quotation mark) or can // continue an expression (like the body of a string). // // `isLoop` marks a keyword as starting a loop, which is important // to know when parsing a label, in order to allow or disallow // continue jumps to that label. var TokenType = function TokenType(label, conf) { if ( conf === void 0 ) conf = {}; this.label = label; this.keyword = conf.keyword; this.beforeExpr = !!conf.beforeExpr; this.startsExpr = !!conf.startsExpr; this.isLoop = !!conf.isLoop; this.isAssign = !!conf.isAssign; this.prefix = !!conf.prefix; this.postfix = !!conf.postfix; this.binop = conf.binop || null; this.updateContext = null; }; function binop(name, prec) { return new TokenType(name, {beforeExpr: true, binop: prec}) } var beforeExpr = {beforeExpr: true}, startsExpr = {startsExpr: true}; // Map keyword names to token types. var keywords = {}; // Succinct definitions of keyword token types function kw(name, options) { if ( options === void 0 ) options = {}; options.keyword = name; return keywords[name] = new TokenType(name, options) } var types$1 = { num: new TokenType("num", startsExpr), regexp: new TokenType("regexp", startsExpr), string: new TokenType("string", startsExpr), name: new TokenType("name", startsExpr), privateId: new TokenType("privateId", startsExpr), eof: new TokenType("eof"), // Punctuation token types. bracketL: new TokenType("[", {beforeExpr: true, startsExpr: true}), bracketR: new TokenType("]"), braceL: new TokenType("{", {beforeExpr: true, startsExpr: true}), braceR: new TokenType("}"), parenL: new TokenType("(", {beforeExpr: true, startsExpr: true}), parenR: new TokenType(")"), comma: new TokenType(",", beforeExpr), semi: new TokenType(";", beforeExpr), colon: new TokenType(":", beforeExpr), dot: new TokenType("."), question: new TokenType("?", beforeExpr), questionDot: new TokenType("?."), arrow: new TokenType("=>", beforeExpr), template: new TokenType("template"), invalidTemplate: new TokenType("invalidTemplate"), ellipsis: new TokenType("...", beforeExpr), backQuote: new TokenType("`", startsExpr), dollarBraceL: new TokenType("${", {beforeExpr: true, startsExpr: true}), // Operators. These carry several kinds of properties to help the // parser use them properly (the presence of these properties is // what categorizes them as operators). // // `binop`, when present, specifies that this operator is a binary // operator, and will refer to its precedence. // // `prefix` and `postfix` mark the operator as a prefix or postfix // unary operator. // // `isAssign` marks all of `=`, `+=`, `-=` etcetera, which act as // binary operators with a very low precedence, that should result // in AssignmentExpression nodes. eq: new TokenType("=", {beforeExpr: true, isAssign: true}), assign: new TokenType("_=", {beforeExpr: true, isAssign: true}), incDec: new TokenType("++/--", {prefix: true, postfix: true, startsExpr: true}), prefix: new TokenType("!/~", {beforeExpr: true, prefix: true, startsExpr: true}), logicalOR: binop("||", 1), logicalAND: binop("&&", 2), bitwiseOR: binop("|", 3), bitwiseXOR: binop("^", 4), bitwiseAND: binop("&", 5), equality: binop("==/!=/===/!==", 6), relational: binop("/<=/>=", 7), bitShift: binop("<>/>>>", 8), plusMin: new TokenType("+/-", {beforeExpr: true, binop: 9, prefix: true, startsExpr: true}), modulo: binop("%", 10), star: binop("*", 10), slash: binop("/", 10), starstar: new TokenType("**", {beforeExpr: true}), coalesce: binop("??", 1), // Keyword token types. _break: kw("break"), _case: kw("case", beforeExpr), _catch: kw("catch"), _continue: kw("continue"), _debugger: kw("debugger"), _default: kw("default", beforeExpr), _do: kw("do", {isLoop: true, beforeExpr: true}), _else: kw("else", beforeExpr), _finally: kw("finally"), _for: kw("for", {isLoop: true}), _function: kw("function", startsExpr), _if: kw("if"), _return: kw("return", beforeExpr), _switch: kw("switch"), _throw: kw("throw", beforeExpr), _try: kw("try"), _var: kw("var"), _const: kw("const"), _while: kw("while", {isLoop: true}), _with: kw("with"), _new: kw("new", {beforeExpr: true, startsExpr: true}), _this: kw("this", startsExpr), _super: kw("super", startsExpr), _class: kw("class", startsExpr), _extends: kw("extends", beforeExpr), _export: kw("export"), _import: kw("import", startsExpr), _null: kw("null", startsExpr), _true: kw("true", startsExpr), _false: kw("false", startsExpr), _in: kw("in", {beforeExpr: true, binop: 7}), _instanceof: kw("instanceof", {beforeExpr: true, binop: 7}), _typeof: kw("typeof", {beforeExpr: true, prefix: true, startsExpr: true}), _void: kw("void", {beforeExpr: true, prefix: true, startsExpr: true}), _delete: kw("delete", {beforeExpr: true, prefix: true, startsExpr: true}) }; // Matches a whole line break (where CRLF is considered a single // line break). Used to count lines. var lineBreak = /\r\n?|\n|\u2028|\u2029/; var lineBreakG = new RegExp(lineBreak.source, "g"); function isNewLine(code) { return code === 10 || code === 13 || code === 0x2028 || code === 0x2029 } function nextLineBreak(code, from, end) { if ( end === void 0 ) end = code.length; for (var i = from; i < end; i++) { var next = code.charCodeAt(i); if (isNewLine(next)) { return i < end - 1 && next === 13 && code.charCodeAt(i + 1) === 10 ? i + 2 : i + 1 } } return -1 } var nonASCIIwhitespace = /[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/; var skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g; var ref = Object.prototype; var hasOwnProperty = ref.hasOwnProperty; var toString = ref.toString; var hasOwn = Object.hasOwn || (function (obj, propName) { return ( hasOwnProperty.call(obj, propName) ); }); var isArray = Array.isArray || (function (obj) { return ( toString.call(obj) === "[object Array]" ); }); var regexpCache = Object.create(null); function wordsRegexp(words) { return regexpCache[words] || (regexpCache[words] = new RegExp("^(?:" + words.replace(/ /g, "|") + ")$")) } function codePointToString(code) { // UTF-16 Decoding if (code <= 0xFFFF) { return String.fromCharCode(code) } code -= 0x10000; return String.fromCharCode((code >> 10) + 0xD800, (code & 1023) + 0xDC00) } var loneSurrogate = /(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/; // These are used when `options.locations` is on, for the // `startLoc` and `endLoc` properties. var Position = function Position(line, col) { this.line = line; this.column = col; }; Position.prototype.offset = function offset (n) { return new Position(this.line, this.column + n) }; var SourceLocation = function SourceLocation(p, start, end) { this.start = start; this.end = end; if (p.sourceFile !== null) { this.source = p.sourceFile; } }; // The `getLineInfo` function is mostly useful when the // `locations` option is off (for performance reasons) and you // want to find the line/column position for a given character // offset. `input` should be the code string that the offset refers // into. function getLineInfo(input, offset) { for (var line = 1, cur = 0;;) { var nextBreak = nextLineBreak(input, cur, offset); if (nextBreak < 0) { return new Position(line, offset - cur) } ++line; cur = nextBreak; } } // A second argument must be given to configure the parser process. // These options are recognized (only `ecmaVersion` is required): var defaultOptions = { // `ecmaVersion` indicates the ECMAScript version to parse. Must be // either 3, 5, 6 (or 2015), 7 (2016), 8 (2017), 9 (2018), 10 // (2019), 11 (2020), 12 (2021), 13 (2022), 14 (2023), or `"latest"` // (the latest version the library supports). This influences // support for strict mode, the set of reserved words, and support // for new syntax features. ecmaVersion: null, // `sourceType` indicates the mode the code should be parsed in. // Can be either `"script"` or `"module"`. This influences global // strict mode and parsing of `import` and `export` declarations. sourceType: "script", // `onInsertedSemicolon` can be a callback that will be called when // a semicolon is automatically inserted. It will be passed the // position of the inserted semicolon as an offset, and if // `locations` is enabled, it is given the location as a `{line, // column}` object as second argument. onInsertedSemicolon: null, // `onTrailingComma` is similar to `onInsertedSemicolon`, but for // trailing commas. onTrailingComma: null, // By default, reserved words are only enforced if ecmaVersion >= 5. // Set `allowReserved` to a boolean value to explicitly turn this on // an off. When this option has the value "never", reserved words // and keywords can also not be used as property names. allowReserved: null, // When enabled, a return at the top level is not considered an // error. allowReturnOutsideFunction: false, // When enabled, import/export statements are not constrained to // appearing at the top of the program, and an import.meta expression // in a script isn't considered an error. allowImportExportEverywhere: false, // By default, await identifiers are allowed to appear at the top-level scope only if ecmaVersion >= 2022. // When enabled, await identifiers are allowed to appear at the top-level scope, // but they are still not allowed in non-async functions. allowAwaitOutsideFunction: null, // When enabled, super identifiers are not constrained to // appearing in methods and do not raise an error when they appear elsewhere. allowSuperOutsideMethod: null, // When enabled, hashbang directive in the beginning of file is // allowed and treated as a line comment. Enabled by default when // `ecmaVersion` >= 2023. allowHashBang: false, // By default, the parser will verify that private properties are // only used in places where they are valid and have been declared. // Set this to false to turn such checks off. checkPrivateFields: true, // When `locations` is on, `loc` properties holding objects with // `start` and `end` properties in `{line, column}` form (with // line being 1-based and column 0-based) will be attached to the // nodes. locations: false, // A function can be passed as `onToken` option, which will // cause Acorn to call that function with object in the same // format as tokens returned from `tokenizer().getToken()`. Note // that you are not allowed to call the parser from the // callback—that will corrupt its internal state. onToken: null, // A function can be passed as `onComment` option, which will // cause Acorn to call that function with `(block, text, start, // end)` parameters whenever a comment is skipped. `block` is a // boolean indicating whether this is a block (`/* */`) comment, // `text` is the content of the comment, and `start` and `end` are // character offsets that denote the start and end of the comment. // When the `locations` option is on, two more parameters are // passed, the full `{line, column}` locations of the start and // end of the comments. Note that you are not allowed to call the // parser from the callback—that will corrupt its internal state. // When this option has an array as value, objects representing the // comments are pushed to it. onComment: null, // Nodes have their start and end characters offsets recorded in // `start` and `end` properties (directly on the node, rather than // the `loc` object, which holds line/column data. To also add a // [semi-standardized][range] `range` property holding a `[start, // end]` array with the same numbers, set the `ranges` option to // `true`. // // [range]: https://bugzilla.mozilla.org/show_bug.cgi?id=745678 ranges: false, // It is possible to parse multiple files into a single AST by // passing the tree produced by parsing the first file as // `program` option in subsequent parses. This will add the // toplevel forms of the parsed file to the `Program` (top) node // of an existing parse tree. program: null, // When `locations` is on, you can pass this to record the source // file in every node's `loc` object. sourceFile: null, // This value, if given, is stored in every node, whether // `locations` is on or off. directSourceFile: null, // When enabled, parenthesized expressions are represented by // (non-standard) ParenthesizedExpression nodes preserveParens: false }; // Interpret and default an options object var warnedAboutEcmaVersion = false; function getOptions(opts) { var options = {}; for (var opt in defaultOptions) { options[opt] = opts && hasOwn(opts, opt) ? opts[opt] : defaultOptions[opt]; } if (options.ecmaVersion === "latest") { options.ecmaVersion = 1e8; } else if (options.ecmaVersion == null) { if (!warnedAboutEcmaVersion && typeof console === "object" && console.warn) { warnedAboutEcmaVersion = true; console.warn("Since Acorn 8.0.0, options.ecmaVersion is required.\nDefaulting to 2020, but this will stop working in the future."); } options.ecmaVersion = 11; } else if (options.ecmaVersion >= 2015) { options.ecmaVersion -= 2009; } if (options.allowReserved == null) { options.allowReserved = options.ecmaVersion < 5; } if (!opts || opts.allowHashBang == null) { options.allowHashBang = options.ecmaVersion >= 14; } if (isArray(options.onToken)) { var tokens = options.onToken; options.onToken = function (token) { return tokens.push(token); }; } if (isArray(options.onComment)) { options.onComment = pushComment(options, options.onComment); } return options } function pushComment(options, array) { return function(block, text, start, end, startLoc, endLoc) { var comment = { type: block ? "Block" : "Line", value: text, start: start, end: end }; if (options.locations) { comment.loc = new SourceLocation(this, startLoc, endLoc); } if (options.ranges) { comment.range = [start, end]; } array.push(comment); } } // Each scope gets a bitset that may contain these flags var SCOPE_TOP = 1, SCOPE_FUNCTION = 2, SCOPE_ASYNC = 4, SCOPE_GENERATOR = 8, SCOPE_ARROW = 16, SCOPE_SIMPLE_CATCH = 32, SCOPE_SUPER = 64, SCOPE_DIRECT_SUPER = 128, SCOPE_CLASS_STATIC_BLOCK = 256, SCOPE_CLASS_FIELD_INIT = 512, SCOPE_VAR = SCOPE_TOP | SCOPE_FUNCTION | SCOPE_CLASS_STATIC_BLOCK; function functionFlags(async, generator) { return SCOPE_FUNCTION | (async ? SCOPE_ASYNC : 0) | (generator ? SCOPE_GENERATOR : 0) } // Used in checkLVal* and declareName to determine the type of a binding var BIND_NONE = 0, // Not a binding BIND_VAR = 1, // Var-style binding BIND_LEXICAL = 2, // Let- or const-style binding BIND_FUNCTION = 3, // Function declaration BIND_SIMPLE_CATCH = 4, // Simple (identifier pattern) catch binding BIND_OUTSIDE = 5; // Special case for function names as bound inside the function var Parser = function Parser(options, input, startPos) { this.options = options = getOptions(options); this.sourceFile = options.sourceFile; this.keywords = wordsRegexp(keywords$1[options.ecmaVersion >= 6 ? 6 : options.sourceType === "module" ? "5module" : 5]); var reserved = ""; if (options.allowReserved !== true) { reserved = reservedWords[options.ecmaVersion >= 6 ? 6 : options.ecmaVersion === 5 ? 5 : 3]; if (options.sourceType === "module") { reserved += " await"; } } this.reservedWords = wordsRegexp(reserved); var reservedStrict = (reserved ? reserved + " " : "") + reservedWords.strict; this.reservedWordsStrict = wordsRegexp(reservedStrict); this.reservedWordsStrictBind = wordsRegexp(reservedStrict + " " + reservedWords.strictBind); this.input = String(input); // Used to signal to callers of `readWord1` whether the word // contained any escape sequences. This is needed because words with // escape sequences must not be interpreted as keywords. this.containsEsc = false; // Set up token state // The current position of the tokenizer in the input. if (startPos) { this.pos = startPos; this.lineStart = this.input.lastIndexOf("\n", startPos - 1) + 1; this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length; } else { this.pos = this.lineStart = 0; this.curLine = 1; } // Properties of the current token: // Its type this.type = types$1.eof; // For tokens that include more information than their type, the value this.value = null; // Its start and end offset this.start = this.end = this.pos; // And, if locations are used, the {line, column} object // corresponding to those offsets this.startLoc = this.endLoc = this.curPosition(); // Position information for the previous token this.lastTokEndLoc = this.lastTokStartLoc = null; this.lastTokStart = this.lastTokEnd = this.pos; // The context stack is used to superficially track syntactic // context to predict whether a regular expression is allowed in a // given position. this.context = this.initialContext(); this.exprAllowed = true; // Figure out if it's a module code. this.inModule = options.sourceType === "module"; this.strict = this.inModule || this.strictDirective(this.pos); // Used to signify the start of a potential arrow function this.potentialArrowAt = -1; this.potentialArrowInForAwait = false; // Positions to delayed-check that yield/await does not exist in default parameters. this.yieldPos = this.awaitPos = this.awaitIdentPos = 0; // Labels in scope. this.labels = []; // Thus-far undefined exports. this.undefinedExports = Object.create(null); // If enabled, skip leading hashbang line. if (this.pos === 0 && options.allowHashBang && this.input.slice(0, 2) === "#!") { this.skipLineComment(2); } // Scope tracking for duplicate variable names (see scope.js) this.scopeStack = []; this.enterScope(SCOPE_TOP); // For RegExp validation this.regexpState = null; // The stack of private names. // Each element has two properties: 'declared' and 'used'. // When it exited from the outermost class definition, all used private names must be declared. this.privateNameStack = []; }; var prototypeAccessors = { inFunction: { configurable: true },inGenerator: { configurable: true },inAsync: { configurable: true },canAwait: { configurable: true },allowSuper: { configurable: true },allowDirectSuper: { configurable: true },treatFunctionsAsVar: { configurable: true },allowNewDotTarget: { configurable: true },inClassStaticBlock: { configurable: true } }; Parser.prototype.parse = function parse () { var node = this.options.program || this.startNode(); this.nextToken(); return this.parseTopLevel(node) }; prototypeAccessors.inFunction.get = function () { return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0 }; prototypeAccessors.inGenerator.get = function () { return (this.currentVarScope().flags & SCOPE_GENERATOR) > 0 }; prototypeAccessors.inAsync.get = function () { return (this.currentVarScope().flags & SCOPE_ASYNC) > 0 }; prototypeAccessors.canAwait.get = function () { for (var i = this.scopeStack.length - 1; i >= 0; i--) { var ref = this.scopeStack[i]; var flags = ref.flags; if (flags & (SCOPE_CLASS_STATIC_BLOCK | SCOPE_CLASS_FIELD_INIT)) { return false } if (flags & SCOPE_FUNCTION) { return (flags & SCOPE_ASYNC) > 0 } } return (this.inModule && this.options.ecmaVersion >= 13) || this.options.allowAwaitOutsideFunction }; prototypeAccessors.allowSuper.get = function () { var ref = this.currentThisScope(); var flags = ref.flags; return (flags & SCOPE_SUPER) > 0 || this.options.allowSuperOutsideMethod }; prototypeAccessors.allowDirectSuper.get = function () { return (this.currentThisScope().flags & SCOPE_DIRECT_SUPER) > 0 }; prototypeAccessors.treatFunctionsAsVar.get = function () { return this.treatFunctionsAsVarInScope(this.currentScope()) }; prototypeAccessors.allowNewDotTarget.get = function () { for (var i = this.scopeStack.length - 1; i >= 0; i--) { var ref = this.scopeStack[i]; var flags = ref.flags; if (flags & (SCOPE_CLASS_STATIC_BLOCK | SCOPE_CLASS_FIELD_INIT) || ((flags & SCOPE_FUNCTION) && !(flags & SCOPE_ARROW))) { return true } } return false }; prototypeAccessors.inClassStaticBlock.get = function () { return (this.currentVarScope().flags & SCOPE_CLASS_STATIC_BLOCK) > 0 }; Parser.extend = function extend () { var plugins = [], len = arguments.length; while ( len-- ) plugins[ len ] = arguments[ len ]; var cls = this; for (var i = 0; i < plugins.length; i++) { cls = plugins[i](cls); } return cls }; Parser.parse = function parse (input, options) { return new this(options, input).parse() }; Parser.parseExpressionAt = function parseExpressionAt (input, pos, options) { var parser = new this(options, input, pos); parser.nextToken(); return parser.parseExpression() }; Parser.tokenizer = function tokenizer (input, options) { return new this(options, input) }; Object.defineProperties( Parser.prototype, prototypeAccessors ); var pp$9 = Parser.prototype; // ## Parser utilities var literal = /^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/; pp$9.strictDirective = function(start) { if (this.options.ecmaVersion < 5) { return false } for (;;) { // Try to find string literal. skipWhiteSpace.lastIndex = start; start += skipWhiteSpace.exec(this.input)[0].length; var match = literal.exec(this.input.slice(start)); if (!match) { return false } if ((match[1] || match[2]) === "use strict") { skipWhiteSpace.lastIndex = start + match[0].length; var spaceAfter = skipWhiteSpace.exec(this.input), end = spaceAfter.index + spaceAfter[0].length; var next = this.input.charAt(end); return next === ";" || next === "}" || (lineBreak.test(spaceAfter[0]) && !(/[(`.[+\-/*%<>=,?^&]/.test(next) || next === "!" && this.input.charAt(end + 1) === "=")) } start += match[0].length; // Skip semicolon, if any. skipWhiteSpace.lastIndex = start; start += skipWhiteSpace.exec(this.input)[0].length; if (this.input[start] === ";") { start++; } } }; // Predicate that tests whether the next token is of the given // type, and if yes, consumes it as a side effect. pp$9.eat = function(type) { if (this.type === type) { this.next(); return true } else { return false } }; // Tests whether parsed token is a contextual keyword. pp$9.isContextual = function(name) { return this.type === types$1.name && this.value === name && !this.containsEsc }; // Consumes contextual keyword if possible. pp$9.eatContextual = function(name) { if (!this.isContextual(name)) { return false } this.next(); return true }; // Asserts that following token is given contextual keyword. pp$9.expectContextual = function(name) { if (!this.eatContextual(name)) { this.unexpected(); } }; // Test whether a semicolon can be inserted at the current position. pp$9.canInsertSemicolon = function() { return this.type === types$1.eof || this.type === types$1.braceR || lineBreak.test(this.input.slice(this.lastTokEnd, this.start)) }; pp$9.insertSemicolon = function() { if (this.canInsertSemicolon()) { if (this.options.onInsertedSemicolon) { this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc); } return true } }; // Consume a semicolon, or, failing that, see if we are allowed to // pretend that there is a semicolon at this position. pp$9.semicolon = function() { if (!this.eat(types$1.semi) && !this.insertSemicolon()) { this.unexpected(); } }; pp$9.afterTrailingComma = function(tokType, notNext) { if (this.type === tokType) { if (this.options.onTrailingComma) { this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc); } if (!notNext) { this.next(); } return true } }; // Expect a token of a given type. If found, consume it, otherwise, // raise an unexpected token error. pp$9.expect = function(type) { this.eat(type) || this.unexpected(); }; // Raise an unexpected token error. pp$9.unexpected = function(pos) { this.raise(pos != null ? pos : this.start, "Unexpected token"); }; var DestructuringErrors = function DestructuringErrors() { this.shorthandAssign = this.trailingComma = this.parenthesizedAssign = this.parenthesizedBind = this.doubleProto = -1; }; pp$9.checkPatternErrors = function(refDestructuringErrors, isAssign) { if (!refDestructuringErrors) { return } if (refDestructuringErrors.trailingComma > -1) { this.raiseRecoverable(refDestructuringErrors.trailingComma, "Comma is not permitted after the rest element"); } var parens = isAssign ? refDestructuringErrors.parenthesizedAssign : refDestructuringErrors.parenthesizedBind; if (parens > -1) { this.raiseRecoverable(parens, isAssign ? "Assigning to rvalue" : "Parenthesized pattern"); } }; pp$9.checkExpressionErrors = function(refDestructuringErrors, andThrow) { if (!refDestructuringErrors) { return false } var shorthandAssign = refDestructuringErrors.shorthandAssign; var doubleProto = refDestructuringErrors.doubleProto; if (!andThrow) { return shorthandAssign >= 0 || doubleProto >= 0 } if (shorthandAssign >= 0) { this.raise(shorthandAssign, "Shorthand property assignments are valid only in destructuring patterns"); } if (doubleProto >= 0) { this.raiseRecoverable(doubleProto, "Redefinition of __proto__ property"); } }; pp$9.checkYieldAwaitInDefaultParams = function() { if (this.yieldPos && (!this.awaitPos || this.yieldPos < this.awaitPos)) { this.raise(this.yieldPos, "Yield expression cannot be a default value"); } if (this.awaitPos) { this.raise(this.awaitPos, "Await expression cannot be a default value"); } }; pp$9.isSimpleAssignTarget = function(expr) { if (expr.type === "ParenthesizedExpression") { return this.isSimpleAssignTarget(expr.expression) } return expr.type === "Identifier" || expr.type === "MemberExpression" }; var pp$8 = Parser.prototype; // ### Statement parsing // Parse a program. Initializes the parser, reads any number of // statements, and wraps them in a Program node. Optionally takes a // `program` argument. If present, the statements will be appended // to its body instead of creating a new node. pp$8.parseTopLevel = function(node) { var exports = Object.create(null); if (!node.body) { node.body = []; } while (this.type !== types$1.eof) { var stmt = this.parseStatement(null, true, exports); node.body.push(stmt); } if (this.inModule) { for (var i = 0, list = Object.keys(this.undefinedExports); i < list.length; i += 1) { var name = list[i]; this.raiseRecoverable(this.undefinedExports[name].start, ("Export '" + name + "' is not defined")); } } this.adaptDirectivePrologue(node.body); this.next(); node.sourceType = this.options.sourceType; return this.finishNode(node, "Program") }; var loopLabel = {kind: "loop"}, switchLabel = {kind: "switch"}; pp$8.isLet = function(context) { if (this.options.ecmaVersion < 6 || !this.isContextual("let")) { return false } skipWhiteSpace.lastIndex = this.pos; var skip = skipWhiteSpace.exec(this.input); var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next); // For ambiguous cases, determine if a LexicalDeclaration (or only a // Statement) is allowed here. If context is not empty then only a Statement // is allowed. However, `let [` is an explicit negative lookahead for // ExpressionStatement, so special-case it first. if (nextCh === 91 || nextCh === 92) { return true } // '[', '\' if (context) { return false } if (nextCh === 123 || nextCh > 0xd7ff && nextCh < 0xdc00) { return true } // '{', astral if (isIdentifierStart(nextCh, true)) { var pos = next + 1; while (isIdentifierChar(nextCh = this.input.charCodeAt(pos), true)) { ++pos; } if (nextCh === 92 || nextCh > 0xd7ff && nextCh < 0xdc00) { return true } var ident = this.input.slice(next, pos); if (!keywordRelationalOperator.test(ident)) { return true } } return false }; // check 'async [no LineTerminator here] function' // - 'async /*foo*/ function' is OK. // - 'async /*\n*/ function' is invalid. pp$8.isAsyncFunction = function() { if (this.options.ecmaVersion < 8 || !this.isContextual("async")) { return false } skipWhiteSpace.lastIndex = this.pos; var skip = skipWhiteSpace.exec(this.input); var next = this.pos + skip[0].length, after; return !lineBreak.test(this.input.slice(this.pos, next)) && this.input.slice(next, next + 8) === "function" && (next + 8 === this.input.length || !(isIdentifierChar(after = this.input.charCodeAt(next + 8)) || after > 0xd7ff && after < 0xdc00)) }; pp$8.isUsingKeyword = function(isAwaitUsing, isFor) { if (this.options.ecmaVersion < 17 || !this.isContextual(isAwaitUsing ? "await" : "using")) { return false } skipWhiteSpace.lastIndex = this.pos; var skip = skipWhiteSpace.exec(this.input); var next = this.pos + skip[0].length; if (lineBreak.test(this.input.slice(this.pos, next))) { return false } if (isAwaitUsing) { var awaitEndPos = next + 5 /* await */, after; if (this.input.slice(next, awaitEndPos) !== "using" || awaitEndPos === this.input.length || isIdentifierChar(after = this.input.charCodeAt(awaitEndPos)) || (after > 0xd7ff && after < 0xdc00) ) { return false } skipWhiteSpace.lastIndex = awaitEndPos; var skipAfterUsing = skipWhiteSpace.exec(this.input); if (skipAfterUsing && lineBreak.test(this.input.slice(awaitEndPos, awaitEndPos + skipAfterUsing[0].length))) { return false } } if (isFor) { var ofEndPos = next + 2 /* of */, after$1; if (this.input.slice(next, ofEndPos) === "of") { if (ofEndPos === this.input.length || (!isIdentifierChar(after$1 = this.input.charCodeAt(ofEndPos)) && !(after$1 > 0xd7ff && after$1 < 0xdc00))) { return false } } } var ch = this.input.charCodeAt(next); return isIdentifierStart(ch, true) || ch === 92 // '\' }; pp$8.isAwaitUsing = function(isFor) { return this.isUsingKeyword(true, isFor) }; pp$8.isUsing = function(isFor) { return this.isUsingKeyword(false, isFor) }; // Parse a single statement. // // If expecting a statement and finding a slash operator, parse a // regular expression literal. This is to handle cases like // `if (foo) /blah/.exec(foo)`, where looking at the previous token // does not help. pp$8.parseStatement = function(context, topLevel, exports) { var starttype = this.type, node = this.startNode(), kind; if (this.isLet(context)) { starttype = types$1._var; kind = "let"; } // Most types of statements are recognized by the keyword they // start with. Many are trivial to parse, some require a bit of // complexity. switch (starttype) { case types$1._break: case types$1._continue: return this.parseBreakContinueStatement(node, starttype.keyword) case types$1._debugger: return this.parseDebuggerStatement(node) case types$1._do: return this.parseDoStatement(node) case types$1._for: return this.parseForStatement(node) case types$1._function: // Function as sole body of either an if statement or a labeled statement // works, but not when it is part of a labeled statement that is the sole // body of an if statement. if ((context && (this.strict || context !== "if" && context !== "label")) && this.options.ecmaVersion >= 6) { this.unexpected(); } return this.parseFunctionStatement(node, false, !context) case types$1._class: if (context) { this.unexpected(); } return this.parseClass(node, true) case types$1._if: return this.parseIfStatement(node) case types$1._return: return this.parseReturnStatement(node) case types$1._switch: return this.parseSwitchStatement(node) case types$1._throw: return this.parseThrowStatement(node) case types$1._try: return this.parseTryStatement(node) case types$1._const: case types$1._var: kind = kind || this.value; if (context && kind !== "var") { this.unexpected(); } return this.parseVarStatement(node, kind) case types$1._while: return this.parseWhileStatement(node) case types$1._with: return this.parseWithStatement(node) case types$1.braceL: return this.parseBlock(true, node) case types$1.semi: return this.parseEmptyStatement(node) case types$1._export: case types$1._import: if (this.options.ecmaVersion > 10 && starttype === types$1._import) { skipWhiteSpace.lastIndex = this.pos; var skip = skipWhiteSpace.exec(this.input); var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next); if (nextCh === 40 || nextCh === 46) // '(' or '.' { return this.parseExpressionStatement(node, this.parseExpression()) } } if (!this.options.allowImportExportEverywhere) { if (!topLevel) { this.raise(this.start, "'import' and 'export' may only appear at the top level"); } if (!this.inModule) { this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'"); } } return starttype === types$1._import ? this.parseImport(node) : this.parseExport(node, exports) // If the statement does not start with a statement keyword or a // brace, it's an ExpressionStatement or LabeledStatement. We // simply start parsing an expression, and afterwards, if the // next token is a colon and the expression was a simple // Identifier node, we switch to interpreting it as a label. default: if (this.isAsyncFunction()) { if (context) { this.unexpected(); } this.next(); return this.parseFunctionStatement(node, true, !context) } var usingKind = this.isAwaitUsing(false) ? "await using" : this.isUsing(false) ? "using" : null; if (usingKind) { if (topLevel && this.options.sourceType === "script") { this.raise(this.start, "Using declaration cannot appear in the top level when source type is `script`"); } if (usingKind === "await using") { if (!this.canAwait) { this.raise(this.start, "Await using cannot appear outside of async function"); } this.next(); } this.next(); this.parseVar(node, false, usingKind); this.semicolon(); return this.finishNode(node, "VariableDeclaration") } var maybeName = this.value, expr = this.parseExpression(); if (starttype === types$1.name && expr.type === "Identifier" && this.eat(types$1.colon)) { return this.parseLabeledStatement(node, maybeName, expr, context) } else { return this.parseExpressionStatement(node, expr) } } }; pp$8.parseBreakContinueStatement = function(node, keyword) { var isBreak = keyword === "break"; this.next(); if (this.eat(types$1.semi) || this.insertSemicolon()) { node.label = null; } else if (this.type !== types$1.name) { this.unexpected(); } else { node.label = this.parseIdent(); this.semicolon(); } // Verify that there is an actual destination to break or // continue to. var i = 0; for (; i < this.labels.length; ++i) { var lab = this.labels[i]; if (node.label == null || lab.name === node.label.name) { if (lab.kind != null && (isBreak || lab.kind === "loop")) { break } if (node.label && isBreak) { break } } } if (i === this.labels.length) { this.raise(node.start, "Unsyntactic " + keyword); } return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement") }; pp$8.parseDebuggerStatement = function(node) { this.next(); this.semicolon(); return this.finishNode(node, "DebuggerStatement") }; pp$8.parseDoStatement = function(node) { this.next(); this.labels.push(loopLabel); node.body = this.parseStatement("do"); this.labels.pop(); this.expect(types$1._while); node.test = this.parseParenExpression(); if (this.options.ecmaVersion >= 6) { this.eat(types$1.semi); } else { this.semicolon(); } return this.finishNode(node, "DoWhileStatement") }; // Disambiguating between a `for` and a `for`/`in` or `for`/`of` // loop is non-trivial. Basically, we have to parse the init `var` // statement or expression, disallowing the `in` operator (see // the second parameter to `parseExpression`), and then check // whether the next token is `in` or `of`. When there is no init // part (semicolon immediately after the opening parenthesis), it // is a regular `for` loop. pp$8.parseForStatement = function(node) { this.next(); var awaitAt = (this.options.ecmaVersion >= 9 && this.canAwait && this.eatContextual("await")) ? this.lastTokStart : -1; this.labels.push(loopLabel); this.enterScope(0); this.expect(types$1.parenL); if (this.type === types$1.semi) { if (awaitAt > -1) { this.unexpected(awaitAt); } return this.parseFor(node, null) } var isLet = this.isLet(); if (this.type === types$1._var || this.type === types$1._const || isLet) { var init$1 = this.startNode(), kind = isLet ? "let" : this.value; this.next(); this.parseVar(init$1, true, kind); this.finishNode(init$1, "VariableDeclaration"); return this.parseForAfterInit(node, init$1, awaitAt) } var startsWithLet = this.isContextual("let"), isForOf = false; var usingKind = this.isUsing(true) ? "using" : this.isAwaitUsing(true) ? "await using" : null; if (usingKind) { var init$2 = this.startNode(); this.next(); if (usingKind === "await using") { this.next(); } this.parseVar(init$2, true, usingKind); this.finishNode(init$2, "VariableDeclaration"); return this.parseForAfterInit(node, init$2, awaitAt) } var containsEsc = this.containsEsc; var refDestructuringErrors = new DestructuringErrors; var initPos = this.start; var init = awaitAt > -1 ? this.parseExprSubscripts(refDestructuringErrors, "await") : this.parseExpression(true, refDestructuringErrors); if (this.type === types$1._in || (isForOf = this.options.ecmaVersion >= 6 && this.isContextual("of"))) { if (awaitAt > -1) { // implies `ecmaVersion >= 9` (see declaration of awaitAt) if (this.type === types$1._in) { this.unexpected(awaitAt); } node.await = true; } else if (isForOf && this.options.ecmaVersion >= 8) { if (init.start === initPos && !containsEsc && init.type === "Identifier" && init.name === "async") { this.unexpected(); } else if (this.options.ecmaVersion >= 9) { node.await = false; } } if (startsWithLet && isForOf) { this.raise(init.start, "The left-hand side of a for-of loop may not start with 'let'."); } this.toAssignable(init, false, refDestructuringErrors); this.checkLValPattern(init); return this.parseForIn(node, init) } else { this.checkExpressionErrors(refDestructuringErrors, true); } if (awaitAt > -1) { this.unexpected(awaitAt); } return this.parseFor(node, init) }; // Helper method to parse for loop after variable initialization pp$8.parseForAfterInit = function(node, init, awaitAt) { if ((this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) && init.declarations.length === 1) { if (this.options.ecmaVersion >= 9) { if (this.type === types$1._in) { if (awaitAt > -1) { this.unexpected(awaitAt); } } else { node.await = awaitAt > -1; } } return this.parseForIn(node, init) } if (awaitAt > -1) { this.unexpected(awaitAt); } return this.parseFor(node, init) }; pp$8.parseFunctionStatement = function(node, isAsync, declarationPosition) { this.next(); return this.parseFunction(node, FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), false, isAsync) }; pp$8.parseIfStatement = function(node) { this.next(); node.test = this.parseParenExpression(); // allow function declarations in branches, but only in non-strict mode node.consequent = this.parseStatement("if"); node.alternate = this.eat(types$1._else) ? this.parseStatement("if") : null; return this.finishNode(node, "IfStatement") }; pp$8.parseReturnStatement = function(node) { if (!this.inFunction && !this.options.allowReturnOutsideFunction) { this.raise(this.start, "'return' outside of function"); } this.next(); // In `return` (and `break`/`continue`), the keywords with // optional arguments, we eagerly look for a semicolon or the // possibility to insert one. if (this.eat(types$1.semi) || this.insertSemicolon()) { node.argument = null; } else { node.argument = this.parseExpression(); this.semicolon(); } return this.finishNode(node, "ReturnStatement") }; pp$8.parseSwitchStatement = function(node) { this.next(); node.discriminant = this.parseParenExpression(); node.cases = []; this.expect(types$1.braceL); this.labels.push(switchLabel); this.enterScope(0); // Statements under must be grouped (by label) in SwitchCase // nodes. `cur` is used to keep the node that we are currently // adding statements to. var cur; for (var sawDefault = false; this.type !== types$1.braceR;) { if (this.type === types$1._case || this.type === types$1._default) { var isCase = this.type === types$1._case; if (cur) { this.finishNode(cur, "SwitchCase"); } node.cases.push(cur = this.startNode()); cur.consequent = []; this.next(); if (isCase) { cur.test = this.parseExpression(); } else { if (sawDefault) { this.raiseRecoverable(this.lastTokStart, "Multiple default clauses"); } sawDefault = true; cur.test = null; } this.expect(types$1.colon); } else { if (!cur) { this.unexpected(); } cur.consequent.push(this.parseStatement(null)); } } this.exitScope(); if (cur) { this.finishNode(cur, "SwitchCase"); } this.next(); // Closing brace this.labels.pop(); return this.finishNode(node, "SwitchStatement") }; pp$8.parseThrowStatement = function(node) { this.next(); if (lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) { this.raise(this.lastTokEnd, "Illegal newline after throw"); } node.argument = this.parseExpression(); this.semicolon(); return this.finishNode(node, "ThrowStatement") }; // Reused empty array added for node fields that are always empty. var empty$1 = []; pp$8.parseCatchClauseParam = function() { var param = this.parseBindingAtom(); var simple = param.type === "Identifier"; this.enterScope(simple ? SCOPE_SIMPLE_CATCH : 0); this.checkLValPattern(param, simple ? BIND_SIMPLE_CATCH : BIND_LEXICAL); this.expect(types$1.parenR); return param }; pp$8.parseTryStatement = function(node) { this.next(); node.block = this.parseBlock(); node.handler = null; if (this.type === types$1._catch) { var clause = this.startNode(); this.next(); if (this.eat(types$1.parenL)) { clause.param = this.parseCatchClauseParam(); } else { if (this.options.ecmaVersion < 10) { this.unexpected(); } clause.param = null; this.enterScope(0); } clause.body = this.parseBlock(false); this.exitScope(); node.handler = this.finishNode(clause, "CatchClause"); } node.finalizer = this.eat(types$1._finally) ? this.parseBlock() : null; if (!node.handler && !node.finalizer) { this.raise(node.start, "Missing catch or finally clause"); } return this.finishNode(node, "TryStatement") }; pp$8.parseVarStatement = function(node, kind, allowMissingInitializer) { this.next(); this.parseVar(node, false, kind, allowMissingInitializer); this.semicolon(); return this.finishNode(node, "VariableDeclaration") }; pp$8.parseWhileStatement = function(node) { this.next(); node.test = this.parseParenExpression(); this.labels.push(loopLabel); node.body = this.parseStatement("while"); this.labels.pop(); return this.finishNode(node, "WhileStatement") }; pp$8.parseWithStatement = function(node) { if (this.strict) { this.raise(this.start, "'with' in strict mode"); } this.next(); node.object = this.parseParenExpression(); node.body = this.parseStatement("with"); return this.finishNode(node, "WithStatement") }; pp$8.parseEmptyStatement = function(node) { this.next(); return this.finishNode(node, "EmptyStatement") }; pp$8.parseLabeledStatement = function(node, maybeName, expr, context) { for (var i$1 = 0, list = this.labels; i$1 < list.length; i$1 += 1) { var label = list[i$1]; if (label.name === maybeName) { this.raise(expr.start, "Label '" + maybeName + "' is already declared"); } } var kind = this.type.isLoop ? "loop" : this.type === types$1._switch ? "switch" : null; for (var i = this.labels.length - 1; i >= 0; i--) { var label$1 = this.labels[i]; if (label$1.statementStart === node.start) { // Update information about previous labels on this node label$1.statementStart = this.start; label$1.kind = kind; } else { break } } this.labels.push({name: maybeName, kind: kind, statementStart: this.start}); node.body = this.parseStatement(context ? context.indexOf("label") === -1 ? context + "label" : context : "label"); this.labels.pop(); node.label = expr; return this.finishNode(node, "LabeledStatement") }; pp$8.parseExpressionStatement = function(node, expr) { node.expression = expr; this.semicolon(); return this.finishNode(node, "ExpressionStatement") }; // Parse a semicolon-enclosed block of statements, handling `"use // strict"` declarations when `allowStrict` is true (used for // function bodies). pp$8.parseBlock = function(createNewLexicalScope, node, exitStrict) { if ( createNewLexicalScope === void 0 ) createNewLexicalScope = true; if ( node === void 0 ) node = this.startNode(); node.body = []; this.expect(types$1.braceL); if (createNewLexicalScope) { this.enterScope(0); } while (this.type !== types$1.braceR) { var stmt = this.parseStatement(null); node.body.push(stmt); } if (exitStrict) { this.strict = false; } this.next(); if (createNewLexicalScope) { this.exitScope(); } return this.finishNode(node, "BlockStatement") }; // Parse a regular `for` loop. The disambiguation code in // `parseStatement` will already have parsed the init statement or // expression. pp$8.parseFor = function(node, init) { node.init = init; this.expect(types$1.semi); node.test = this.type === types$1.semi ? null : this.parseExpression(); this.expect(types$1.semi); node.update = this.type === types$1.parenR ? null : this.parseExpression(); this.expect(types$1.parenR); node.body = this.parseStatement("for"); this.exitScope(); this.labels.pop(); return this.finishNode(node, "ForStatement") }; // Parse a `for`/`in` and `for`/`of` loop, which are almost // same from parser's perspective. pp$8.parseForIn = function(node, init) { var isForIn = this.type === types$1._in; this.next(); if ( init.type === "VariableDeclaration" && init.declarations[0].init != null && ( !isForIn || this.options.ecmaVersion < 8 || this.strict || init.kind !== "var" || init.declarations[0].id.type !== "Identifier" ) ) { this.raise( init.start, ((isForIn ? "for-in" : "for-of") + " loop variable declaration may not have an initializer") ); } node.left = init; node.right = isForIn ? this.parseExpression() : this.parseMaybeAssign(); this.expect(types$1.parenR); node.body = this.parseStatement("for"); this.exitScope(); this.labels.pop(); return this.finishNode(node, isForIn ? "ForInStatement" : "ForOfStatement") }; // Parse a list of variable declarations. pp$8.parseVar = function(node, isFor, kind, allowMissingInitializer) { node.declarations = []; node.kind = kind; for (;;) { var decl = this.startNode(); this.parseVarId(decl, kind); if (this.eat(types$1.eq)) { decl.init = this.parseMaybeAssign(isFor); } else if (!allowMissingInitializer && kind === "const" && !(this.type === types$1._in || (this.options.ecmaVersion >= 6 && this.isContextual("of")))) { this.unexpected(); } else if (!allowMissingInitializer && (kind === "using" || kind === "await using") && this.options.ecmaVersion >= 17 && this.type !== types$1._in && !this.isContextual("of")) { this.raise(this.lastTokEnd, ("Missing initializer in " + kind + " declaration")); } else if (!allowMissingInitializer && decl.id.type !== "Identifier" && !(isFor && (this.type === types$1._in || this.isContextual("of")))) { this.raise(this.lastTokEnd, "Complex binding patterns require an initialization value"); } else { decl.init = null; } node.declarations.push(this.finishNode(decl, "VariableDeclarator")); if (!this.eat(types$1.comma)) { break } } return node }; pp$8.parseVarId = function(decl, kind) { decl.id = kind === "using" || kind === "await using" ? this.parseIdent() : this.parseBindingAtom(); this.checkLValPattern(decl.id, kind === "var" ? BIND_VAR : BIND_LEXICAL, false); }; var FUNC_STATEMENT = 1, FUNC_HANGING_STATEMENT = 2, FUNC_NULLABLE_ID = 4; // Parse a function declaration or literal (depending on the // `statement & FUNC_STATEMENT`). // Remove `allowExpressionBody` for 7.0.0, as it is only called with false pp$8.parseFunction = function(node, statement, allowExpressionBody, isAsync, forInit) { this.initFunction(node); if (this.options.ecmaVersion >= 9 || this.options.ecmaVersion >= 6 && !isAsync) { if (this.type === types$1.star && (statement & FUNC_HANGING_STATEMENT)) { this.unexpected(); } node.generator = this.eat(types$1.star); } if (this.options.ecmaVersion >= 8) { node.async = !!isAsync; } if (statement & FUNC_STATEMENT) { node.id = (statement & FUNC_NULLABLE_ID) && this.type !== types$1.name ? null : this.parseIdent(); if (node.id && !(statement & FUNC_HANGING_STATEMENT)) // If it is a regular function declaration in sloppy mode, then it is // subject to Annex B semantics (BIND_FUNCTION). Otherwise, the binding // mode depends on properties of the current scope (see // treatFunctionsAsVar). { this.checkLValSimple(node.id, (this.strict || node.generator || node.async) ? this.treatFunctionsAsVar ? BIND_VAR : BIND_LEXICAL : BIND_FUNCTION); } } var oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos; this.yieldPos = 0; this.awaitPos = 0; this.awaitIdentPos = 0; this.enterScope(functionFlags(node.async, node.generator)); if (!(statement & FUNC_STATEMENT)) { node.id = this.type === types$1.name ? this.parseIdent() : null; } this.parseFunctionParams(node); this.parseFunctionBody(node, allowExpressionBody, false, forInit); this.yieldPos = oldYieldPos; this.awaitPos = oldAwaitPos; this.awaitIdentPos = oldAwaitIdentPos; return this.finishNode(node, (statement & FUNC_STATEMENT) ? "FunctionDeclaration" : "FunctionExpression") }; pp$8.parseFunctionParams = function(node) { this.expect(types$1.parenL); node.params = this.parseBindingList(types$1.parenR, false, this.options.ecmaVersion >= 8); this.checkYieldAwaitInDefaultParams(); }; // Parse a class declaration or literal (depending on the // `isStatement` parameter). pp$8.parseClass = function(node, isStatement) { this.next(); // ecma-262 14.6 Class Definitions // A class definition is always strict mode code. var oldStrict = this.strict; this.strict = true; this.parseClassId(node, isStatement); this.parseClassSuper(node); var privateNameMap = this.enterClassBody(); var classBody = this.startNode(); var hadConstructor = false; classBody.body = []; this.expect(types$1.braceL); while (this.type !== types$1.braceR) { var element = this.parseClassElement(node.superClass !== null); if (element) { classBody.body.push(element); if (element.type === "MethodDefinition" && element.kind === "constructor") { if (hadConstructor) { this.raiseRecoverable(element.start, "Duplicate constructor in the same class"); } hadConstructor = true; } else if (element.key && element.key.type === "PrivateIdentifier" && isPrivateNameConflicted(privateNameMap, element)) { this.raiseRecoverable(element.key.start, ("Identifier '#" + (element.key.name) + "' has already been declared")); } } } this.strict = oldStrict; this.next(); node.body = this.finishNode(classBody, "ClassBody"); this.exitClassBody(); return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression") }; pp$8.parseClassElement = function(constructorAllowsSuper) { if (this.eat(types$1.semi)) { return null } var ecmaVersion = this.options.ecmaVersion; var node = this.startNode(); var keyName = ""; var isGenerator = false; var isAsync = false; var kind = "method"; var isStatic = false; if (this.eatContextual("static")) { // Parse static init block if (ecmaVersion >= 13 && this.eat(types$1.braceL)) { this.parseClassStaticBlock(node); return node } if (this.isClassElementNameStart() || this.type === types$1.star) { isStatic = true; } else { keyName = "static"; } } node.static = isStatic; if (!keyName && ecmaVersion >= 8 && this.eatContextual("async")) { if ((this.isClassElementNameStart() || this.type === types$1.star) && !this.canInsertSemicolon()) { isAsync = true; } else { keyName = "async"; } } if (!keyName && (ecmaVersion >= 9 || !isAsync) && this.eat(types$1.star)) { isGenerator = true; } if (!keyName && !isAsync && !isGenerator) { var lastValue = this.value; if (this.eatContextual("get") || this.eatContextual("set")) { if (this.isClassElementNameStart()) { kind = lastValue; } else { keyName = lastValue; } } } // Parse element name if (keyName) { // 'async', 'get', 'set', or 'static' were not a keyword contextually. // The last token is any of those. Make it the element name. node.computed = false; node.key = this.startNodeAt(this.lastTokStart, this.lastTokStartLoc); node.key.name = keyName; this.finishNode(node.key, "Identifier"); } else { this.parseClassElementName(node); } // Parse element value if (ecmaVersion < 13 || this.type === types$1.parenL || kind !== "method" || isGenerator || isAsync) { var isConstructor = !node.static && checkKeyName(node, "constructor"); var allowsDirectSuper = isConstructor && constructorAllowsSuper; // Couldn't move this check into the 'parseClassMethod' method for backward compatibility. if (isConstructor && kind !== "method") { this.raise(node.key.start, "Constructor can't have get/set modifier"); } node.kind = isConstructor ? "constructor" : kind; this.parseClassMethod(node, isGenerator, isAsync, allowsDirectSuper); } else { this.parseClassField(node); } return node }; pp$8.isClassElementNameStart = function() { return ( this.type === types$1.name || this.type === types$1.privateId || this.type === types$1.num || this.type === types$1.string || this.type === types$1.bracketL || this.type.keyword ) }; pp$8.parseClassElementName = function(element) { if (this.type === types$1.privateId) { if (this.value === "constructor") { this.raise(this.start, "Classes can't have an element named '#constructor'"); } element.computed = false; element.key = this.parsePrivateIdent(); } else { this.parsePropertyName(element); } }; pp$8.parseClassMethod = function(method, isGenerator, isAsync, allowsDirectSuper) { // Check key and flags var key = method.key; if (method.kind === "constructor") { if (isGenerator) { this.raise(key.start, "Constructor can't be a generator"); } if (isAsync) { this.raise(key.start, "Constructor can't be an async method"); } } else if (method.static && checkKeyName(method, "prototype")) { this.raise(key.start, "Classes may not have a static property named prototype"); } // Parse value var value = method.value = this.parseMethod(isGenerator, isAsync, allowsDirectSuper); // Check value if (method.kind === "get" && value.params.length !== 0) { this.raiseRecoverable(value.start, "getter should have no params"); } if (method.kind === "set" && value.params.length !== 1) { this.raiseRecoverable(value.start, "setter should have exactly one param"); } if (method.kind === "set" && value.params[0].type === "RestElement") { this.raiseRecoverable(value.params[0].start, "Setter cannot use rest params"); } return this.finishNode(method, "MethodDefinition") }; pp$8.parseClassField = function(field) { if (checkKeyName(field, "constructor")) { this.raise(field.key.start, "Classes can't have a field named 'constructor'"); } else if (field.static && checkKeyName(field, "prototype")) { this.raise(field.key.start, "Classes can't have a static field named 'prototype'"); } if (this.eat(types$1.eq)) { // To raise SyntaxError if 'arguments' exists in the initializer. this.enterScope(SCOPE_CLASS_FIELD_INIT | SCOPE_SUPER); field.value = this.parseMaybeAssign(); this.exitScope(); } else { field.value = null; } this.semicolon(); return this.finishNode(field, "PropertyDefinition") }; pp$8.parseClassStaticBlock = function(node) { node.body = []; var oldLabels = this.labels; this.labels = []; this.enterScope(SCOPE_CLASS_STATIC_BLOCK | SCOPE_SUPER); while (this.type !== types$1.braceR) { var stmt = this.parseStatement(null); node.body.push(stmt); } this.next(); this.exitScope(); this.labels = oldLabels; return this.finishNode(node, "StaticBlock") }; pp$8.parseClassId = function(node, isStatement) { if (this.type === types$1.name) { node.id = this.parseIdent(); if (isStatement) { this.checkLValSimple(node.id, BIND_LEXICAL, false); } } else { if (isStatement === true) { this.unexpected(); } node.id = null; } }; pp$8.parseClassSuper = function(node) { node.superClass = this.eat(types$1._extends) ? this.parseExprSubscripts(null, false) : null; }; pp$8.enterClassBody = function() { var element = {declared: Object.create(null), used: []}; this.privateNameStack.push(element); return element.declared }; pp$8.exitClassBody = function() { var ref = this.privateNameStack.pop(); var declared = ref.declared; var used = ref.used; if (!this.options.checkPrivateFields) { return } var len = this.privateNameStack.length; var parent = len === 0 ? null : this.privateNameStack[len - 1]; for (var i = 0; i < used.length; ++i) { var id = used[i]; if (!hasOwn(declared, id.name)) { if (parent) { parent.used.push(id); } else { this.raiseRecoverable(id.start, ("Private field '#" + (id.name) + "' must be declared in an enclosing class")); } } } }; function isPrivateNameConflicted(privateNameMap, element) { var name = element.key.name; var curr = privateNameMap[name]; var next = "true"; if (element.type === "MethodDefinition" && (element.kind === "get" || element.kind === "set")) { next = (element.static ? "s" : "i") + element.kind; } // `class { get #a(){}; static set #a(_){} }` is also conflict. if ( curr === "iget" && next === "iset" || curr === "iset" && next === "iget" || curr === "sget" && next === "sset" || curr === "sset" && next === "sget" ) { privateNameMap[name] = "true"; return false } else if (!curr) { privateNameMap[name] = next; return false } else { return true } } function checkKeyName(node, name) { var computed = node.computed; var key = node.key; return !computed && ( key.type === "Identifier" && key.name === name || key.type === "Literal" && key.value === name ) } // Parses module export declaration. pp$8.parseExportAllDeclaration = function(node, exports) { if (this.options.ecmaVersion >= 11) { if (this.eatContextual("as")) { node.exported = this.parseModuleExportName(); this.checkExport(exports, node.exported, this.lastTokStart); } else { node.exported = null; } } this.expectContextual("from"); if (this.type !== types$1.string) { this.unexpected(); } node.source = this.parseExprAtom(); if (this.options.ecmaVersion >= 16) { node.attributes = this.parseWithClause(); } this.semicolon(); return this.finishNode(node, "ExportAllDeclaration") }; pp$8.parseExport = function(node, exports) { this.next(); // export * from '...' if (this.eat(types$1.star)) { return this.parseExportAllDeclaration(node, exports) } if (this.eat(types$1._default)) { // export default ... this.checkExport(exports, "default", this.lastTokStart); node.declaration = this.parseExportDefaultDeclaration(); return this.finishNode(node, "ExportDefaultDeclaration") } // export var|const|let|function|class ... if (this.shouldParseExportStatement()) { node.declaration = this.parseExportDeclaration(node); if (node.declaration.type === "VariableDeclaration") { this.checkVariableExport(exports, node.declaration.declarations); } else { this.checkExport(exports, node.declaration.id, node.declaration.id.start); } node.specifiers = []; node.source = null; if (this.options.ecmaVersion >= 16) { node.attributes = []; } } else { // export { x, y as z } [from '...'] node.declaration = null; node.specifiers = this.parseExportSpecifiers(exports); if (this.eatContextual("from")) { if (this.type !== types$1.string) { this.unexpected(); } node.source = this.parseExprAtom(); if (this.options.ecmaVersion >= 16) { node.attributes = this.parseWithClause(); } } else { for (var i = 0, list = node.specifiers; i < list.length; i += 1) { // check for keywords used as local names var spec = list[i]; this.checkUnreserved(spec.local); // check if export is defined this.checkLocalExport(spec.local); if (spec.local.type === "Literal") { this.raise(spec.local.start, "A string literal cannot be used as an exported binding without `from`."); } } node.source = null; if (this.options.ecmaVersion >= 16) { node.attributes = []; } } this.semicolon(); } return this.finishNode(node, "ExportNamedDeclaration") }; pp$8.parseExportDeclaration = function(node) { return this.parseStatement(null) }; pp$8.parseExportDefaultDeclaration = function() { var isAsync; if (this.type === types$1._function || (isAsync = this.isAsyncFunction())) { var fNode = this.startNode(); this.next(); if (isAsync) { this.next(); } return this.parseFunction(fNode, FUNC_STATEMENT | FUNC_NULLABLE_ID, false, isAsync) } else if (this.type === types$1._class) { var cNode = this.startNode(); return this.parseClass(cNode, "nullableID") } else { var declaration = this.parseMaybeAssign(); this.semicolon(); return declaration } }; pp$8.checkExport = function(exports, name, pos) { if (!exports) { return } if (typeof name !== "string") { name = name.type === "Identifier" ? name.name : name.value; } if (hasOwn(exports, name)) { this.raiseRecoverable(pos, "Duplicate export '" + name + "'"); } exports[name] = true; }; pp$8.checkPatternExport = function(exports, pat) { var type = pat.type; if (type === "Identifier") { this.checkExport(exports, pat, pat.start); } else if (type === "ObjectPattern") { for (var i = 0, list = pat.properties; i < list.length; i += 1) { var prop = list[i]; this.checkPatternExport(exports, prop); } } else if (type === "ArrayPattern") { for (var i$1 = 0, list$1 = pat.elements; i$1 < list$1.length; i$1 += 1) { var elt = list$1[i$1]; if (elt) { this.checkPatternExport(exports, elt); } } } else if (type === "Property") { this.checkPatternExport(exports, pat.value); } else if (type === "AssignmentPattern") { this.checkPatternExport(exports, pat.left); } else if (type === "RestElement") { this.checkPatternExport(exports, pat.argument); } }; pp$8.checkVariableExport = function(exports, decls) { if (!exports) { return } for (var i = 0, list = decls; i < list.length; i += 1) { var decl = list[i]; this.checkPatternExport(exports, decl.id); } }; pp$8.shouldParseExportStatement = function() { return this.type.keyword === "var" || this.type.keyword === "const" || this.type.keyword === "class" || this.type.keyword === "function" || this.isLet() || this.isAsyncFunction() }; // Parses a comma-separated list of module exports. pp$8.parseExportSpecifier = function(exports) { var node = this.startNode(); node.local = this.parseModuleExportName(); node.exported = this.eatContextual("as") ? this.parseModuleExportName() : node.local; this.checkExport( exports, node.exported, node.exported.start ); return this.finishNode(node, "ExportSpecifier") }; pp$8.parseExportSpecifiers = function(exports) { var nodes = [], first = true; // export { x, y as z } [from '...'] this.expect(types$1.braceL); while (!this.eat(types$1.braceR)) { if (!first) { this.expect(types$1.comma); if (this.afterTrailingComma(types$1.braceR)) { break } } else { first = false; } nodes.push(this.parseExportSpecifier(exports)); } return nodes }; // Parses import declaration. pp$8.parseImport = function(node) { this.next(); // import '...' if (this.type === types$1.string) { node.specifiers = empty$1; node.source = this.parseExprAtom(); } else { node.specifiers = this.parseImportSpecifiers(); this.expectContextual("from"); node.source = this.type === types$1.string ? this.parseExprAtom() : this.unexpected(); } if (this.options.ecmaVersion >= 16) { node.attributes = this.parseWithClause(); } this.semicolon(); return this.finishNode(node, "ImportDeclaration") }; // Parses a comma-separated list of module imports. pp$8.parseImportSpecifier = function() { var node = this.startNode(); node.imported = this.parseModuleExportName(); if (this.eatContextual("as")) { node.local = this.parseIdent(); } else { this.checkUnreserved(node.imported); node.local = node.imported; } this.checkLValSimple(node.local, BIND_LEXICAL); return this.finishNode(node, "ImportSpecifier") }; pp$8.parseImportDefaultSpecifier = function() { // import defaultObj, { x, y as z } from '...' var node = this.startNode(); node.local = this.parseIdent(); this.checkLValSimple(node.local, BIND_LEXICAL); return this.finishNode(node, "ImportDefaultSpecifier") }; pp$8.parseImportNamespaceSpecifier = function() { var node = this.startNode(); this.next(); this.expectContextual("as"); node.local = this.parseIdent(); this.checkLValSimple(node.local, BIND_LEXICAL); return this.finishNode(node, "ImportNamespaceSpecifier") }; pp$8.parseImportSpecifiers = function() { var nodes = [], first = true; if (this.type === types$1.name) { nodes.push(this.parseImportDefaultSpecifier()); if (!this.eat(types$1.comma)) { return nodes } } if (this.type === types$1.star) { nodes.push(this.parseImportNamespaceSpecifier()); return nodes } this.expect(types$1.braceL); while (!this.eat(types$1.braceR)) { if (!first) { this.expect(types$1.comma); if (this.afterTrailingComma(types$1.braceR)) { break } } else { first = false; } nodes.push(this.parseImportSpecifier()); } return nodes }; pp$8.parseWithClause = function() { var nodes = []; if (!this.eat(types$1._with)) { return nodes } this.expect(types$1.braceL); var attributeKeys = {}; var first = true; while (!this.eat(types$1.braceR)) { if (!first) { this.expect(types$1.comma); if (this.afterTrailingComma(types$1.braceR)) { break } } else { first = false; } var attr = this.parseImportAttribute(); var keyName = attr.key.type === "Identifier" ? attr.key.name : attr.key.value; if (hasOwn(attributeKeys, keyName)) { this.raiseRecoverable(attr.key.start, "Duplicate attribute key '" + keyName + "'"); } attributeKeys[keyName] = true; nodes.push(attr); } return nodes }; pp$8.parseImportAttribute = function() { var node = this.startNode(); node.key = this.type === types$1.string ? this.parseExprAtom() : this.parseIdent(this.options.allowReserved !== "never"); this.expect(types$1.colon); if (this.type !== types$1.string) { this.unexpected(); } node.value = this.parseExprAtom(); return this.finishNode(node, "ImportAttribute") }; pp$8.parseModuleExportName = function() { if (this.options.ecmaVersion >= 13 && this.type === types$1.string) { var stringLiteral = this.parseLiteral(this.value); if (loneSurrogate.test(stringLiteral.value)) { this.raise(stringLiteral.start, "An export name cannot include a lone surrogate."); } return stringLiteral } return this.parseIdent(true) }; // Set `ExpressionStatement#directive` property for directive prologues. pp$8.adaptDirectivePrologue = function(statements) { for (var i = 0; i < statements.length && this.isDirectiveCandidate(statements[i]); ++i) { statements[i].directive = statements[i].expression.raw.slice(1, -1); } }; pp$8.isDirectiveCandidate = function(statement) { return ( this.options.ecmaVersion >= 5 && statement.type === "ExpressionStatement" && statement.expression.type === "Literal" && typeof statement.expression.value === "string" && // Reject parenthesized strings. (this.input[statement.start] === "\"" || this.input[statement.start] === "'") ) }; var pp$7 = Parser.prototype; // Convert existing expression atom to assignable pattern // if possible. pp$7.toAssignable = function(node, isBinding, refDestructuringErrors) { if (this.options.ecmaVersion >= 6 && node) { switch (node.type) { case "Identifier": if (this.inAsync && node.name === "await") { this.raise(node.start, "Cannot use 'await' as identifier inside an async function"); } break case "ObjectPattern": case "ArrayPattern": case "AssignmentPattern": case "RestElement": break case "ObjectExpression": node.type = "ObjectPattern"; if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true); } for (var i = 0, list = node.properties; i < list.length; i += 1) { var prop = list[i]; this.toAssignable(prop, isBinding); // Early error: // AssignmentRestProperty[Yield, Await] : // `...` DestructuringAssignmentTarget[Yield, Await] // // It is a Syntax Error if |DestructuringAssignmentTarget| is an |ArrayLiteral| or an |ObjectLiteral|. if ( prop.type === "RestElement" && (prop.argument.type === "ArrayPattern" || prop.argument.type === "ObjectPattern") ) { this.raise(prop.argument.start, "Unexpected token"); } } break case "Property": // AssignmentProperty has type === "Property" if (node.kind !== "init") { this.raise(node.key.start, "Object pattern can't contain getter or setter"); } this.toAssignable(node.value, isBinding); break case "ArrayExpression": node.type = "ArrayPattern"; if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true); } this.toAssignableList(node.elements, isBinding); break case "SpreadElement": node.type = "RestElement"; this.toAssignable(node.argument, isBinding); if (node.argument.type === "AssignmentPattern") { this.raise(node.argument.start, "Rest elements cannot have a default value"); } break case "AssignmentExpression": if (node.operator !== "=") { this.raise(node.left.end, "Only '=' operator can be used for specifying default value."); } node.type = "AssignmentPattern"; delete node.operator; this.toAssignable(node.left, isBinding); break case "ParenthesizedExpression": this.toAssignable(node.expression, isBinding, refDestructuringErrors); break case "ChainExpression": this.raiseRecoverable(node.start, "Optional chaining cannot appear in left-hand side"); break case "MemberExpression": if (!isBinding) { break } default: this.raise(node.start, "Assigning to rvalue"); } } else if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true); } return node }; // Convert list of expression atoms to binding list. pp$7.toAssignableList = function(exprList, isBinding) { var end = exprList.length; for (var i = 0; i < end; i++) { var elt = exprList[i]; if (elt) { this.toAssignable(elt, isBinding); } } if (end) { var last = exprList[end - 1]; if (this.options.ecmaVersion === 6 && isBinding && last && last.type === "RestElement" && last.argument.type !== "Identifier") { this.unexpected(last.argument.start); } } return exprList }; // Parses spread element. pp$7.parseSpread = function(refDestructuringErrors) { var node = this.startNode(); this.next(); node.argument = this.parseMaybeAssign(false, refDestructuringErrors); return this.finishNode(node, "SpreadElement") }; pp$7.parseRestBinding = function() { var node = this.startNode(); this.next(); // RestElement inside of a function parameter must be an identifier if (this.options.ecmaVersion === 6 && this.type !== types$1.name) { this.unexpected(); } node.argument = this.parseBindingAtom(); return this.finishNode(node, "RestElement") }; // Parses lvalue (assignable) atom. pp$7.parseBindingAtom = function() { if (this.options.ecmaVersion >= 6) { switch (this.type) { case types$1.bracketL: var node = this.startNode(); this.next(); node.elements = this.parseBindingList(types$1.bracketR, true, true); return this.finishNode(node, "ArrayPattern") case types$1.braceL: return this.parseObj(true) } } return this.parseIdent() }; pp$7.parseBindingList = function(close, allowEmpty, allowTrailingComma, allowModifiers) { var elts = [], first = true; while (!this.eat(close)) { if (first) { first = false; } else { this.expect(types$1.comma); } if (allowEmpty && this.type === types$1.comma) { elts.push(null); } else if (allowTrailingComma && this.afterTrailingComma(close)) { break } else if (this.type === types$1.ellipsis) { var rest = this.parseRestBinding(); this.parseBindingListItem(rest); elts.push(rest); if (this.type === types$1.comma) { this.raiseRecoverable(this.start, "Comma is not permitted after the rest element"); } this.expect(close); break } else { elts.push(this.parseAssignableListItem(allowModifiers)); } } return elts }; pp$7.parseAssignableListItem = function(allowModifiers) { var elem = this.parseMaybeDefault(this.start, this.startLoc); this.parseBindingListItem(elem); return elem }; pp$7.parseBindingListItem = function(param) { return param }; // Parses assignment pattern around given atom if possible. pp$7.parseMaybeDefault = function(startPos, startLoc, left) { left = left || this.parseBindingAtom(); if (this.options.ecmaVersion < 6 || !this.eat(types$1.eq)) { return left } var node = this.startNodeAt(startPos, startLoc); node.left = left; node.right = this.parseMaybeAssign(); return this.finishNode(node, "AssignmentPattern") }; // The following three functions all verify that a node is an lvalue — // something that can be bound, or assigned to. In order to do so, they perform // a variety of checks: // // - Check that none of the bound/assigned-to identifiers are reserved words. // - Record name declarations for bindings in the appropriate scope. // - Check duplicate argument names, if checkClashes is set. // // If a complex binding pattern is encountered (e.g., object and array // destructuring), the entire pattern is recursively checked. // // There are three versions of checkLVal*() appropriate for different // circumstances: // // - checkLValSimple() shall be used if the syntactic construct supports // nothing other than identifiers and member expressions. Parenthesized // expressions are also correctly handled. This is generally appropriate for // constructs for which the spec says // // > It is a Syntax Error if AssignmentTargetType of [the production] is not // > simple. // // It is also appropriate for checking if an identifier is valid and not // defined elsewhere, like import declarations or function/class identifiers. // // Examples where this is used include: // a += …; // import a from '…'; // where a is the node to be checked. // // - checkLValPattern() shall be used if the syntactic construct supports // anything checkLValSimple() supports, as well as object and array // destructuring patterns. This is generally appropriate for constructs for // which the spec says // // > It is a Syntax Error if [the production] is neither an ObjectLiteral nor // > an ArrayLiteral and AssignmentTargetType of [the production] is not // > simple. // // Examples where this is used include: // (a = …); // const a = …; // try { … } catch (a) { … } // where a is the node to be checked. // // - checkLValInnerPattern() shall be used if the syntactic construct supports // anything checkLValPattern() supports, as well as default assignment // patterns, rest elements, and other constructs that may appear within an // object or array destructuring pattern. // // As a special case, function parameters also use checkLValInnerPattern(), // as they also support defaults and rest constructs. // // These functions deliberately support both assignment and binding constructs, // as the logic for both is exceedingly similar. If the node is the target of // an assignment, then bindingType should be set to BIND_NONE. Otherwise, it // should be set to the appropriate BIND_* constant, like BIND_VAR or // BIND_LEXICAL. // // If the function is called with a non-BIND_NONE bindingType, then // additionally a checkClashes object may be specified to allow checking for // duplicate argument names. checkClashes is ignored if the provided construct // is an assignment (i.e., bindingType is BIND_NONE). pp$7.checkLValSimple = function(expr, bindingType, checkClashes) { if ( bindingType === void 0 ) bindingType = BIND_NONE; var isBind = bindingType !== BIND_NONE; switch (expr.type) { case "Identifier": if (this.strict && this.reservedWordsStrictBind.test(expr.name)) { this.raiseRecoverable(expr.start, (isBind ? "Binding " : "Assigning to ") + expr.name + " in strict mode"); } if (isBind) { if (bindingType === BIND_LEXICAL && expr.name === "let") { this.raiseRecoverable(expr.start, "let is disallowed as a lexically bound name"); } if (checkClashes) { if (hasOwn(checkClashes, expr.name)) { this.raiseRecoverable(expr.start, "Argument name clash"); } checkClashes[expr.name] = true; } if (bindingType !== BIND_OUTSIDE) { this.declareName(expr.name, bindingType, expr.start); } } break case "ChainExpression": this.raiseRecoverable(expr.start, "Optional chaining cannot appear in left-hand side"); break case "MemberExpression": if (isBind) { this.raiseRecoverable(expr.start, "Binding member expression"); } break case "ParenthesizedExpression": if (isBind) { this.raiseRecoverable(expr.start, "Binding parenthesized expression"); } return this.checkLValSimple(expr.expression, bindingType, checkClashes) default: this.raise(expr.start, (isBind ? "Binding" : "Assigning to") + " rvalue"); } }; pp$7.checkLValPattern = function(expr, bindingType, checkClashes) { if ( bindingType === void 0 ) bindingType = BIND_NONE; switch (expr.type) { case "ObjectPattern": for (var i = 0, list = expr.properties; i < list.length; i += 1) { var prop = list[i]; this.checkLValInnerPattern(prop, bindingType, checkClashes); } break case "ArrayPattern": for (var i$1 = 0, list$1 = expr.elements; i$1 < list$1.length; i$1 += 1) { var elem = list$1[i$1]; if (elem) { this.checkLValInnerPattern(elem, bindingType, checkClashes); } } break default: this.checkLValSimple(expr, bindingType, checkClashes); } }; pp$7.checkLValInnerPattern = function(expr, bindingType, checkClashes) { if ( bindingType === void 0 ) bindingType = BIND_NONE; switch (expr.type) { case "Property": // AssignmentProperty has type === "Property" this.checkLValInnerPattern(expr.value, bindingType, checkClashes); break case "AssignmentPattern": this.checkLValPattern(expr.left, bindingType, checkClashes); break case "RestElement": this.checkLValPattern(expr.argument, bindingType, checkClashes); break default: this.checkLValPattern(expr, bindingType, checkClashes); } }; // The algorithm used to determine whether a regexp can appear at a // given point in the program is loosely based on sweet.js' approach. // See https://github.com/mozilla/sweet.js/wiki/design var TokContext = function TokContext(token, isExpr, preserveSpace, override, generator) { this.token = token; this.isExpr = !!isExpr; this.preserveSpace = !!preserveSpace; this.override = override; this.generator = !!generator; }; var types = { b_stat: new TokContext("{", false), b_expr: new TokContext("{", true), b_tmpl: new TokContext("${", false), p_stat: new TokContext("(", false), p_expr: new TokContext("(", true), q_tmpl: new TokContext("`", true, true, function (p) { return p.tryReadTemplateToken(); }), f_stat: new TokContext("function", false), f_expr: new TokContext("function", true), f_expr_gen: new TokContext("function", true, false, null, true), f_gen: new TokContext("function", false, false, null, true) }; var pp$6 = Parser.prototype; pp$6.initialContext = function() { return [types.b_stat] }; pp$6.curContext = function() { return this.context[this.context.length - 1] }; pp$6.braceIsBlock = function(prevType) { var parent = this.curContext(); if (parent === types.f_expr || parent === types.f_stat) { return true } if (prevType === types$1.colon && (parent === types.b_stat || parent === types.b_expr)) { return !parent.isExpr } // The check for `tt.name && exprAllowed` detects whether we are // after a `yield` or `of` construct. See the `updateContext` for // `tt.name`. if (prevType === types$1._return || prevType === types$1.name && this.exprAllowed) { return lineBreak.test(this.input.slice(this.lastTokEnd, this.start)) } if (prevType === types$1._else || prevType === types$1.semi || prevType === types$1.eof || prevType === types$1.parenR || prevType === types$1.arrow) { return true } if (prevType === types$1.braceL) { return parent === types.b_stat } if (prevType === types$1._var || prevType === types$1._const || prevType === types$1.name) { return false } return !this.exprAllowed }; pp$6.inGeneratorContext = function() { for (var i = this.context.length - 1; i >= 1; i--) { var context = this.context[i]; if (context.token === "function") { return context.generator } } return false }; pp$6.updateContext = function(prevType) { var update, type = this.type; if (type.keyword && prevType === types$1.dot) { this.exprAllowed = false; } else if (update = type.updateContext) { update.call(this, prevType); } else { this.exprAllowed = type.beforeExpr; } }; // Used to handle edge cases when token context could not be inferred correctly during tokenization phase pp$6.overrideContext = function(tokenCtx) { if (this.curContext() !== tokenCtx) { this.context[this.context.length - 1] = tokenCtx; } }; // Token-specific context update code types$1.parenR.updateContext = types$1.braceR.updateContext = function() { if (this.context.length === 1) { this.exprAllowed = true; return } var out = this.context.pop(); if (out === types.b_stat && this.curContext().token === "function") { out = this.context.pop(); } this.exprAllowed = !out.isExpr; }; types$1.braceL.updateContext = function(prevType) { this.context.push(this.braceIsBlock(prevType) ? types.b_stat : types.b_expr); this.exprAllowed = true; }; types$1.dollarBraceL.updateContext = function() { this.context.push(types.b_tmpl); this.exprAllowed = true; }; types$1.parenL.updateContext = function(prevType) { var statementParens = prevType === types$1._if || prevType === types$1._for || prevType === types$1._with || prevType === types$1._while; this.context.push(statementParens ? types.p_stat : types.p_expr); this.exprAllowed = true; }; types$1.incDec.updateContext = function() { // tokExprAllowed stays unchanged }; types$1._function.updateContext = types$1._class.updateContext = function(prevType) { if (prevType.beforeExpr && prevType !== types$1._else && !(prevType === types$1.semi && this.curContext() !== types.p_stat) && !(prevType === types$1._return && lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) && !((prevType === types$1.colon || prevType === types$1.braceL) && this.curContext() === types.b_stat)) { this.context.push(types.f_expr); } else { this.context.push(types.f_stat); } this.exprAllowed = false; }; types$1.colon.updateContext = function() { if (this.curContext().token === "function") { this.context.pop(); } this.exprAllowed = true; }; types$1.backQuote.updateContext = function() { if (this.curContext() === types.q_tmpl) { this.context.pop(); } else { this.context.push(types.q_tmpl); } this.exprAllowed = false; }; types$1.star.updateContext = function(prevType) { if (prevType === types$1._function) { var index = this.context.length - 1; if (this.context[index] === types.f_expr) { this.context[index] = types.f_expr_gen; } else { this.context[index] = types.f_gen; } } this.exprAllowed = true; }; types$1.name.updateContext = function(prevType) { var allowed = false; if (this.options.ecmaVersion >= 6 && prevType !== types$1.dot) { if (this.value === "of" && !this.exprAllowed || this.value === "yield" && this.inGeneratorContext()) { allowed = true; } } this.exprAllowed = allowed; }; // A recursive descent parser operates by defining functions for all // syntactic elements, and recursively calling those, each function // advancing the input stream and returning an AST node. Precedence // of constructs (for example, the fact that `!x[1]` means `!(x[1])` // instead of `(!x)[1]` is handled by the fact that the parser // function that parses unary prefix operators is called first, and // in turn calls the function that parses `[]` subscripts — that // way, it'll receive the node for `x[1]` already parsed, and wraps // *that* in the unary operator node. // // Acorn uses an [operator precedence parser][opp] to handle binary // operator precedence, because it is much more compact than using // the technique outlined above, which uses different, nesting // functions to specify precedence, for all of the ten binary // precedence levels that JavaScript defines. // // [opp]: http://en.wikipedia.org/wiki/Operator-precedence_parser var pp$5 = Parser.prototype; // Check if property name clashes with already added. // Object/class getters and setters are not allowed to clash — // either with each other or with an init property — and in // strict mode, init properties are also not allowed to be repeated. pp$5.checkPropClash = function(prop, propHash, refDestructuringErrors) { if (this.options.ecmaVersion >= 9 && prop.type === "SpreadElement") { return } if (this.options.ecmaVersion >= 6 && (prop.computed || prop.method || prop.shorthand)) { return } var key = prop.key; var name; switch (key.type) { case "Identifier": name = key.name; break case "Literal": name = String(key.value); break default: return } var kind = prop.kind; if (this.options.ecmaVersion >= 6) { if (name === "__proto__" && kind === "init") { if (propHash.proto) { if (refDestructuringErrors) { if (refDestructuringErrors.doubleProto < 0) { refDestructuringErrors.doubleProto = key.start; } } else { this.raiseRecoverable(key.start, "Redefinition of __proto__ property"); } } propHash.proto = true; } return } name = "$" + name; var other = propHash[name]; if (other) { var redefinition; if (kind === "init") { redefinition = this.strict && other.init || other.get || other.set; } else { redefinition = other.init || other[kind]; } if (redefinition) { this.raiseRecoverable(key.start, "Redefinition of property"); } } else { other = propHash[name] = { init: false, get: false, set: false }; } other[kind] = true; }; // ### Expression parsing // These nest, from the most general expression type at the top to // 'atomic', nondivisible expression types at the bottom. Most of // the functions will simply let the function(s) below them parse, // and, *if* the syntactic construct they handle is present, wrap // the AST node that the inner parser gave them in another node. // Parse a full expression. The optional arguments are used to // forbid the `in` operator (in for loops initalization expressions) // and provide reference for storing '=' operator inside shorthand // property assignment in contexts where both object expression // and object pattern might appear (so it's possible to raise // delayed syntax error at correct position). pp$5.parseExpression = function(forInit, refDestructuringErrors) { var startPos = this.start, startLoc = this.startLoc; var expr = this.parseMaybeAssign(forInit, refDestructuringErrors); if (this.type === types$1.comma) { var node = this.startNodeAt(startPos, startLoc); node.expressions = [expr]; while (this.eat(types$1.comma)) { node.expressions.push(this.parseMaybeAssign(forInit, refDestructuringErrors)); } return this.finishNode(node, "SequenceExpression") } return expr }; // Parse an assignment expression. This includes applications of // operators like `+=`. pp$5.parseMaybeAssign = function(forInit, refDestructuringErrors, afterLeftParse) { if (this.isContextual("yield")) { if (this.inGenerator) { return this.parseYield(forInit) } // The tokenizer will assume an expression is allowed after // `yield`, but this isn't that kind of yield else { this.exprAllowed = false; } } var ownDestructuringErrors = false, oldParenAssign = -1, oldTrailingComma = -1, oldDoubleProto = -1; if (refDestructuringErrors) { oldParenAssign = refDestructuringErrors.parenthesizedAssign; oldTrailingComma = refDestructuringErrors.trailingComma; oldDoubleProto = refDestructuringErrors.doubleProto; refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = -1; } else { refDestructuringErrors = new DestructuringErrors; ownDestructuringErrors = true; } var startPos = this.start, startLoc = this.startLoc; if (this.type === types$1.parenL || this.type === types$1.name) { this.potentialArrowAt = this.start; this.potentialArrowInForAwait = forInit === "await"; } var left = this.parseMaybeConditional(forInit, refDestructuringErrors); if (afterLeftParse) { left = afterLeftParse.call(this, left, startPos, startLoc); } if (this.type.isAssign) { var node = this.startNodeAt(startPos, startLoc); node.operator = this.value; if (this.type === types$1.eq) { left = this.toAssignable(left, false, refDestructuringErrors); } if (!ownDestructuringErrors) { refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = refDestructuringErrors.doubleProto = -1; } if (refDestructuringErrors.shorthandAssign >= left.start) { refDestructuringErrors.shorthandAssign = -1; } // reset because shorthand default was used correctly if (this.type === types$1.eq) { this.checkLValPattern(left); } else { this.checkLValSimple(left); } node.left = left; this.next(); node.right = this.parseMaybeAssign(forInit); if (oldDoubleProto > -1) { refDestructuringErrors.doubleProto = oldDoubleProto; } return this.finishNode(node, "AssignmentExpression") } else { if (ownDestructuringErrors) { this.checkExpressionErrors(refDestructuringErrors, true); } } if (oldParenAssign > -1) { refDestructuringErrors.parenthesizedAssign = oldParenAssign; } if (oldTrailingComma > -1) { refDestructuringErrors.trailingComma = oldTrailingComma; } return left }; // Parse a ternary conditional (`?:`) operator. pp$5.parseMaybeConditional = function(forInit, refDestructuringErrors) { var startPos = this.start, startLoc = this.startLoc; var expr = this.parseExprOps(forInit, refDestructuringErrors); if (this.checkExpressionErrors(refDestructuringErrors)) { return expr } if (this.eat(types$1.question)) { var node = this.startNodeAt(startPos, startLoc); node.test = expr; node.consequent = this.parseMaybeAssign(); this.expect(types$1.colon); node.alternate = this.parseMaybeAssign(forInit); return this.finishNode(node, "ConditionalExpression") } return expr }; // Start the precedence parser. pp$5.parseExprOps = function(forInit, refDestructuringErrors) { var startPos = this.start, startLoc = this.startLoc; var expr = this.parseMaybeUnary(refDestructuringErrors, false, false, forInit); if (this.checkExpressionErrors(refDestructuringErrors)) { return expr } return expr.start === startPos && expr.type === "ArrowFunctionExpression" ? expr : this.parseExprOp(expr, startPos, startLoc, -1, forInit) }; // Parse binary operators with the operator precedence parsing // algorithm. `left` is the left-hand side of the operator. // `minPrec` provides context that allows the function to stop and // defer further parser to one of its callers when it encounters an // operator that has a lower precedence than the set it is parsing. pp$5.parseExprOp = function(left, leftStartPos, leftStartLoc, minPrec, forInit) { var prec = this.type.binop; if (prec != null && (!forInit || this.type !== types$1._in)) { if (prec > minPrec) { var logical = this.type === types$1.logicalOR || this.type === types$1.logicalAND; var coalesce = this.type === types$1.coalesce; if (coalesce) { // Handle the precedence of `tt.coalesce` as equal to the range of logical expressions. // In other words, `node.right` shouldn't contain logical expressions in order to check the mixed error. prec = types$1.logicalAND.binop; } var op = this.value; this.next(); var startPos = this.start, startLoc = this.startLoc; var right = this.parseExprOp(this.parseMaybeUnary(null, false, false, forInit), startPos, startLoc, prec, forInit); var node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical || coalesce); if ((logical && this.type === types$1.coalesce) || (coalesce && (this.type === types$1.logicalOR || this.type === types$1.logicalAND))) { this.raiseRecoverable(this.start, "Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"); } return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, forInit) } } return left }; pp$5.buildBinary = function(startPos, startLoc, left, right, op, logical) { if (right.type === "PrivateIdentifier") { this.raise(right.start, "Private identifier can only be left side of binary expression"); } var node = this.startNodeAt(startPos, startLoc); node.left = left; node.operator = op; node.right = right; return this.finishNode(node, logical ? "LogicalExpression" : "BinaryExpression") }; // Parse unary operators, both prefix and postfix. pp$5.parseMaybeUnary = function(refDestructuringErrors, sawUnary, incDec, forInit) { var startPos = this.start, startLoc = this.startLoc, expr; if (this.isContextual("await") && this.canAwait) { expr = this.parseAwait(forInit); sawUnary = true; } else if (this.type.prefix) { var node = this.startNode(), update = this.type === types$1.incDec; node.operator = this.value; node.prefix = true; this.next(); node.argument = this.parseMaybeUnary(null, true, update, forInit); this.checkExpressionErrors(refDestructuringErrors, true); if (update) { this.checkLValSimple(node.argument); } else if (this.strict && node.operator === "delete" && isLocalVariableAccess(node.argument)) { this.raiseRecoverable(node.start, "Deleting local variable in strict mode"); } else if (node.operator === "delete" && isPrivateFieldAccess(node.argument)) { this.raiseRecoverable(node.start, "Private fields can not be deleted"); } else { sawUnary = true; } expr = this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression"); } else if (!sawUnary && this.type === types$1.privateId) { if ((forInit || this.privateNameStack.length === 0) && this.options.checkPrivateFields) { this.unexpected(); } expr = this.parsePrivateIdent(); // only could be private fields in 'in', such as #x in obj if (this.type !== types$1._in) { this.unexpected(); } } else { expr = this.parseExprSubscripts(refDestructuringErrors, forInit); if (this.checkExpressionErrors(refDestructuringErrors)) { return expr } while (this.type.postfix && !this.canInsertSemicolon()) { var node$1 = this.startNodeAt(startPos, startLoc); node$1.operator = this.value; node$1.prefix = false; node$1.argument = expr; this.checkLValSimple(expr); this.next(); expr = this.finishNode(node$1, "UpdateExpression"); } } if (!incDec && this.eat(types$1.starstar)) { if (sawUnary) { this.unexpected(this.lastTokStart); } else { return this.buildBinary(startPos, startLoc, expr, this.parseMaybeUnary(null, false, false, forInit), "**", false) } } else { return expr } }; function isLocalVariableAccess(node) { return ( node.type === "Identifier" || node.type === "ParenthesizedExpression" && isLocalVariableAccess(node.expression) ) } function isPrivateFieldAccess(node) { return ( node.type === "MemberExpression" && node.property.type === "PrivateIdentifier" || node.type === "ChainExpression" && isPrivateFieldAccess(node.expression) || node.type === "ParenthesizedExpression" && isPrivateFieldAccess(node.expression) ) } // Parse call, dot, and `[]`-subscript expressions. pp$5.parseExprSubscripts = function(refDestructuringErrors, forInit) { var startPos = this.start, startLoc = this.startLoc; var expr = this.parseExprAtom(refDestructuringErrors, forInit); if (expr.type === "ArrowFunctionExpression" && this.input.slice(this.lastTokStart, this.lastTokEnd) !== ")") { return expr } var result = this.parseSubscripts(expr, startPos, startLoc, false, forInit); if (refDestructuringErrors && result.type === "MemberExpression") { if (refDestructuringErrors.parenthesizedAssign >= result.start) { refDestructuringErrors.parenthesizedAssign = -1; } if (refDestructuringErrors.parenthesizedBind >= result.start) { refDestructuringErrors.parenthesizedBind = -1; } if (refDestructuringErrors.trailingComma >= result.start) { refDestructuringErrors.trailingComma = -1; } } return result }; pp$5.parseSubscripts = function(base, startPos, startLoc, noCalls, forInit) { var maybeAsyncArrow = this.options.ecmaVersion >= 8 && base.type === "Identifier" && base.name === "async" && this.lastTokEnd === base.end && !this.canInsertSemicolon() && base.end - base.start === 5 && this.potentialArrowAt === base.start; var optionalChained = false; while (true) { var element = this.parseSubscript(base, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained, forInit); if (element.optional) { optionalChained = true; } if (element === base || element.type === "ArrowFunctionExpression") { if (optionalChained) { var chainNode = this.startNodeAt(startPos, startLoc); chainNode.expression = element; element = this.finishNode(chainNode, "ChainExpression"); } return element } base = element; } }; pp$5.shouldParseAsyncArrow = function() { return !this.canInsertSemicolon() && this.eat(types$1.arrow) }; pp$5.parseSubscriptAsyncArrow = function(startPos, startLoc, exprList, forInit) { return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, true, forInit) }; pp$5.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained, forInit) { var optionalSupported = this.options.ecmaVersion >= 11; var optional = optionalSupported && this.eat(types$1.questionDot); if (noCalls && optional) { this.raise(this.lastTokStart, "Optional chaining cannot appear in the callee of new expressions"); } var computed = this.eat(types$1.bracketL); if (computed || (optional && this.type !== types$1.parenL && this.type !== types$1.backQuote) || this.eat(types$1.dot)) { var node = this.startNodeAt(startPos, startLoc); node.object = base; if (computed) { node.property = this.parseExpression(); this.expect(types$1.bracketR); } else if (this.type === types$1.privateId && base.type !== "Super") { node.property = this.parsePrivateIdent(); } else { node.property = this.parseIdent(this.options.allowReserved !== "never"); } node.computed = !!computed; if (optionalSupported) { node.optional = optional; } base = this.finishNode(node, "MemberExpression"); } else if (!noCalls && this.eat(types$1.parenL)) { var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos; this.yieldPos = 0; this.awaitPos = 0; this.awaitIdentPos = 0; var exprList = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false, refDestructuringErrors); if (maybeAsyncArrow && !optional && this.shouldParseAsyncArrow()) { this.checkPatternErrors(refDestructuringErrors, false); this.checkYieldAwaitInDefaultParams(); if (this.awaitIdentPos > 0) { this.raise(this.awaitIdentPos, "Cannot use 'await' as identifier inside an async function"); } this.yieldPos = oldYieldPos; this.awaitPos = oldAwaitPos; this.awaitIdentPos = oldAwaitIdentPos; return this.parseSubscriptAsyncArrow(startPos, startLoc, exprList, forInit) } this.checkExpressionErrors(refDestructuringErrors, true); this.yieldPos = oldYieldPos || this.yieldPos; this.awaitPos = oldAwaitPos || this.awaitPos; this.awaitIdentPos = oldAwaitIdentPos || this.awaitIdentPos; var node$1 = this.startNodeAt(startPos, startLoc); node$1.callee = base; node$1.arguments = exprList; if (optionalSupported) { node$1.optional = optional; } base = this.finishNode(node$1, "CallExpression"); } else if (this.type === types$1.backQuote) { if (optional || optionalChained) { this.raise(this.start, "Optional chaining cannot appear in the tag of tagged template expressions"); } var node$2 = this.startNodeAt(startPos, startLoc); node$2.tag = base; node$2.quasi = this.parseTemplate({isTagged: true}); base = this.finishNode(node$2, "TaggedTemplateExpression"); } return base }; // Parse an atomic expression — either a single token that is an // expression, an expression started by a keyword like `function` or // `new`, or an expression wrapped in punctuation like `()`, `[]`, // or `{}`. pp$5.parseExprAtom = function(refDestructuringErrors, forInit, forNew) { // If a division operator appears in an expression position, the // tokenizer got confused, and we force it to read a regexp instead. if (this.type === types$1.slash) { this.readRegexp(); } var node, canBeArrow = this.potentialArrowAt === this.start; switch (this.type) { case types$1._super: if (!this.allowSuper) { this.raise(this.start, "'super' keyword outside a method"); } node = this.startNode(); this.next(); if (this.type === types$1.parenL && !this.allowDirectSuper) { this.raise(node.start, "super() call outside constructor of a subclass"); } // The `super` keyword can appear at below: // SuperProperty: // super [ Expression ] // super . IdentifierName // SuperCall: // super ( Arguments ) if (this.type !== types$1.dot && this.type !== types$1.bracketL && this.type !== types$1.parenL) { this.unexpected(); } return this.finishNode(node, "Super") case types$1._this: node = this.startNode(); this.next(); return this.finishNode(node, "ThisExpression") case types$1.name: var startPos = this.start, startLoc = this.startLoc, containsEsc = this.containsEsc; var id = this.parseIdent(false); if (this.options.ecmaVersion >= 8 && !containsEsc && id.name === "async" && !this.canInsertSemicolon() && this.eat(types$1._function)) { this.overrideContext(types.f_expr); return this.parseFunction(this.startNodeAt(startPos, startLoc), 0, false, true, forInit) } if (canBeArrow && !this.canInsertSemicolon()) { if (this.eat(types$1.arrow)) { return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], false, forInit) } if (this.options.ecmaVersion >= 8 && id.name === "async" && this.type === types$1.name && !containsEsc && (!this.potentialArrowInForAwait || this.value !== "of" || this.containsEsc)) { id = this.parseIdent(false); if (this.canInsertSemicolon() || !this.eat(types$1.arrow)) { this.unexpected(); } return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], true, forInit) } } return id case types$1.regexp: var value = this.value; node = this.parseLiteral(value.value); node.regex = {pattern: value.pattern, flags: value.flags}; return node case types$1.num: case types$1.string: return this.parseLiteral(this.value) case types$1._null: case types$1._true: case types$1._false: node = this.startNode(); node.value = this.type === types$1._null ? null : this.type === types$1._true; node.raw = this.type.keyword; this.next(); return this.finishNode(node, "Literal") case types$1.parenL: var start = this.start, expr = this.parseParenAndDistinguishExpression(canBeArrow, forInit); if (refDestructuringErrors) { if (refDestructuringErrors.parenthesizedAssign < 0 && !this.isSimpleAssignTarget(expr)) { refDestructuringErrors.parenthesizedAssign = start; } if (refDestructuringErrors.parenthesizedBind < 0) { refDestructuringErrors.parenthesizedBind = start; } } return expr case types$1.bracketL: node = this.startNode(); this.next(); node.elements = this.parseExprList(types$1.bracketR, true, true, refDestructuringErrors); return this.finishNode(node, "ArrayExpression") case types$1.braceL: this.overrideContext(types.b_expr); return this.parseObj(false, refDestructuringErrors) case types$1._function: node = this.startNode(); this.next(); return this.parseFunction(node, 0) case types$1._class: return this.parseClass(this.startNode(), false) case types$1._new: return this.parseNew() case types$1.backQuote: return this.parseTemplate() case types$1._import: if (this.options.ecmaVersion >= 11) { return this.parseExprImport(forNew) } else { return this.unexpected() } default: return this.parseExprAtomDefault() } }; pp$5.parseExprAtomDefault = function() { this.unexpected(); }; pp$5.parseExprImport = function(forNew) { var node = this.startNode(); // Consume `import` as an identifier for `import.meta`. // Because `this.parseIdent(true)` doesn't check escape sequences, it needs the check of `this.containsEsc`. if (this.containsEsc) { this.raiseRecoverable(this.start, "Escape sequence in keyword import"); } this.next(); if (this.type === types$1.parenL && !forNew) { return this.parseDynamicImport(node) } else if (this.type === types$1.dot) { var meta = this.startNodeAt(node.start, node.loc && node.loc.start); meta.name = "import"; node.meta = this.finishNode(meta, "Identifier"); return this.parseImportMeta(node) } else { this.unexpected(); } }; pp$5.parseDynamicImport = function(node) { this.next(); // skip `(` // Parse node.source. node.source = this.parseMaybeAssign(); if (this.options.ecmaVersion >= 16) { if (!this.eat(types$1.parenR)) { this.expect(types$1.comma); if (!this.afterTrailingComma(types$1.parenR)) { node.options = this.parseMaybeAssign(); if (!this.eat(types$1.parenR)) { this.expect(types$1.comma); if (!this.afterTrailingComma(types$1.parenR)) { this.unexpected(); } } } else { node.options = null; } } else { node.options = null; } } else { // Verify ending. if (!this.eat(types$1.parenR)) { var errorPos = this.start; if (this.eat(types$1.comma) && this.eat(types$1.parenR)) { this.raiseRecoverable(errorPos, "Trailing comma is not allowed in import()"); } else { this.unexpected(errorPos); } } } return this.finishNode(node, "ImportExpression") }; pp$5.parseImportMeta = function(node) { this.next(); // skip `.` var containsEsc = this.containsEsc; node.property = this.parseIdent(true); if (node.property.name !== "meta") { this.raiseRecoverable(node.property.start, "The only valid meta property for import is 'import.meta'"); } if (containsEsc) { this.raiseRecoverable(node.start, "'import.meta' must not contain escaped characters"); } if (this.options.sourceType !== "module" && !this.options.allowImportExportEverywhere) { this.raiseRecoverable(node.start, "Cannot use 'import.meta' outside a module"); } return this.finishNode(node, "MetaProperty") }; pp$5.parseLiteral = function(value) { var node = this.startNode(); node.value = value; node.raw = this.input.slice(this.start, this.end); if (node.raw.charCodeAt(node.raw.length - 1) === 110) { node.bigint = node.value != null ? node.value.toString() : node.raw.slice(0, -1).replace(/_/g, ""); } this.next(); return this.finishNode(node, "Literal") }; pp$5.parseParenExpression = function() { this.expect(types$1.parenL); var val = this.parseExpression(); this.expect(types$1.parenR); return val }; pp$5.shouldParseArrow = function(exprList) { return !this.canInsertSemicolon() }; pp$5.parseParenAndDistinguishExpression = function(canBeArrow, forInit) { var startPos = this.start, startLoc = this.startLoc, val, allowTrailingComma = this.options.ecmaVersion >= 8; if (this.options.ecmaVersion >= 6) { this.next(); var innerStartPos = this.start, innerStartLoc = this.startLoc; var exprList = [], first = true, lastIsComma = false; var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, spreadStart; this.yieldPos = 0; this.awaitPos = 0; // Do not save awaitIdentPos to allow checking awaits nested in parameters while (this.type !== types$1.parenR) { first ? first = false : this.expect(types$1.comma); if (allowTrailingComma && this.afterTrailingComma(types$1.parenR, true)) { lastIsComma = true; break } else if (this.type === types$1.ellipsis) { spreadStart = this.start; exprList.push(this.parseParenItem(this.parseRestBinding())); if (this.type === types$1.comma) { this.raiseRecoverable( this.start, "Comma is not permitted after the rest element" ); } break } else { exprList.push(this.parseMaybeAssign(false, refDestructuringErrors, this.parseParenItem)); } } var innerEndPos = this.lastTokEnd, innerEndLoc = this.lastTokEndLoc; this.expect(types$1.parenR); if (canBeArrow && this.shouldParseArrow(exprList) && this.eat(types$1.arrow)) { this.checkPatternErrors(refDestructuringErrors, false); this.checkYieldAwaitInDefaultParams(); this.yieldPos = oldYieldPos; this.awaitPos = oldAwaitPos; return this.parseParenArrowList(startPos, startLoc, exprList, forInit) } if (!exprList.length || lastIsComma) { this.unexpected(this.lastTokStart); } if (spreadStart) { this.unexpected(spreadStart); } this.checkExpressionErrors(refDestructuringErrors, true); this.yieldPos = oldYieldPos || this.yieldPos; this.awaitPos = oldAwaitPos || this.awaitPos; if (exprList.length > 1) { val = this.startNodeAt(innerStartPos, innerStartLoc); val.expressions = exprList; this.finishNodeAt(val, "SequenceExpression", innerEndPos, innerEndLoc); } else { val = exprList[0]; } } else { val = this.parseParenExpression(); } if (this.options.preserveParens) { var par = this.startNodeAt(startPos, startLoc); par.expression = val; return this.finishNode(par, "ParenthesizedExpression") } else { return val } }; pp$5.parseParenItem = function(item) { return item }; pp$5.parseParenArrowList = function(startPos, startLoc, exprList, forInit) { return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, false, forInit) }; // New's precedence is slightly tricky. It must allow its argument to // be a `[]` or dot subscript expression, but not a call — at least, // not without wrapping it in parentheses. Thus, it uses the noCalls // argument to parseSubscripts to prevent it from consuming the // argument list. var empty = []; pp$5.parseNew = function() { if (this.containsEsc) { this.raiseRecoverable(this.start, "Escape sequence in keyword new"); } var node = this.startNode(); this.next(); if (this.options.ecmaVersion >= 6 && this.type === types$1.dot) { var meta = this.startNodeAt(node.start, node.loc && node.loc.start); meta.name = "new"; node.meta = this.finishNode(meta, "Identifier"); this.next(); var containsEsc = this.containsEsc; node.property = this.parseIdent(true); if (node.property.name !== "target") { this.raiseRecoverable(node.property.start, "The only valid meta property for new is 'new.target'"); } if (containsEsc) { this.raiseRecoverable(node.start, "'new.target' must not contain escaped characters"); } if (!this.allowNewDotTarget) { this.raiseRecoverable(node.start, "'new.target' can only be used in functions and class static block"); } return this.finishNode(node, "MetaProperty") } var startPos = this.start, startLoc = this.startLoc; node.callee = this.parseSubscripts(this.parseExprAtom(null, false, true), startPos, startLoc, true, false); if (this.eat(types$1.parenL)) { node.arguments = this.parseExprList(types$1.parenR, this.options.ecmaVersion >= 8, false); } else { node.arguments = empty; } return this.finishNode(node, "NewExpression") }; // Parse template expression. pp$5.parseTemplateElement = function(ref) { var isTagged = ref.isTagged; var elem = this.startNode(); if (this.type === types$1.invalidTemplate) { if (!isTagged) { this.raiseRecoverable(this.start, "Bad escape sequence in untagged template literal"); } elem.value = { raw: this.value.replace(/\r\n?/g, "\n"), cooked: null }; } else { elem.value = { raw: this.input.slice(this.start, this.end).replace(/\r\n?/g, "\n"), cooked: this.value }; } this.next(); elem.tail = this.type === types$1.backQuote; return this.finishNode(elem, "TemplateElement") }; pp$5.parseTemplate = function(ref) { if ( ref === void 0 ) ref = {}; var isTagged = ref.isTagged; if ( isTagged === void 0 ) isTagged = false; var node = this.startNode(); this.next(); node.expressions = []; var curElt = this.parseTemplateElement({isTagged: isTagged}); node.quasis = [curElt]; while (!curElt.tail) { if (this.type === types$1.eof) { this.raise(this.pos, "Unterminated template literal"); } this.expect(types$1.dollarBraceL); node.expressions.push(this.parseExpression()); this.expect(types$1.braceR); node.quasis.push(curElt = this.parseTemplateElement({isTagged: isTagged})); } this.next(); return this.finishNode(node, "TemplateLiteral") }; pp$5.isAsyncProp = function(prop) { return !prop.computed && prop.key.type === "Identifier" && prop.key.name === "async" && (this.type === types$1.name || this.type === types$1.num || this.type === types$1.string || this.type === types$1.bracketL || this.type.keyword || (this.options.ecmaVersion >= 9 && this.type === types$1.star)) && !lineBreak.test(this.input.slice(this.lastTokEnd, this.start)) }; // Parse an object literal or binding pattern. pp$5.parseObj = function(isPattern, refDestructuringErrors) { var node = this.startNode(), first = true, propHash = {}; node.properties = []; this.next(); while (!this.eat(types$1.braceR)) { if (!first) { this.expect(types$1.comma); if (this.options.ecmaVersion >= 5 && this.afterTrailingComma(types$1.braceR)) { break } } else { first = false; } var prop = this.parseProperty(isPattern, refDestructuringErrors); if (!isPattern) { this.checkPropClash(prop, propHash, refDestructuringErrors); } node.properties.push(prop); } return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression") }; pp$5.parseProperty = function(isPattern, refDestructuringErrors) { var prop = this.startNode(), isGenerator, isAsync, startPos, startLoc; if (this.options.ecmaVersion >= 9 && this.eat(types$1.ellipsis)) { if (isPattern) { prop.argument = this.parseIdent(false); if (this.type === types$1.comma) { this.raiseRecoverable(this.start, "Comma is not permitted after the rest element"); } return this.finishNode(prop, "RestElement") } // Parse argument. prop.argument = this.parseMaybeAssign(false, refDestructuringErrors); // To disallow trailing comma via `this.toAssignable()`. if (this.type === types$1.comma && refDestructuringErrors && refDestructuringErrors.trailingComma < 0) { refDestructuringErrors.trailingComma = this.start; } // Finish return this.finishNode(prop, "SpreadElement") } if (this.options.ecmaVersion >= 6) { prop.method = false; prop.shorthand = false; if (isPattern || refDestructuringErrors) { startPos = this.start; startLoc = this.startLoc; } if (!isPattern) { isGenerator = this.eat(types$1.star); } } var containsEsc = this.containsEsc; this.parsePropertyName(prop); if (!isPattern && !containsEsc && this.options.ecmaVersion >= 8 && !isGenerator && this.isAsyncProp(prop)) { isAsync = true; isGenerator = this.options.ecmaVersion >= 9 && this.eat(types$1.star); this.parsePropertyName(prop); } else { isAsync = false; } this.parsePropertyValue(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc); return this.finishNode(prop, "Property") }; pp$5.parseGetterSetter = function(prop) { var kind = prop.key.name; this.parsePropertyName(prop); prop.value = this.parseMethod(false); prop.kind = kind; var paramCount = prop.kind === "get" ? 0 : 1; if (prop.value.params.length !== paramCount) { var start = prop.value.start; if (prop.kind === "get") { this.raiseRecoverable(start, "getter should have no params"); } else { this.raiseRecoverable(start, "setter should have exactly one param"); } } else { if (prop.kind === "set" && prop.value.params[0].type === "RestElement") { this.raiseRecoverable(prop.value.params[0].start, "Setter cannot use rest params"); } } }; pp$5.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc) { if ((isGenerator || isAsync) && this.type === types$1.colon) { this.unexpected(); } if (this.eat(types$1.colon)) { prop.value = isPattern ? this.parseMaybeDefault(this.start, this.startLoc) : this.parseMaybeAssign(false, refDestructuringErrors); prop.kind = "init"; } else if (this.options.ecmaVersion >= 6 && this.type === types$1.parenL) { if (isPattern) { this.unexpected(); } prop.method = true; prop.value = this.parseMethod(isGenerator, isAsync); prop.kind = "init"; } else if (!isPattern && !containsEsc && this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" && (prop.key.name === "get" || prop.key.name === "set") && (this.type !== types$1.comma && this.type !== types$1.braceR && this.type !== types$1.eq)) { if (isGenerator || isAsync) { this.unexpected(); } this.parseGetterSetter(prop); } else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") { if (isGenerator || isAsync) { this.unexpected(); } this.checkUnreserved(prop.key); if (prop.key.name === "await" && !this.awaitIdentPos) { this.awaitIdentPos = startPos; } if (isPattern) { prop.value = this.parseMaybeDefault(startPos, startLoc, this.copyNode(prop.key)); } else if (this.type === types$1.eq && refDestructuringErrors) { if (refDestructuringErrors.shorthandAssign < 0) { refDestructuringErrors.shorthandAssign = this.start; } prop.value = this.parseMaybeDefault(startPos, startLoc, this.copyNode(prop.key)); } else { prop.value = this.copyNode(prop.key); } prop.kind = "init"; prop.shorthand = true; } else { this.unexpected(); } }; pp$5.parsePropertyName = function(prop) { if (this.options.ecmaVersion >= 6) { if (this.eat(types$1.bracketL)) { prop.computed = true; prop.key = this.parseMaybeAssign(); this.expect(types$1.bracketR); return prop.key } else { prop.computed = false; } } return prop.key = this.type === types$1.num || this.type === types$1.string ? this.parseExprAtom() : this.parseIdent(this.options.allowReserved !== "never") }; // Initialize empty function node. pp$5.initFunction = function(node) { node.id = null; if (this.options.ecmaVersion >= 6) { node.generator = node.expression = false; } if (this.options.ecmaVersion >= 8) { node.async = false; } }; // Parse object or class method. pp$5.parseMethod = function(isGenerator, isAsync, allowDirectSuper) { var node = this.startNode(), oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos; this.initFunction(node); if (this.options.ecmaVersion >= 6) { node.generator = isGenerator; } if (this.options.ecmaVersion >= 8) { node.async = !!isAsync; } this.yieldPos = 0; this.awaitPos = 0; this.awaitIdentPos = 0; this.enterScope(functionFlags(isAsync, node.generator) | SCOPE_SUPER | (allowDirectSuper ? SCOPE_DIRECT_SUPER : 0)); this.expect(types$1.parenL); node.params = this.parseBindingList(types$1.parenR, false, this.options.ecmaVersion >= 8); this.checkYieldAwaitInDefaultParams(); this.parseFunctionBody(node, false, true, false); this.yieldPos = oldYieldPos; this.awaitPos = oldAwaitPos; this.awaitIdentPos = oldAwaitIdentPos; return this.finishNode(node, "FunctionExpression") }; // Parse arrow function expression with given parameters. pp$5.parseArrowExpression = function(node, params, isAsync, forInit) { var oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos; this.enterScope(functionFlags(isAsync, false) | SCOPE_ARROW); this.initFunction(node); if (this.options.ecmaVersion >= 8) { node.async = !!isAsync; } this.yieldPos = 0; this.awaitPos = 0; this.awaitIdentPos = 0; node.params = this.toAssignableList(params, true); this.parseFunctionBody(node, true, false, forInit); this.yieldPos = oldYieldPos; this.awaitPos = oldAwaitPos; this.awaitIdentPos = oldAwaitIdentPos; return this.finishNode(node, "ArrowFunctionExpression") }; // Parse function body and check parameters. pp$5.parseFunctionBody = function(node, isArrowFunction, isMethod, forInit) { var isExpression = isArrowFunction && this.type !== types$1.braceL; var oldStrict = this.strict, useStrict = false; if (isExpression) { node.body = this.parseMaybeAssign(forInit); node.expression = true; this.checkParams(node, false); } else { var nonSimple = this.options.ecmaVersion >= 7 && !this.isSimpleParamList(node.params); if (!oldStrict || nonSimple) { useStrict = this.strictDirective(this.end); // If this is a strict mode function, verify that argument names // are not repeated, and it does not try to bind the words `eval` // or `arguments`. if (useStrict && nonSimple) { this.raiseRecoverable(node.start, "Illegal 'use strict' directive in function with non-simple parameter list"); } } // Start a new scope with regard to labels and the `inFunction` // flag (restore them to their old value afterwards). var oldLabels = this.labels; this.labels = []; if (useStrict) { this.strict = true; } // Add the params to varDeclaredNames to ensure that an error is thrown // if a let/const declaration in the function clashes with one of the params. this.checkParams(node, !oldStrict && !useStrict && !isArrowFunction && !isMethod && this.isSimpleParamList(node.params)); // Ensure the function name isn't a forbidden identifier in strict mode, e.g. 'eval' if (this.strict && node.id) { this.checkLValSimple(node.id, BIND_OUTSIDE); } node.body = this.parseBlock(false, undefined, useStrict && !oldStrict); node.expression = false; this.adaptDirectivePrologue(node.body.body); this.labels = oldLabels; } this.exitScope(); }; pp$5.isSimpleParamList = function(params) { for (var i = 0, list = params; i < list.length; i += 1) { var param = list[i]; if (param.type !== "Identifier") { return false } } return true }; // Checks function params for various disallowed patterns such as using "eval" // or "arguments" and duplicate parameters. pp$5.checkParams = function(node, allowDuplicates) { var nameHash = Object.create(null); for (var i = 0, list = node.params; i < list.length; i += 1) { var param = list[i]; this.checkLValInnerPattern(param, BIND_VAR, allowDuplicates ? null : nameHash); } }; // Parses a comma-separated list of expressions, and returns them as // an array. `close` is the token type that ends the list, and // `allowEmpty` can be turned on to allow subsequent commas with // nothing in between them to be parsed as `null` (which is needed // for array literals). pp$5.parseExprList = function(close, allowTrailingComma, allowEmpty, refDestructuringErrors) { var elts = [], first = true; while (!this.eat(close)) { if (!first) { this.expect(types$1.comma); if (allowTrailingComma && this.afterTrailingComma(close)) { break } } else { first = false; } var elt = (void 0); if (allowEmpty && this.type === types$1.comma) { elt = null; } else if (this.type === types$1.ellipsis) { elt = this.parseSpread(refDestructuringErrors); if (refDestructuringErrors && this.type === types$1.comma && refDestructuringErrors.trailingComma < 0) { refDestructuringErrors.trailingComma = this.start; } } else { elt = this.parseMaybeAssign(false, refDestructuringErrors); } elts.push(elt); } return elts }; pp$5.checkUnreserved = function(ref) { var start = ref.start; var end = ref.end; var name = ref.name; if (this.inGenerator && name === "yield") { this.raiseRecoverable(start, "Cannot use 'yield' as identifier inside a generator"); } if (this.inAsync && name === "await") { this.raiseRecoverable(start, "Cannot use 'await' as identifier inside an async function"); } if (!(this.currentThisScope().flags & SCOPE_VAR) && name === "arguments") { this.raiseRecoverable(start, "Cannot use 'arguments' in class field initializer"); } if (this.inClassStaticBlock && (name === "arguments" || name === "await")) { this.raise(start, ("Cannot use " + name + " in class static initialization block")); } if (this.keywords.test(name)) { this.raise(start, ("Unexpected keyword '" + name + "'")); } if (this.options.ecmaVersion < 6 && this.input.slice(start, end).indexOf("\\") !== -1) { return } var re = this.strict ? this.reservedWordsStrict : this.reservedWords; if (re.test(name)) { if (!this.inAsync && name === "await") { this.raiseRecoverable(start, "Cannot use keyword 'await' outside an async function"); } this.raiseRecoverable(start, ("The keyword '" + name + "' is reserved")); } }; // Parse the next token as an identifier. If `liberal` is true (used // when parsing properties), it will also convert keywords into // identifiers. pp$5.parseIdent = function(liberal) { var node = this.parseIdentNode(); this.next(!!liberal); this.finishNode(node, "Identifier"); if (!liberal) { this.checkUnreserved(node); if (node.name === "await" && !this.awaitIdentPos) { this.awaitIdentPos = node.start; } } return node }; pp$5.parseIdentNode = function() { var node = this.startNode(); if (this.type === types$1.name) { node.name = this.value; } else if (this.type.keyword) { node.name = this.type.keyword; // To fix https://github.com/acornjs/acorn/issues/575 // `class` and `function` keywords push new context into this.context. // But there is no chance to pop the context if the keyword is consumed as an identifier such as a property name. // If the previous token is a dot, this does not apply because the context-managing code already ignored the keyword if ((node.name === "class" || node.name === "function") && (this.lastTokEnd !== this.lastTokStart + 1 || this.input.charCodeAt(this.lastTokStart) !== 46)) { this.context.pop(); } this.type = types$1.name; } else { this.unexpected(); } return node }; pp$5.parsePrivateIdent = function() { var node = this.startNode(); if (this.type === types$1.privateId) { node.name = this.value; } else { this.unexpected(); } this.next(); this.finishNode(node, "PrivateIdentifier"); // For validating existence if (this.options.checkPrivateFields) { if (this.privateNameStack.length === 0) { this.raise(node.start, ("Private field '#" + (node.name) + "' must be declared in an enclosing class")); } else { this.privateNameStack[this.privateNameStack.length - 1].used.push(node); } } return node }; // Parses yield expression inside generator. pp$5.parseYield = function(forInit) { if (!this.yieldPos) { this.yieldPos = this.start; } var node = this.startNode(); this.next(); if (this.type === types$1.semi || this.canInsertSemicolon() || (this.type !== types$1.star && !this.type.startsExpr)) { node.delegate = false; node.argument = null; } else { node.delegate = this.eat(types$1.star); node.argument = this.parseMaybeAssign(forInit); } return this.finishNode(node, "YieldExpression") }; pp$5.parseAwait = function(forInit) { if (!this.awaitPos) { this.awaitPos = this.start; } var node = this.startNode(); this.next(); node.argument = this.parseMaybeUnary(null, true, false, forInit); return this.finishNode(node, "AwaitExpression") }; var pp$4 = Parser.prototype; // This function is used to raise exceptions on parse errors. It // takes an offset integer (into the current `input`) to indicate // the location of the error, attaches the position to the end // of the error message, and then raises a `SyntaxError` with that // message. pp$4.raise = function(pos, message) { var loc = getLineInfo(this.input, pos); message += " (" + loc.line + ":" + loc.column + ")"; if (this.sourceFile) { message += " in " + this.sourceFile; } var err = new SyntaxError(message); err.pos = pos; err.loc = loc; err.raisedAt = this.pos; throw err }; pp$4.raiseRecoverable = pp$4.raise; pp$4.curPosition = function() { if (this.options.locations) { return new Position(this.curLine, this.pos - this.lineStart) } }; var pp$3 = Parser.prototype; var Scope = function Scope(flags) { this.flags = flags; // A list of var-declared names in the current lexical scope this.var = []; // A list of lexically-declared names in the current lexical scope this.lexical = []; // A list of lexically-declared FunctionDeclaration names in the current lexical scope this.functions = []; }; // The functions in this module keep track of declared variables in the current scope in order to detect duplicate variable names. pp$3.enterScope = function(flags) { this.scopeStack.push(new Scope(flags)); }; pp$3.exitScope = function() { this.scopeStack.pop(); }; // The spec says: // > At the top level of a function, or script, function declarations are // > treated like var declarations rather than like lexical declarations. pp$3.treatFunctionsAsVarInScope = function(scope) { return (scope.flags & SCOPE_FUNCTION) || !this.inModule && (scope.flags & SCOPE_TOP) }; pp$3.declareName = function(name, bindingType, pos) { var redeclared = false; if (bindingType === BIND_LEXICAL) { var scope = this.currentScope(); redeclared = scope.lexical.indexOf(name) > -1 || scope.functions.indexOf(name) > -1 || scope.var.indexOf(name) > -1; scope.lexical.push(name); if (this.inModule && (scope.flags & SCOPE_TOP)) { delete this.undefinedExports[name]; } } else if (bindingType === BIND_SIMPLE_CATCH) { var scope$1 = this.currentScope(); scope$1.lexical.push(name); } else if (bindingType === BIND_FUNCTION) { var scope$2 = this.currentScope(); if (this.treatFunctionsAsVar) { redeclared = scope$2.lexical.indexOf(name) > -1; } else { redeclared = scope$2.lexical.indexOf(name) > -1 || scope$2.var.indexOf(name) > -1; } scope$2.functions.push(name); } else { for (var i = this.scopeStack.length - 1; i >= 0; --i) { var scope$3 = this.scopeStack[i]; if (scope$3.lexical.indexOf(name) > -1 && !((scope$3.flags & SCOPE_SIMPLE_CATCH) && scope$3.lexical[0] === name) || !this.treatFunctionsAsVarInScope(scope$3) && scope$3.functions.indexOf(name) > -1) { redeclared = true; break } scope$3.var.push(name); if (this.inModule && (scope$3.flags & SCOPE_TOP)) { delete this.undefinedExports[name]; } if (scope$3.flags & SCOPE_VAR) { break } } } if (redeclared) { this.raiseRecoverable(pos, ("Identifier '" + name + "' has already been declared")); } }; pp$3.checkLocalExport = function(id) { // scope.functions must be empty as Module code is always strict. if (this.scopeStack[0].lexical.indexOf(id.name) === -1 && this.scopeStack[0].var.indexOf(id.name) === -1) { this.undefinedExports[id.name] = id; } }; pp$3.currentScope = function() { return this.scopeStack[this.scopeStack.length - 1] }; pp$3.currentVarScope = function() { for (var i = this.scopeStack.length - 1;; i--) { var scope = this.scopeStack[i]; if (scope.flags & (SCOPE_VAR | SCOPE_CLASS_FIELD_INIT | SCOPE_CLASS_STATIC_BLOCK)) { return scope } } }; // Could be useful for `this`, `new.target`, `super()`, `super.property`, and `super[property]`. pp$3.currentThisScope = function() { for (var i = this.scopeStack.length - 1;; i--) { var scope = this.scopeStack[i]; if (scope.flags & (SCOPE_VAR | SCOPE_CLASS_FIELD_INIT | SCOPE_CLASS_STATIC_BLOCK) && !(scope.flags & SCOPE_ARROW)) { return scope } } }; var Node = function Node(parser, pos, loc) { this.type = ""; this.start = pos; this.end = 0; if (parser.options.locations) { this.loc = new SourceLocation(parser, loc); } if (parser.options.directSourceFile) { this.sourceFile = parser.options.directSourceFile; } if (parser.options.ranges) { this.range = [pos, 0]; } }; // Start an AST node, attaching a start offset. var pp$2 = Parser.prototype; pp$2.startNode = function() { return new Node(this, this.start, this.startLoc) }; pp$2.startNodeAt = function(pos, loc) { return new Node(this, pos, loc) }; // Finish an AST node, adding `type` and `end` properties. function finishNodeAt(node, type, pos, loc) { node.type = type; node.end = pos; if (this.options.locations) { node.loc.end = loc; } if (this.options.ranges) { node.range[1] = pos; } return node } pp$2.finishNode = function(node, type) { return finishNodeAt.call(this, node, type, this.lastTokEnd, this.lastTokEndLoc) }; // Finish node at given position pp$2.finishNodeAt = function(node, type, pos, loc) { return finishNodeAt.call(this, node, type, pos, loc) }; pp$2.copyNode = function(node) { var newNode = new Node(this, node.start, this.startLoc); for (var prop in node) { newNode[prop] = node[prop]; } return newNode }; // This file was generated by "bin/generate-unicode-script-values.js". Do not modify manually! var scriptValuesAddedInUnicode = "Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sunu Sunuwar Todhri Todr Tulu_Tigalari Tutg Unknown Zzzz"; // This file contains Unicode properties extracted from the ECMAScript specification. // The lists are extracted like so: // $$('#table-binary-unicode-properties > figure > table > tbody > tr > td:nth-child(1) code').map(el => el.innerText) // #table-binary-unicode-properties var ecma9BinaryProperties = "ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS"; var ecma10BinaryProperties = ecma9BinaryProperties + " Extended_Pictographic"; var ecma11BinaryProperties = ecma10BinaryProperties; var ecma12BinaryProperties = ecma11BinaryProperties + " EBase EComp EMod EPres ExtPict"; var ecma13BinaryProperties = ecma12BinaryProperties; var ecma14BinaryProperties = ecma13BinaryProperties; var unicodeBinaryProperties = { 9: ecma9BinaryProperties, 10: ecma10BinaryProperties, 11: ecma11BinaryProperties, 12: ecma12BinaryProperties, 13: ecma13BinaryProperties, 14: ecma14BinaryProperties }; // #table-binary-unicode-properties-of-strings var ecma14BinaryPropertiesOfStrings = "Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji"; var unicodeBinaryPropertiesOfStrings = { 9: "", 10: "", 11: "", 12: "", 13: "", 14: ecma14BinaryPropertiesOfStrings }; // #table-unicode-general-category-values var unicodeGeneralCategoryValues = "Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu"; // #table-unicode-script-values var ecma9ScriptValues = "Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb"; var ecma10ScriptValues = ecma9ScriptValues + " Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd"; var ecma11ScriptValues = ecma10ScriptValues + " Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho"; var ecma12ScriptValues = ecma11ScriptValues + " Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi"; var ecma13ScriptValues = ecma12ScriptValues + " Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith"; var ecma14ScriptValues = ecma13ScriptValues + " " + scriptValuesAddedInUnicode; var unicodeScriptValues = { 9: ecma9ScriptValues, 10: ecma10ScriptValues, 11: ecma11ScriptValues, 12: ecma12ScriptValues, 13: ecma13ScriptValues, 14: ecma14ScriptValues }; var data = {}; function buildUnicodeData(ecmaVersion) { var d = data[ecmaVersion] = { binary: wordsRegexp(unicodeBinaryProperties[ecmaVersion] + " " + unicodeGeneralCategoryValues), binaryOfStrings: wordsRegexp(unicodeBinaryPropertiesOfStrings[ecmaVersion]), nonBinary: { General_Category: wordsRegexp(unicodeGeneralCategoryValues), Script: wordsRegexp(unicodeScriptValues[ecmaVersion]) } }; d.nonBinary.Script_Extensions = d.nonBinary.Script; d.nonBinary.gc = d.nonBinary.General_Category; d.nonBinary.sc = d.nonBinary.Script; d.nonBinary.scx = d.nonBinary.Script_Extensions; } for (var i = 0, list = [9, 10, 11, 12, 13, 14]; i < list.length; i += 1) { var ecmaVersion = list[i]; buildUnicodeData(ecmaVersion); } var pp$1 = Parser.prototype; // Track disjunction structure to determine whether a duplicate // capture group name is allowed because it is in a separate branch. var BranchID = function BranchID(parent, base) { // Parent disjunction branch this.parent = parent; // Identifies this set of sibling branches this.base = base || this; }; BranchID.prototype.separatedFrom = function separatedFrom (alt) { // A branch is separate from another branch if they or any of // their parents are siblings in a given disjunction for (var self = this; self; self = self.parent) { for (var other = alt; other; other = other.parent) { if (self.base === other.base && self !== other) { return true } } } return false }; BranchID.prototype.sibling = function sibling () { return new BranchID(this.parent, this.base) }; var RegExpValidationState = function RegExpValidationState(parser) { this.parser = parser; this.validFlags = "gim" + (parser.options.ecmaVersion >= 6 ? "uy" : "") + (parser.options.ecmaVersion >= 9 ? "s" : "") + (parser.options.ecmaVersion >= 13 ? "d" : "") + (parser.options.ecmaVersion >= 15 ? "v" : ""); this.unicodeProperties = data[parser.options.ecmaVersion >= 14 ? 14 : parser.options.ecmaVersion]; this.source = ""; this.flags = ""; this.start = 0; this.switchU = false; this.switchV = false; this.switchN = false; this.pos = 0; this.lastIntValue = 0; this.lastStringValue = ""; this.lastAssertionIsQuantifiable = false; this.numCapturingParens = 0; this.maxBackReference = 0; this.groupNames = Object.create(null); this.backReferenceNames = []; this.branchID = null; }; RegExpValidationState.prototype.reset = function reset (start, pattern, flags) { var unicodeSets = flags.indexOf("v") !== -1; var unicode = flags.indexOf("u") !== -1; this.start = start | 0; this.source = pattern + ""; this.flags = flags; if (unicodeSets && this.parser.options.ecmaVersion >= 15) { this.switchU = true; this.switchV = true; this.switchN = true; } else { this.switchU = unicode && this.parser.options.ecmaVersion >= 6; this.switchV = false; this.switchN = unicode && this.parser.options.ecmaVersion >= 9; } }; RegExpValidationState.prototype.raise = function raise (message) { this.parser.raiseRecoverable(this.start, ("Invalid regular expression: /" + (this.source) + "/: " + message)); }; // If u flag is given, this returns the code point at the index (it combines a surrogate pair). // Otherwise, this returns the code unit of the index (can be a part of a surrogate pair). RegExpValidationState.prototype.at = function at (i, forceU) { if ( forceU === void 0 ) forceU = false; var s = this.source; var l = s.length; if (i >= l) { return -1 } var c = s.charCodeAt(i); if (!(forceU || this.switchU) || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l) { return c } var next = s.charCodeAt(i + 1); return next >= 0xDC00 && next <= 0xDFFF ? (c << 10) + next - 0x35FDC00 : c }; RegExpValidationState.prototype.nextIndex = function nextIndex (i, forceU) { if ( forceU === void 0 ) forceU = false; var s = this.source; var l = s.length; if (i >= l) { return l } var c = s.charCodeAt(i), next; if (!(forceU || this.switchU) || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l || (next = s.charCodeAt(i + 1)) < 0xDC00 || next > 0xDFFF) { return i + 1 } return i + 2 }; RegExpValidationState.prototype.current = function current (forceU) { if ( forceU === void 0 ) forceU = false; return this.at(this.pos, forceU) }; RegExpValidationState.prototype.lookahead = function lookahead (forceU) { if ( forceU === void 0 ) forceU = false; return this.at(this.nextIndex(this.pos, forceU), forceU) }; RegExpValidationState.prototype.advance = function advance (forceU) { if ( forceU === void 0 ) forceU = false; this.pos = this.nextIndex(this.pos, forceU); }; RegExpValidationState.prototype.eat = function eat (ch, forceU) { if ( forceU === void 0 ) forceU = false; if (this.current(forceU) === ch) { this.advance(forceU); return true } return false }; RegExpValidationState.prototype.eatChars = function eatChars (chs, forceU) { if ( forceU === void 0 ) forceU = false; var pos = this.pos; for (var i = 0, list = chs; i < list.length; i += 1) { var ch = list[i]; var current = this.at(pos, forceU); if (current === -1 || current !== ch) { return false } pos = this.nextIndex(pos, forceU); } this.pos = pos; return true }; /** * Validate the flags part of a given RegExpLiteral. * * @param {RegExpValidationState} state The state to validate RegExp. * @returns {void} */ pp$1.validateRegExpFlags = function(state) { var validFlags = state.validFlags; var flags = state.flags; var u = false; var v = false; for (var i = 0; i < flags.length; i++) { var flag = flags.charAt(i); if (validFlags.indexOf(flag) === -1) { this.raise(state.start, "Invalid regular expression flag"); } if (flags.indexOf(flag, i + 1) > -1) { this.raise(state.start, "Duplicate regular expression flag"); } if (flag === "u") { u = true; } if (flag === "v") { v = true; } } if (this.options.ecmaVersion >= 15 && u && v) { this.raise(state.start, "Invalid regular expression flag"); } }; function hasProp(obj) { for (var _ in obj) { return true } return false } /** * Validate the pattern part of a given RegExpLiteral. * * @param {RegExpValidationState} state The state to validate RegExp. * @returns {void} */ pp$1.validateRegExpPattern = function(state) { this.regexp_pattern(state); // The goal symbol for the parse is |Pattern[~U, ~N]|. If the result of // parsing contains a |GroupName|, reparse with the goal symbol // |Pattern[~U, +N]| and use this result instead. Throw a *SyntaxError* // exception if _P_ did not conform to the grammar, if any elements of _P_ // were not matched by the parse, or if any Early Error conditions exist. if (!state.switchN && this.options.ecmaVersion >= 9 && hasProp(state.groupNames)) { state.switchN = true; this.regexp_pattern(state); } }; // https://www.ecma-international.org/ecma-262/8.0/#prod-Pattern pp$1.regexp_pattern = function(state) { state.pos = 0; state.lastIntValue = 0; state.lastStringValue = ""; state.lastAssertionIsQuantifiable = false; state.numCapturingParens = 0; state.maxBackReference = 0; state.groupNames = Object.create(null); state.backReferenceNames.length = 0; state.branchID = null; this.regexp_disjunction(state); if (state.pos !== state.source.length) { // Make the same messages as V8. if (state.eat(0x29 /* ) */)) { state.raise("Unmatched ')'"); } if (state.eat(0x5D /* ] */) || state.eat(0x7D /* } */)) { state.raise("Lone quantifier brackets"); } } if (state.maxBackReference > state.numCapturingParens) { state.raise("Invalid escape"); } for (var i = 0, list = state.backReferenceNames; i < list.length; i += 1) { var name = list[i]; if (!state.groupNames[name]) { state.raise("Invalid named capture referenced"); } } }; // https://www.ecma-international.org/ecma-262/8.0/#prod-Disjunction pp$1.regexp_disjunction = function(state) { var trackDisjunction = this.options.ecmaVersion >= 16; if (trackDisjunction) { state.branchID = new BranchID(state.branchID, null); } this.regexp_alternative(state); while (state.eat(0x7C /* | */)) { if (trackDisjunction) { state.branchID = state.branchID.sibling(); } this.regexp_alternative(state); } if (trackDisjunction) { state.branchID = state.branchID.parent; } // Make the same message as V8. if (this.regexp_eatQuantifier(state, true)) { state.raise("Nothing to repeat"); } if (state.eat(0x7B /* { */)) { state.raise("Lone quantifier brackets"); } }; // https://www.ecma-international.org/ecma-262/8.0/#prod-Alternative pp$1.regexp_alternative = function(state) { while (state.pos < state.source.length && this.regexp_eatTerm(state)) {} }; // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Term pp$1.regexp_eatTerm = function(state) { if (this.regexp_eatAssertion(state)) { // Handle `QuantifiableAssertion Quantifier` alternative. // `state.lastAssertionIsQuantifiable` is true if the last eaten Assertion // is a QuantifiableAssertion. if (state.lastAssertionIsQuantifiable && this.regexp_eatQuantifier(state)) { // Make the same message as V8. if (state.switchU) { state.raise("Invalid quantifier"); } } return true } if (state.switchU ? this.regexp_eatAtom(state) : this.regexp_eatExtendedAtom(state)) { this.regexp_eatQuantifier(state); return true } return false }; // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Assertion pp$1.regexp_eatAssertion = function(state) { var start = state.pos; state.lastAssertionIsQuantifiable = false; // ^, $ if (state.eat(0x5E /* ^ */) || state.eat(0x24 /* $ */)) { return true } // \b \B if (state.eat(0x5C /* \ */)) { if (state.eat(0x42 /* B */) || state.eat(0x62 /* b */)) { return true } state.pos = start; } // Lookahead / Lookbehind if (state.eat(0x28 /* ( */) && state.eat(0x3F /* ? */)) { var lookbehind = false; if (this.options.ecmaVersion >= 9) { lookbehind = state.eat(0x3C /* < */); } if (state.eat(0x3D /* = */) || state.eat(0x21 /* ! */)) { this.regexp_disjunction(state); if (!state.eat(0x29 /* ) */)) { state.raise("Unterminated group"); } state.lastAssertionIsQuantifiable = !lookbehind; return true } } state.pos = start; return false }; // https://www.ecma-international.org/ecma-262/8.0/#prod-Quantifier pp$1.regexp_eatQuantifier = function(state, noError) { if ( noError === void 0 ) noError = false; if (this.regexp_eatQuantifierPrefix(state, noError)) { state.eat(0x3F /* ? */); return true } return false }; // https://www.ecma-international.org/ecma-262/8.0/#prod-QuantifierPrefix pp$1.regexp_eatQuantifierPrefix = function(state, noError) { return ( state.eat(0x2A /* * */) || state.eat(0x2B /* + */) || state.eat(0x3F /* ? */) || this.regexp_eatBracedQuantifier(state, noError) ) }; pp$1.regexp_eatBracedQuantifier = function(state, noError) { var start = state.pos; if (state.eat(0x7B /* { */)) { var min = 0, max = -1; if (this.regexp_eatDecimalDigits(state)) { min = state.lastIntValue; if (state.eat(0x2C /* , */) && this.regexp_eatDecimalDigits(state)) { max = state.lastIntValue; } if (state.eat(0x7D /* } */)) { // SyntaxError in https://www.ecma-international.org/ecma-262/8.0/#sec-term if (max !== -1 && max < min && !noError) { state.raise("numbers out of order in {} quantifier"); } return true } } if (state.switchU && !noError) { state.raise("Incomplete quantifier"); } state.pos = start; } return false }; // https://www.ecma-international.org/ecma-262/8.0/#prod-Atom pp$1.regexp_eatAtom = function(state) { return ( this.regexp_eatPatternCharacters(state) || state.eat(0x2E /* . */) || this.regexp_eatReverseSolidusAtomEscape(state) || this.regexp_eatCharacterClass(state) || this.regexp_eatUncapturingGroup(state) || this.regexp_eatCapturingGroup(state) ) }; pp$1.regexp_eatReverseSolidusAtomEscape = function(state) { var start = state.pos; if (state.eat(0x5C /* \ */)) { if (this.regexp_eatAtomEscape(state)) { return true } state.pos = start; } return false }; pp$1.regexp_eatUncapturingGroup = function(state) { var start = state.pos; if (state.eat(0x28 /* ( */)) { if (state.eat(0x3F /* ? */)) { if (this.options.ecmaVersion >= 16) { var addModifiers = this.regexp_eatModifiers(state); var hasHyphen = state.eat(0x2D /* - */); if (addModifiers || hasHyphen) { for (var i = 0; i < addModifiers.length; i++) { var modifier = addModifiers.charAt(i); if (addModifiers.indexOf(modifier, i + 1) > -1) { state.raise("Duplicate regular expression modifiers"); } } if (hasHyphen) { var removeModifiers = this.regexp_eatModifiers(state); if (!addModifiers && !removeModifiers && state.current() === 0x3A /* : */) { state.raise("Invalid regular expression modifiers"); } for (var i$1 = 0; i$1 < removeModifiers.length; i$1++) { var modifier$1 = removeModifiers.charAt(i$1); if ( removeModifiers.indexOf(modifier$1, i$1 + 1) > -1 || addModifiers.indexOf(modifier$1) > -1 ) { state.raise("Duplicate regular expression modifiers"); } } } } } if (state.eat(0x3A /* : */)) { this.regexp_disjunction(state); if (state.eat(0x29 /* ) */)) { return true } state.raise("Unterminated group"); } } state.pos = start; } return false }; pp$1.regexp_eatCapturingGroup = function(state) { if (state.eat(0x28 /* ( */)) { if (this.options.ecmaVersion >= 9) { this.regexp_groupSpecifier(state); } else if (state.current() === 0x3F /* ? */) { state.raise("Invalid group"); } this.regexp_disjunction(state); if (state.eat(0x29 /* ) */)) { state.numCapturingParens += 1; return true } state.raise("Unterminated group"); } return false }; // RegularExpressionModifiers :: // [empty] // RegularExpressionModifiers RegularExpressionModifier pp$1.regexp_eatModifiers = function(state) { var modifiers = ""; var ch = 0; while ((ch = state.current()) !== -1 && isRegularExpressionModifier(ch)) { modifiers += codePointToString(ch); state.advance(); } return modifiers }; // RegularExpressionModifier :: one of // `i` `m` `s` function isRegularExpressionModifier(ch) { return ch === 0x69 /* i */ || ch === 0x6d /* m */ || ch === 0x73 /* s */ } // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedAtom pp$1.regexp_eatExtendedAtom = function(state) { return ( state.eat(0x2E /* . */) || this.regexp_eatReverseSolidusAtomEscape(state) || this.regexp_eatCharacterClass(state) || this.regexp_eatUncapturingGroup(state) || this.regexp_eatCapturingGroup(state) || this.regexp_eatInvalidBracedQuantifier(state) || this.regexp_eatExtendedPatternCharacter(state) ) }; // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-InvalidBracedQuantifier pp$1.regexp_eatInvalidBracedQuantifier = function(state) { if (this.regexp_eatBracedQuantifier(state, true)) { state.raise("Nothing to repeat"); } return false }; // https://www.ecma-international.org/ecma-262/8.0/#prod-SyntaxCharacter pp$1.regexp_eatSyntaxCharacter = function(state) { var ch = state.current(); if (isSyntaxCharacter(ch)) { state.lastIntValue = ch; state.advance(); return true } return false }; function isSyntaxCharacter(ch) { return ( ch === 0x24 /* $ */ || ch >= 0x28 /* ( */ && ch <= 0x2B /* + */ || ch === 0x2E /* . */ || ch === 0x3F /* ? */ || ch >= 0x5B /* [ */ && ch <= 0x5E /* ^ */ || ch >= 0x7B /* { */ && ch <= 0x7D /* } */ ) } // https://www.ecma-international.org/ecma-262/8.0/#prod-PatternCharacter // But eat eager. pp$1.regexp_eatPatternCharacters = function(state) { var start = state.pos; var ch = 0; while ((ch = state.current()) !== -1 && !isSyntaxCharacter(ch)) { state.advance(); } return state.pos !== start }; // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedPatternCharacter pp$1.regexp_eatExtendedPatternCharacter = function(state) { var ch = state.current(); if ( ch !== -1 && ch !== 0x24 /* $ */ && !(ch >= 0x28 /* ( */ && ch <= 0x2B /* + */) && ch !== 0x2E /* . */ && ch !== 0x3F /* ? */ && ch !== 0x5B /* [ */ && ch !== 0x5E /* ^ */ && ch !== 0x7C /* | */ ) { state.advance(); return true } return false }; // GroupSpecifier :: // [empty] // `?` GroupName pp$1.regexp_groupSpecifier = function(state) { if (state.eat(0x3F /* ? */)) { if (!this.regexp_eatGroupName(state)) { state.raise("Invalid group"); } var trackDisjunction = this.options.ecmaVersion >= 16; var known = state.groupNames[state.lastStringValue]; if (known) { if (trackDisjunction) { for (var i = 0, list = known; i < list.length; i += 1) { var altID = list[i]; if (!altID.separatedFrom(state.branchID)) { state.raise("Duplicate capture group name"); } } } else { state.raise("Duplicate capture group name"); } } if (trackDisjunction) { (known || (state.groupNames[state.lastStringValue] = [])).push(state.branchID); } else { state.groupNames[state.lastStringValue] = true; } } }; // GroupName :: // `<` RegExpIdentifierName `>` // Note: this updates `state.lastStringValue` property with the eaten name. pp$1.regexp_eatGroupName = function(state) { state.lastStringValue = ""; if (state.eat(0x3C /* < */)) { if (this.regexp_eatRegExpIdentifierName(state) && state.eat(0x3E /* > */)) { return true } state.raise("Invalid capture group name"); } return false }; // RegExpIdentifierName :: // RegExpIdentifierStart // RegExpIdentifierName RegExpIdentifierPart // Note: this updates `state.lastStringValue` property with the eaten name. pp$1.regexp_eatRegExpIdentifierName = function(state) { state.lastStringValue = ""; if (this.regexp_eatRegExpIdentifierStart(state)) { state.lastStringValue += codePointToString(state.lastIntValue); while (this.regexp_eatRegExpIdentifierPart(state)) { state.lastStringValue += codePointToString(state.lastIntValue); } return true } return false }; // RegExpIdentifierStart :: // UnicodeIDStart // `$` // `_` // `\` RegExpUnicodeEscapeSequence[+U] pp$1.regexp_eatRegExpIdentifierStart = function(state) { var start = state.pos; var forceU = this.options.ecmaVersion >= 11; var ch = state.current(forceU); state.advance(forceU); if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU)) { ch = state.lastIntValue; } if (isRegExpIdentifierStart(ch)) { state.lastIntValue = ch; return true } state.pos = start; return false }; function isRegExpIdentifierStart(ch) { return isIdentifierStart(ch, true) || ch === 0x24 /* $ */ || ch === 0x5F /* _ */ } // RegExpIdentifierPart :: // UnicodeIDContinue // `$` // `_` // `\` RegExpUnicodeEscapeSequence[+U] // // pp$1.regexp_eatRegExpIdentifierPart = function(state) { var start = state.pos; var forceU = this.options.ecmaVersion >= 11; var ch = state.current(forceU); state.advance(forceU); if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU)) { ch = state.lastIntValue; } if (isRegExpIdentifierPart(ch)) { state.lastIntValue = ch; return true } state.pos = start; return false }; function isRegExpIdentifierPart(ch) { return isIdentifierChar(ch, true) || ch === 0x24 /* $ */ || ch === 0x5F /* _ */ || ch === 0x200C /* */ || ch === 0x200D /* */ } // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-AtomEscape pp$1.regexp_eatAtomEscape = function(state) { if ( this.regexp_eatBackReference(state) || this.regexp_eatCharacterClassEscape(state) || this.regexp_eatCharacterEscape(state) || (state.switchN && this.regexp_eatKGroupName(state)) ) { return true } if (state.switchU) { // Make the same message as V8. if (state.current() === 0x63 /* c */) { state.raise("Invalid unicode escape"); } state.raise("Invalid escape"); } return false }; pp$1.regexp_eatBackReference = function(state) { var start = state.pos; if (this.regexp_eatDecimalEscape(state)) { var n = state.lastIntValue; if (state.switchU) { // For SyntaxError in https://www.ecma-international.org/ecma-262/8.0/#sec-atomescape if (n > state.maxBackReference) { state.maxBackReference = n; } return true } if (n <= state.numCapturingParens) { return true } state.pos = start; } return false }; pp$1.regexp_eatKGroupName = function(state) { if (state.eat(0x6B /* k */)) { if (this.regexp_eatGroupName(state)) { state.backReferenceNames.push(state.lastStringValue); return true } state.raise("Invalid named reference"); } return false }; // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-CharacterEscape pp$1.regexp_eatCharacterEscape = function(state) { return ( this.regexp_eatControlEscape(state) || this.regexp_eatCControlLetter(state) || this.regexp_eatZero(state) || this.regexp_eatHexEscapeSequence(state) || this.regexp_eatRegExpUnicodeEscapeSequence(state, false) || (!state.switchU && this.regexp_eatLegacyOctalEscapeSequence(state)) || this.regexp_eatIdentityEscape(state) ) }; pp$1.regexp_eatCControlLetter = function(state) { var start = state.pos; if (state.eat(0x63 /* c */)) { if (this.regexp_eatControlLetter(state)) { return true } state.pos = start; } return false }; pp$1.regexp_eatZero = function(state) { if (state.current() === 0x30 /* 0 */ && !isDecimalDigit(state.lookahead())) { state.lastIntValue = 0; state.advance(); return true } return false }; // https://www.ecma-international.org/ecma-262/8.0/#prod-ControlEscape pp$1.regexp_eatControlEscape = function(state) { var ch = state.current(); if (ch === 0x74 /* t */) { state.lastIntValue = 0x09; /* \t */ state.advance(); return true } if (ch === 0x6E /* n */) { state.lastIntValue = 0x0A; /* \n */ state.advance(); return true } if (ch === 0x76 /* v */) { state.lastIntValue = 0x0B; /* \v */ state.advance(); return true } if (ch === 0x66 /* f */) { state.lastIntValue = 0x0C; /* \f */ state.advance(); return true } if (ch === 0x72 /* r */) { state.lastIntValue = 0x0D; /* \r */ state.advance(); return true } return false }; // https://www.ecma-international.org/ecma-262/8.0/#prod-ControlLetter pp$1.regexp_eatControlLetter = function(state) { var ch = state.current(); if (isControlLetter(ch)) { state.lastIntValue = ch % 0x20; state.advance(); return true } return false }; function isControlLetter(ch) { return ( (ch >= 0x41 /* A */ && ch <= 0x5A /* Z */) || (ch >= 0x61 /* a */ && ch <= 0x7A /* z */) ) } // https://www.ecma-international.org/ecma-262/8.0/#prod-RegExpUnicodeEscapeSequence pp$1.regexp_eatRegExpUnicodeEscapeSequence = function(state, forceU) { if ( forceU === void 0 ) forceU = false; var start = state.pos; var switchU = forceU || state.switchU; if (state.eat(0x75 /* u */)) { if (this.regexp_eatFixedHexDigits(state, 4)) { var lead = state.lastIntValue; if (switchU && lead >= 0xD800 && lead <= 0xDBFF) { var leadSurrogateEnd = state.pos; if (state.eat(0x5C /* \ */) && state.eat(0x75 /* u */) && this.regexp_eatFixedHexDigits(state, 4)) { var trail = state.lastIntValue; if (trail >= 0xDC00 && trail <= 0xDFFF) { state.lastIntValue = (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000; return true } } state.pos = leadSurrogateEnd; state.lastIntValue = lead; } return true } if ( switchU && state.eat(0x7B /* { */) && this.regexp_eatHexDigits(state) && state.eat(0x7D /* } */) && isValidUnicode(state.lastIntValue) ) { return true } if (switchU) { state.raise("Invalid unicode escape"); } state.pos = start; } return false }; function isValidUnicode(ch) { return ch >= 0 && ch <= 0x10FFFF } // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-IdentityEscape pp$1.regexp_eatIdentityEscape = function(state) { if (state.switchU) { if (this.regexp_eatSyntaxCharacter(state)) { return true } if (state.eat(0x2F /* / */)) { state.lastIntValue = 0x2F; /* / */ return true } return false } var ch = state.current(); if (ch !== 0x63 /* c */ && (!state.switchN || ch !== 0x6B /* k */)) { state.lastIntValue = ch; state.advance(); return true } return false }; // https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalEscape pp$1.regexp_eatDecimalEscape = function(state) { state.lastIntValue = 0; var ch = state.current(); if (ch >= 0x31 /* 1 */ && ch <= 0x39 /* 9 */) { do { state.lastIntValue = 10 * state.lastIntValue + (ch - 0x30 /* 0 */); state.advance(); } while ((ch = state.current()) >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */) return true } return false }; // Return values used by character set parsing methods, needed to // forbid negation of sets that can match strings. var CharSetNone = 0; // Nothing parsed var CharSetOk = 1; // Construct parsed, cannot contain strings var CharSetString = 2; // Construct parsed, can contain strings // https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClassEscape pp$1.regexp_eatCharacterClassEscape = function(state) { var ch = state.current(); if (isCharacterClassEscape(ch)) { state.lastIntValue = -1; state.advance(); return CharSetOk } var negate = false; if ( state.switchU && this.options.ecmaVersion >= 9 && ((negate = ch === 0x50 /* P */) || ch === 0x70 /* p */) ) { state.lastIntValue = -1; state.advance(); var result; if ( state.eat(0x7B /* { */) && (result = this.regexp_eatUnicodePropertyValueExpression(state)) && state.eat(0x7D /* } */) ) { if (negate && result === CharSetString) { state.raise("Invalid property name"); } return result } state.raise("Invalid property name"); } return CharSetNone }; function isCharacterClassEscape(ch) { return ( ch === 0x64 /* d */ || ch === 0x44 /* D */ || ch === 0x73 /* s */ || ch === 0x53 /* S */ || ch === 0x77 /* w */ || ch === 0x57 /* W */ ) } // UnicodePropertyValueExpression :: // UnicodePropertyName `=` UnicodePropertyValue // LoneUnicodePropertyNameOrValue pp$1.regexp_eatUnicodePropertyValueExpression = function(state) { var start = state.pos; // UnicodePropertyName `=` UnicodePropertyValue if (this.regexp_eatUnicodePropertyName(state) && state.eat(0x3D /* = */)) { var name = state.lastStringValue; if (this.regexp_eatUnicodePropertyValue(state)) { var value = state.lastStringValue; this.regexp_validateUnicodePropertyNameAndValue(state, name, value); return CharSetOk } } state.pos = start; // LoneUnicodePropertyNameOrValue if (this.regexp_eatLoneUnicodePropertyNameOrValue(state)) { var nameOrValue = state.lastStringValue; return this.regexp_validateUnicodePropertyNameOrValue(state, nameOrValue) } return CharSetNone }; pp$1.regexp_validateUnicodePropertyNameAndValue = function(state, name, value) { if (!hasOwn(state.unicodeProperties.nonBinary, name)) { state.raise("Invalid property name"); } if (!state.unicodeProperties.nonBinary[name].test(value)) { state.raise("Invalid property value"); } }; pp$1.regexp_validateUnicodePropertyNameOrValue = function(state, nameOrValue) { if (state.unicodeProperties.binary.test(nameOrValue)) { return CharSetOk } if (state.switchV && state.unicodeProperties.binaryOfStrings.test(nameOrValue)) { return CharSetString } state.raise("Invalid property name"); }; // UnicodePropertyName :: // UnicodePropertyNameCharacters pp$1.regexp_eatUnicodePropertyName = function(state) { var ch = 0; state.lastStringValue = ""; while (isUnicodePropertyNameCharacter(ch = state.current())) { state.lastStringValue += codePointToString(ch); state.advance(); } return state.lastStringValue !== "" }; function isUnicodePropertyNameCharacter(ch) { return isControlLetter(ch) || ch === 0x5F /* _ */ } // UnicodePropertyValue :: // UnicodePropertyValueCharacters pp$1.regexp_eatUnicodePropertyValue = function(state) { var ch = 0; state.lastStringValue = ""; while (isUnicodePropertyValueCharacter(ch = state.current())) { state.lastStringValue += codePointToString(ch); state.advance(); } return state.lastStringValue !== "" }; function isUnicodePropertyValueCharacter(ch) { return isUnicodePropertyNameCharacter(ch) || isDecimalDigit(ch) } // LoneUnicodePropertyNameOrValue :: // UnicodePropertyValueCharacters pp$1.regexp_eatLoneUnicodePropertyNameOrValue = function(state) { return this.regexp_eatUnicodePropertyValue(state) }; // https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClass pp$1.regexp_eatCharacterClass = function(state) { if (state.eat(0x5B /* [ */)) { var negate = state.eat(0x5E /* ^ */); var result = this.regexp_classContents(state); if (!state.eat(0x5D /* ] */)) { state.raise("Unterminated character class"); } if (negate && result === CharSetString) { state.raise("Negated character class may contain strings"); } return true } return false }; // https://tc39.es/ecma262/#prod-ClassContents // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassRanges pp$1.regexp_classContents = function(state) { if (state.current() === 0x5D /* ] */) { return CharSetOk } if (state.switchV) { return this.regexp_classSetExpression(state) } this.regexp_nonEmptyClassRanges(state); return CharSetOk }; // https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRanges // https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRangesNoDash pp$1.regexp_nonEmptyClassRanges = function(state) { while (this.regexp_eatClassAtom(state)) { var left = state.lastIntValue; if (state.eat(0x2D /* - */) && this.regexp_eatClassAtom(state)) { var right = state.lastIntValue; if (state.switchU && (left === -1 || right === -1)) { state.raise("Invalid character class"); } if (left !== -1 && right !== -1 && left > right) { state.raise("Range out of order in character class"); } } } }; // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtom // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtomNoDash pp$1.regexp_eatClassAtom = function(state) { var start = state.pos; if (state.eat(0x5C /* \ */)) { if (this.regexp_eatClassEscape(state)) { return true } if (state.switchU) { // Make the same message as V8. var ch$1 = state.current(); if (ch$1 === 0x63 /* c */ || isOctalDigit(ch$1)) { state.raise("Invalid class escape"); } state.raise("Invalid escape"); } state.pos = start; } var ch = state.current(); if (ch !== 0x5D /* ] */) { state.lastIntValue = ch; state.advance(); return true } return false }; // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassEscape pp$1.regexp_eatClassEscape = function(state) { var start = state.pos; if (state.eat(0x62 /* b */)) { state.lastIntValue = 0x08; /* */ return true } if (state.switchU && state.eat(0x2D /* - */)) { state.lastIntValue = 0x2D; /* - */ return true } if (!state.switchU && state.eat(0x63 /* c */)) { if (this.regexp_eatClassControlLetter(state)) { return true } state.pos = start; } return ( this.regexp_eatCharacterClassEscape(state) || this.regexp_eatCharacterEscape(state) ) }; // https://tc39.es/ecma262/#prod-ClassSetExpression // https://tc39.es/ecma262/#prod-ClassUnion // https://tc39.es/ecma262/#prod-ClassIntersection // https://tc39.es/ecma262/#prod-ClassSubtraction pp$1.regexp_classSetExpression = function(state) { var result = CharSetOk, subResult; if (this.regexp_eatClassSetRange(state)) ; else if (subResult = this.regexp_eatClassSetOperand(state)) { if (subResult === CharSetString) { result = CharSetString; } // https://tc39.es/ecma262/#prod-ClassIntersection var start = state.pos; while (state.eatChars([0x26, 0x26] /* && */)) { if ( state.current() !== 0x26 /* & */ && (subResult = this.regexp_eatClassSetOperand(state)) ) { if (subResult !== CharSetString) { result = CharSetOk; } continue } state.raise("Invalid character in character class"); } if (start !== state.pos) { return result } // https://tc39.es/ecma262/#prod-ClassSubtraction while (state.eatChars([0x2D, 0x2D] /* -- */)) { if (this.regexp_eatClassSetOperand(state)) { continue } state.raise("Invalid character in character class"); } if (start !== state.pos) { return result } } else { state.raise("Invalid character in character class"); } // https://tc39.es/ecma262/#prod-ClassUnion for (;;) { if (this.regexp_eatClassSetRange(state)) { continue } subResult = this.regexp_eatClassSetOperand(state); if (!subResult) { return result } if (subResult === CharSetString) { result = CharSetString; } } }; // https://tc39.es/ecma262/#prod-ClassSetRange pp$1.regexp_eatClassSetRange = function(state) { var start = state.pos; if (this.regexp_eatClassSetCharacter(state)) { var left = state.lastIntValue; if (state.eat(0x2D /* - */) && this.regexp_eatClassSetCharacter(state)) { var right = state.lastIntValue; if (left !== -1 && right !== -1 && left > right) { state.raise("Range out of order in character class"); } return true } state.pos = start; } return false }; // https://tc39.es/ecma262/#prod-ClassSetOperand pp$1.regexp_eatClassSetOperand = function(state) { if (this.regexp_eatClassSetCharacter(state)) { return CharSetOk } return this.regexp_eatClassStringDisjunction(state) || this.regexp_eatNestedClass(state) }; // https://tc39.es/ecma262/#prod-NestedClass pp$1.regexp_eatNestedClass = function(state) { var start = state.pos; if (state.eat(0x5B /* [ */)) { var negate = state.eat(0x5E /* ^ */); var result = this.regexp_classContents(state); if (state.eat(0x5D /* ] */)) { if (negate && result === CharSetString) { state.raise("Negated character class may contain strings"); } return result } state.pos = start; } if (state.eat(0x5C /* \ */)) { var result$1 = this.regexp_eatCharacterClassEscape(state); if (result$1) { return result$1 } state.pos = start; } return null }; // https://tc39.es/ecma262/#prod-ClassStringDisjunction pp$1.regexp_eatClassStringDisjunction = function(state) { var start = state.pos; if (state.eatChars([0x5C, 0x71] /* \q */)) { if (state.eat(0x7B /* { */)) { var result = this.regexp_classStringDisjunctionContents(state); if (state.eat(0x7D /* } */)) { return result } } else { // Make the same message as V8. state.raise("Invalid escape"); } state.pos = start; } return null }; // https://tc39.es/ecma262/#prod-ClassStringDisjunctionContents pp$1.regexp_classStringDisjunctionContents = function(state) { var result = this.regexp_classString(state); while (state.eat(0x7C /* | */)) { if (this.regexp_classString(state) === CharSetString) { result = CharSetString; } } return result }; // https://tc39.es/ecma262/#prod-ClassString // https://tc39.es/ecma262/#prod-NonEmptyClassString pp$1.regexp_classString = function(state) { var count = 0; while (this.regexp_eatClassSetCharacter(state)) { count++; } return count === 1 ? CharSetOk : CharSetString }; // https://tc39.es/ecma262/#prod-ClassSetCharacter pp$1.regexp_eatClassSetCharacter = function(state) { var start = state.pos; if (state.eat(0x5C /* \ */)) { if ( this.regexp_eatCharacterEscape(state) || this.regexp_eatClassSetReservedPunctuator(state) ) { return true } if (state.eat(0x62 /* b */)) { state.lastIntValue = 0x08; /* */ return true } state.pos = start; return false } var ch = state.current(); if (ch < 0 || ch === state.lookahead() && isClassSetReservedDoublePunctuatorCharacter(ch)) { return false } if (isClassSetSyntaxCharacter(ch)) { return false } state.advance(); state.lastIntValue = ch; return true }; // https://tc39.es/ecma262/#prod-ClassSetReservedDoublePunctuator function isClassSetReservedDoublePunctuatorCharacter(ch) { return ( ch === 0x21 /* ! */ || ch >= 0x23 /* # */ && ch <= 0x26 /* & */ || ch >= 0x2A /* * */ && ch <= 0x2C /* , */ || ch === 0x2E /* . */ || ch >= 0x3A /* : */ && ch <= 0x40 /* @ */ || ch === 0x5E /* ^ */ || ch === 0x60 /* ` */ || ch === 0x7E /* ~ */ ) } // https://tc39.es/ecma262/#prod-ClassSetSyntaxCharacter function isClassSetSyntaxCharacter(ch) { return ( ch === 0x28 /* ( */ || ch === 0x29 /* ) */ || ch === 0x2D /* - */ || ch === 0x2F /* / */ || ch >= 0x5B /* [ */ && ch <= 0x5D /* ] */ || ch >= 0x7B /* { */ && ch <= 0x7D /* } */ ) } // https://tc39.es/ecma262/#prod-ClassSetReservedPunctuator pp$1.regexp_eatClassSetReservedPunctuator = function(state) { var ch = state.current(); if (isClassSetReservedPunctuator(ch)) { state.lastIntValue = ch; state.advance(); return true } return false }; // https://tc39.es/ecma262/#prod-ClassSetReservedPunctuator function isClassSetReservedPunctuator(ch) { return ( ch === 0x21 /* ! */ || ch === 0x23 /* # */ || ch === 0x25 /* % */ || ch === 0x26 /* & */ || ch === 0x2C /* , */ || ch === 0x2D /* - */ || ch >= 0x3A /* : */ && ch <= 0x3E /* > */ || ch === 0x40 /* @ */ || ch === 0x60 /* ` */ || ch === 0x7E /* ~ */ ) } // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassControlLetter pp$1.regexp_eatClassControlLetter = function(state) { var ch = state.current(); if (isDecimalDigit(ch) || ch === 0x5F /* _ */) { state.lastIntValue = ch % 0x20; state.advance(); return true } return false }; // https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence pp$1.regexp_eatHexEscapeSequence = function(state) { var start = state.pos; if (state.eat(0x78 /* x */)) { if (this.regexp_eatFixedHexDigits(state, 2)) { return true } if (state.switchU) { state.raise("Invalid escape"); } state.pos = start; } return false }; // https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalDigits pp$1.regexp_eatDecimalDigits = function(state) { var start = state.pos; var ch = 0; state.lastIntValue = 0; while (isDecimalDigit(ch = state.current())) { state.lastIntValue = 10 * state.lastIntValue + (ch - 0x30 /* 0 */); state.advance(); } return state.pos !== start }; function isDecimalDigit(ch) { return ch >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */ } // https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigits pp$1.regexp_eatHexDigits = function(state) { var start = state.pos; var ch = 0; state.lastIntValue = 0; while (isHexDigit(ch = state.current())) { state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch); state.advance(); } return state.pos !== start }; function isHexDigit(ch) { return ( (ch >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */) || (ch >= 0x41 /* A */ && ch <= 0x46 /* F */) || (ch >= 0x61 /* a */ && ch <= 0x66 /* f */) ) } function hexToInt(ch) { if (ch >= 0x41 /* A */ && ch <= 0x46 /* F */) { return 10 + (ch - 0x41 /* A */) } if (ch >= 0x61 /* a */ && ch <= 0x66 /* f */) { return 10 + (ch - 0x61 /* a */) } return ch - 0x30 /* 0 */ } // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-LegacyOctalEscapeSequence // Allows only 0-377(octal) i.e. 0-255(decimal). pp$1.regexp_eatLegacyOctalEscapeSequence = function(state) { if (this.regexp_eatOctalDigit(state)) { var n1 = state.lastIntValue; if (this.regexp_eatOctalDigit(state)) { var n2 = state.lastIntValue; if (n1 <= 3 && this.regexp_eatOctalDigit(state)) { state.lastIntValue = n1 * 64 + n2 * 8 + state.lastIntValue; } else { state.lastIntValue = n1 * 8 + n2; } } else { state.lastIntValue = n1; } return true } return false }; // https://www.ecma-international.org/ecma-262/8.0/#prod-OctalDigit pp$1.regexp_eatOctalDigit = function(state) { var ch = state.current(); if (isOctalDigit(ch)) { state.lastIntValue = ch - 0x30; /* 0 */ state.advance(); return true } state.lastIntValue = 0; return false }; function isOctalDigit(ch) { return ch >= 0x30 /* 0 */ && ch <= 0x37 /* 7 */ } // https://www.ecma-international.org/ecma-262/8.0/#prod-Hex4Digits // https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigit // And HexDigit HexDigit in https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence pp$1.regexp_eatFixedHexDigits = function(state, length) { var start = state.pos; state.lastIntValue = 0; for (var i = 0; i < length; ++i) { var ch = state.current(); if (!isHexDigit(ch)) { state.pos = start; return false } state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch); state.advance(); } return true }; // Object type used to represent tokens. Note that normally, tokens // simply exist as properties on the parser object. This is only // used for the onToken callback and the external tokenizer. var Token = function Token(p) { this.type = p.type; this.value = p.value; this.start = p.start; this.end = p.end; if (p.options.locations) { this.loc = new SourceLocation(p, p.startLoc, p.endLoc); } if (p.options.ranges) { this.range = [p.start, p.end]; } }; // ## Tokenizer var pp = Parser.prototype; // Move to the next token pp.next = function(ignoreEscapeSequenceInKeyword) { if (!ignoreEscapeSequenceInKeyword && this.type.keyword && this.containsEsc) { this.raiseRecoverable(this.start, "Escape sequence in keyword " + this.type.keyword); } if (this.options.onToken) { this.options.onToken(new Token(this)); } this.lastTokEnd = this.end; this.lastTokStart = this.start; this.lastTokEndLoc = this.endLoc; this.lastTokStartLoc = this.startLoc; this.nextToken(); }; pp.getToken = function() { this.next(); return new Token(this) }; // If we're in an ES6 environment, make parsers iterable if (typeof Symbol !== "undefined") { pp[Symbol.iterator] = function() { var this$1$1 = this; return { next: function () { var token = this$1$1.getToken(); return { done: token.type === types$1.eof, value: token } } } }; } // Toggle strict mode. Re-reads the next number or string to please // pedantic tests (`"use strict"; 010;` should fail). // Read a single token, updating the parser object's token-related // properties. pp.nextToken = function() { var curContext = this.curContext(); if (!curContext || !curContext.preserveSpace) { this.skipSpace(); } this.start = this.pos; if (this.options.locations) { this.startLoc = this.curPosition(); } if (this.pos >= this.input.length) { return this.finishToken(types$1.eof) } if (curContext.override) { return curContext.override(this) } else { this.readToken(this.fullCharCodeAtPos()); } }; pp.readToken = function(code) { // Identifier or keyword. '\uXXXX' sequences are allowed in // identifiers, so '\' also dispatches to that. if (isIdentifierStart(code, this.options.ecmaVersion >= 6) || code === 92 /* '\' */) { return this.readWord() } return this.getTokenFromCode(code) }; pp.fullCharCodeAtPos = function() { var code = this.input.charCodeAt(this.pos); if (code <= 0xd7ff || code >= 0xdc00) { return code } var next = this.input.charCodeAt(this.pos + 1); return next <= 0xdbff || next >= 0xe000 ? code : (code << 10) + next - 0x35fdc00 }; pp.skipBlockComment = function() { var startLoc = this.options.onComment && this.curPosition(); var start = this.pos, end = this.input.indexOf("*/", this.pos += 2); if (end === -1) { this.raise(this.pos - 2, "Unterminated comment"); } this.pos = end + 2; if (this.options.locations) { for (var nextBreak = (void 0), pos = start; (nextBreak = nextLineBreak(this.input, pos, this.pos)) > -1;) { ++this.curLine; pos = this.lineStart = nextBreak; } } if (this.options.onComment) { this.options.onComment(true, this.input.slice(start + 2, end), start, this.pos, startLoc, this.curPosition()); } }; pp.skipLineComment = function(startSkip) { var start = this.pos; var startLoc = this.options.onComment && this.curPosition(); var ch = this.input.charCodeAt(this.pos += startSkip); while (this.pos < this.input.length && !isNewLine(ch)) { ch = this.input.charCodeAt(++this.pos); } if (this.options.onComment) { this.options.onComment(false, this.input.slice(start + startSkip, this.pos), start, this.pos, startLoc, this.curPosition()); } }; // Called at the start of the parse and after every token. Skips // whitespace and comments, and. pp.skipSpace = function() { loop: while (this.pos < this.input.length) { var ch = this.input.charCodeAt(this.pos); switch (ch) { case 32: case 160: // ' ' ++this.pos; break case 13: if (this.input.charCodeAt(this.pos + 1) === 10) { ++this.pos; } case 10: case 8232: case 8233: ++this.pos; if (this.options.locations) { ++this.curLine; this.lineStart = this.pos; } break case 47: // '/' switch (this.input.charCodeAt(this.pos + 1)) { case 42: // '*' this.skipBlockComment(); break case 47: this.skipLineComment(2); break default: break loop } break default: if (ch > 8 && ch < 14 || ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) { ++this.pos; } else { break loop } } } }; // Called at the end of every token. Sets `end`, `val`, and // maintains `context` and `exprAllowed`, and skips the space after // the token, so that the next one's `start` will point at the // right position. pp.finishToken = function(type, val) { this.end = this.pos; if (this.options.locations) { this.endLoc = this.curPosition(); } var prevType = this.type; this.type = type; this.value = val; this.updateContext(prevType); }; // ### Token reading // This is the function that is called to fetch the next token. It // is somewhat obscure, because it works in character codes rather // than characters, and because operator parsing has been inlined // into it. // // All in the name of speed. // pp.readToken_dot = function() { var next = this.input.charCodeAt(this.pos + 1); if (next >= 48 && next <= 57) { return this.readNumber(true) } var next2 = this.input.charCodeAt(this.pos + 2); if (this.options.ecmaVersion >= 6 && next === 46 && next2 === 46) { // 46 = dot '.' this.pos += 3; return this.finishToken(types$1.ellipsis) } else { ++this.pos; return this.finishToken(types$1.dot) } }; pp.readToken_slash = function() { // '/' var next = this.input.charCodeAt(this.pos + 1); if (this.exprAllowed) { ++this.pos; return this.readRegexp() } if (next === 61) { return this.finishOp(types$1.assign, 2) } return this.finishOp(types$1.slash, 1) }; pp.readToken_mult_modulo_exp = function(code) { // '%*' var next = this.input.charCodeAt(this.pos + 1); var size = 1; var tokentype = code === 42 ? types$1.star : types$1.modulo; // exponentiation operator ** and **= if (this.options.ecmaVersion >= 7 && code === 42 && next === 42) { ++size; tokentype = types$1.starstar; next = this.input.charCodeAt(this.pos + 2); } if (next === 61) { return this.finishOp(types$1.assign, size + 1) } return this.finishOp(tokentype, size) }; pp.readToken_pipe_amp = function(code) { // '|&' var next = this.input.charCodeAt(this.pos + 1); if (next === code) { if (this.options.ecmaVersion >= 12) { var next2 = this.input.charCodeAt(this.pos + 2); if (next2 === 61) { return this.finishOp(types$1.assign, 3) } } return this.finishOp(code === 124 ? types$1.logicalOR : types$1.logicalAND, 2) } if (next === 61) { return this.finishOp(types$1.assign, 2) } return this.finishOp(code === 124 ? types$1.bitwiseOR : types$1.bitwiseAND, 1) }; pp.readToken_caret = function() { // '^' var next = this.input.charCodeAt(this.pos + 1); if (next === 61) { return this.finishOp(types$1.assign, 2) } return this.finishOp(types$1.bitwiseXOR, 1) }; pp.readToken_plus_min = function(code) { // '+-' var next = this.input.charCodeAt(this.pos + 1); if (next === code) { if (next === 45 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 62 && (this.lastTokEnd === 0 || lineBreak.test(this.input.slice(this.lastTokEnd, this.pos)))) { // A `-->` line comment this.skipLineComment(3); this.skipSpace(); return this.nextToken() } return this.finishOp(types$1.incDec, 2) } if (next === 61) { return this.finishOp(types$1.assign, 2) } return this.finishOp(types$1.plusMin, 1) }; pp.readToken_lt_gt = function(code) { // '<>' var next = this.input.charCodeAt(this.pos + 1); var size = 1; if (next === code) { size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2; if (this.input.charCodeAt(this.pos + size) === 61) { return this.finishOp(types$1.assign, size + 1) } return this.finishOp(types$1.bitShift, size) } if (next === 33 && code === 60 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 45 && this.input.charCodeAt(this.pos + 3) === 45) { // `' is a single-line comment this.index += 3; var comment = this.skipSingleLineComment(3); if (this.trackComment) { comments = comments.concat(comment); } } else { break; } } else if (ch === 0x3C && !this.isModule) { if (this.source.slice(this.index + 1, this.index + 4) === '!--') { this.index += 4; // ` args argumentsVar.references.forEach(function (ref) { ref.identifier.name = 'args'; }); // Change function() --> function(...args) node.params = [createRestElement()]; } } } })); } function isES5Function(node) { return node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression'; } function hasArgs(scope) { if (!scope) { return false; } if (scope.variables.some(function (v) { return v.name === 'args'; })) { return true; } return hasArgs(scope.upper); } function createRestElement() { return { type: 'RestElement', argument: { type: 'Identifier', name: 'args' } }; } /***/ }), /***/ "./node_modules/lebab/lib/transform/argSpread.js": /*!*******************************************************!*\ !*** ./node_modules/lebab/lib/transform/argSpread.js ***! \*******************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = _default; var _fp = __webpack_require__(/*! lodash/fp */ "./node_modules/lodash/fp.js"); var _traverser = _interopRequireDefault(__webpack_require__(/*! ../traverser */ "./node_modules/lebab/lib/traverser.js")); var _fMatches = __webpack_require__(/*! f-matches */ "./node_modules/f-matches/index.js"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _default(ast) { _traverser["default"].replace(ast, { enter: function enter(node) { var _matchFunctionApplyCa = matchFunctionApplyCall(node), func = _matchFunctionApplyCa.func, array = _matchFunctionApplyCa.array; if (func) { return createCallWithSpread(func, array); } var _matchObjectApplyCall = matchObjectApplyCall(node), memberExpr = _matchObjectApplyCall.memberExpr, thisParam = _matchObjectApplyCall.thisParam, arrayParam = _matchObjectApplyCall.arrayParam; if (memberExpr && (0, _fp.isEqual)(omitLoc(memberExpr.object), omitLoc(thisParam))) { return createCallWithSpread(memberExpr, arrayParam); } } }); } function createCallWithSpread(func, array) { return { type: 'CallExpression', callee: func, arguments: [{ type: 'SpreadElement', argument: array }] }; } // Recursively strips `loc`, `start` and `end` fields from given object and its nested objects, // removing the location information that we don't care about when comparing // AST nodes. function omitLoc(obj) { if ((0, _fp.isArray)(obj)) { return obj.map(omitLoc); } else if ((0, _fp.isObjectLike)(obj)) { return (0, _fp.flow)((0, _fp.omit)(['loc', 'start', 'end']), (0, _fp.mapValues)(omitLoc))(obj); } else { return obj; } } var isUndefined = (0, _fMatches.matches)({ type: 'Identifier', name: 'undefined' }); var isNull = (0, _fMatches.matches)({ type: 'Literal', value: null, // eslint-disable-line no-null/no-null raw: 'null' }); function matchFunctionApplyCall(node) { return (0, _fMatches.matches)({ type: 'CallExpression', callee: { type: 'MemberExpression', computed: false, object: (0, _fMatches.extract)('func', { type: 'Identifier' }), property: { type: 'Identifier', name: 'apply' } }, arguments: [function (arg) { return isUndefined(arg) || isNull(arg); }, (0, _fMatches.extractAny)('array')] }, node); } function matchObjectApplyCall(node) { return (0, _fMatches.matches)({ type: 'CallExpression', callee: { type: 'MemberExpression', computed: false, object: (0, _fMatches.extract)('memberExpr', { type: 'MemberExpression' }), property: { type: 'Identifier', name: 'apply' } }, arguments: [(0, _fMatches.extractAny)('thisParam'), (0, _fMatches.extractAny)('arrayParam')] }, node); } /***/ }), /***/ "./node_modules/lebab/lib/transform/arrow.js": /*!***************************************************!*\ !*** ./node_modules/lebab/lib/transform/arrow.js ***! \***************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = _default; var _fp = __webpack_require__(/*! lodash/fp */ "./node_modules/lodash/fp.js"); var _traverser = _interopRequireDefault(__webpack_require__(/*! ../traverser */ "./node_modules/lebab/lib/traverser.js")); var _ArrowFunctionExpression = _interopRequireDefault(__webpack_require__(/*! ../syntax/ArrowFunctionExpression */ "./node_modules/lebab/lib/syntax/ArrowFunctionExpression.js")); var _fMatches = __webpack_require__(/*! f-matches */ "./node_modules/f-matches/index.js"); var _copyComments = _interopRequireDefault(__webpack_require__(/*! ../utils/copyComments */ "./node_modules/lebab/lib/utils/copyComments.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _default(ast, logger) { _traverser["default"].replace(ast, { enter: function enter(node, parent) { if (isFunctionConvertableToArrow(node, parent)) { if (hasArguments(node.body)) { logger.warn(node, 'Can not use arguments in arrow function', 'arrow'); return; } return functionToArrow(node, parent); } var _matchBoundFunction = matchBoundFunction(node), func = _matchBoundFunction.func; if (func) { return functionToArrow(func, parent); } } }); } function isFunctionConvertableToArrow(node, parent) { return node.type === 'FunctionExpression' && parent.type !== 'Property' && parent.type !== 'MethodDefinition' && !node.id && !node.generator && !hasThis(node.body); } // Matches: function(){}.bind(this) function matchBoundFunction(node) { return (0, _fMatches.matches)({ type: 'CallExpression', callee: { type: 'MemberExpression', computed: false, object: (0, _fMatches.extract)('func', { type: 'FunctionExpression', id: null, // eslint-disable-line no-null/no-null body: function body(_body) { return !hasArguments(_body); }, generator: false }), property: { type: 'Identifier', name: 'bind' } }, arguments: (0, _fMatches.matchesLength)([{ type: 'ThisExpression' }]) }, node); } function hasThis(ast) { return hasInFunctionBody(ast, { type: 'ThisExpression' }); } function hasArguments(ast) { return hasInFunctionBody(ast, { type: 'Identifier', name: 'arguments' }); } // Returns true when pattern matches any node in given function body, // excluding any nested functions function hasInFunctionBody(ast, pattern) { return _traverser["default"].find(ast, (0, _fp.matches)(pattern), { skipTypes: ['FunctionExpression', 'FunctionDeclaration'] }); } function functionToArrow(func, parent) { var arrow = new _ArrowFunctionExpression["default"]({ body: func.body, params: func.params, defaults: func.defaults, rest: func.rest, async: func.async }); (0, _copyComments["default"])({ from: func, to: arrow }); // Get rid of extra parentheses around IIFE // by forcing Recast to reformat the CallExpression if (isIIFE(func, parent)) { parent.original = null; // eslint-disable-line no-null/no-null } return arrow; } // Is it immediately invoked function expression? function isIIFE(func, parent) { return parent.type === 'CallExpression' && parent.callee === func; } /***/ }), /***/ "./node_modules/lebab/lib/transform/arrowReturn.js": /*!*********************************************************!*\ !*** ./node_modules/lebab/lib/transform/arrowReturn.js ***! \*********************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = _default; var _traverser = _interopRequireDefault(__webpack_require__(/*! ../traverser */ "./node_modules/lebab/lib/traverser.js")); var _fMatches = __webpack_require__(/*! f-matches */ "./node_modules/f-matches/index.js"); var _copyComments = _interopRequireDefault(__webpack_require__(/*! ../utils/copyComments */ "./node_modules/lebab/lib/utils/copyComments.js")); var _fp = __webpack_require__(/*! lodash/fp */ "./node_modules/lodash/fp.js"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _default(ast) { _traverser["default"].replace(ast, { enter: function enter(node) { if (isShortenableArrowFunction(node)) { return shortenReturn(node); } } }); } function shortenReturn(node) { node.body = extractArrowBody(node.body); return node; } var matchesReturnBlock = (0, _fMatches.matches)({ type: 'BlockStatement', body: (0, _fMatches.matchesLength)([(0, _fMatches.extract)('returnStatement', { type: 'ReturnStatement', argument: (0, _fMatches.extract)('returnVal', (0, _fp.negate)(_fp.isNull)) })]) }); function isShortenableArrowFunction(node) { return node.type === 'ArrowFunctionExpression' && matchesReturnBlock(node.body); } function extractArrowBody(block) { var _matchesReturnBlock = matchesReturnBlock(block), returnStatement = _matchesReturnBlock.returnStatement, returnVal = _matchesReturnBlock.returnVal; // preserve return statement comments (0, _copyComments["default"])({ from: returnStatement, to: returnVal }); return returnVal; } /***/ }), /***/ "./node_modules/lebab/lib/transform/class/PotentialClass.js": /*!******************************************************************!*\ !*** ./node_modules/lebab/lib/transform/class/PotentialClass.js ***! \******************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = void 0; var _fp = __webpack_require__(/*! lodash/fp */ "./node_modules/lodash/fp.js"); var _extractComments = _interopRequireDefault(__webpack_require__(/*! ./extractComments */ "./node_modules/lebab/lib/transform/class/extractComments.js")); var _multiReplaceStatement = _interopRequireDefault(__webpack_require__(/*! ./../../utils/multiReplaceStatement */ "./node_modules/lebab/lib/utils/multiReplaceStatement.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /** * Represents a potential class to be created. */ var PotentialClass = /*#__PURE__*/function () { /** * @param {Object} cfg * @param {String} cfg.name Class name * @param {Object} cfg.fullNode Node to remove after converting to class * @param {Object[]} cfg.commentNodes Nodes to extract comments from * @param {Object} cfg.parent */ function PotentialClass(_ref) { var name = _ref.name, fullNode = _ref.fullNode, commentNodes = _ref.commentNodes, parent = _ref.parent; _classCallCheck(this, PotentialClass); this.name = name; this.constructor = undefined; this.fullNode = fullNode; this.superClass = undefined; this.commentNodes = commentNodes; this.parent = parent; this.methods = []; this.replacements = []; } /** * Returns the name of the class. * @return {String} */ _createClass(PotentialClass, [{ key: "getName", value: function getName() { return this.name; } /** * Returns the AST node for the original function * @return {Object} */ }, { key: "getFullNode", value: function getFullNode() { return this.fullNode; } /** * Set the constructor. * @param {PotentialMethod} method. */ }, { key: "setConstructor", value: function setConstructor(method) { this.constructor = method; } /** * Set the superClass and set up the related assignment expressions to be * removed during transformation. * @param {Node} superClass The super class node. * @param {Node[]} relatedExpressions The related expressions to be removed * during transformation. */ }, { key: "setSuperClass", value: function setSuperClass(superClass, relatedExpressions) { this.superClass = superClass; var _iterator = _createForOfIteratorHelper(relatedExpressions), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var _step$value = _step.value, parent = _step$value.parent, node = _step$value.node; this.replacements.push({ parent: parent, node: node, replacements: [] }); } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } this.constructor.setSuperClass(superClass); } /** * Adds method to class. * @param {PotentialMethod} method */ }, { key: "addMethod", value: function addMethod(method) { this.methods.push(method); } /** * True when class has at least one method (besides constructor). * @return {Boolean} */ }, { key: "isTransformable", value: function isTransformable() { return this.methods.length > 0 || this.superClass !== undefined; } /** * Replaces original constructor function and manual prototype assignments * with ClassDeclaration. */ }, { key: "transform", value: function transform() { (0, _multiReplaceStatement["default"])({ parent: this.parent, node: this.fullNode, replacements: [this.toClassDeclaration()] }); this.replacements.forEach(_multiReplaceStatement["default"]); this.methods.forEach(function (method) { return method.remove(); }); } }, { key: "toClassDeclaration", value: function toClassDeclaration() { return { type: 'ClassDeclaration', superClass: this.superClass, id: { type: 'Identifier', name: this.name }, body: { type: 'ClassBody', body: this.createMethods() }, comments: (0, _extractComments["default"])(this.commentNodes) }; } }, { key: "createMethods", value: function createMethods() { var _this = this; return (0, _fp.compact)([this.createConstructor()].concat(_toConsumableArray(this.methods.map(function (method) { method.setSuperClass(_this.superClass); return method.toMethodDefinition(); })))); } }, { key: "createConstructor", value: function createConstructor() { return this.constructor.isEmpty() ? undefined : this.constructor.toMethodDefinition(); } }]); return PotentialClass; }(); exports["default"] = PotentialClass; /***/ }), /***/ "./node_modules/lebab/lib/transform/class/PotentialConstructor.js": /*!************************************************************************!*\ !*** ./node_modules/lebab/lib/transform/class/PotentialConstructor.js ***! \************************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = void 0; var _traverser = _interopRequireDefault(__webpack_require__(/*! ../../traverser */ "./node_modules/lebab/lib/traverser.js")); var _isEqualAst = _interopRequireDefault(__webpack_require__(/*! ./../../utils/isEqualAst */ "./node_modules/lebab/lib/utils/isEqualAst.js")); var _fMatches = __webpack_require__(/*! f-matches */ "./node_modules/f-matches/index.js"); var _PotentialMethod2 = _interopRequireDefault(__webpack_require__(/*! ./PotentialMethod */ "./node_modules/lebab/lib/transform/class/PotentialMethod.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } /** * Represents a potential constructor method to be created. */ var PotentialConstructor = /*#__PURE__*/function (_PotentialMethod) { _inherits(PotentialConstructor, _PotentialMethod); var _super = _createSuper(PotentialConstructor); function PotentialConstructor(cfg) { _classCallCheck(this, PotentialConstructor); cfg.name = 'constructor'; return _super.call(this, cfg); } // Override superclass method _createClass(PotentialConstructor, [{ key: "getBody", value: function getBody() { if (this.superClass) { return this.transformSuperCalls(this.getBodyBlock()); } else { return this.getBodyBlock(); } } // Transforms constructor body by replacing // SuperClass.call(this, ...args) --> super(...args) }, { key: "transformSuperCalls", value: function transformSuperCalls(body) { var _this = this; return _traverser["default"].replace(body, { enter: function enter(node) { if (_this.isSuperConstructorCall(node)) { node.expression.callee = { type: 'Super' }; node.expression.arguments = node.expression.arguments.slice(1); } } }); } }, { key: "isSuperConstructorCall", value: function isSuperConstructorCall(node) { var _this2 = this; return (0, _fMatches.matches)({ type: 'ExpressionStatement', expression: { type: 'CallExpression', callee: { type: 'MemberExpression', object: function object(obj) { return (0, _isEqualAst["default"])(obj, _this2.superClass); }, property: { type: 'Identifier', name: 'call' } }, arguments: [{ type: 'ThisExpression' }] } }, node); } }]); return PotentialConstructor; }(_PotentialMethod2["default"]); exports["default"] = PotentialConstructor; /***/ }), /***/ "./node_modules/lebab/lib/transform/class/PotentialMethod.js": /*!*******************************************************************!*\ !*** ./node_modules/lebab/lib/transform/class/PotentialMethod.js ***! \*******************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = void 0; var _traverser = _interopRequireDefault(__webpack_require__(/*! ../../traverser */ "./node_modules/lebab/lib/traverser.js")); var _isEqualAst = _interopRequireDefault(__webpack_require__(/*! ./../../utils/isEqualAst */ "./node_modules/lebab/lib/utils/isEqualAst.js")); var _fMatches = __webpack_require__(/*! f-matches */ "./node_modules/f-matches/index.js"); var _extractComments = _interopRequireDefault(__webpack_require__(/*! ./extractComments */ "./node_modules/lebab/lib/transform/class/extractComments.js")); var _multiReplaceStatement = _interopRequireDefault(__webpack_require__(/*! ./../../utils/multiReplaceStatement */ "./node_modules/lebab/lib/utils/multiReplaceStatement.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /** * Represents a potential class method to be created. */ var PotentialMethod = /*#__PURE__*/function () { /** * @param {Object} cfg * @param {String} cfg.name Method name * @param {Object} cfg.methodNode * @param {Object} cfg.fullNode Node to remove after converting to class * @param {Object[]} cfg.commentNodes Nodes to extract comments from * @param {Object} cfg.parent * @param {String} [cfg.kind] Either 'get' or 'set' (optional) * @param {Boolean} [cfg.static] True to make static method (optional) */ function PotentialMethod(cfg) { _classCallCheck(this, PotentialMethod); this.name = cfg.name; this.methodNode = cfg.methodNode; this.fullNode = cfg.fullNode; this.commentNodes = cfg.commentNodes || []; this.parent = cfg.parent; this.kind = cfg.kind || 'method'; this["static"] = cfg["static"] || false; } /** * Sets the superClass node. * @param {Node} superClass */ _createClass(PotentialMethod, [{ key: "setSuperClass", value: function setSuperClass(superClass) { this.superClass = superClass; } /** * True when method body is empty. * @return {Boolean} */ }, { key: "isEmpty", value: function isEmpty() { return this.getBodyBlock().body.length === 0; } /** * Transforms the potential method to actual MethodDefinition node. * @return {MethodDefinition} */ }, { key: "toMethodDefinition", value: function toMethodDefinition() { return { type: 'MethodDefinition', key: { type: 'Identifier', name: this.name }, computed: false, value: { type: 'FunctionExpression', async: this.methodNode.async, params: this.methodNode.params, defaults: this.methodNode.defaults, body: this.getBody(), generator: false, expression: false }, kind: this.kind, "static": this["static"], comments: (0, _extractComments["default"])(this.commentNodes) }; } /** * Removes original prototype assignment node from AST. */ }, { key: "remove", value: function remove() { (0, _multiReplaceStatement["default"])({ parent: this.parent, node: this.fullNode, replacements: [] }); } // To be overridden in subclasses }, { key: "getBody", value: function getBody() { if (this.superClass) { return this.transformSuperCalls(this.getBodyBlock()); } else { return this.getBodyBlock(); } } }, { key: "getBodyBlock", value: function getBodyBlock() { if (this.methodNode.body.type === 'BlockStatement') { return this.methodNode.body; } else { return { type: 'BlockStatement', body: [{ type: 'ReturnStatement', argument: this.methodNode.body }] }; } } // Transforms method body by replacing // SuperClass.prototype.foo.call(this, ...args) --> super.foo(...args) }, { key: "transformSuperCalls", value: function transformSuperCalls(body) { var _this = this; return _traverser["default"].replace(body, { enter: function enter(node) { var m = _this.matchSuperCall(node); if (m) { node.expression.callee = { type: 'MemberExpression', computed: false, object: { type: 'Super' }, property: m.method }; node.expression.arguments = node.expression.arguments.slice(1); } } }); } }, { key: "matchSuperCall", value: function matchSuperCall(node) { var _this2 = this; return (0, _fMatches.matches)({ type: 'ExpressionStatement', expression: { type: 'CallExpression', callee: { type: 'MemberExpression', computed: false, object: { type: 'MemberExpression', computed: false, object: { type: 'MemberExpression', computed: false, object: function object(obj) { return (0, _isEqualAst["default"])(obj, _this2.superClass); }, property: { type: 'Identifier', name: 'prototype' } }, property: (0, _fMatches.extract)('method', { type: 'Identifier' }) }, property: { type: 'Identifier', name: 'call' } }, arguments: [{ type: 'ThisExpression' }] } }, node); } }]); return PotentialMethod; }(); exports["default"] = PotentialMethod; /***/ }), /***/ "./node_modules/lebab/lib/transform/class/extractComments.js": /*!*******************************************************************!*\ !*** ./node_modules/lebab/lib/transform/class/extractComments.js ***! \*******************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = extractComments; var _fp = __webpack_require__(/*! lodash/fp */ "./node_modules/lodash/fp.js"); /** * Extracts comments from an array of nodes. * @param {Object[]} nodes * @param {Object[]} extracted comments */ function extractComments(nodes) { return (0, _fp.flatMap)(function (n) { return n.comments || []; }, nodes); } /***/ }), /***/ "./node_modules/lebab/lib/transform/class/index.js": /*!*********************************************************!*\ !*** ./node_modules/lebab/lib/transform/class/index.js ***! \*********************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = _default; var _fp = __webpack_require__(/*! lodash/fp */ "./node_modules/lodash/fp.js"); var _traverser = _interopRequireDefault(__webpack_require__(/*! ../../traverser */ "./node_modules/lebab/lib/traverser.js")); var _PotentialClass = _interopRequireDefault(__webpack_require__(/*! ./PotentialClass */ "./node_modules/lebab/lib/transform/class/PotentialClass.js")); var _PotentialMethod = _interopRequireDefault(__webpack_require__(/*! ./PotentialMethod */ "./node_modules/lebab/lib/transform/class/PotentialMethod.js")); var _PotentialConstructor = _interopRequireDefault(__webpack_require__(/*! ./PotentialConstructor */ "./node_modules/lebab/lib/transform/class/PotentialConstructor.js")); var _matchFunctionDeclaration = _interopRequireDefault(__webpack_require__(/*! ./matchFunctionDeclaration */ "./node_modules/lebab/lib/transform/class/matchFunctionDeclaration.js")); var _matchFunctionVar = _interopRequireDefault(__webpack_require__(/*! ./matchFunctionVar */ "./node_modules/lebab/lib/transform/class/matchFunctionVar.js")); var _matchFunctionAssignment = _interopRequireDefault(__webpack_require__(/*! ./matchFunctionAssignment */ "./node_modules/lebab/lib/transform/class/matchFunctionAssignment.js")); var _matchPrototypeFunctionAssignment = _interopRequireDefault(__webpack_require__(/*! ./matchPrototypeFunctionAssignment */ "./node_modules/lebab/lib/transform/class/matchPrototypeFunctionAssignment.js")); var _matchPrototypeObjectAssignment = _interopRequireDefault(__webpack_require__(/*! ./matchPrototypeObjectAssignment */ "./node_modules/lebab/lib/transform/class/matchPrototypeObjectAssignment.js")); var _matchObjectDefinePropertyCall = _interopRequireWildcard(__webpack_require__(/*! ./matchObjectDefinePropertyCall */ "./node_modules/lebab/lib/transform/class/matchObjectDefinePropertyCall.js")); var _Inheritance = _interopRequireDefault(__webpack_require__(/*! ./inheritance/Inheritance */ "./node_modules/lebab/lib/transform/class/inheritance/Inheritance.js")); var _matchObjectDefinePropertiesCall = _interopRequireWildcard(__webpack_require__(/*! ./matchObjectDefinePropertiesCall.js */ "./node_modules/lebab/lib/transform/class/matchObjectDefinePropertiesCall.js")); function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _default(ast, logger) { var potentialClasses = {}; var inheritance = new _Inheritance["default"](); _traverser["default"].traverse(ast, { enter: function enter(node, parent) { var m; if (m = (0, _matchFunctionDeclaration["default"])(node) || (0, _matchFunctionVar["default"])(node)) { potentialClasses[m.className] = new _PotentialClass["default"]({ name: m.className, fullNode: node, commentNodes: [node], parent: parent }); potentialClasses[m.className].setConstructor(new _PotentialConstructor["default"]({ methodNode: m.constructorNode, potentialClass: potentialClasses[m.className] })); } else if (m = (0, _matchFunctionAssignment["default"])(node)) { if (potentialClasses[m.className]) { potentialClasses[m.className].addMethod(new _PotentialMethod["default"]({ name: m.methodName, methodNode: m.methodNode, fullNode: node, commentNodes: [node], parent: parent, "static": true })); } } else if (m = (0, _matchPrototypeFunctionAssignment["default"])(node)) { if (potentialClasses[m.className]) { potentialClasses[m.className].addMethod(new _PotentialMethod["default"]({ name: m.methodName, methodNode: m.methodNode, fullNode: node, commentNodes: [node], parent: parent })); } } else if (m = (0, _matchPrototypeObjectAssignment["default"])(node)) { if (potentialClasses[m.className]) { m.methods.forEach(function (method, i) { var assignmentComments = i === 0 ? [node] : []; potentialClasses[m.className].addMethod(new _PotentialMethod["default"]({ name: method.methodName, methodNode: method.methodNode, fullNode: node, commentNodes: assignmentComments.concat([method.propertyNode]), parent: parent, kind: classMethodKind(method.kind) })); }); } } else if (m = (0, _matchObjectDefinePropertyCall["default"])(node)) { if (potentialClasses[m.className]) { m.descriptors.forEach(function (desc, i) { var parentComments = i === 0 ? [node] : []; potentialClasses[m.className].addMethod(new _PotentialMethod["default"]({ name: m.methodName, methodNode: desc.methodNode, fullNode: node, commentNodes: parentComments.concat([desc.propertyNode]), parent: parent, kind: desc.kind, "static": m["static"] })); }); } } else if (m = (0, _matchObjectDefinePropertiesCall["default"])(node)) { // defineProperties allows mixing method definitions we CAN transform // with ones we CANT. This check looks for whether every property is // one we CAN transform and if they are it removes the whole call // to defineProperties var removeWholeNode = false; if (node.expression.arguments[1].properties.every(function (propertyNode) { var _matchDefinedProperti = (0, _matchObjectDefinePropertiesCall.matchDefinedProperties)(propertyNode), properties = _matchDefinedProperti.properties; return properties.some(_matchObjectDefinePropertyCall.isAccessorDescriptor); })) { removeWholeNode = true; } m.forEach(function (method, i) { if (potentialClasses[method.className]) { method.descriptors.forEach(function (desc, j) { var parentComments = j === 0 ? [method.methodNode] : []; // by default remove only the single method property of the object passed to defineProperties // otherwise if they should all be remove AND this is the last descriptor set it up // to remove the whole node that's calling defineProperties var lastDescriptor = i === m.length - 1 && j === method.descriptors.length - 1; var fullNode = lastDescriptor && removeWholeNode ? node : method.methodNode; var parentNode = lastDescriptor && removeWholeNode ? parent : node.expression.arguments[1]; potentialClasses[method.className].addMethod(new _PotentialMethod["default"]({ name: method.methodName, methodNode: desc.methodNode, fullNode: fullNode, commentNodes: parentComments.concat([desc.propertyNode]), parent: parentNode, kind: desc.kind, "static": method["static"] })); }); } }); } else if (m = inheritance.process(node, parent)) { if (potentialClasses[m.className]) { potentialClasses[m.className].setSuperClass(m.superClass, m.relatedExpressions); } } }, leave: function leave(node) { if (node.type === 'Program') { (0, _fp.values)(potentialClasses).filter(function (cls) { return cls.isTransformable() ? true : logWarning(cls); }).forEach(function (cls) { return cls.transform(); }); } } }); // Ordinary methods inside class use kind=method, // unlike methods inside object literal, which use kind=init. function classMethodKind(kind) { return kind === 'init' ? 'method' : kind; } function logWarning(cls) { if (/^[A-Z]/.test(cls.getName())) { logger.warn(cls.getFullNode(), "Function ".concat(cls.getName(), " looks like class, but has no prototype"), 'class'); } } } /***/ }), /***/ "./node_modules/lebab/lib/transform/class/inheritance/ImportUtilDetector.js": /*!**********************************************************************************!*\ !*** ./node_modules/lebab/lib/transform/class/inheritance/ImportUtilDetector.js ***! \**********************************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = void 0; var _fMatches = __webpack_require__(/*! f-matches */ "./node_modules/f-matches/index.js"); function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /** * Detects variable name imported from: import from "util" */ var ImportUtilDetector = /*#__PURE__*/function () { function ImportUtilDetector() { _classCallCheck(this, ImportUtilDetector); } _createClass(ImportUtilDetector, [{ key: "detect", value: /** * Detects: import from "util" * * @param {Object} node * @return {Object} MemberExpression of .inherits */ function detect(node) { var m = this.matchImportUtil(node); if (m) { return { type: 'MemberExpression', computed: false, object: { type: 'Identifier', name: m.name }, property: { type: 'Identifier', name: 'inherits' } }; } } // Matches: import from "util" }, { key: "matchImportUtil", value: function matchImportUtil(node) { return (0, _fMatches.matches)({ type: 'ImportDeclaration', specifiers: (0, _fMatches.matchesLength)([{ type: 'ImportDefaultSpecifier', local: { type: 'Identifier', name: (0, _fMatches.extractAny)('name') } }]), source: { type: 'Literal', value: 'util' } }, node); } }]); return ImportUtilDetector; }(); exports["default"] = ImportUtilDetector; /***/ }), /***/ "./node_modules/lebab/lib/transform/class/inheritance/Inheritance.js": /*!***************************************************************************!*\ !*** ./node_modules/lebab/lib/transform/class/inheritance/Inheritance.js ***! \***************************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = void 0; var _UtilInherits = _interopRequireDefault(__webpack_require__(/*! ./UtilInherits */ "./node_modules/lebab/lib/transform/class/inheritance/UtilInherits.js")); var _Prototypal = _interopRequireDefault(__webpack_require__(/*! ./Prototypal */ "./node_modules/lebab/lib/transform/class/inheritance/Prototypal.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /** * Processes nodes to detect super classes and return information for later * transformation. */ var Inheritance = /*#__PURE__*/function () { /** * @param {Object} cfg * @param {PotentialClass[]} cfg.potentialClasses Class name */ function Inheritance() { _classCallCheck(this, Inheritance); this.utilInherits = new _UtilInherits["default"](); this.prototypal = new _Prototypal["default"](); } /** * Process a node and return inheritance details if found. * @param {Object} node * @param {Object} parent * @returns {Object} * {String} className * {Node} superClass * {Object[]} relatedExpressions */ _createClass(Inheritance, [{ key: "process", value: function process(node, parent) { return this.utilInherits.process(node, parent) || this.prototypal.process(node, parent); } }]); return Inheritance; }(); exports["default"] = Inheritance; /***/ }), /***/ "./node_modules/lebab/lib/transform/class/inheritance/Prototypal.js": /*!**************************************************************************!*\ !*** ./node_modules/lebab/lib/transform/class/inheritance/Prototypal.js ***! \**************************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = void 0; var _fMatches = __webpack_require__(/*! f-matches */ "./node_modules/f-matches/index.js"); function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /** * Processes nodes to detect super classes and return information for later * transformation. * * Detects: * * Class1.prototype = Object.create(Class2.prototype); * * or: * * Class1.prototype = new Class2(); * * optionally followed by: * * Class1.prototype.constructor = Class1; */ var Prototypal = /*#__PURE__*/function () { function Prototypal() { _classCallCheck(this, Prototypal); this.foundSuperclasses = {}; } /** * Process a node and return inheritance details if found. * @param {Object} node * @param {Object} parent * @returns {Object/undefined} m * {String} m.className * {Node} m.superClass * {Object[]} m.relatedExpressions */ _createClass(Prototypal, [{ key: "process", value: function process(node, parent) { var m; if (m = this.matchNewAssignment(node) || this.matchObjectCreateAssignment(node)) { this.foundSuperclasses[m.className] = m.superClass; return { className: m.className, superClass: m.superClass, relatedExpressions: [{ node: node, parent: parent }] }; } else if (m = this.matchConstructorAssignment(node)) { var superClass = this.foundSuperclasses[m.className]; if (superClass && m.className === m.constructorClassName) { return { className: m.className, superClass: superClass, relatedExpressions: [{ node: node, parent: parent }] }; } } } // Matches: .prototype = new (); }, { key: "matchNewAssignment", value: function matchNewAssignment(node) { return (0, _fMatches.matches)({ type: 'ExpressionStatement', expression: { type: 'AssignmentExpression', left: { type: 'MemberExpression', object: { type: 'Identifier', name: (0, _fMatches.extractAny)('className') }, property: { type: 'Identifier', name: 'prototype' } }, right: { type: 'NewExpression', callee: (0, _fMatches.extractAny)('superClass') } } }, node); } // Matches: .prototype = Object.create(); }, { key: "matchObjectCreateAssignment", value: function matchObjectCreateAssignment(node) { return (0, _fMatches.matches)({ type: 'ExpressionStatement', expression: { type: 'AssignmentExpression', left: { type: 'MemberExpression', object: { type: 'Identifier', name: (0, _fMatches.extractAny)('className') }, property: { type: 'Identifier', name: 'prototype' } }, right: { type: 'CallExpression', callee: { type: 'MemberExpression', object: { type: 'Identifier', name: 'Object' }, property: { type: 'Identifier', name: 'create' } }, arguments: (0, _fMatches.matchesLength)([{ type: 'MemberExpression', object: (0, _fMatches.extractAny)('superClass'), property: { type: 'Identifier', name: 'prototype' } }]) } } }, node); } // Matches: .prototype.constructor = ; }, { key: "matchConstructorAssignment", value: function matchConstructorAssignment(node) { return (0, _fMatches.matches)({ type: 'ExpressionStatement', expression: { type: 'AssignmentExpression', left: { type: 'MemberExpression', object: { type: 'MemberExpression', object: { type: 'Identifier', name: (0, _fMatches.extractAny)('className') }, property: { type: 'Identifier', name: 'prototype' } }, property: { type: 'Identifier', name: 'constructor' } }, right: { type: 'Identifier', name: (0, _fMatches.extractAny)('constructorClassName') } } }, node); } }]); return Prototypal; }(); exports["default"] = Prototypal; /***/ }), /***/ "./node_modules/lebab/lib/transform/class/inheritance/RequireUtilDetector.js": /*!***********************************************************************************!*\ !*** ./node_modules/lebab/lib/transform/class/inheritance/RequireUtilDetector.js ***! \***********************************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = void 0; var _fp = __webpack_require__(/*! lodash/fp */ "./node_modules/lodash/fp.js"); var _fMatches = __webpack_require__(/*! f-matches */ "./node_modules/f-matches/index.js"); function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /** * Detects variable name imported from require("util") */ var RequireUtilDetector = /*#__PURE__*/function () { function RequireUtilDetector() { _classCallCheck(this, RequireUtilDetector); } _createClass(RequireUtilDetector, [{ key: "detect", value: /** * Detects: var = require("util") * * @param {Object} node * @return {Object} MemberExpression of .inherits */ function detect(node) { var _this = this; if (node.type !== 'VariableDeclaration') { return; } var declaration = (0, _fp.find)(function (dec) { return _this.isRequireUtil(dec); }, node.declarations); if (declaration) { return { type: 'MemberExpression', computed: false, object: { type: 'Identifier', name: declaration.id.name }, property: { type: 'Identifier', name: 'inherits' } }; } } // Matches: = require("util") }, { key: "isRequireUtil", value: function isRequireUtil(dec) { return (0, _fMatches.matches)({ type: 'VariableDeclarator', id: { type: 'Identifier' }, init: { type: 'CallExpression', callee: { type: 'Identifier', name: 'require' }, arguments: (0, _fMatches.matchesLength)([{ type: 'Literal', value: 'util' }]) } }, dec); } }]); return RequireUtilDetector; }(); exports["default"] = RequireUtilDetector; /***/ }), /***/ "./node_modules/lebab/lib/transform/class/inheritance/RequireUtilInheritsDetector.js": /*!*******************************************************************************************!*\ !*** ./node_modules/lebab/lib/transform/class/inheritance/RequireUtilInheritsDetector.js ***! \*******************************************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = void 0; var _fp = __webpack_require__(/*! lodash/fp */ "./node_modules/lodash/fp.js"); var _fMatches = __webpack_require__(/*! f-matches */ "./node_modules/f-matches/index.js"); function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /** * Detects variable name imported from require("util").inherits */ var RequireUtilInheritsDetector = /*#__PURE__*/function () { function RequireUtilInheritsDetector() { _classCallCheck(this, RequireUtilInheritsDetector); } _createClass(RequireUtilInheritsDetector, [{ key: "detect", value: /** * Detects: var = require("util").inherits * * @param {Object} node * @return {Object} Identifier */ function detect(node) { var _this = this; if (node.type !== 'VariableDeclaration') { return; } var declaration = (0, _fp.find)(function (dec) { return _this.isRequireUtilInherits(dec); }, node.declarations); if (declaration) { return { type: 'Identifier', name: declaration.id.name }; } } // Matches: = require("util").inherits }, { key: "isRequireUtilInherits", value: function isRequireUtilInherits(dec) { return (0, _fMatches.matches)({ type: 'VariableDeclarator', id: { type: 'Identifier' }, init: { type: 'MemberExpression', computed: false, object: { type: 'CallExpression', callee: { type: 'Identifier', name: 'require' }, arguments: (0, _fMatches.matchesLength)([{ type: 'Literal', value: 'util' }]) }, property: { type: 'Identifier', name: 'inherits' } } }, dec); } }]); return RequireUtilInheritsDetector; }(); exports["default"] = RequireUtilInheritsDetector; /***/ }), /***/ "./node_modules/lebab/lib/transform/class/inheritance/UtilInherits.js": /*!****************************************************************************!*\ !*** ./node_modules/lebab/lib/transform/class/inheritance/UtilInherits.js ***! \****************************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = void 0; var _fMatches = __webpack_require__(/*! f-matches */ "./node_modules/f-matches/index.js"); var _RequireUtilDetector = _interopRequireDefault(__webpack_require__(/*! ./RequireUtilDetector */ "./node_modules/lebab/lib/transform/class/inheritance/RequireUtilDetector.js")); var _RequireUtilInheritsDetector = _interopRequireDefault(__webpack_require__(/*! ./RequireUtilInheritsDetector */ "./node_modules/lebab/lib/transform/class/inheritance/RequireUtilInheritsDetector.js")); var _ImportUtilDetector = _interopRequireDefault(__webpack_require__(/*! ./ImportUtilDetector */ "./node_modules/lebab/lib/transform/class/inheritance/ImportUtilDetector.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /** * Processes nodes to detect super classes and return information for later * transformation. * * Detects: * * var util = require('util'); * ... * util.inherits(Class1, Class2); */ var UtilInherits = /*#__PURE__*/function () { function UtilInherits() { _classCallCheck(this, UtilInherits); this.inheritsNode = undefined; this.detectors = [new _RequireUtilDetector["default"](), new _RequireUtilInheritsDetector["default"](), new _ImportUtilDetector["default"]()]; } /** * Process a node and return inheritance details if found. * @param {Object} node * @param {Object} parent * @returns {Object/undefined} m * {String} m.className * {Node} m.superClass * {Object[]} m.relatedExpressions */ _createClass(UtilInherits, [{ key: "process", value: function process(node, parent) { var m; if (parent && parent.type === 'Program' && (m = this.detectInheritsNode(node))) { this.inheritsNode = m; } else if (this.inheritsNode && (m = this.matchUtilInherits(node))) { return { className: m.className, superClass: m.superClass, relatedExpressions: [{ node: node, parent: parent }] }; } } }, { key: "detectInheritsNode", value: function detectInheritsNode(node) { var _iterator = _createForOfIteratorHelper(this.detectors), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var detector = _step.value; var inheritsNode = void 0; if (inheritsNode = detector.detect(node)) { return inheritsNode; } } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } } // Discover usage of this.inheritsNode // // Matches: (, ); }, { key: "matchUtilInherits", value: function matchUtilInherits(node) { return (0, _fMatches.matches)({ type: 'ExpressionStatement', expression: { type: 'CallExpression', callee: this.inheritsNode, arguments: [{ type: 'Identifier', name: (0, _fMatches.extractAny)('className') }, (0, _fMatches.extractAny)('superClass')] } }, node); } }]); return UtilInherits; }(); exports["default"] = UtilInherits; /***/ }), /***/ "./node_modules/lebab/lib/transform/class/isFunctionProperty.js": /*!**********************************************************************!*\ !*** ./node_modules/lebab/lib/transform/class/isFunctionProperty.js ***! \**********************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = void 0; var _fMatches = __webpack_require__(/*! f-matches */ "./node_modules/f-matches/index.js"); var _isTransformableToMethod = _interopRequireDefault(__webpack_require__(/*! ./isTransformableToMethod */ "./node_modules/lebab/lib/transform/class/isTransformableToMethod.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } /** * Matches: : function() { ... } * * @param {Object} node * @return {Boolean} */ var _default = (0, _fMatches.matches)({ type: 'Property', key: { type: 'Identifier' // name: }, computed: false, value: _isTransformableToMethod["default"] }); exports["default"] = _default; /***/ }), /***/ "./node_modules/lebab/lib/transform/class/isTransformableToMethod.js": /*!***************************************************************************!*\ !*** ./node_modules/lebab/lib/transform/class/isTransformableToMethod.js ***! \***************************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = isTransformableToMethod; var _traverser = _interopRequireDefault(__webpack_require__(/*! ../../traverser */ "./node_modules/lebab/lib/traverser.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } /** * Detects if function can be transformed to class method * @param {Object} node * @return {Boolean} */ function isTransformableToMethod(node) { if (node.type === 'FunctionExpression') { return true; } if (node.type === 'ArrowFunctionExpression' && !usesThis(node)) { return true; } } function usesThis(ast) { return _traverser["default"].find(ast, 'ThisExpression', { skipTypes: ['FunctionExpression', 'FunctionDeclaration'] }); } /***/ }), /***/ "./node_modules/lebab/lib/transform/class/matchFunctionAssignment.js": /*!***************************************************************************!*\ !*** ./node_modules/lebab/lib/transform/class/matchFunctionAssignment.js ***! \***************************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = void 0; var _fMatches = __webpack_require__(/*! f-matches */ "./node_modules/f-matches/index.js"); /** * Matches: . = function () { ... } * * When node matches returns the extracted fields: * * - className * - methodName * - methodNode * * @param {Object} node * @return {Object} */ var _default = (0, _fMatches.matches)({ type: 'ExpressionStatement', expression: { type: 'AssignmentExpression', left: { type: 'MemberExpression', computed: false, object: { type: 'Identifier', name: (0, _fMatches.extractAny)('className') }, property: { type: 'Identifier', name: (0, _fMatches.extractAny)('methodName') } }, operator: '=', right: (0, _fMatches.extract)('methodNode', { type: 'FunctionExpression' }) } }); exports["default"] = _default; /***/ }), /***/ "./node_modules/lebab/lib/transform/class/matchFunctionDeclaration.js": /*!****************************************************************************!*\ !*** ./node_modules/lebab/lib/transform/class/matchFunctionDeclaration.js ***! \****************************************************************************/ /***/ ((__unused_webpack_module, exports) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = _default; /** * Matches: function () { ... } * * When node matches returns the extracted fields: * * - className * - constructorNode * * @param {Object} node * @return {Object} */ function _default(node) { if (node.type === 'FunctionDeclaration' && node.id) { return { className: node.id.name, constructorNode: node }; } } /***/ }), /***/ "./node_modules/lebab/lib/transform/class/matchFunctionVar.js": /*!********************************************************************!*\ !*** ./node_modules/lebab/lib/transform/class/matchFunctionVar.js ***! \********************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = _default; var _fMatches = __webpack_require__(/*! f-matches */ "./node_modules/f-matches/index.js"); function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } var isFunctionExpression = (0, _fMatches.matches)({ type: 'FunctionExpression' }); var isFunctionVariableDeclaration = (0, _fMatches.matches)({ type: 'VariableDeclaration', declarations: function declarations(decs) { return decs.length === 1 && isFunctionExpression(decs[0].init); } }); /** * Matches: var = function () { ... } * * When node matches returns the extracted fields: * * - className * - constructorNode * * @param {Object} node * @return {Object} */ function _default(node) { if (isFunctionVariableDeclaration(node)) { var _node$declarations = _slicedToArray(node.declarations, 1), _node$declarations$ = _node$declarations[0], className = _node$declarations$.id.name, constructorNode = _node$declarations$.init; return { className: className, constructorNode: constructorNode }; } } /***/ }), /***/ "./node_modules/lebab/lib/transform/class/matchObjectDefinePropertiesCall.js": /*!***********************************************************************************!*\ !*** ./node_modules/lebab/lib/transform/class/matchObjectDefinePropertiesCall.js ***! \***********************************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = _default; exports.matchDefinedProperties = void 0; var _fMatches = __webpack_require__(/*! f-matches */ "./node_modules/f-matches/index.js"); var _matchObjectDefinePropertyCall = __webpack_require__(/*! ./matchObjectDefinePropertyCall.js */ "./node_modules/lebab/lib/transform/class/matchObjectDefinePropertyCall.js"); var matchObjectDefinePropertiesCallOnPrototype = (0, _fMatches.matches)({ type: 'ExpressionStatement', expression: { type: 'CallExpression', callee: { type: 'MemberExpression', computed: false, object: { type: 'Identifier', name: 'Object' }, property: { type: 'Identifier', name: 'defineProperties' } }, arguments: [{ type: 'MemberExpression', computed: false, object: { type: 'Identifier', name: (0, _fMatches.extractAny)('className') }, property: { type: 'Identifier', name: 'prototype' } }, { type: 'ObjectExpression', properties: (0, _fMatches.extractAny)('methods') }] } }); var matchObjectDefinePropertiesCall = (0, _fMatches.matches)({ type: 'ExpressionStatement', expression: { type: 'CallExpression', callee: { type: 'MemberExpression', computed: false, object: { type: 'Identifier', name: 'Object' }, property: { type: 'Identifier', name: 'defineProperties' } }, arguments: [{ type: 'Identifier', name: (0, _fMatches.extractAny)('className') }, { type: 'ObjectExpression', properties: (0, _fMatches.extractAny)('methods') }] } }); var matchDefinedProperties = (0, _fMatches.matches)({ type: 'Property', key: { type: 'Identifier', name: (0, _fMatches.extractAny)('methodName') }, computed: false, value: { type: 'ObjectExpression', properties: (0, _fMatches.extractAny)('properties') } }); /** * Matches: Object.defineProperties(.prototype, { * : { * : , * } * ... * }) * * When node matches returns an array of objects with the extracted fields for each method: * * [{ * - className * - methodName * - descriptors: * - propertyNode * - methodNode * - kind * }] * * @param {Object} node * @return {Object[] | undefined} */ exports.matchDefinedProperties = matchDefinedProperties; function _default(node) { var _matchObjectDefinePro = matchObjectDefinePropertiesCallOnPrototype(node), className = _matchObjectDefinePro.className, methods = _matchObjectDefinePro.methods; var isStatic = false; if (!className) { var _matchObjectDefinePro2 = matchObjectDefinePropertiesCall(node); className = _matchObjectDefinePro2.className; methods = _matchObjectDefinePro2.methods; isStatic = true; } if (className) { return methods.map(function (methodNode) { var _matchDefinedProperti = matchDefinedProperties(methodNode), methodName = _matchDefinedProperti.methodName, properties = _matchDefinedProperti.properties; return { className: className, methodName: methodName, methodNode: methodNode, descriptors: properties.filter(_matchObjectDefinePropertyCall.isAccessorDescriptor).map(function (prop) { return { propertyNode: prop, methodNode: prop.value, kind: prop.key.name }; }), "static": isStatic }; }); } } /***/ }), /***/ "./node_modules/lebab/lib/transform/class/matchObjectDefinePropertyCall.js": /*!*********************************************************************************!*\ !*** ./node_modules/lebab/lib/transform/class/matchObjectDefinePropertyCall.js ***! \*********************************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = _default; exports.isAccessorDescriptor = isAccessorDescriptor; var _fMatches = __webpack_require__(/*! f-matches */ "./node_modules/f-matches/index.js"); var _isFunctionProperty = _interopRequireDefault(__webpack_require__(/*! ./isFunctionProperty */ "./node_modules/lebab/lib/transform/class/isFunctionProperty.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } var matchObjectDefinePropertyCallOnPrototype = (0, _fMatches.matches)({ type: 'ExpressionStatement', expression: { type: 'CallExpression', callee: { type: 'MemberExpression', computed: false, object: { type: 'Identifier', name: 'Object' }, property: { type: 'Identifier', name: 'defineProperty' } }, arguments: [{ type: 'MemberExpression', computed: false, object: { type: 'Identifier', name: (0, _fMatches.extractAny)('className') }, property: { type: 'Identifier', name: 'prototype' } }, { type: 'Literal', value: (0, _fMatches.extractAny)('methodName') }, { type: 'ObjectExpression', properties: (0, _fMatches.extractAny)('properties') }] } }); var matchObjectDefinePropertyCall = (0, _fMatches.matches)({ type: 'ExpressionStatement', expression: { type: 'CallExpression', callee: { type: 'MemberExpression', computed: false, object: { type: 'Identifier', name: 'Object' }, property: { type: 'Identifier', name: 'defineProperty' } }, arguments: [{ type: 'Identifier', name: (0, _fMatches.extractAny)('className') }, { type: 'Literal', value: (0, _fMatches.extractAny)('methodName') }, { type: 'ObjectExpression', properties: (0, _fMatches.extractAny)('properties') }] } }); function isAccessorDescriptor(node) { return (0, _isFunctionProperty["default"])(node) && (node.key.name === 'get' || node.key.name === 'set'); } /** * Matches: Object.defineProperty(.prototype, "", { * : , * ... * }) * * When node matches returns the extracted fields: * * - className * - methodName * - descriptors: * - propertyNode * - methodNode * - kind * * @param {Object} node * @return {Object} */ function _default(node) { var _matchObjectDefinePro = matchObjectDefinePropertyCallOnPrototype(node), className = _matchObjectDefinePro.className, methodName = _matchObjectDefinePro.methodName, properties = _matchObjectDefinePro.properties; var isStatic = false; if (!className) { var _matchObjectDefinePro2 = matchObjectDefinePropertyCall(node); className = _matchObjectDefinePro2.className; methodName = _matchObjectDefinePro2.methodName; properties = _matchObjectDefinePro2.properties; isStatic = true; } if (className) { return { className: className, methodName: methodName, descriptors: properties.filter(isAccessorDescriptor).map(function (prop) { return { propertyNode: prop, methodNode: prop.value, kind: prop.key.name }; }), "static": isStatic }; } } /***/ }), /***/ "./node_modules/lebab/lib/transform/class/matchPrototypeFunctionAssignment.js": /*!************************************************************************************!*\ !*** ./node_modules/lebab/lib/transform/class/matchPrototypeFunctionAssignment.js ***! \************************************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = void 0; var _fMatches = __webpack_require__(/*! f-matches */ "./node_modules/f-matches/index.js"); var _isTransformableToMethod = _interopRequireDefault(__webpack_require__(/*! ./isTransformableToMethod */ "./node_modules/lebab/lib/transform/class/isTransformableToMethod.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } /** * Matches: .prototype. = function () { ... } * * When node matches returns the extracted fields: * * - className * - methodName * - methodNode * * @param {Object} node * @return {Object} */ var _default = (0, _fMatches.matches)({ type: 'ExpressionStatement', expression: { type: 'AssignmentExpression', left: { type: 'MemberExpression', computed: false, object: { type: 'MemberExpression', computed: false, object: { type: 'Identifier', name: (0, _fMatches.extractAny)('className') }, property: { type: 'Identifier', name: 'prototype' } }, property: { type: 'Identifier', name: (0, _fMatches.extractAny)('methodName') } }, operator: '=', right: (0, _fMatches.extract)('methodNode', _isTransformableToMethod["default"]) } }); exports["default"] = _default; /***/ }), /***/ "./node_modules/lebab/lib/transform/class/matchPrototypeObjectAssignment.js": /*!**********************************************************************************!*\ !*** ./node_modules/lebab/lib/transform/class/matchPrototypeObjectAssignment.js ***! \**********************************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = _default; var _fMatches = __webpack_require__(/*! f-matches */ "./node_modules/f-matches/index.js"); var _isFunctionProperty = _interopRequireDefault(__webpack_require__(/*! ./isFunctionProperty */ "./node_modules/lebab/lib/transform/class/isFunctionProperty.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } var matchPrototypeObjectAssignment = (0, _fMatches.matches)({ type: 'ExpressionStatement', expression: { type: 'AssignmentExpression', left: { type: 'MemberExpression', computed: false, object: { type: 'Identifier', name: (0, _fMatches.extractAny)('className') }, property: { type: 'Identifier', name: 'prototype' } }, operator: '=', right: { type: 'ObjectExpression', properties: (0, _fMatches.extract)('properties', function (props) { return props.every(_isFunctionProperty["default"]); }) } } }); /** * Matches: .prototype = { * : , * ... * }; * * When node matches returns the extracted fields: * * - className * - methods * - propertyNode * - methodName * - methodNode * - kind * * @param {Object} node * @return {Object} */ function _default(node) { var _matchPrototypeObject = matchPrototypeObjectAssignment(node), className = _matchPrototypeObject.className, properties = _matchPrototypeObject.properties; if (className) { return { className: className, methods: properties.map(function (prop) { return { propertyNode: prop, methodName: prop.key.name, methodNode: prop.value, kind: prop.kind }; }) }; } } /***/ }), /***/ "./node_modules/lebab/lib/transform/commonjs/exportCommonjs.js": /*!*********************************************************************!*\ !*** ./node_modules/lebab/lib/transform/commonjs/exportCommonjs.js ***! \*********************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = _default; var _traverser = _interopRequireDefault(__webpack_require__(/*! ../../traverser */ "./node_modules/lebab/lib/traverser.js")); var _matchDefaultExport = _interopRequireDefault(__webpack_require__(/*! ./matchDefaultExport */ "./node_modules/lebab/lib/transform/commonjs/matchDefaultExport.js")); var _matchNamedExport = _interopRequireDefault(__webpack_require__(/*! ./matchNamedExport */ "./node_modules/lebab/lib/transform/commonjs/matchNamedExport.js")); var _functionType = __webpack_require__(/*! ../../utils/functionType */ "./node_modules/lebab/lib/utils/functionType.js"); var _ExportNamedDeclaration = _interopRequireDefault(__webpack_require__(/*! ../../syntax/ExportNamedDeclaration */ "./node_modules/lebab/lib/syntax/ExportNamedDeclaration.js")); var _VariableDeclaration = _interopRequireDefault(__webpack_require__(/*! ../../syntax/VariableDeclaration */ "./node_modules/lebab/lib/syntax/VariableDeclaration.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _default(ast, logger) { _traverser["default"].replace(ast, { enter: function enter(node, parent) { var m; if (m = (0, _matchDefaultExport["default"])(node)) { if (parent.type !== 'Program') { logger.warn(node, 'export can only be at root level', 'commonjs'); return; } return exportDefault(m, node.comments); } else if (m = (0, _matchNamedExport["default"])(node)) { if (parent.type !== 'Program') { logger.warn(node, 'export can only be at root level', 'commonjs'); return; } return exportNamed(m, node.comments); } } }); } function exportDefault(_ref, comments) { var value = _ref.value; return { type: 'ExportDefaultDeclaration', declaration: value, comments: comments }; } function exportNamed(_ref2, comments) { var id = _ref2.id, value = _ref2.value; if ((0, _functionType.isFunctionExpression)(value)) { // Exclude functions with different name than the assigned property name if (compatibleIdentifiers(id, value.id)) { return new _ExportNamedDeclaration["default"]({ declaration: functionExpressionToDeclaration(value, id), comments: comments }); } } else if (value.type === 'ClassExpression') { // Exclude classes with different name than the assigned property name if (compatibleIdentifiers(id, value.id)) { return new _ExportNamedDeclaration["default"]({ declaration: classExpressionToDeclaration(value, id), comments: comments }); } } else if (value.type === 'Identifier') { return new _ExportNamedDeclaration["default"]({ specifiers: [{ type: 'ExportSpecifier', exported: id, local: value }], comments: comments }); } else { return new _ExportNamedDeclaration["default"]({ declaration: new _VariableDeclaration["default"]('var', [{ type: 'VariableDeclarator', id: id, init: value }]), comments: comments }); } } // True when one of the identifiers is null or their names are equal. function compatibleIdentifiers(id1, id2) { return !id1 || !id2 || id1.name === id2.name; } function functionExpressionToDeclaration(func, id) { func.type = 'FunctionDeclaration'; func.id = id; // Transform to { return ; } if (func.body.type !== 'BlockStatement') { func.body = { type: 'BlockStatement', body: [{ type: 'ReturnStatement', argument: func.body }] }; } return func; } function classExpressionToDeclaration(cls, id) { cls.type = 'ClassDeclaration'; cls.id = id; return cls; } /***/ }), /***/ "./node_modules/lebab/lib/transform/commonjs/importCommonjs.js": /*!*********************************************************************!*\ !*** ./node_modules/lebab/lib/transform/commonjs/importCommonjs.js ***! \*********************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = _default; var _traverser = _interopRequireDefault(__webpack_require__(/*! ../../traverser */ "./node_modules/lebab/lib/traverser.js")); var _isVarWithRequireCalls = _interopRequireDefault(__webpack_require__(/*! ./isVarWithRequireCalls */ "./node_modules/lebab/lib/transform/commonjs/isVarWithRequireCalls.js")); var _matchRequire = __webpack_require__(/*! ./matchRequire */ "./node_modules/lebab/lib/transform/commonjs/matchRequire.js"); var _multiReplaceStatement = _interopRequireDefault(__webpack_require__(/*! ../../utils/multiReplaceStatement */ "./node_modules/lebab/lib/utils/multiReplaceStatement.js")); var _ImportDeclaration = _interopRequireDefault(__webpack_require__(/*! ../../syntax/ImportDeclaration */ "./node_modules/lebab/lib/syntax/ImportDeclaration.js")); var _ImportSpecifier = _interopRequireDefault(__webpack_require__(/*! ../../syntax/ImportSpecifier */ "./node_modules/lebab/lib/syntax/ImportSpecifier.js")); var _ImportDefaultSpecifier = _interopRequireDefault(__webpack_require__(/*! ../../syntax/ImportDefaultSpecifier */ "./node_modules/lebab/lib/syntax/ImportDefaultSpecifier.js")); var _VariableDeclaration = _interopRequireDefault(__webpack_require__(/*! ../../syntax/VariableDeclaration */ "./node_modules/lebab/lib/syntax/VariableDeclaration.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _default(ast, logger) { _traverser["default"].replace(ast, { enter: function enter(node, parent) { if ((0, _isVarWithRequireCalls["default"])(node)) { if (parent.type !== 'Program') { logger.warn(node, 'import can only be at root level', 'commonjs'); return; } (0, _multiReplaceStatement["default"])({ parent: parent, node: node, replacements: node.declarations.map(function (dec) { return varToImport(dec, node.kind); }), preserveComments: true }); } } }); } // Converts VariableDeclarator to ImportDeclaration when we recognize it // as such, otherwise converts it to full VariableDeclaration (of original kind). function varToImport(dec, kind) { var m; if (m = (0, _matchRequire.matchRequire)(dec)) { if (m.id.type === 'ObjectPattern') { return patternToNamedImport(m); } else if (m.id.type === 'Identifier') { return identifierToDefaultImport(m); } } else if (m = (0, _matchRequire.matchRequireWithProperty)(dec)) { if (m.property.name === 'default') { return identifierToDefaultImport(m); } return propertyToNamedImport(m); } else { return new _VariableDeclaration["default"](kind, [dec]); } } function patternToNamedImport(_ref) { var id = _ref.id, sources = _ref.sources; return new _ImportDeclaration["default"]({ specifiers: id.properties.map(function (_ref2) { var key = _ref2.key, value = _ref2.value; return createImportSpecifier({ local: value, imported: key }); }), source: sources[0] }); } function identifierToDefaultImport(_ref3) { var id = _ref3.id, sources = _ref3.sources; return new _ImportDeclaration["default"]({ specifiers: [new _ImportDefaultSpecifier["default"](id)], source: sources[0] }); } function propertyToNamedImport(_ref4) { var id = _ref4.id, property = _ref4.property, sources = _ref4.sources; return new _ImportDeclaration["default"]({ specifiers: [createImportSpecifier({ local: id, imported: property })], source: sources[0] }); } function createImportSpecifier(_ref5) { var local = _ref5.local, imported = _ref5.imported; if (imported.name === 'default') { return new _ImportDefaultSpecifier["default"](local); } return new _ImportSpecifier["default"]({ local: local, imported: imported }); } /***/ }), /***/ "./node_modules/lebab/lib/transform/commonjs/index.js": /*!************************************************************!*\ !*** ./node_modules/lebab/lib/transform/commonjs/index.js ***! \************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = _default; var _importCommonjs = _interopRequireDefault(__webpack_require__(/*! ./importCommonjs */ "./node_modules/lebab/lib/transform/commonjs/importCommonjs.js")); var _exportCommonjs = _interopRequireDefault(__webpack_require__(/*! ./exportCommonjs */ "./node_modules/lebab/lib/transform/commonjs/exportCommonjs.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _default(ast, logger) { (0, _importCommonjs["default"])(ast, logger); (0, _exportCommonjs["default"])(ast, logger); } /***/ }), /***/ "./node_modules/lebab/lib/transform/commonjs/isExports.js": /*!****************************************************************!*\ !*** ./node_modules/lebab/lib/transform/commonjs/isExports.js ***! \****************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = void 0; var _fMatches = __webpack_require__(/*! f-matches */ "./node_modules/f-matches/index.js"); /** * Matches just identifier `exports` * @param {Object} node * @return {Boolean} */ var _default = (0, _fMatches.matches)({ type: 'Identifier', name: 'exports' }); exports["default"] = _default; /***/ }), /***/ "./node_modules/lebab/lib/transform/commonjs/isModuleExports.js": /*!**********************************************************************!*\ !*** ./node_modules/lebab/lib/transform/commonjs/isModuleExports.js ***! \**********************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = void 0; var _fMatches = __webpack_require__(/*! f-matches */ "./node_modules/f-matches/index.js"); var _isExports = _interopRequireDefault(__webpack_require__(/*! ./isExports */ "./node_modules/lebab/lib/transform/commonjs/isExports.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } /** * Matches: module.exports * @param {Object} node * @return {Boolean} */ var _default = (0, _fMatches.matches)({ type: 'MemberExpression', computed: false, object: { type: 'Identifier', name: 'module' }, property: _isExports["default"] }); exports["default"] = _default; /***/ }), /***/ "./node_modules/lebab/lib/transform/commonjs/isVarWithRequireCalls.js": /*!****************************************************************************!*\ !*** ./node_modules/lebab/lib/transform/commonjs/isVarWithRequireCalls.js ***! \****************************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = isVarWithRequireCalls; var _matchRequire = __webpack_require__(/*! ./matchRequire */ "./node_modules/lebab/lib/transform/commonjs/matchRequire.js"); /** * Matches: var = require(); * var = require().; */ function isVarWithRequireCalls(node) { return node.type === 'VariableDeclaration' && node.declarations.some(function (dec) { return (0, _matchRequire.matchRequire)(dec) || (0, _matchRequire.matchRequireWithProperty)(dec); }); } /***/ }), /***/ "./node_modules/lebab/lib/transform/commonjs/matchDefaultExport.js": /*!*************************************************************************!*\ !*** ./node_modules/lebab/lib/transform/commonjs/matchDefaultExport.js ***! \*************************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = void 0; var _fMatches = __webpack_require__(/*! f-matches */ "./node_modules/f-matches/index.js"); var _isModuleExports = _interopRequireDefault(__webpack_require__(/*! ./isModuleExports */ "./node_modules/lebab/lib/transform/commonjs/isModuleExports.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } /** * Matches: module.exports = * * When match found, return object with: * * - value * * @param {Object} node * @return {Object|Boolean} */ var _default = (0, _fMatches.matches)({ type: 'ExpressionStatement', expression: { type: 'AssignmentExpression', operator: '=', left: _isModuleExports["default"], right: (0, _fMatches.extractAny)('value') } }); exports["default"] = _default; /***/ }), /***/ "./node_modules/lebab/lib/transform/commonjs/matchNamedExport.js": /*!***********************************************************************!*\ !*** ./node_modules/lebab/lib/transform/commonjs/matchNamedExport.js ***! \***********************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = void 0; var _fMatches = __webpack_require__(/*! f-matches */ "./node_modules/f-matches/index.js"); var _isExports = _interopRequireDefault(__webpack_require__(/*! ./isExports */ "./node_modules/lebab/lib/transform/commonjs/isExports.js")); var _isModuleExports = _interopRequireDefault(__webpack_require__(/*! ./isModuleExports */ "./node_modules/lebab/lib/transform/commonjs/isModuleExports.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } /** * Matches: exports. = * Matches: module.exports. = * * When match found, returns object with: * * - id * - value * * @param {[type]} node [description] * @return {[type]} [description] */ var _default = (0, _fMatches.matches)({ type: 'ExpressionStatement', expression: { type: 'AssignmentExpression', operator: '=', left: { type: 'MemberExpression', computed: false, object: function object(ast) { return (0, _isExports["default"])(ast) || (0, _isModuleExports["default"])(ast); }, property: (0, _fMatches.extract)('id', { type: 'Identifier' }) }, right: (0, _fMatches.extractAny)('value') } }); exports["default"] = _default; /***/ }), /***/ "./node_modules/lebab/lib/transform/commonjs/matchRequire.js": /*!*******************************************************************!*\ !*** ./node_modules/lebab/lib/transform/commonjs/matchRequire.js ***! \*******************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.matchRequireWithProperty = exports.matchRequire = void 0; var _isString = _interopRequireDefault(__webpack_require__(/*! ../../utils/isString */ "./node_modules/lebab/lib/utils/isString.js")); var _fMatches = __webpack_require__(/*! f-matches */ "./node_modules/f-matches/index.js"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } var isIdentifier = (0, _fMatches.matches)({ type: 'Identifier' }); // matches Property with Identifier key and value (possibly shorthand) var isSimpleProperty = (0, _fMatches.matches)({ type: 'Property', key: isIdentifier, computed: false, value: isIdentifier }); // matches: {a, b: myB, c, ...} var isObjectPattern = (0, _fMatches.matches)({ type: 'ObjectPattern', properties: function properties(props) { return props.every(isSimpleProperty); } }); // matches: require() var matchRequireCall = (0, _fMatches.matches)({ type: 'CallExpression', callee: { type: 'Identifier', name: 'require' }, arguments: (0, _fMatches.extract)('sources', function (args) { return args.length === 1 && (0, _isString["default"])(args[0]); }) }); /** * Matches: = require(); */ var matchRequire = (0, _fMatches.matches)({ type: 'VariableDeclarator', id: (0, _fMatches.extract)('id', function (id) { return isIdentifier(id) || isObjectPattern(id); }), init: matchRequireCall }); /** * Matches: = require().; */ exports.matchRequire = matchRequire; var matchRequireWithProperty = (0, _fMatches.matches)({ type: 'VariableDeclarator', id: (0, _fMatches.extract)('id', isIdentifier), init: { type: 'MemberExpression', computed: false, object: matchRequireCall, property: (0, _fMatches.extract)('property', { type: 'Identifier' }) } }); exports.matchRequireWithProperty = matchRequireWithProperty; /***/ }), /***/ "./node_modules/lebab/lib/transform/defaultParam/index.js": /*!****************************************************************!*\ !*** ./node_modules/lebab/lib/transform/defaultParam/index.js ***! \****************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = _default; var _fMatches = __webpack_require__(/*! f-matches */ "./node_modules/f-matches/index.js"); var _fp = __webpack_require__(/*! lodash/fp */ "./node_modules/lodash/fp.js"); var _destructuring = __webpack_require__(/*! ../../utils/destructuring */ "./node_modules/lebab/lib/utils/destructuring.js"); var _traverser = _interopRequireDefault(__webpack_require__(/*! ../../traverser */ "./node_modules/lebab/lib/traverser.js")); var _multiReplaceStatement = _interopRequireDefault(__webpack_require__(/*! ../../utils/multiReplaceStatement */ "./node_modules/lebab/lib/utils/multiReplaceStatement.js")); var _functionType = __webpack_require__(/*! ../../utils/functionType */ "./node_modules/lebab/lib/utils/functionType.js"); var _matchOrAssignment = _interopRequireDefault(__webpack_require__(/*! ./matchOrAssignment */ "./node_modules/lebab/lib/transform/defaultParam/matchOrAssignment.js")); var _matchTernaryAssignment = _interopRequireDefault(__webpack_require__(/*! ./matchTernaryAssignment */ "./node_modules/lebab/lib/transform/defaultParam/matchTernaryAssignment.js")); var _matchIfUndefinedAssignment = _interopRequireDefault(__webpack_require__(/*! ./matchIfUndefinedAssignment */ "./node_modules/lebab/lib/transform/defaultParam/matchIfUndefinedAssignment.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } function _default(ast) { _traverser["default"].replace(ast, { enter: function enter(node) { if ((0, _functionType.isFunction)(node) && node.body.type === 'BlockStatement') { transformDefaultParams(node); } } }); } function transformDefaultParams(fn) { var detectedDefaults = findDefaults(fn.body.body); fn.params = fn.params.map(function (param, i) { // Ignore params that use destructuring or already have a default if (param.type !== 'Identifier') { return param; } var detected = detectedDefaults[param.name]; // Transform when default value detected // and default does not contain this or any of the remaining parameters if (detected && !containsParams(detected.value, remainingParams(fn, i))) { (0, _multiReplaceStatement["default"])({ parent: fn.body, node: detected.node, replacements: [] }); return withDefault(param, detected.value); } return param; }); } function withDefault(param, value) { return { type: 'AssignmentPattern', left: param, right: value }; } function remainingParams(fn, i) { return fn.params.slice(i); } function containsParams(defaultValue, params) { return (0, _fp.flow)((0, _fp.flatMap)(_destructuring.extractVariables), (0, _fp.some)(function (param) { return _traverser["default"].find(defaultValue, (0, _fMatches.matches)({ type: 'Identifier', name: param.name })); }))(params); } // Looks default value assignments at the beginning of a function // // Returns a map of variable-name:{name, value, node} function findDefaults(fnBody) { var defaults = {}; var _iterator = _createForOfIteratorHelper(fnBody), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var node = _step.value; var def = matchDefaultAssignment(node); if (!def) { break; } defaults[def.name] = def; } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } return defaults; } function matchDefaultAssignment(node) { return (0, _matchOrAssignment["default"])(node) || (0, _matchTernaryAssignment["default"])(node) || (0, _matchIfUndefinedAssignment["default"])(node); } /***/ }), /***/ "./node_modules/lebab/lib/transform/defaultParam/matchIfUndefinedAssignment.js": /*!*************************************************************************************!*\ !*** ./node_modules/lebab/lib/transform/defaultParam/matchIfUndefinedAssignment.js ***! \*************************************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = _default; var _fMatches = __webpack_require__(/*! f-matches */ "./node_modules/f-matches/index.js"); var matchEqualsUndefined = (0, _fMatches.matches)({ type: 'BinaryExpression', left: { type: 'Identifier', name: (0, _fMatches.extractAny)('name2') }, operator: (0, _fMatches.extractAny)('operator'), right: { type: 'Identifier', name: 'undefined' } }); var matchTypeofUndefined = (0, _fMatches.matches)({ type: 'BinaryExpression', left: { type: 'UnaryExpression', operator: 'typeof', prefix: true, argument: { type: 'Identifier', name: (0, _fMatches.extractAny)('name2') } }, operator: (0, _fMatches.extractAny)('operator'), right: { type: 'Literal', value: 'undefined' } }); var matchIfUndefinedAssignment = (0, _fMatches.matches)({ type: 'ExpressionStatement', expression: { type: 'AssignmentExpression', left: { type: 'Identifier', name: (0, _fMatches.extractAny)('name') }, operator: '=', right: { type: 'ConditionalExpression', test: function test(ast) { return matchEqualsUndefined(ast) || matchTypeofUndefined(ast); }, consequent: (0, _fMatches.extractAny)('consequent'), alternate: (0, _fMatches.extractAny)('alternate') } } }); function isEquals(operator) { return operator === '===' || operator === '=='; } function isNotEquals(operator) { return operator === '!==' || operator === '!='; } function isIdent(node, name) { return node.type === 'Identifier' && node.name === name; } /** * Matches: = === undefined ? : ; * Matches: = typeof === 'undefined' ? : ; * * When node matches returns the extracted fields: * * - name * - value * - node (the entire node) * * @param {Object} node * @return {Object} */ function _default(node) { var _ref = matchIfUndefinedAssignment(node) || {}, name = _ref.name, name2 = _ref.name2, operator = _ref.operator, consequent = _ref.consequent, alternate = _ref.alternate; if (name && name === name2) { if (isEquals(operator) && isIdent(alternate, name)) { return { name: name, value: consequent, node: node }; } if (isNotEquals(operator) && isIdent(consequent, name)) { return { name: name, value: alternate, node: node }; } } } /***/ }), /***/ "./node_modules/lebab/lib/transform/defaultParam/matchOrAssignment.js": /*!****************************************************************************!*\ !*** ./node_modules/lebab/lib/transform/defaultParam/matchOrAssignment.js ***! \****************************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = _default; var _fMatches = __webpack_require__(/*! f-matches */ "./node_modules/f-matches/index.js"); var matchOrAssignment = (0, _fMatches.matches)({ type: 'ExpressionStatement', expression: { type: 'AssignmentExpression', left: { type: 'Identifier', name: (0, _fMatches.extractAny)('name') }, operator: '=', right: { type: 'LogicalExpression', left: { type: 'Identifier', name: (0, _fMatches.extractAny)('name2') }, operator: '||', right: (0, _fMatches.extractAny)('value') } } }); /** * Matches: = || ; * * When node matches returns the extracted fields: * * - name * - value * - node (the entire node) * * @param {Object} node * @return {Object} */ function _default(node) { var _ref = matchOrAssignment(node) || {}, name = _ref.name, name2 = _ref.name2, value = _ref.value; if (name && name === name2) { return { name: name, value: value, node: node }; } } /***/ }), /***/ "./node_modules/lebab/lib/transform/defaultParam/matchTernaryAssignment.js": /*!*********************************************************************************!*\ !*** ./node_modules/lebab/lib/transform/defaultParam/matchTernaryAssignment.js ***! \*********************************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = _default; var _fMatches = __webpack_require__(/*! f-matches */ "./node_modules/f-matches/index.js"); var matchTernaryAssignment = (0, _fMatches.matches)({ type: 'ExpressionStatement', expression: { type: 'AssignmentExpression', left: { type: 'Identifier', name: (0, _fMatches.extractAny)('name') }, operator: '=', right: { type: 'ConditionalExpression', test: { type: 'Identifier', name: (0, _fMatches.extractAny)('name2') }, consequent: { type: 'Identifier', name: (0, _fMatches.extractAny)('name3') }, alternate: (0, _fMatches.extractAny)('value') } } }); /** * Matches: = ? : ; * * When node matches returns the extracted fields: * * - name * - value * - node (the entire node) * * @param {Object} node * @return {Object} */ function _default(node) { var _ref = matchTernaryAssignment(node) || {}, name = _ref.name, name2 = _ref.name2, name3 = _ref.name3, value = _ref.value; if (name && name === name2 && name === name3) { return { name: name, value: value, node: node }; } } /***/ }), /***/ "./node_modules/lebab/lib/transform/destructParam.js": /*!***********************************************************!*\ !*** ./node_modules/lebab/lib/transform/destructParam.js ***! \***********************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = _default; var _fp = __webpack_require__(/*! lodash/fp */ "./node_modules/lodash/fp.js"); var _recast = __webpack_require__(/*! recast */ "./node_modules/recast/main.js"); var _Parser = _interopRequireDefault(__webpack_require__(/*! ../Parser */ "./node_modules/lebab/lib/Parser.js")); var _traverser = _interopRequireDefault(__webpack_require__(/*! ../traverser */ "./node_modules/lebab/lib/traverser.js")); var _withScope = _interopRequireDefault(__webpack_require__(/*! ../withScope */ "./node_modules/lebab/lib/withScope.js")); var functionType = _interopRequireWildcard(__webpack_require__(/*! ../utils/functionType */ "./node_modules/lebab/lib/utils/functionType.js")); var _Hierarchy = _interopRequireDefault(__webpack_require__(/*! ../utils/Hierarchy */ "./node_modules/lebab/lib/utils/Hierarchy.js")); function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } var MAX_PROPS = 4; function _default(ast, logger) { var hierarchy = new _Hierarchy["default"](ast); _traverser["default"].traverse(ast, (0, _withScope["default"])(ast, { enter: function enter(fnNode, parent, scope) { if (functionType.isFunction(fnNode)) { scope.variables.filter(isParameter).map(function (v) { return { variable: v, exs: getMemberExpressions(v, hierarchy) }; }).filter(function (_ref) { var exs = _ref.exs; return exs.length > 0; }).forEach(function (_ref2) { var variable = _ref2.variable, exs = _ref2.exs; // Replace parameter with destruct-pattern var index = fnNode.params.findIndex(function (param) { return param === variable.defs[0].name; }); if (index === -1) { return; } if (uniqPropNames(exs).length > MAX_PROPS) { logger.warn(fnNode, "".concat(uniqPropNames(exs).length, " different props found, will not transform more than ").concat(MAX_PROPS), 'destruct-param'); return; } fnNode.params[index] = createDestructPattern(exs); // Replace references of obj.foo with simply foo exs.forEach(function (ex) { ex.type = ex.property.type; ex.name = ex.property.name; }); }); } } })); } function isParameter(variable) { return variable.defs.length === 1 && variable.defs[0].type === 'Parameter'; } function getMemberExpressions(variable, hierarchy) { var memberExpressions = []; var _iterator = _createForOfIteratorHelper(variable.references), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var ref = _step.value; var memEx = hierarchy.getParent(ref.identifier); if (!isMemberExpressionObject(memEx, ref.identifier)) { return []; } var ex = hierarchy.getParent(memEx); if (isAssignment(ex, memEx) || isUpdate(ex, memEx) || isMethodCall(ex, memEx)) { return []; } if (isKeyword(memEx.property.name) || variableExists(memEx.property.name, ref.from)) { return []; } memberExpressions.push(memEx); } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } return memberExpressions; } function isMemberExpressionObject(memEx, object) { return memEx.type === 'MemberExpression' && memEx.object === object && memEx.computed === false; } function isAssignment(ex, node) { return ex.type === 'AssignmentExpression' && ex.left === node; } function isUpdate(ex, node) { return ex.type === 'UpdateExpression' && ex.argument === node; } function isMethodCall(ex, node) { return ex.type === 'CallExpression' && ex.callee === node; } function variableExists(variableName, scope) { while (scope) { if (scope.through.some(function (ref) { return ref.identifier.name === variableName; })) { return true; } if (scope.set.get(variableName)) { return true; } scope = scope.upper; } return false; } function isKeyword(name) { return _Parser["default"].tokenize(name)[0].type === 'Keyword'; } function uniqPropNames(exs) { return (0, _fp.uniq)(exs.map(function (_ref3) { var property = _ref3.property; return property.name; })); } // By default recast indents the ObjectPattern AST node // See: https://github.com/benjamn/recast/issues/240 // // To work around this, we're building the desired string by ourselves, // and parsing it with Recast and extracting the ObjectPatter node. // Feeding this back to Recast will preserve the formatting. function createDestructPattern(exs) { var props = uniqPropNames(exs).join(', '); var js = "function foo({".concat(props, "}) {};"); var ast = (0, _recast.parse)(js, { parser: _Parser["default"] }); return ast.program.body[0].params[0]; } /***/ }), /***/ "./node_modules/lebab/lib/transform/exponent.js": /*!******************************************************!*\ !*** ./node_modules/lebab/lib/transform/exponent.js ***! \******************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = _default; var _fMatches = __webpack_require__(/*! f-matches */ "./node_modules/f-matches/index.js"); var _traverser = _interopRequireDefault(__webpack_require__(/*! ../traverser */ "./node_modules/lebab/lib/traverser.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } var isMathPow = (0, _fMatches.matches)({ type: 'CallExpression', callee: { type: 'MemberExpression', computed: false, object: { type: 'Identifier', name: 'Math' }, property: { type: 'Identifier', name: 'pow' } }, arguments: function _arguments(args) { return args.length === 2; } }); function _default(ast) { _traverser["default"].replace(ast, { enter: function enter(node) { if (isMathPow(node)) { return { type: 'BinaryExpression', operator: '**', left: node.arguments[0], right: node.arguments[1] }; } } }); } /***/ }), /***/ "./node_modules/lebab/lib/transform/forEach/index.js": /*!***********************************************************!*\ !*** ./node_modules/lebab/lib/transform/forEach/index.js ***! \***********************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = _default; var _fp = __webpack_require__(/*! lodash/fp */ "./node_modules/lodash/fp.js"); var _traverser = _interopRequireDefault(__webpack_require__(/*! ../../traverser */ "./node_modules/lebab/lib/traverser.js")); var _isEqualAst = _interopRequireDefault(__webpack_require__(/*! ../../utils/isEqualAst */ "./node_modules/lebab/lib/utils/isEqualAst.js")); var _variableType = __webpack_require__(/*! ../../utils/variableType */ "./node_modules/lebab/lib/utils/variableType.js"); var _copyComments = _interopRequireDefault(__webpack_require__(/*! ../../utils/copyComments */ "./node_modules/lebab/lib/utils/copyComments.js")); var _matchAliasedForLoop = _interopRequireDefault(__webpack_require__(/*! ../../utils/matchAliasedForLoop */ "./node_modules/lebab/lib/utils/matchAliasedForLoop.js")); var _validateForLoop = _interopRequireDefault(__webpack_require__(/*! ./validateForLoop */ "./node_modules/lebab/lib/transform/forEach/validateForLoop.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } function _default(ast, logger) { _traverser["default"].replace(ast, { enter: function enter(node) { var matches = (0, _matchAliasedForLoop["default"])(node); if (matches) { var warning = (0, _validateForLoop["default"])(node, matches); if (warning) { logger.warn.apply(logger, _toConsumableArray(warning).concat(['for-each'])); return; } return withComments(node, createForEach(matches)); } if (node.type === 'ForStatement') { logger.warn(node, 'Unable to transform for loop', 'for-each'); } } }); } function withComments(node, forEach) { (0, _copyComments["default"])({ from: node, to: forEach }); (0, _copyComments["default"])({ from: node.body.body[0], to: forEach }); return forEach; } function createForEach(_ref) { var body = _ref.body, item = _ref.item, index = _ref.index, array = _ref.array; var newBody = removeFirstBodyElement(body); var params = createForEachParams(newBody, item, index); return { type: 'ExpressionStatement', expression: { type: 'CallExpression', callee: { type: 'MemberExpression', object: array, property: { type: 'Identifier', name: 'forEach' } }, arguments: [{ type: 'ArrowFunctionExpression', params: params, body: newBody }] } }; } function removeFirstBodyElement(body) { return _objectSpread(_objectSpread({}, body), {}, { body: (0, _fp.tail)(body.body) }); } function createForEachParams(newBody, item, index) { if (indexUsedInBody(newBody, index)) { return [item, index]; } return [item]; } function indexUsedInBody(newBody, index) { return _traverser["default"].find(newBody, function (node, parent) { return (0, _isEqualAst["default"])(node, index) && (0, _variableType.isReference)(node, parent); }); } /***/ }), /***/ "./node_modules/lebab/lib/transform/forEach/validateForLoop.js": /*!*********************************************************************!*\ !*** ./node_modules/lebab/lib/transform/forEach/validateForLoop.js ***! \*********************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = validateForLoop; var _traverser = _interopRequireDefault(__webpack_require__(/*! ../../traverser */ "./node_modules/lebab/lib/traverser.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } /** * Checks that for-loop can be transformed to Array.forEach() * * Returns a warning message in case we can't transform. * * @param {Object} node The ForStatement * @param {Object} body BlockStatement that's body of ForStatement * @param {String} indexKind * @param {String} itemKind * @return {Array} Array of node and warnings message or undefined on success. */ function validateForLoop(node, _ref) { var body = _ref.body, indexKind = _ref.indexKind, itemKind = _ref.itemKind; var statement; if (statement = returnUsed(body)) { return [statement, 'Return statement used in for-loop body']; } else if (statement = breakWithLabelUsed(body)) { return [statement, 'Break statement with label used in for-loop body']; } else if (statement = continueWithLabelUsed(body)) { return [statement, 'Continue statement with label used in for-loop body']; } else if (statement = breakUsed(body)) { return [statement, 'Break statement used in for-loop body']; } else if (statement = continueUsed(body)) { return [statement, 'Continue statement used in for-loop body']; } else if (indexKind !== 'let') { return [node, 'Only for-loops with indexes declared as let can be transformed (use let transform first)']; } else if (itemKind !== 'const') { return [node, 'Only for-loops with const array items can be transformed (use let transform first)']; } } var loopStatements = ['ForStatement', 'ForInStatement', 'ForOfStatement', 'DoWhileStatement', 'WhileStatement']; function returnUsed(body) { return _traverser["default"].find(body, 'ReturnStatement'); } function breakWithLabelUsed(body) { return _traverser["default"].find(body, function (_ref2) { var type = _ref2.type, label = _ref2.label; return type === 'BreakStatement' && label; }); } function continueWithLabelUsed(body) { return _traverser["default"].find(body, function (_ref3) { var type = _ref3.type, label = _ref3.label; return type === 'ContinueStatement' && label; }); } function breakUsed(body) { return _traverser["default"].find(body, 'BreakStatement', { skipTypes: [].concat(loopStatements, ['SwitchStatement']) }); } function continueUsed(body) { return _traverser["default"].find(body, 'ContinueStatement', { skipTypes: loopStatements }); } /***/ }), /***/ "./node_modules/lebab/lib/transform/forOf.js": /*!***************************************************!*\ !*** ./node_modules/lebab/lib/transform/forOf.js ***! \***************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = _default; var _fp = __webpack_require__(/*! lodash/fp */ "./node_modules/lodash/fp.js"); var _traverser = _interopRequireDefault(__webpack_require__(/*! ../traverser */ "./node_modules/lebab/lib/traverser.js")); var _isEqualAst = _interopRequireDefault(__webpack_require__(/*! ../utils/isEqualAst */ "./node_modules/lebab/lib/utils/isEqualAst.js")); var _variableType = __webpack_require__(/*! ../utils/variableType */ "./node_modules/lebab/lib/utils/variableType.js"); var _copyComments = _interopRequireDefault(__webpack_require__(/*! ../utils/copyComments */ "./node_modules/lebab/lib/utils/copyComments.js")); var _matchAliasedForLoop = _interopRequireDefault(__webpack_require__(/*! ../utils/matchAliasedForLoop */ "./node_modules/lebab/lib/utils/matchAliasedForLoop.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } function _default(ast, logger) { _traverser["default"].replace(ast, { enter: function enter(node) { var matches = (0, _matchAliasedForLoop["default"])(node); if (matches) { if (indexUsedInBody(matches)) { logger.warn(node, 'Index variable used in for-loop body', 'for-of'); return; } if (matches.itemKind === 'var' || matches.indexKind === 'var') { logger.warn(node, 'Only for-loops with let/const can be transformed (use let transform first)', 'for-of'); return; } return withComments(node, createForOf(matches)); } if (node.type === 'ForStatement') { logger.warn(node, 'Unable to transform for loop', 'for-of'); } } }); } function indexUsedInBody(_ref) { var body = _ref.body, index = _ref.index; return _traverser["default"].find(removeFirstBodyElement(body), function (node, parent) { return (0, _isEqualAst["default"])(node, index) && (0, _variableType.isReference)(node, parent); }); } function withComments(node, forOf) { (0, _copyComments["default"])({ from: node, to: forOf }); (0, _copyComments["default"])({ from: node.body.body[0], to: forOf }); return forOf; } function createForOf(_ref2) { var item = _ref2.item, itemKind = _ref2.itemKind, array = _ref2.array, body = _ref2.body; return { type: 'ForOfStatement', left: { type: 'VariableDeclaration', declarations: [{ type: 'VariableDeclarator', id: item, init: null // eslint-disable-line no-null/no-null }], kind: itemKind }, right: array, body: removeFirstBodyElement(body) }; } function removeFirstBodyElement(body) { return _objectSpread(_objectSpread({}, body), {}, { body: (0, _fp.tail)(body.body) }); } /***/ }), /***/ "./node_modules/lebab/lib/transform/includes/comparison.js": /*!*****************************************************************!*\ !*** ./node_modules/lebab/lib/transform/includes/comparison.js ***! \*****************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.isIncludesComparison = isIncludesComparison; exports.isNotIncludesComparison = isNotIncludesComparison; var _matchesIndexOf = __webpack_require__(/*! ./matchesIndexOf */ "./node_modules/lebab/lib/transform/includes/matchesIndexOf.js"); /** * True when indexOf() comparison can be translated to includes() * @param {Object} matches * @return {Boolean} */ function isIncludesComparison(_ref) { var operator = _ref.operator, index = _ref.index; switch (operator) { case '!==': case '!=': case '>': return (0, _matchesIndexOf.isMinusOne)(index); case '>=': return (0, _matchesIndexOf.isZero)(index); default: return false; } } /** * True when indexOf() comparison can be translated to !includes() * @param {Object} matches * @return {Boolean} */ function isNotIncludesComparison(_ref2) { var operator = _ref2.operator, index = _ref2.index; switch (operator) { case '===': case '==': return (0, _matchesIndexOf.isMinusOne)(index); case '<': return (0, _matchesIndexOf.isZero)(index); default: return false; } } /***/ }), /***/ "./node_modules/lebab/lib/transform/includes/index.js": /*!************************************************************!*\ !*** ./node_modules/lebab/lib/transform/includes/index.js ***! \************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = _default; var _traverser = _interopRequireDefault(__webpack_require__(/*! ../../traverser */ "./node_modules/lebab/lib/traverser.js")); var _matchesIndexOf = _interopRequireDefault(__webpack_require__(/*! ./matchesIndexOf */ "./node_modules/lebab/lib/transform/includes/matchesIndexOf.js")); var _comparison = __webpack_require__(/*! ./comparison */ "./node_modules/lebab/lib/transform/includes/comparison.js"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _default(ast) { _traverser["default"].replace(ast, { enter: function enter(node) { var matches = (0, _matchesIndexOf["default"])(node); if (matches && (0, _comparison.isIncludesComparison)(matches)) { return createIncludes(matches); } if (matches && (0, _comparison.isNotIncludesComparison)(matches)) { return createNot(createIncludes(matches)); } } }); } function createNot(argument) { return { type: 'UnaryExpression', operator: '!', prefix: true, argument: argument }; } function createIncludes(_ref) { var object = _ref.object, searchElement = _ref.searchElement; return { type: 'CallExpression', callee: { type: 'MemberExpression', computed: false, object: object, property: { type: 'Identifier', name: 'includes' } }, arguments: [searchElement] }; } /***/ }), /***/ "./node_modules/lebab/lib/transform/includes/matchesIndexOf.js": /*!*********************************************************************!*\ !*** ./node_modules/lebab/lib/transform/includes/matchesIndexOf.js ***! \*********************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = _default; exports.isZero = exports.isMinusOne = void 0; var _fMatches = __webpack_require__(/*! f-matches */ "./node_modules/f-matches/index.js"); function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /** * Matches: -1 */ var isMinusOne = (0, _fMatches.matches)({ type: 'UnaryExpression', operator: '-', argument: { type: 'Literal', value: 1 }, prefix: true }); /** * Matches: 0 */ exports.isMinusOne = isMinusOne; var isZero = (0, _fMatches.matches)({ type: 'Literal', value: 0 }); // Matches: object.indexOf(searchElement) exports.isZero = isZero; var matchesCallIndexOf = (0, _fMatches.matches)({ type: 'CallExpression', callee: { type: 'MemberExpression', computed: false, object: (0, _fMatches.extractAny)('object'), property: { type: 'Identifier', name: 'indexOf' } }, arguments: (0, _fMatches.matchesLength)([(0, _fMatches.extractAny)('searchElement')]) }); // Matches: -1 or 0 var matchesIndex = (0, _fMatches.extract)('index', function (v) { return isMinusOne(v) || isZero(v); }); // Matches: object.indexOf(searchElement) index var matchesIndexOfNormal = (0, _fMatches.matches)({ type: 'BinaryExpression', operator: (0, _fMatches.extractAny)('operator'), left: matchesCallIndexOf, right: matchesIndex }); // Matches: index object.indexOf(searchElement) var matchesIndexOfReversed = (0, _fMatches.matches)({ type: 'BinaryExpression', operator: (0, _fMatches.extractAny)('operator'), left: matchesIndex, right: matchesCallIndexOf }); // Reverses the direction of comparison operator function reverseOperator(operator) { return operator.replace(/[><]/, function (op) { return op === '>' ? '<' : '>'; }); } function reverseOperatorField(match) { if (!match) { return false; } return _objectSpread(_objectSpread({}, match), {}, { operator: reverseOperator(match.operator) }); } /** * Matches: * * object.indexOf(searchElement) index * * or * * index object.indexOf(searchElement) * * On success returns object with keys: * * - object * - searchElement * - operator * - index * * @param {Object} node * @return {Object} */ function _default(node) { return matchesIndexOfNormal(node) || reverseOperatorField(matchesIndexOfReversed(node)); } /***/ }), /***/ "./node_modules/lebab/lib/transform/let.js": /*!*************************************************!*\ !*** ./node_modules/lebab/lib/transform/let.js ***! \*************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = _default; var _fp = __webpack_require__(/*! lodash/fp */ "./node_modules/lodash/fp.js"); var _traverser = _interopRequireDefault(__webpack_require__(/*! ../traverser */ "./node_modules/lebab/lib/traverser.js")); var functionType = _interopRequireWildcard(__webpack_require__(/*! ../utils/functionType */ "./node_modules/lebab/lib/utils/functionType.js")); var variableType = _interopRequireWildcard(__webpack_require__(/*! ../utils/variableType */ "./node_modules/lebab/lib/utils/variableType.js")); var destructuring = _interopRequireWildcard(__webpack_require__(/*! ../utils/destructuring.js */ "./node_modules/lebab/lib/utils/destructuring.js")); var _multiReplaceStatement = _interopRequireDefault(__webpack_require__(/*! ../utils/multiReplaceStatement */ "./node_modules/lebab/lib/utils/multiReplaceStatement.js")); var _ScopeManager = _interopRequireDefault(__webpack_require__(/*! ../scope/ScopeManager */ "./node_modules/lebab/lib/scope/ScopeManager.js")); var _VariableMarker = _interopRequireDefault(__webpack_require__(/*! ../scope/VariableMarker */ "./node_modules/lebab/lib/scope/VariableMarker.js")); var _FunctionHoister = _interopRequireDefault(__webpack_require__(/*! ../scope/FunctionHoister */ "./node_modules/lebab/lib/scope/FunctionHoister.js")); var _VariableDeclaration = _interopRequireDefault(__webpack_require__(/*! ../syntax/VariableDeclaration */ "./node_modules/lebab/lib/syntax/VariableDeclaration.js")); function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } var logger; var scopeManager; function _default(ast, loggerInstance) { logger = loggerInstance; scopeManager = new _ScopeManager["default"](); var variableMarker = new _VariableMarker["default"](scopeManager); _traverser["default"].traverse(ast, { enter: function enter(node, parent) { if (node.type === 'Program') { enterProgram(node); } else if (functionType.isFunctionDeclaration(node)) { enterFunctionDeclaration(node); } else if (functionType.isFunctionExpression(node)) { enterFunctionExpression(node); } else if (isBlockScopedStatement(node)) { scopeManager.enterBlock(); } else if (node.type === 'VariableDeclaration') { node.declarations.forEach(function (decl) { variableMarker.markDeclared(destructuring.extractVariableNames(decl.id)); // Uninitialized variables can never be const. // But variables in for-in/of loop heads are actually initialized (although init === null). var inForLoopHead = isAnyForStatement(parent) && parent.left === node; if (decl.init === null && !inForLoopHead) { // eslint-disable-line no-null/no-null variableMarker.markModified(decl.id.name); } }); } else if (node.type === 'AssignmentExpression') { destructuring.extractVariableNames(node.left).forEach(function (name) { variableMarker.markModified(name); }); } else if (variableType.isUpdate(node)) { variableMarker.markModified(node.argument.name); } else if (variableType.isReference(node, parent)) { variableMarker.markReferenced(node.name); } }, leave: function leave(node) { if (node.type === 'Program') { leaveProgram(); } else if (functionType.isFunction(node)) { leaveFunction(); } else if (isBlockScopedStatement(node)) { scopeManager.leaveScope(); } } }); } // Block scope is usually delimited by { ... } // But for-loop heads also constitute a block scope. function isBlockScopedStatement(node) { return node.type === 'BlockStatement' || isAnyForStatement(node); } // True when dealing with any kind of for-loop function isAnyForStatement(node) { return node.type === 'ForStatement' || node.type === 'ForInStatement' || node.type === 'ForOfStatement'; } // True when dealing with any kind of while-loop function isAnyWhileStatement(node) { return node.type === 'WhileStatement' || node.type === 'DoWhileStatement'; } // Program node works almost like a function: // it hoists all variables which can be transformed to block-scoped let/const. // It just doesn't have name and parameters. // So we create an implied FunctionScope and BlockScope. function enterProgram(node) { scopeManager.enterFunction(); hoistFunction({ body: node }); scopeManager.enterBlock(); } // FunctionDeclaration has it's name visible outside the function, // so we first register it in surrounding block-scope and // after that enter new FunctionScope. function enterFunctionDeclaration(func) { if (func.id) { getScope().register(func.id.name, getScope().findFunctionScoped(func.id.name)); } scopeManager.enterFunction(); hoistFunction({ params: func.params, body: func.body }); } // FunctionExpression has it's name visible only inside the function, // so we first enter new FunctionScope and // hoist function name and params variables inside it. function enterFunctionExpression(func) { scopeManager.enterFunction(); hoistFunction({ id: func.id, params: func.params, body: func.body }); } function hoistFunction(cfg) { new _FunctionHoister["default"](getScope()).hoist(cfg); } // Exits the implied BlockScope and FunctionScope of Program node function leaveProgram() { scopeManager.leaveScope(); leaveFunction(); } // Exits FunctionScope but first transforms all variables inside it function leaveFunction() { transformVarsToLetOrConst(); scopeManager.leaveScope(); } // This is where the actual transform happens function transformVarsToLetOrConst() { getFunctionVariableGroups().forEach(function (group) { // Do not modify existing let & const if (group.getNode().kind !== 'var') { return; } if (isLexicalVariableProhibited(group)) { logWarningForVarKind(group.getNode()); return; } var commonKind = group.getCommonKind(); if (commonKind) { // When all variables in group are of the same kind, // just set appropriate `kind` value for the existing // VariableDeclaration node. group.getNode().kind = commonKind; logWarningForVarKind(group.getNode()); } else if (hasMultiStatementBody(group.getParentNode())) { // When some variables are of a different kind, // create separate VariableDeclaration nodes for each // VariableDeclarator and set their `kind` value appropriately. var varNodes = group.getVariables().map(function (v) { return new _VariableDeclaration["default"](v.getKind(), [v.getNode()]); }); (0, _multiReplaceStatement["default"])({ parent: group.getParentNode(), node: group.getNode(), replacements: varNodes, preserveComments: true }); logWarningForVarKind(group.getNode()); } else { // When parent node restricts breaking VariableDeclaration to multiple ones // just change the kind of the declaration to the most restrictive possible group.getNode().kind = group.getMostRestrictiveKind(); logWarningForVarKind(group.getNode()); } }); } // let and const declarations aren't allowed in all the same places where // var declarations are allowed. Notably, only var-declaration can occur // directlt in if-statement (and other similar statements) body: // // if (true) var x = 10; // // let or const can only be used when the variable is declared in inside // a block-statement: // // if (true) { const x = 10; } // function isLexicalVariableProhibited(group) { var node = group.getNode(); var parentNode = group.getParentNode(); if (parentNode.type === 'IfStatement') { return parentNode.consequent === node || parentNode.alternate === node; } if (isAnyForStatement(parentNode) || isAnyWhileStatement(parentNode)) { return parentNode.body === node; } return false; } function logWarningForVarKind(node) { if (node.kind === 'var') { logger.warn(node, 'Unable to transform var', 'let'); } } // Does a node have body that can contain an array of statements function hasMultiStatementBody(node) { return node.type === 'BlockStatement' || node.type === 'Program' || node.type === 'SwitchCase'; } // Returns all VariableGroups of variables in current function scope, // including from all the nested block-scopes (but not the nested // functions). function getFunctionVariableGroups() { return (0, _fp.flow)((0, _fp.map)(function (v) { return v.getGroup(); }), _fp.uniq, _fp.compact)(getScope().getVariables()); } function getScope() { return scopeManager.getScope(); } /***/ }), /***/ "./node_modules/lebab/lib/transform/multiVar.js": /*!******************************************************!*\ !*** ./node_modules/lebab/lib/transform/multiVar.js ***! \******************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = _default; var _traverser = _interopRequireDefault(__webpack_require__(/*! ../traverser */ "./node_modules/lebab/lib/traverser.js")); var _multiReplaceStatement = _interopRequireDefault(__webpack_require__(/*! ../utils/multiReplaceStatement */ "./node_modules/lebab/lib/utils/multiReplaceStatement.js")); var _VariableDeclaration = _interopRequireDefault(__webpack_require__(/*! ../syntax/VariableDeclaration */ "./node_modules/lebab/lib/syntax/VariableDeclaration.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _default(ast, logger) { _traverser["default"].traverse(ast, { enter: function enter(node, parent) { if (node.type === 'VariableDeclaration' && node.declarations.length > 1) { splitDeclaration(node, parent, logger); return _traverser["default"].VisitorOption.Skip; } } }); } function splitDeclaration(node, parent, logger) { var declNodes = node.declarations.map(function (declarator) { return new _VariableDeclaration["default"](node.kind, [declarator]); }); try { (0, _multiReplaceStatement["default"])({ parent: parent, node: node, replacements: declNodes, preserveComments: true }); } catch (e) { logger.warn(parent, "Unable to split var statement in a ".concat(parent.type), 'multi-var'); } } /***/ }), /***/ "./node_modules/lebab/lib/transform/noStrict.js": /*!******************************************************!*\ !*** ./node_modules/lebab/lib/transform/noStrict.js ***! \******************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = _default; var _traverser = _interopRequireDefault(__webpack_require__(/*! ../traverser */ "./node_modules/lebab/lib/traverser.js")); var _isString = _interopRequireDefault(__webpack_require__(/*! ../utils/isString */ "./node_modules/lebab/lib/utils/isString.js")); var _copyComments = _interopRequireDefault(__webpack_require__(/*! ../utils/copyComments */ "./node_modules/lebab/lib/utils/copyComments.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _default(ast) { _traverser["default"].replace(ast, { enter: function enter(node, parent) { if (node.type === 'ExpressionStatement' && isUseStrictString(node.expression)) { (0, _copyComments["default"])({ from: node, to: parent }); this.remove(); } } }); } function isUseStrictString(node) { return (0, _isString["default"])(node) && node.value === 'use strict'; } /***/ }), /***/ "./node_modules/lebab/lib/transform/objMethod.js": /*!*******************************************************!*\ !*** ./node_modules/lebab/lib/transform/objMethod.js ***! \*******************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = _default; var _fMatches = __webpack_require__(/*! f-matches */ "./node_modules/f-matches/index.js"); var _traverser = _interopRequireDefault(__webpack_require__(/*! ../traverser */ "./node_modules/lebab/lib/traverser.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } var matchTransformableProperty = (0, _fMatches.matches)({ type: 'Property', key: { type: 'Identifier' }, value: { type: 'FunctionExpression', id: (0, _fMatches.extractAny)('functionName') }, method: false, computed: false, shorthand: false }); function _default(ast, logger) { _traverser["default"].replace(ast, { enter: function enter(node) { var match = matchTransformableProperty(node); if (match) { // Do not transform functions with name, // as the name might be recursively referenced from inside. if (match.functionName) { logger.warn(node, 'Unable to transform named function', 'obj-method'); return; } node.method = true; } } }); } /***/ }), /***/ "./node_modules/lebab/lib/transform/objShorthand.js": /*!**********************************************************!*\ !*** ./node_modules/lebab/lib/transform/objShorthand.js ***! \**********************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = _default; var _traverser = _interopRequireDefault(__webpack_require__(/*! ../traverser */ "./node_modules/lebab/lib/traverser.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _default(ast) { _traverser["default"].replace(ast, { enter: propertyToShorthand }); } function propertyToShorthand(node) { if (node.type === 'Property' && equalIdentifiers(node.key, node.value)) { node.shorthand = true; } } function equalIdentifiers(a, b) { return a.type === 'Identifier' && b.type === 'Identifier' && a.name === b.name; } /***/ }), /***/ "./node_modules/lebab/lib/transform/template.js": /*!******************************************************!*\ !*** ./node_modules/lebab/lib/transform/template.js ***! \******************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = _default; var _traverser = _interopRequireDefault(__webpack_require__(/*! ../traverser */ "./node_modules/lebab/lib/traverser.js")); var _TemplateLiteral = _interopRequireDefault(__webpack_require__(/*! ./../syntax/TemplateLiteral */ "./node_modules/lebab/lib/syntax/TemplateLiteral.js")); var _TemplateElement = _interopRequireDefault(__webpack_require__(/*! ./../syntax/TemplateElement */ "./node_modules/lebab/lib/syntax/TemplateElement.js")); var _isString = _interopRequireDefault(__webpack_require__(/*! ./../utils/isString */ "./node_modules/lebab/lib/utils/isString.js")); var _fp = __webpack_require__(/*! lodash/fp */ "./node_modules/lodash/fp.js"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _default(ast) { _traverser["default"].replace(ast, { enter: function enter(node) { if (isPlusExpression(node)) { var plusExpr = flattenPlusExpression(node); if (plusExpr.isString && !plusExpr.operands.every(_isString["default"])) { var literal = new _TemplateLiteral["default"](splitQuasisAndExpressions(plusExpr.operands)); // Ensure correct order of comments by sorting them by their position in source literal.comments = (0, _fp.sortBy)('start', plusExpr.comments); return literal; } } } }); } // Returns object of three fields: // - operands: flat array of all the plus operation sub-expressions // - comments: array of comments // - isString: true when the result of the whole plus operation is a string function flattenPlusExpression(node) { if (isPlusExpression(node)) { var left = flattenPlusExpression(node.left); var right = flattenPlusExpression(node.right); if (left.isString || right.isString) { return { operands: (0, _fp.flatten)([left.operands, right.operands]), comments: (0, _fp.flatten)([node.comments || [], left.comments, right.comments]), isString: true }; } else { return { operands: [node], comments: node.comments || [], isString: false }; } } else { return { operands: [node], comments: node.comments || [], isString: (0, _isString["default"])(node) }; } } function isPlusExpression(node) { return node.type === 'BinaryExpression' && node.operator === '+'; } function splitQuasisAndExpressions(operands) { var quasis = []; var expressions = []; for (var i = 0; i < operands.length; i++) { var curr = operands[i]; if ((0, _isString["default"])(curr)) { var currVal = curr.value; var currRaw = escapeForTemplate(curr.raw); while ((0, _isString["default"])(operands[i + 1] || {})) { i++; currVal += operands[i].value; currRaw += escapeForTemplate(operands[i].raw); } quasis.push(new _TemplateElement["default"]({ raw: currRaw, cooked: currVal })); } else { if (i === 0) { quasis.push(new _TemplateElement["default"]({})); } if (!(0, _isString["default"])(operands[i + 1] || {})) { quasis.push(new _TemplateElement["default"]({ tail: operands[i + 1] === undefined })); } expressions.push(curr); } } return { quasis: quasis, expressions: expressions }; } // Strip surrounding quotes, escape backticks and unescape escaped quotes function escapeForTemplate(raw) { return raw.replace(/^['"]|['"]$/g, '').replace(/`/g, '\\`').replace(/\\(['"])/g, '$1'); } /***/ }), /***/ "./node_modules/lebab/lib/traverser.js": /*!*********************************************!*\ !*** ./node_modules/lebab/lib/traverser.js ***! \*********************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = void 0; var _fp = __webpack_require__(/*! lodash/fp */ "./node_modules/lodash/fp.js"); var _estraverse = _interopRequireDefault(__webpack_require__(/*! estraverse */ "./node_modules/estraverse/estraverse.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } // JSX AST types, as documented in: // https://github.com/facebook/jsx/blob/master/AST.md var jsxExtensionKeys = { keys: { JSXIdentifier: [], JSXMemberExpression: ['object', 'property'], JSXNamespacedName: ['namespace', 'name'], JSXEmptyExpression: [], JSXExpressionContainer: ['expression'], JSXOpeningElement: ['name', 'attributes'], JSXClosingElement: ['name'], JSXOpeningFragment: [], JSXClosingFragment: [], JSXAttribute: ['name', 'value'], JSXSpreadAttribute: ['argument'], JSXElement: ['openingElement', 'closingElement', 'children'], JSXFragment: ['openingFragment', 'closingFragment', 'children'], JSXText: [] } }; /** * Proxy for ESTraverse. * Providing a single place to easily extend its functionality. * * Exposes the traverse() and replace() methods just like ESTraverse, * plus some custom helpers. */ var _default = { /** * Traverses AST like ESTraverse.traverse() * @param {Object} tree * @param {Object} cfg Object with optional enter() and leave() methods. * @return {Object} The transformed tree */ traverse: function traverse(tree, cfg) { return _estraverse["default"].traverse(tree, Object.assign(cfg, jsxExtensionKeys)); }, /** * Traverses AST like ESTraverse.replace() * @param {Object} tree * @param {Object} cfg Object with optional enter() and leave() methods. * @return {Object} The transformed tree */ replace: function replace(tree, cfg) { return _estraverse["default"].replace(tree, Object.assign(cfg, jsxExtensionKeys)); }, /** * Constants to return from enter()/leave() to control traversal: * * - Skip - skips walking child nodes * - Break - ends it all * - Remove - removes the current node (only with replace()) */ VisitorOption: _estraverse["default"].VisitorOption, /** * Searches in AST tree for node which satisfies the predicate. * @param {Object} tree * @param {Function|String} query Search function called with `node` and `parent` * Alternatively it can be string: the node type to search for. * @param {String[]} opts.skipTypes List of node types to skip (not traversing into these nodes) * @return {Object} The found node or undefined when not found */ find: function find(tree, query) { var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, _ref$skipTypes = _ref.skipTypes, skipTypes = _ref$skipTypes === void 0 ? [] : _ref$skipTypes; var predicate = this.createFindPredicate(query); var found; this.traverse(tree, { enter: function enter(node, parent) { if ((0, _fp.includes)(node.type, skipTypes)) { return _estraverse["default"].VisitorOption.Skip; } if (predicate(node, parent)) { found = node; return _estraverse["default"].VisitorOption.Break; } } }); return found; }, createFindPredicate: function createFindPredicate(query) { if ((0, _fp.isString)(query)) { return function (node) { return node.type === query; }; } else { return query; } } }; exports["default"] = _default; /***/ }), /***/ "./node_modules/lebab/lib/utils/Hierarchy.js": /*!***************************************************!*\ !*** ./node_modules/lebab/lib/utils/Hierarchy.js ***! \***************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = void 0; var _traverser = _interopRequireDefault(__webpack_require__(/*! ../traverser */ "./node_modules/lebab/lib/traverser.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /** * Provides a way to look up parent nodes. */ var Hierarchy = /*#__PURE__*/function () { /** * @param {Object} ast Root node */ function Hierarchy(ast) { var _this = this; _classCallCheck(this, Hierarchy); this.parents = new Map(); _traverser["default"].traverse(ast, { enter: function enter(node, parent) { _this.parents.set(node, parent); } }); } /** * Returns parent node of given AST node. * @param {Object} node * @return {Object} */ _createClass(Hierarchy, [{ key: "getParent", value: function getParent(node) { return this.parents.get(node); } }]); return Hierarchy; }(); exports["default"] = Hierarchy; /***/ }), /***/ "./node_modules/lebab/lib/utils/copyComments.js": /*!******************************************************!*\ !*** ./node_modules/lebab/lib/utils/copyComments.js ***! \******************************************************/ /***/ ((__unused_webpack_module, exports) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = copyComments; /** * Appends comments of one node to comments of another. * * - Modifies `to` node with added comments. * - Does nothing when there are no comments to copy * (ensuring we don't modify the `to` node when not needed). * * @param {Object} from Node to copy comments from * @param {Object} to Node to copy comments to */ function copyComments(_ref) { var from = _ref.from, to = _ref.to; if (from.comments && from.comments.length > 0) { to.comments = (to.comments || []).concat(from.comments || []); } } /***/ }), /***/ "./node_modules/lebab/lib/utils/destructuring.js": /*!*******************************************************!*\ !*** ./node_modules/lebab/lib/utils/destructuring.js ***! \*******************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.extractVariableNames = extractVariableNames; exports.extractVariables = extractVariables; var _fp = __webpack_require__(/*! lodash/fp */ "./node_modules/lodash/fp.js"); /** * Extracts all variables from from destructuring * operation in assignment or variable declaration. * * Also works for a single identifier (so it generalizes * for all assignments / variable declarations). * * @param {Object} node * @return {Object[]} Identifiers */ function extractVariables(node) { if (node.type === 'Identifier') { return [node]; } if (node.type === 'ArrayPattern') { // Use compact() to ignore missing elements in ArrayPattern return (0, _fp.flatMap)(extractVariables, (0, _fp.compact)(node.elements)); } if (node.type === 'ObjectPattern') { return (0, _fp.flatMap)(extractVariables, node.properties); } if (node.type === 'Property') { return extractVariables(node.value); } if (node.type === 'AssignmentPattern') { return extractVariables(node.left); } // Ignore stuff like MemberExpressions, // we only care about variables. return []; } /** * Like extractVariables(), but returns the names of variables * instead of Identifier objects. * * @param {Object} node * @return {String[]} variable names */ function extractVariableNames(node) { return extractVariables(node).map(function (v) { return v.name; }); } /***/ }), /***/ "./node_modules/lebab/lib/utils/functionType.js": /*!******************************************************!*\ !*** ./node_modules/lebab/lib/utils/functionType.js ***! \******************************************************/ /***/ ((__unused_webpack_module, exports) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.isFunction = isFunction; exports.isFunctionDeclaration = isFunctionDeclaration; exports.isFunctionExpression = isFunctionExpression; /** * True when node is any kind of function. */ function isFunction(node) { return isFunctionDeclaration(node) || isFunctionExpression(node); } /** * True when node is (arrow) function expression. */ function isFunctionExpression(node) { return node.type === 'FunctionExpression' || node.type === 'ArrowFunctionExpression'; } /** * True when node is function declaration. */ function isFunctionDeclaration(node) { return node.type === 'FunctionDeclaration'; } /***/ }), /***/ "./node_modules/lebab/lib/utils/isEqualAst.js": /*!****************************************************!*\ !*** ./node_modules/lebab/lib/utils/isEqualAst.js ***! \****************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = isEqualAst; var _fp = __webpack_require__(/*! lodash/fp */ "./node_modules/lodash/fp.js"); var metaDataFields = { comments: true, loc: true, start: true, end: true }; /** * True when two AST nodes are structurally equal. * When comparing objects it ignores the meta-data fields for * comments and source-code position. * @param {Object} a * @param {Object} b * @return {Boolean} */ function isEqualAst(a, b) { return (0, _fp.isEqualWith)(function (aValue, bValue, key) { return metaDataFields[key]; }, a, b); } /***/ }), /***/ "./node_modules/lebab/lib/utils/isString.js": /*!**************************************************!*\ !*** ./node_modules/lebab/lib/utils/isString.js ***! \**************************************************/ /***/ ((__unused_webpack_module, exports) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = isString; /** * True when the given node is string literal. * @param {Object} node * @return {Boolean} */ function isString(node) { return node.type === 'Literal' && typeof node.value === 'string'; } /***/ }), /***/ "./node_modules/lebab/lib/utils/matchAliasedForLoop.js": /*!*************************************************************!*\ !*** ./node_modules/lebab/lib/utils/matchAliasedForLoop.js ***! \*************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = _default; var _isEqualAst = _interopRequireDefault(__webpack_require__(/*! ./isEqualAst */ "./node_modules/lebab/lib/utils/isEqualAst.js")); var _fMatches = __webpack_require__(/*! f-matches */ "./node_modules/f-matches/index.js"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } // Matches ++ or ++ var matchPlusPlus = (0, _fMatches.matches)({ type: 'UpdateExpression', operator: '++', argument: (0, _fMatches.extract)('indexIncrement', { type: 'Identifier' }) }); // Matches +=1 var matchPlusOne = (0, _fMatches.matches)({ type: 'AssignmentExpression', operator: '+=', left: (0, _fMatches.extract)('indexIncrement', { type: 'Identifier' }), right: { type: 'Literal', value: 1 } }); // Matches the first element in array pattern // The default matches() tries to match against any array element. var matchesFirst = function matchesFirst(patterns) { return function (array) { return (0, _fMatches.matches)(patterns[0], array[0]); }; }; // Matches for-loop // without checking the consistency of index and array variables: // // for (let index = 0; indexComparison < array.length; indexIncrement++) { // let item = arrayReference[indexReference]; // ... // } var matchLooseForLoop = (0, _fMatches.matches)({ type: 'ForStatement', init: { type: 'VariableDeclaration', declarations: (0, _fMatches.matchesLength)([{ type: 'VariableDeclarator', id: (0, _fMatches.extract)('index', { type: 'Identifier' }), init: { type: 'Literal', value: 0 } }]), kind: (0, _fMatches.extractAny)('indexKind') }, test: { type: 'BinaryExpression', operator: '<', left: (0, _fMatches.extract)('indexComparison', { type: 'Identifier' }), right: { type: 'MemberExpression', computed: false, object: (0, _fMatches.extractAny)('array'), property: { type: 'Identifier', name: 'length' } } }, update: function update(node) { return matchPlusPlus(node) || matchPlusOne(node); }, body: (0, _fMatches.extract)('body', { type: 'BlockStatement', body: matchesFirst([{ type: 'VariableDeclaration', declarations: [{ type: 'VariableDeclarator', id: (0, _fMatches.extract)('item', { type: 'Identifier' }), init: { type: 'MemberExpression', computed: true, object: (0, _fMatches.extractAny)('arrayReference'), property: (0, _fMatches.extract)('indexReference', { type: 'Identifier' }) } }], kind: (0, _fMatches.extractAny)('itemKind') }]) }) }); function isConsistentIndexVar(_ref) { var index = _ref.index, indexComparison = _ref.indexComparison, indexIncrement = _ref.indexIncrement, indexReference = _ref.indexReference; return (0, _isEqualAst["default"])(index, indexComparison) && (0, _isEqualAst["default"])(index, indexIncrement) && (0, _isEqualAst["default"])(index, indexReference); } function isConsistentArrayVar(_ref2) { var array = _ref2.array, arrayReference = _ref2.arrayReference; return (0, _isEqualAst["default"])(array, arrayReference); } /** * Matches for-loop that aliases current array element * in the first line of the loop body: * * for (let index = 0; index < array.length; index++) { * let item = array[index]; * ... * } * * Extracts the following fields: * * - index - loop index identifier * - indexKind - the kind of * - array - array identifier or expression * - item - identifier used to alias current array element * - itemKind - the kind of * - body - the whole BlockStatement of for-loop body * * @param {Object} node * @return {Object} */ function _default(ast) { var match = matchLooseForLoop(ast); if (match && isConsistentIndexVar(match) && isConsistentArrayVar(match)) { return match; } } /***/ }), /***/ "./node_modules/lebab/lib/utils/multiReplaceStatement.js": /*!***************************************************************!*\ !*** ./node_modules/lebab/lib/utils/multiReplaceStatement.js ***! \***************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = multiReplaceStatement; var _copyComments = _interopRequireDefault(__webpack_require__(/*! ./copyComments */ "./node_modules/lebab/lib/utils/copyComments.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } /** * Replaces `node` inside `parent` with any number of `replacements`. * * ESTraverse only allows replacing one node with a single other node. * This function overcomes this limitation, allowing to replace it with multiple nodes. * * NOTE: Only works for nodes that allow multiple elements in their body. * When node doesn't exist inside parent, does nothing. * * @param {Object} cfg * @param {Object} cfg.parent Parent node of the node to replace * @param {Object} cfg.node The node to replace * @param {Object[]} cfg.replacements Replacement nodes (can be empty array) * @param {Boolean} [cfg.preserveComments] True to copy over comments from * node to first replacement node */ function multiReplaceStatement(_ref) { var parent = _ref.parent, node = _ref.node, replacements = _ref.replacements, preserveComments = _ref.preserveComments; var body = getBody(parent); var index = body.indexOf(node); if (preserveComments && replacements[0]) { (0, _copyComments["default"])({ from: node, to: replacements[0] }); } if (index !== -1) { body.splice.apply(body, [index, 1].concat(_toConsumableArray(replacements))); } } function getBody(node) { switch (node.type) { case 'BlockStatement': case 'Program': return node.body; case 'SwitchCase': return node.consequent; case 'ObjectExpression': return node.properties; default: throw "Unsupported node type '".concat(node.type, "' in multiReplaceStatement()"); } } /***/ }), /***/ "./node_modules/lebab/lib/utils/variableType.js": /*!******************************************************!*\ !*** ./node_modules/lebab/lib/utils/variableType.js ***! \******************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.isReference = isReference; exports.isUpdate = isUpdate; var _functionType = __webpack_require__(/*! ./functionType */ "./node_modules/lebab/lib/utils/functionType.js"); /** * True when node is variable update expression (like x++). * * @param {Object} node * @return {Boolean} */ function isUpdate(node) { return node.type === 'UpdateExpression' && node.argument.type === 'Identifier'; } /** * True when node is reference to a variable. * * That is it's an identifier, that's not used: * * - as function name in function declaration/expression, * - as parameter name in function declaration/expression, * - as declared variable name in variable declaration, * - as object property name in member expression. * - as object property name in object literal. * * @param {Object} node * @param {Object} parent Immediate parent node (to determine context) * @return {Boolean} */ function isReference(node, parent) { return node.type === 'Identifier' && !isFunctionName(node, parent) && !isFunctionParameter(node, parent) && !isDeclaredVariable(node, parent) && !isPropertyInMemberExpression(node, parent) && !isPropertyInObjectLiteral(node, parent); } function isFunctionName(node, parent) { return (0, _functionType.isFunction)(parent) && parent.id === node; } function isFunctionParameter(node, parent) { return (0, _functionType.isFunction)(parent) && parent.params.some(function (p) { return p === node; }); } function isDeclaredVariable(node, parent) { return parent.type === 'VariableDeclarator' && parent.id === node; } function isPropertyInMemberExpression(node, parent) { return parent.type === 'MemberExpression' && parent.property === node && !parent.computed; } function isPropertyInObjectLiteral(node, parent) { return parent.type === 'Property' && parent.key === node; } /***/ }), /***/ "./node_modules/lebab/lib/withScope.js": /*!*********************************************!*\ !*** ./node_modules/lebab/lib/withScope.js ***! \*********************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports["default"] = withScope; var _escope = __webpack_require__(/*! escope */ "./node_modules/escope/lib/index.js"); var _functionType = __webpack_require__(/*! ./utils/functionType */ "./node_modules/lebab/lib/utils/functionType.js"); var emptyFn = function emptyFn() {}; // eslint-disable-line no-empty-function /** * A helper for traversing with scope info from escope. * * Usage: * * traverser.traverse(ast, withScope(ast, { * enter(node, parent, scope) { * // do something with node and scope * } * })) * * @param {Object} ast The AST root node also passed to traverser. * @param {Object} cfg Object with enter function as expected by traverser. * @return {Object} Object with enter function to be passed to traverser. */ function withScope(ast, _ref) { var _ref$enter = _ref.enter, _enter = _ref$enter === void 0 ? emptyFn : _ref$enter; var scopeManager = (0, _escope.analyze)(ast, { ecmaVersion: 2022, sourceType: 'module' }); var currentScope = scopeManager.acquire(ast); return { enter: function enter(node, parent) { if ((0, _functionType.isFunction)(node)) { currentScope = scopeManager.acquire(node); } return _enter.call(this, node, parent, currentScope); } // NOTE: leave() is currently not implemented. // See escope docs for supporting it if need arises: https://github.com/estools/escope }; } /***/ }), /***/ "./node_modules/lebab/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs": /*!******************************************************************************************!*\ !*** ./node_modules/lebab/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs ***! \******************************************************************************************/ /***/ ((__unused_webpack_module, exports) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); /** * @typedef {{ readonly [type: string]: ReadonlyArray }} VisitorKeys */ /** * @type {VisitorKeys} */ const KEYS = { ArrayExpression: [ "elements" ], ArrayPattern: [ "elements" ], ArrowFunctionExpression: [ "params", "body" ], AssignmentExpression: [ "left", "right" ], AssignmentPattern: [ "left", "right" ], AwaitExpression: [ "argument" ], BinaryExpression: [ "left", "right" ], BlockStatement: [ "body" ], BreakStatement: [ "label" ], CallExpression: [ "callee", "arguments" ], CatchClause: [ "param", "body" ], ChainExpression: [ "expression" ], ClassBody: [ "body" ], ClassDeclaration: [ "id", "superClass", "body" ], ClassExpression: [ "id", "superClass", "body" ], ConditionalExpression: [ "test", "consequent", "alternate" ], ContinueStatement: [ "label" ], DebuggerStatement: [], DoWhileStatement: [ "body", "test" ], EmptyStatement: [], ExperimentalRestProperty: [ "argument" ], ExperimentalSpreadProperty: [ "argument" ], ExportAllDeclaration: [ "exported", "source" ], ExportDefaultDeclaration: [ "declaration" ], ExportNamedDeclaration: [ "declaration", "specifiers", "source" ], ExportSpecifier: [ "exported", "local" ], ExpressionStatement: [ "expression" ], ForInStatement: [ "left", "right", "body" ], ForOfStatement: [ "left", "right", "body" ], ForStatement: [ "init", "test", "update", "body" ], FunctionDeclaration: [ "id", "params", "body" ], FunctionExpression: [ "id", "params", "body" ], Identifier: [], IfStatement: [ "test", "consequent", "alternate" ], ImportDeclaration: [ "specifiers", "source" ], ImportDefaultSpecifier: [ "local" ], ImportExpression: [ "source" ], ImportNamespaceSpecifier: [ "local" ], ImportSpecifier: [ "imported", "local" ], JSXAttribute: [ "name", "value" ], JSXClosingElement: [ "name" ], JSXClosingFragment: [], JSXElement: [ "openingElement", "children", "closingElement" ], JSXEmptyExpression: [], JSXExpressionContainer: [ "expression" ], JSXFragment: [ "openingFragment", "children", "closingFragment" ], JSXIdentifier: [], JSXMemberExpression: [ "object", "property" ], JSXNamespacedName: [ "namespace", "name" ], JSXOpeningElement: [ "name", "attributes" ], JSXOpeningFragment: [], JSXSpreadAttribute: [ "argument" ], JSXSpreadChild: [ "expression" ], JSXText: [], LabeledStatement: [ "label", "body" ], Literal: [], LogicalExpression: [ "left", "right" ], MemberExpression: [ "object", "property" ], MetaProperty: [ "meta", "property" ], MethodDefinition: [ "key", "value" ], NewExpression: [ "callee", "arguments" ], ObjectExpression: [ "properties" ], ObjectPattern: [ "properties" ], PrivateIdentifier: [], Program: [ "body" ], Property: [ "key", "value" ], PropertyDefinition: [ "key", "value" ], RestElement: [ "argument" ], ReturnStatement: [ "argument" ], SequenceExpression: [ "expressions" ], SpreadElement: [ "argument" ], StaticBlock: [ "body" ], Super: [], SwitchCase: [ "test", "consequent" ], SwitchStatement: [ "discriminant", "cases" ], TaggedTemplateExpression: [ "tag", "quasi" ], TemplateElement: [], TemplateLiteral: [ "quasis", "expressions" ], ThisExpression: [], ThrowStatement: [ "argument" ], TryStatement: [ "block", "handler", "finalizer" ], UnaryExpression: [ "argument" ], UpdateExpression: [ "argument" ], VariableDeclaration: [ "declarations" ], VariableDeclarator: [ "id", "init" ], WhileStatement: [ "test", "body" ], WithStatement: [ "object", "body" ], YieldExpression: [ "argument" ] }; // Types. const NODE_TYPES = Object.keys(KEYS); // Freeze the keys. for (const type of NODE_TYPES) { Object.freeze(KEYS[type]); } Object.freeze(KEYS); /** * @author Toru Nagashima * See LICENSE file in root directory for full license. */ /** * @typedef {import('./visitor-keys.js').VisitorKeys} VisitorKeys */ // List to ignore keys. const KEY_BLACKLIST = new Set([ "parent", "leadingComments", "trailingComments" ]); /** * Check whether a given key should be used or not. * @param {string} key The key to check. * @returns {boolean} `true` if the key should be used. */ function filterKey(key) { return !KEY_BLACKLIST.has(key) && key[0] !== "_"; } /** * Get visitor keys of a given node. * @param {object} node The AST node to get keys. * @returns {readonly string[]} Visitor keys of the node. */ function getKeys(node) { return Object.keys(node).filter(filterKey); } // Disable valid-jsdoc rule because it reports syntax error on the type of @returns. // eslint-disable-next-line valid-jsdoc /** * Make the union set with `KEYS` and given keys. * @param {VisitorKeys} additionalKeys The additional keys. * @returns {VisitorKeys} The union set. */ function unionWith(additionalKeys) { const retv = /** @type {{ [type: string]: ReadonlyArray }} */ (Object.assign({}, KEYS)); for (const type of Object.keys(additionalKeys)) { if (Object.prototype.hasOwnProperty.call(retv, type)) { const keys = new Set(additionalKeys[type]); for (const key of retv[type]) { keys.add(key); } retv[type] = Object.freeze(Array.from(keys)); } else { retv[type] = Object.freeze(Array.from(additionalKeys[type])); } } return Object.freeze(retv); } exports.KEYS = KEYS; exports.getKeys = getKeys; exports.unionWith = unionWith; /***/ }), /***/ "./node_modules/lebab/node_modules/espree/dist/espree.cjs": /*!****************************************************************!*\ !*** ./node_modules/lebab/node_modules/espree/dist/espree.cjs ***! \****************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); var acorn = __webpack_require__(/*! acorn */ "./node_modules/acorn/dist/acorn.js"); var jsx = __webpack_require__(/*! acorn-jsx */ "./node_modules/acorn-jsx/index.js"); var visitorKeys = __webpack_require__(/*! eslint-visitor-keys */ "./node_modules/lebab/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs"); function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } function _interopNamespace(e) { if (e && e.__esModule) return e; var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { if (k !== 'default') { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, get: function () { return e[k]; } }); } }); } n["default"] = e; return Object.freeze(n); } var acorn__namespace = /*#__PURE__*/_interopNamespace(acorn); var jsx__default = /*#__PURE__*/_interopDefaultLegacy(jsx); var visitorKeys__namespace = /*#__PURE__*/_interopNamespace(visitorKeys); /** * @fileoverview Translates tokens between Acorn format and Esprima format. * @author Nicholas C. Zakas */ //------------------------------------------------------------------------------ // Requirements //------------------------------------------------------------------------------ // none! //------------------------------------------------------------------------------ // Private //------------------------------------------------------------------------------ // Esprima Token Types const Token = { Boolean: "Boolean", EOF: "", Identifier: "Identifier", PrivateIdentifier: "PrivateIdentifier", Keyword: "Keyword", Null: "Null", Numeric: "Numeric", Punctuator: "Punctuator", String: "String", RegularExpression: "RegularExpression", Template: "Template", JSXIdentifier: "JSXIdentifier", JSXText: "JSXText" }; /** * Converts part of a template into an Esprima token. * @param {AcornToken[]} tokens The Acorn tokens representing the template. * @param {string} code The source code. * @returns {EsprimaToken} The Esprima equivalent of the template token. * @private */ function convertTemplatePart(tokens, code) { const firstToken = tokens[0], lastTemplateToken = tokens[tokens.length - 1]; const token = { type: Token.Template, value: code.slice(firstToken.start, lastTemplateToken.end) }; if (firstToken.loc) { token.loc = { start: firstToken.loc.start, end: lastTemplateToken.loc.end }; } if (firstToken.range) { token.start = firstToken.range[0]; token.end = lastTemplateToken.range[1]; token.range = [token.start, token.end]; } return token; } /** * Contains logic to translate Acorn tokens into Esprima tokens. * @param {Object} acornTokTypes The Acorn token types. * @param {string} code The source code Acorn is parsing. This is necessary * to correct the "value" property of some tokens. * @constructor */ function TokenTranslator(acornTokTypes, code) { // token types this._acornTokTypes = acornTokTypes; // token buffer for templates this._tokens = []; // track the last curly brace this._curlyBrace = null; // the source code this._code = code; } TokenTranslator.prototype = { constructor: TokenTranslator, /** * Translates a single Esprima token to a single Acorn token. This may be * inaccurate due to how templates are handled differently in Esprima and * Acorn, but should be accurate for all other tokens. * @param {AcornToken} token The Acorn token to translate. * @param {Object} extra Espree extra object. * @returns {EsprimaToken} The Esprima version of the token. */ translate(token, extra) { const type = token.type, tt = this._acornTokTypes; if (type === tt.name) { token.type = Token.Identifier; // TODO: See if this is an Acorn bug if (token.value === "static") { token.type = Token.Keyword; } if (extra.ecmaVersion > 5 && (token.value === "yield" || token.value === "let")) { token.type = Token.Keyword; } } else if (type === tt.privateId) { token.type = Token.PrivateIdentifier; } else if (type === tt.semi || type === tt.comma || type === tt.parenL || type === tt.parenR || type === tt.braceL || type === tt.braceR || type === tt.dot || type === tt.bracketL || type === tt.colon || type === tt.question || type === tt.bracketR || type === tt.ellipsis || type === tt.arrow || type === tt.jsxTagStart || type === tt.incDec || type === tt.starstar || type === tt.jsxTagEnd || type === tt.prefix || type === tt.questionDot || (type.binop && !type.keyword) || type.isAssign) { token.type = Token.Punctuator; token.value = this._code.slice(token.start, token.end); } else if (type === tt.jsxName) { token.type = Token.JSXIdentifier; } else if (type.label === "jsxText" || type === tt.jsxAttrValueToken) { token.type = Token.JSXText; } else if (type.keyword) { if (type.keyword === "true" || type.keyword === "false") { token.type = Token.Boolean; } else if (type.keyword === "null") { token.type = Token.Null; } else { token.type = Token.Keyword; } } else if (type === tt.num) { token.type = Token.Numeric; token.value = this._code.slice(token.start, token.end); } else if (type === tt.string) { if (extra.jsxAttrValueToken) { extra.jsxAttrValueToken = false; token.type = Token.JSXText; } else { token.type = Token.String; } token.value = this._code.slice(token.start, token.end); } else if (type === tt.regexp) { token.type = Token.RegularExpression; const value = token.value; token.regex = { flags: value.flags, pattern: value.pattern }; token.value = `/${value.pattern}/${value.flags}`; } return token; }, /** * Function to call during Acorn's onToken handler. * @param {AcornToken} token The Acorn token. * @param {Object} extra The Espree extra object. * @returns {void} */ onToken(token, extra) { const tt = this._acornTokTypes, tokens = extra.tokens, templateTokens = this._tokens; /** * Flushes the buffered template tokens and resets the template * tracking. * @returns {void} * @private */ const translateTemplateTokens = () => { tokens.push(convertTemplatePart(this._tokens, this._code)); this._tokens = []; }; if (token.type === tt.eof) { // might be one last curlyBrace if (this._curlyBrace) { tokens.push(this.translate(this._curlyBrace, extra)); } return; } if (token.type === tt.backQuote) { // if there's already a curly, it's not part of the template if (this._curlyBrace) { tokens.push(this.translate(this._curlyBrace, extra)); this._curlyBrace = null; } templateTokens.push(token); // it's the end if (templateTokens.length > 1) { translateTemplateTokens(); } return; } if (token.type === tt.dollarBraceL) { templateTokens.push(token); translateTemplateTokens(); return; } if (token.type === tt.braceR) { // if there's already a curly, it's not part of the template if (this._curlyBrace) { tokens.push(this.translate(this._curlyBrace, extra)); } // store new curly for later this._curlyBrace = token; return; } if (token.type === tt.template || token.type === tt.invalidTemplate) { if (this._curlyBrace) { templateTokens.push(this._curlyBrace); this._curlyBrace = null; } templateTokens.push(token); return; } if (this._curlyBrace) { tokens.push(this.translate(this._curlyBrace, extra)); this._curlyBrace = null; } tokens.push(this.translate(token, extra)); } }; /** * @fileoverview A collection of methods for processing Espree's options. * @author Kai Cataldo */ //------------------------------------------------------------------------------ // Helpers //------------------------------------------------------------------------------ const SUPPORTED_VERSIONS = [ 3, 5, 6, // 2015 7, // 2016 8, // 2017 9, // 2018 10, // 2019 11, // 2020 12, // 2021 13, // 2022 14, // 2023 15 // 2024 ]; /** * Get the latest ECMAScript version supported by Espree. * @returns {number} The latest ECMAScript version. */ function getLatestEcmaVersion() { return SUPPORTED_VERSIONS[SUPPORTED_VERSIONS.length - 1]; } /** * Get the list of ECMAScript versions supported by Espree. * @returns {number[]} An array containing the supported ECMAScript versions. */ function getSupportedEcmaVersions() { return [...SUPPORTED_VERSIONS]; } /** * Normalize ECMAScript version from the initial config * @param {(number|"latest")} ecmaVersion ECMAScript version from the initial config * @throws {Error} throws an error if the ecmaVersion is invalid. * @returns {number} normalized ECMAScript version */ function normalizeEcmaVersion(ecmaVersion = 5) { let version = ecmaVersion === "latest" ? getLatestEcmaVersion() : ecmaVersion; if (typeof version !== "number") { throw new Error(`ecmaVersion must be a number or "latest". Received value of type ${typeof ecmaVersion} instead.`); } // Calculate ECMAScript edition number from official year version starting with // ES2015, which corresponds with ES6 (or a difference of 2009). if (version >= 2015) { version -= 2009; } if (!SUPPORTED_VERSIONS.includes(version)) { throw new Error("Invalid ecmaVersion."); } return version; } /** * Normalize sourceType from the initial config * @param {string} sourceType to normalize * @throws {Error} throw an error if sourceType is invalid * @returns {string} normalized sourceType */ function normalizeSourceType(sourceType = "script") { if (sourceType === "script" || sourceType === "module") { return sourceType; } if (sourceType === "commonjs") { return "script"; } throw new Error("Invalid sourceType."); } /** * Normalize parserOptions * @param {Object} options the parser options to normalize * @throws {Error} throw an error if found invalid option. * @returns {Object} normalized options */ function normalizeOptions(options) { const ecmaVersion = normalizeEcmaVersion(options.ecmaVersion); const sourceType = normalizeSourceType(options.sourceType); const ranges = options.range === true; const locations = options.loc === true; if (ecmaVersion !== 3 && options.allowReserved) { // a value of `false` is intentionally allowed here, so a shared config can overwrite it when needed throw new Error("`allowReserved` is only supported when ecmaVersion is 3"); } if (typeof options.allowReserved !== "undefined" && typeof options.allowReserved !== "boolean") { throw new Error("`allowReserved`, when present, must be `true` or `false`"); } const allowReserved = ecmaVersion === 3 ? (options.allowReserved || "never") : false; const ecmaFeatures = options.ecmaFeatures || {}; const allowReturnOutsideFunction = options.sourceType === "commonjs" || Boolean(ecmaFeatures.globalReturn); if (sourceType === "module" && ecmaVersion < 6) { throw new Error("sourceType 'module' is not supported when ecmaVersion < 2015. Consider adding `{ ecmaVersion: 2015 }` to the parser options."); } return Object.assign({}, options, { ecmaVersion, sourceType, ranges, locations, allowReserved, allowReturnOutsideFunction }); } /* eslint no-param-reassign: 0 -- stylistic choice */ const STATE = Symbol("espree's internal state"); const ESPRIMA_FINISH_NODE = Symbol("espree's esprimaFinishNode"); /** * Converts an Acorn comment to a Esprima comment. * @param {boolean} block True if it's a block comment, false if not. * @param {string} text The text of the comment. * @param {int} start The index at which the comment starts. * @param {int} end The index at which the comment ends. * @param {Location} startLoc The location at which the comment starts. * @param {Location} endLoc The location at which the comment ends. * @param {string} code The source code being parsed. * @returns {Object} The comment object. * @private */ function convertAcornCommentToEsprimaComment(block, text, start, end, startLoc, endLoc, code) { let type; if (block) { type = "Block"; } else if (code.slice(start, start + 2) === "#!") { type = "Hashbang"; } else { type = "Line"; } const comment = { type, value: text }; if (typeof start === "number") { comment.start = start; comment.end = end; comment.range = [start, end]; } if (typeof startLoc === "object") { comment.loc = { start: startLoc, end: endLoc }; } return comment; } var espree = () => Parser => { const tokTypes = Object.assign({}, Parser.acorn.tokTypes); if (Parser.acornJsx) { Object.assign(tokTypes, Parser.acornJsx.tokTypes); } return class Espree extends Parser { constructor(opts, code) { if (typeof opts !== "object" || opts === null) { opts = {}; } if (typeof code !== "string" && !(code instanceof String)) { code = String(code); } // save original source type in case of commonjs const originalSourceType = opts.sourceType; const options = normalizeOptions(opts); const ecmaFeatures = options.ecmaFeatures || {}; const tokenTranslator = options.tokens === true ? new TokenTranslator(tokTypes, code) : null; /* * Data that is unique to Espree and is not represented internally * in Acorn. * * For ES2023 hashbangs, Espree will call `onComment()` during the * constructor, so we must define state before having access to * `this`. */ const state = { originalSourceType: originalSourceType || options.sourceType, tokens: tokenTranslator ? [] : null, comments: options.comment === true ? [] : null, impliedStrict: ecmaFeatures.impliedStrict === true && options.ecmaVersion >= 5, ecmaVersion: options.ecmaVersion, jsxAttrValueToken: false, lastToken: null, templateElements: [] }; // Initialize acorn parser. super({ // do not use spread, because we don't want to pass any unknown options to acorn ecmaVersion: options.ecmaVersion, sourceType: options.sourceType, ranges: options.ranges, locations: options.locations, allowReserved: options.allowReserved, // Truthy value is true for backward compatibility. allowReturnOutsideFunction: options.allowReturnOutsideFunction, // Collect tokens onToken(token) { if (tokenTranslator) { // Use `tokens`, `ecmaVersion`, and `jsxAttrValueToken` in the state. tokenTranslator.onToken(token, state); } if (token.type !== tokTypes.eof) { state.lastToken = token; } }, // Collect comments onComment(block, text, start, end, startLoc, endLoc) { if (state.comments) { const comment = convertAcornCommentToEsprimaComment(block, text, start, end, startLoc, endLoc, code); state.comments.push(comment); } } }, code); /* * We put all of this data into a symbol property as a way to avoid * potential naming conflicts with future versions of Acorn. */ this[STATE] = state; } tokenize() { do { this.next(); } while (this.type !== tokTypes.eof); // Consume the final eof token this.next(); const extra = this[STATE]; const tokens = extra.tokens; if (extra.comments) { tokens.comments = extra.comments; } return tokens; } finishNode(...args) { const result = super.finishNode(...args); return this[ESPRIMA_FINISH_NODE](result); } finishNodeAt(...args) { const result = super.finishNodeAt(...args); return this[ESPRIMA_FINISH_NODE](result); } parse() { const extra = this[STATE]; const program = super.parse(); program.sourceType = extra.originalSourceType; if (extra.comments) { program.comments = extra.comments; } if (extra.tokens) { program.tokens = extra.tokens; } /* * Adjust opening and closing position of program to match Esprima. * Acorn always starts programs at range 0 whereas Esprima starts at the * first AST node's start (the only real difference is when there's leading * whitespace or leading comments). Acorn also counts trailing whitespace * as part of the program whereas Esprima only counts up to the last token. */ if (program.body.length) { const [firstNode] = program.body; if (program.range) { program.range[0] = firstNode.range[0]; } if (program.loc) { program.loc.start = firstNode.loc.start; } program.start = firstNode.start; } if (extra.lastToken) { if (program.range) { program.range[1] = extra.lastToken.range[1]; } if (program.loc) { program.loc.end = extra.lastToken.loc.end; } program.end = extra.lastToken.end; } /* * https://github.com/eslint/espree/issues/349 * Ensure that template elements have correct range information. * This is one location where Acorn produces a different value * for its start and end properties vs. the values present in the * range property. In order to avoid confusion, we set the start * and end properties to the values that are present in range. * This is done here, instead of in finishNode(), because Acorn * uses the values of start and end internally while parsing, making * it dangerous to change those values while parsing is ongoing. * By waiting until the end of parsing, we can safely change these * values without affect any other part of the process. */ this[STATE].templateElements.forEach(templateElement => { const startOffset = -1; const endOffset = templateElement.tail ? 1 : 2; templateElement.start += startOffset; templateElement.end += endOffset; if (templateElement.range) { templateElement.range[0] += startOffset; templateElement.range[1] += endOffset; } if (templateElement.loc) { templateElement.loc.start.column += startOffset; templateElement.loc.end.column += endOffset; } }); return program; } parseTopLevel(node) { if (this[STATE].impliedStrict) { this.strict = true; } return super.parseTopLevel(node); } /** * Overwrites the default raise method to throw Esprima-style errors. * @param {int} pos The position of the error. * @param {string} message The error message. * @throws {SyntaxError} A syntax error. * @returns {void} */ raise(pos, message) { const loc = Parser.acorn.getLineInfo(this.input, pos); const err = new SyntaxError(message); err.index = pos; err.lineNumber = loc.line; err.column = loc.column + 1; // acorn uses 0-based columns throw err; } /** * Overwrites the default raise method to throw Esprima-style errors. * @param {int} pos The position of the error. * @param {string} message The error message. * @throws {SyntaxError} A syntax error. * @returns {void} */ raiseRecoverable(pos, message) { this.raise(pos, message); } /** * Overwrites the default unexpected method to throw Esprima-style errors. * @param {int} pos The position of the error. * @throws {SyntaxError} A syntax error. * @returns {void} */ unexpected(pos) { let message = "Unexpected token"; if (pos !== null && pos !== void 0) { this.pos = pos; if (this.options.locations) { while (this.pos < this.lineStart) { this.lineStart = this.input.lastIndexOf("\n", this.lineStart - 2) + 1; --this.curLine; } } this.nextToken(); } if (this.end > this.start) { message += ` ${this.input.slice(this.start, this.end)}`; } this.raise(this.start, message); } /* * Esprima-FB represents JSX strings as tokens called "JSXText", but Acorn-JSX * uses regular tt.string without any distinction between this and regular JS * strings. As such, we intercept an attempt to read a JSX string and set a flag * on extra so that when tokens are converted, the next token will be switched * to JSXText via onToken. */ jsx_readString(quote) { // eslint-disable-line camelcase -- required by API const result = super.jsx_readString(quote); if (this.type === tokTypes.string) { this[STATE].jsxAttrValueToken = true; } return result; } /** * Performs last-minute Esprima-specific compatibility checks and fixes. * @param {ASTNode} result The node to check. * @returns {ASTNode} The finished node. */ [ESPRIMA_FINISH_NODE](result) { // Acorn doesn't count the opening and closing backticks as part of templates // so we have to adjust ranges/locations appropriately. if (result.type === "TemplateElement") { // save template element references to fix start/end later this[STATE].templateElements.push(result); } if (result.type.includes("Function") && !result.generator) { result.generator = false; } return result; } }; }; const version$1 = "9.6.1"; /* eslint-disable jsdoc/no-multi-asterisks -- needed to preserve original formatting of licences */ // To initialize lazily. const parsers = { _regular: null, _jsx: null, get regular() { if (this._regular === null) { this._regular = acorn__namespace.Parser.extend(espree()); } return this._regular; }, get jsx() { if (this._jsx === null) { this._jsx = acorn__namespace.Parser.extend(jsx__default["default"](), espree()); } return this._jsx; }, get(options) { const useJsx = Boolean( options && options.ecmaFeatures && options.ecmaFeatures.jsx ); return useJsx ? this.jsx : this.regular; } }; //------------------------------------------------------------------------------ // Tokenizer //------------------------------------------------------------------------------ /** * Tokenizes the given code. * @param {string} code The code to tokenize. * @param {Object} options Options defining how to tokenize. * @returns {Token[]} An array of tokens. * @throws {SyntaxError} If the input code is invalid. * @private */ function tokenize(code, options) { const Parser = parsers.get(options); // Ensure to collect tokens. if (!options || options.tokens !== true) { options = Object.assign({}, options, { tokens: true }); // eslint-disable-line no-param-reassign -- stylistic choice } return new Parser(options, code).tokenize(); } //------------------------------------------------------------------------------ // Parser //------------------------------------------------------------------------------ /** * Parses the given code. * @param {string} code The code to tokenize. * @param {Object} options Options defining how to tokenize. * @returns {ASTNode} The "Program" AST node. * @throws {SyntaxError} If the input code is invalid. */ function parse(code, options) { const Parser = parsers.get(options); return new Parser(options, code).parse(); } //------------------------------------------------------------------------------ // Public //------------------------------------------------------------------------------ const version = version$1; const name = "espree"; /* istanbul ignore next */ const VisitorKeys = (function() { return visitorKeys__namespace.KEYS; }()); // Derive node types from VisitorKeys /* istanbul ignore next */ const Syntax = (function() { let key, types = {}; if (typeof Object.create === "function") { types = Object.create(null); } for (key in VisitorKeys) { if (Object.hasOwnProperty.call(VisitorKeys, key)) { types[key] = key; } } if (typeof Object.freeze === "function") { Object.freeze(types); } return types; }()); const latestEcmaVersion = getLatestEcmaVersion(); const supportedEcmaVersions = getSupportedEcmaVersions(); exports.Syntax = Syntax; exports.VisitorKeys = VisitorKeys; exports.latestEcmaVersion = latestEcmaVersion; exports.name = name; exports.parse = parse; exports.supportedEcmaVersions = supportedEcmaVersions; exports.tokenize = tokenize; exports.version = version; /***/ }), /***/ "./node_modules/lodash/fp.js": /*!***********************************!*\ !*** ./node_modules/lodash/fp.js ***! \***********************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { var _ = (__webpack_require__(/*! ./lodash.min */ "./node_modules/lodash/lodash.min.js").runInContext)(); module.exports = __webpack_require__(/*! ./fp/_baseConvert */ "./node_modules/lodash/fp/_baseConvert.js")(_, _); /***/ }), /***/ "./node_modules/lodash/fp/_baseConvert.js": /*!************************************************!*\ !*** ./node_modules/lodash/fp/_baseConvert.js ***! \************************************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { var mapping = __webpack_require__(/*! ./_mapping */ "./node_modules/lodash/fp/_mapping.js"), fallbackHolder = __webpack_require__(/*! ./placeholder */ "./node_modules/lodash/fp/placeholder.js"); /** Built-in value reference. */ var push = Array.prototype.push; /** * Creates a function, with an arity of `n`, that invokes `func` with the * arguments it receives. * * @private * @param {Function} func The function to wrap. * @param {number} n The arity of the new function. * @returns {Function} Returns the new function. */ function baseArity(func, n) { return n == 2 ? function(a, b) { return func.apply(undefined, arguments); } : function(a) { return func.apply(undefined, arguments); }; } /** * Creates a function that invokes `func`, with up to `n` arguments, ignoring * any additional arguments. * * @private * @param {Function} func The function to cap arguments for. * @param {number} n The arity cap. * @returns {Function} Returns the new function. */ function baseAry(func, n) { return n == 2 ? function(a, b) { return func(a, b); } : function(a) { return func(a); }; } /** * Creates a clone of `array`. * * @private * @param {Array} array The array to clone. * @returns {Array} Returns the cloned array. */ function cloneArray(array) { var length = array ? array.length : 0, result = Array(length); while (length--) { result[length] = array[length]; } return result; } /** * Creates a function that clones a given object using the assignment `func`. * * @private * @param {Function} func The assignment function. * @returns {Function} Returns the new cloner function. */ function createCloner(func) { return function(object) { return func({}, object); }; } /** * A specialized version of `_.spread` which flattens the spread array into * the arguments of the invoked `func`. * * @private * @param {Function} func The function to spread arguments over. * @param {number} start The start position of the spread. * @returns {Function} Returns the new function. */ function flatSpread(func, start) { return function() { var length = arguments.length, lastIndex = length - 1, args = Array(length); while (length--) { args[length] = arguments[length]; } var array = args[start], otherArgs = args.slice(0, start); if (array) { push.apply(otherArgs, array); } if (start != lastIndex) { push.apply(otherArgs, args.slice(start + 1)); } return func.apply(this, otherArgs); }; } /** * Creates a function that wraps `func` and uses `cloner` to clone the first * argument it receives. * * @private * @param {Function} func The function to wrap. * @param {Function} cloner The function to clone arguments. * @returns {Function} Returns the new immutable function. */ function wrapImmutable(func, cloner) { return function() { var length = arguments.length; if (!length) { return; } var args = Array(length); while (length--) { args[length] = arguments[length]; } var result = args[0] = cloner.apply(undefined, args); func.apply(undefined, args); return result; }; } /** * The base implementation of `convert` which accepts a `util` object of methods * required to perform conversions. * * @param {Object} util The util object. * @param {string} name The name of the function to convert. * @param {Function} func The function to convert. * @param {Object} [options] The options object. * @param {boolean} [options.cap=true] Specify capping iteratee arguments. * @param {boolean} [options.curry=true] Specify currying. * @param {boolean} [options.fixed=true] Specify fixed arity. * @param {boolean} [options.immutable=true] Specify immutable operations. * @param {boolean} [options.rearg=true] Specify rearranging arguments. * @returns {Function|Object} Returns the converted function or object. */ function baseConvert(util, name, func, options) { var isLib = typeof name == 'function', isObj = name === Object(name); if (isObj) { options = func; func = name; name = undefined; } if (func == null) { throw new TypeError; } options || (options = {}); var config = { 'cap': 'cap' in options ? options.cap : true, 'curry': 'curry' in options ? options.curry : true, 'fixed': 'fixed' in options ? options.fixed : true, 'immutable': 'immutable' in options ? options.immutable : true, 'rearg': 'rearg' in options ? options.rearg : true }; var defaultHolder = isLib ? func : fallbackHolder, forceCurry = ('curry' in options) && options.curry, forceFixed = ('fixed' in options) && options.fixed, forceRearg = ('rearg' in options) && options.rearg, pristine = isLib ? func.runInContext() : undefined; var helpers = isLib ? func : { 'ary': util.ary, 'assign': util.assign, 'clone': util.clone, 'curry': util.curry, 'forEach': util.forEach, 'isArray': util.isArray, 'isError': util.isError, 'isFunction': util.isFunction, 'isWeakMap': util.isWeakMap, 'iteratee': util.iteratee, 'keys': util.keys, 'rearg': util.rearg, 'toInteger': util.toInteger, 'toPath': util.toPath }; var ary = helpers.ary, assign = helpers.assign, clone = helpers.clone, curry = helpers.curry, each = helpers.forEach, isArray = helpers.isArray, isError = helpers.isError, isFunction = helpers.isFunction, isWeakMap = helpers.isWeakMap, keys = helpers.keys, rearg = helpers.rearg, toInteger = helpers.toInteger, toPath = helpers.toPath; var aryMethodKeys = keys(mapping.aryMethod); var wrappers = { 'castArray': function(castArray) { return function() { var value = arguments[0]; return isArray(value) ? castArray(cloneArray(value)) : castArray.apply(undefined, arguments); }; }, 'iteratee': function(iteratee) { return function() { var func = arguments[0], arity = arguments[1], result = iteratee(func, arity), length = result.length; if (config.cap && typeof arity == 'number') { arity = arity > 2 ? (arity - 2) : 1; return (length && length <= arity) ? result : baseAry(result, arity); } return result; }; }, 'mixin': function(mixin) { return function(source) { var func = this; if (!isFunction(func)) { return mixin(func, Object(source)); } var pairs = []; each(keys(source), function(key) { if (isFunction(source[key])) { pairs.push([key, func.prototype[key]]); } }); mixin(func, Object(source)); each(pairs, function(pair) { var value = pair[1]; if (isFunction(value)) { func.prototype[pair[0]] = value; } else { delete func.prototype[pair[0]]; } }); return func; }; }, 'nthArg': function(nthArg) { return function(n) { var arity = n < 0 ? 1 : (toInteger(n) + 1); return curry(nthArg(n), arity); }; }, 'rearg': function(rearg) { return function(func, indexes) { var arity = indexes ? indexes.length : 0; return curry(rearg(func, indexes), arity); }; }, 'runInContext': function(runInContext) { return function(context) { return baseConvert(util, runInContext(context), options); }; } }; /*--------------------------------------------------------------------------*/ /** * Casts `func` to a function with an arity capped iteratee if needed. * * @private * @param {string} name The name of the function to inspect. * @param {Function} func The function to inspect. * @returns {Function} Returns the cast function. */ function castCap(name, func) { if (config.cap) { var indexes = mapping.iterateeRearg[name]; if (indexes) { return iterateeRearg(func, indexes); } var n = !isLib && mapping.iterateeAry[name]; if (n) { return iterateeAry(func, n); } } return func; } /** * Casts `func` to a curried function if needed. * * @private * @param {string} name The name of the function to inspect. * @param {Function} func The function to inspect. * @param {number} n The arity of `func`. * @returns {Function} Returns the cast function. */ function castCurry(name, func, n) { return (forceCurry || (config.curry && n > 1)) ? curry(func, n) : func; } /** * Casts `func` to a fixed arity function if needed. * * @private * @param {string} name The name of the function to inspect. * @param {Function} func The function to inspect. * @param {number} n The arity cap. * @returns {Function} Returns the cast function. */ function castFixed(name, func, n) { if (config.fixed && (forceFixed || !mapping.skipFixed[name])) { var data = mapping.methodSpread[name], start = data && data.start; return start === undefined ? ary(func, n) : flatSpread(func, start); } return func; } /** * Casts `func` to an rearged function if needed. * * @private * @param {string} name The name of the function to inspect. * @param {Function} func The function to inspect. * @param {number} n The arity of `func`. * @returns {Function} Returns the cast function. */ function castRearg(name, func, n) { return (config.rearg && n > 1 && (forceRearg || !mapping.skipRearg[name])) ? rearg(func, mapping.methodRearg[name] || mapping.aryRearg[n]) : func; } /** * Creates a clone of `object` by `path`. * * @private * @param {Object} object The object to clone. * @param {Array|string} path The path to clone by. * @returns {Object} Returns the cloned object. */ function cloneByPath(object, path) { path = toPath(path); var index = -1, length = path.length, lastIndex = length - 1, result = clone(Object(object)), nested = result; while (nested != null && ++index < length) { var key = path[index], value = nested[key]; if (value != null && !(isFunction(value) || isError(value) || isWeakMap(value))) { nested[key] = clone(index == lastIndex ? value : Object(value)); } nested = nested[key]; } return result; } /** * Converts `lodash` to an immutable auto-curried iteratee-first data-last * version with conversion `options` applied. * * @param {Object} [options] The options object. See `baseConvert` for more details. * @returns {Function} Returns the converted `lodash`. */ function convertLib(options) { return _.runInContext.convert(options)(undefined); } /** * Create a converter function for `func` of `name`. * * @param {string} name The name of the function to convert. * @param {Function} func The function to convert. * @returns {Function} Returns the new converter function. */ function createConverter(name, func) { var realName = mapping.aliasToReal[name] || name, methodName = mapping.remap[realName] || realName, oldOptions = options; return function(options) { var newUtil = isLib ? pristine : helpers, newFunc = isLib ? pristine[methodName] : func, newOptions = assign(assign({}, oldOptions), options); return baseConvert(newUtil, realName, newFunc, newOptions); }; } /** * Creates a function that wraps `func` to invoke its iteratee, with up to `n` * arguments, ignoring any additional arguments. * * @private * @param {Function} func The function to cap iteratee arguments for. * @param {number} n The arity cap. * @returns {Function} Returns the new function. */ function iterateeAry(func, n) { return overArg(func, function(func) { return typeof func == 'function' ? baseAry(func, n) : func; }); } /** * Creates a function that wraps `func` to invoke its iteratee with arguments * arranged according to the specified `indexes` where the argument value at * the first index is provided as the first argument, the argument value at * the second index is provided as the second argument, and so on. * * @private * @param {Function} func The function to rearrange iteratee arguments for. * @param {number[]} indexes The arranged argument indexes. * @returns {Function} Returns the new function. */ function iterateeRearg(func, indexes) { return overArg(func, function(func) { var n = indexes.length; return baseArity(rearg(baseAry(func, n), indexes), n); }); } /** * Creates a function that invokes `func` with its first argument transformed. * * @private * @param {Function} func The function to wrap. * @param {Function} transform The argument transform. * @returns {Function} Returns the new function. */ function overArg(func, transform) { return function() { var length = arguments.length; if (!length) { return func(); } var args = Array(length); while (length--) { args[length] = arguments[length]; } var index = config.rearg ? 0 : (length - 1); args[index] = transform(args[index]); return func.apply(undefined, args); }; } /** * Creates a function that wraps `func` and applys the conversions * rules by `name`. * * @private * @param {string} name The name of the function to wrap. * @param {Function} func The function to wrap. * @returns {Function} Returns the converted function. */ function wrap(name, func, placeholder) { var result, realName = mapping.aliasToReal[name] || name, wrapped = func, wrapper = wrappers[realName]; if (wrapper) { wrapped = wrapper(func); } else if (config.immutable) { if (mapping.mutate.array[realName]) { wrapped = wrapImmutable(func, cloneArray); } else if (mapping.mutate.object[realName]) { wrapped = wrapImmutable(func, createCloner(func)); } else if (mapping.mutate.set[realName]) { wrapped = wrapImmutable(func, cloneByPath); } } each(aryMethodKeys, function(aryKey) { each(mapping.aryMethod[aryKey], function(otherName) { if (realName == otherName) { var data = mapping.methodSpread[realName], afterRearg = data && data.afterRearg; result = afterRearg ? castFixed(realName, castRearg(realName, wrapped, aryKey), aryKey) : castRearg(realName, castFixed(realName, wrapped, aryKey), aryKey); result = castCap(realName, result); result = castCurry(realName, result, aryKey); return false; } }); return !result; }); result || (result = wrapped); if (result == func) { result = forceCurry ? curry(result, 1) : function() { return func.apply(this, arguments); }; } result.convert = createConverter(realName, func); result.placeholder = func.placeholder = placeholder; return result; } /*--------------------------------------------------------------------------*/ if (!isObj) { return wrap(name, func, defaultHolder); } var _ = func; // Convert methods by ary cap. var pairs = []; each(aryMethodKeys, function(aryKey) { each(mapping.aryMethod[aryKey], function(key) { var func = _[mapping.remap[key] || key]; if (func) { pairs.push([key, wrap(key, func, _)]); } }); }); // Convert remaining methods. each(keys(_), function(key) { var func = _[key]; if (typeof func == 'function') { var length = pairs.length; while (length--) { if (pairs[length][0] == key) { return; } } func.convert = createConverter(key, func); pairs.push([key, func]); } }); // Assign to `_` leaving `_.prototype` unchanged to allow chaining. each(pairs, function(pair) { _[pair[0]] = pair[1]; }); _.convert = convertLib; _.placeholder = _; // Assign aliases. each(keys(_), function(key) { each(mapping.realToAlias[key] || [], function(alias) { _[alias] = _[key]; }); }); return _; } module.exports = baseConvert; /***/ }), /***/ "./node_modules/lodash/fp/_mapping.js": /*!********************************************!*\ !*** ./node_modules/lodash/fp/_mapping.js ***! \********************************************/ /***/ ((__unused_webpack_module, exports) => { /** Used to map aliases to their real names. */ exports.aliasToReal = { // Lodash aliases. 'each': 'forEach', 'eachRight': 'forEachRight', 'entries': 'toPairs', 'entriesIn': 'toPairsIn', 'extend': 'assignIn', 'extendAll': 'assignInAll', 'extendAllWith': 'assignInAllWith', 'extendWith': 'assignInWith', 'first': 'head', // Methods that are curried variants of others. 'conforms': 'conformsTo', 'matches': 'isMatch', 'property': 'get', // Ramda aliases. '__': 'placeholder', 'F': 'stubFalse', 'T': 'stubTrue', 'all': 'every', 'allPass': 'overEvery', 'always': 'constant', 'any': 'some', 'anyPass': 'overSome', 'apply': 'spread', 'assoc': 'set', 'assocPath': 'set', 'complement': 'negate', 'compose': 'flowRight', 'contains': 'includes', 'dissoc': 'unset', 'dissocPath': 'unset', 'dropLast': 'dropRight', 'dropLastWhile': 'dropRightWhile', 'equals': 'isEqual', 'identical': 'eq', 'indexBy': 'keyBy', 'init': 'initial', 'invertObj': 'invert', 'juxt': 'over', 'omitAll': 'omit', 'nAry': 'ary', 'path': 'get', 'pathEq': 'matchesProperty', 'pathOr': 'getOr', 'paths': 'at', 'pickAll': 'pick', 'pipe': 'flow', 'pluck': 'map', 'prop': 'get', 'propEq': 'matchesProperty', 'propOr': 'getOr', 'props': 'at', 'symmetricDifference': 'xor', 'symmetricDifferenceBy': 'xorBy', 'symmetricDifferenceWith': 'xorWith', 'takeLast': 'takeRight', 'takeLastWhile': 'takeRightWhile', 'unapply': 'rest', 'unnest': 'flatten', 'useWith': 'overArgs', 'where': 'conformsTo', 'whereEq': 'isMatch', 'zipObj': 'zipObject' }; /** Used to map ary to method names. */ exports.aryMethod = { '1': [ 'assignAll', 'assignInAll', 'attempt', 'castArray', 'ceil', 'create', 'curry', 'curryRight', 'defaultsAll', 'defaultsDeepAll', 'floor', 'flow', 'flowRight', 'fromPairs', 'invert', 'iteratee', 'memoize', 'method', 'mergeAll', 'methodOf', 'mixin', 'nthArg', 'over', 'overEvery', 'overSome','rest', 'reverse', 'round', 'runInContext', 'spread', 'template', 'trim', 'trimEnd', 'trimStart', 'uniqueId', 'words', 'zipAll' ], '2': [ 'add', 'after', 'ary', 'assign', 'assignAllWith', 'assignIn', 'assignInAllWith', 'at', 'before', 'bind', 'bindAll', 'bindKey', 'chunk', 'cloneDeepWith', 'cloneWith', 'concat', 'conformsTo', 'countBy', 'curryN', 'curryRightN', 'debounce', 'defaults', 'defaultsDeep', 'defaultTo', 'delay', 'difference', 'divide', 'drop', 'dropRight', 'dropRightWhile', 'dropWhile', 'endsWith', 'eq', 'every', 'filter', 'find', 'findIndex', 'findKey', 'findLast', 'findLastIndex', 'findLastKey', 'flatMap', 'flatMapDeep', 'flattenDepth', 'forEach', 'forEachRight', 'forIn', 'forInRight', 'forOwn', 'forOwnRight', 'get', 'groupBy', 'gt', 'gte', 'has', 'hasIn', 'includes', 'indexOf', 'intersection', 'invertBy', 'invoke', 'invokeMap', 'isEqual', 'isMatch', 'join', 'keyBy', 'lastIndexOf', 'lt', 'lte', 'map', 'mapKeys', 'mapValues', 'matchesProperty', 'maxBy', 'meanBy', 'merge', 'mergeAllWith', 'minBy', 'multiply', 'nth', 'omit', 'omitBy', 'overArgs', 'pad', 'padEnd', 'padStart', 'parseInt', 'partial', 'partialRight', 'partition', 'pick', 'pickBy', 'propertyOf', 'pull', 'pullAll', 'pullAt', 'random', 'range', 'rangeRight', 'rearg', 'reject', 'remove', 'repeat', 'restFrom', 'result', 'sampleSize', 'some', 'sortBy', 'sortedIndex', 'sortedIndexOf', 'sortedLastIndex', 'sortedLastIndexOf', 'sortedUniqBy', 'split', 'spreadFrom', 'startsWith', 'subtract', 'sumBy', 'take', 'takeRight', 'takeRightWhile', 'takeWhile', 'tap', 'throttle', 'thru', 'times', 'trimChars', 'trimCharsEnd', 'trimCharsStart', 'truncate', 'union', 'uniqBy', 'uniqWith', 'unset', 'unzipWith', 'without', 'wrap', 'xor', 'zip', 'zipObject', 'zipObjectDeep' ], '3': [ 'assignInWith', 'assignWith', 'clamp', 'differenceBy', 'differenceWith', 'findFrom', 'findIndexFrom', 'findLastFrom', 'findLastIndexFrom', 'getOr', 'includesFrom', 'indexOfFrom', 'inRange', 'intersectionBy', 'intersectionWith', 'invokeArgs', 'invokeArgsMap', 'isEqualWith', 'isMatchWith', 'flatMapDepth', 'lastIndexOfFrom', 'mergeWith', 'orderBy', 'padChars', 'padCharsEnd', 'padCharsStart', 'pullAllBy', 'pullAllWith', 'rangeStep', 'rangeStepRight', 'reduce', 'reduceRight', 'replace', 'set', 'slice', 'sortedIndexBy', 'sortedLastIndexBy', 'transform', 'unionBy', 'unionWith', 'update', 'xorBy', 'xorWith', 'zipWith' ], '4': [ 'fill', 'setWith', 'updateWith' ] }; /** Used to map ary to rearg configs. */ exports.aryRearg = { '2': [1, 0], '3': [2, 0, 1], '4': [3, 2, 0, 1] }; /** Used to map method names to their iteratee ary. */ exports.iterateeAry = { 'dropRightWhile': 1, 'dropWhile': 1, 'every': 1, 'filter': 1, 'find': 1, 'findFrom': 1, 'findIndex': 1, 'findIndexFrom': 1, 'findKey': 1, 'findLast': 1, 'findLastFrom': 1, 'findLastIndex': 1, 'findLastIndexFrom': 1, 'findLastKey': 1, 'flatMap': 1, 'flatMapDeep': 1, 'flatMapDepth': 1, 'forEach': 1, 'forEachRight': 1, 'forIn': 1, 'forInRight': 1, 'forOwn': 1, 'forOwnRight': 1, 'map': 1, 'mapKeys': 1, 'mapValues': 1, 'partition': 1, 'reduce': 2, 'reduceRight': 2, 'reject': 1, 'remove': 1, 'some': 1, 'takeRightWhile': 1, 'takeWhile': 1, 'times': 1, 'transform': 2 }; /** Used to map method names to iteratee rearg configs. */ exports.iterateeRearg = { 'mapKeys': [1], 'reduceRight': [1, 0] }; /** Used to map method names to rearg configs. */ exports.methodRearg = { 'assignInAllWith': [1, 0], 'assignInWith': [1, 2, 0], 'assignAllWith': [1, 0], 'assignWith': [1, 2, 0], 'differenceBy': [1, 2, 0], 'differenceWith': [1, 2, 0], 'getOr': [2, 1, 0], 'intersectionBy': [1, 2, 0], 'intersectionWith': [1, 2, 0], 'isEqualWith': [1, 2, 0], 'isMatchWith': [2, 1, 0], 'mergeAllWith': [1, 0], 'mergeWith': [1, 2, 0], 'padChars': [2, 1, 0], 'padCharsEnd': [2, 1, 0], 'padCharsStart': [2, 1, 0], 'pullAllBy': [2, 1, 0], 'pullAllWith': [2, 1, 0], 'rangeStep': [1, 2, 0], 'rangeStepRight': [1, 2, 0], 'setWith': [3, 1, 2, 0], 'sortedIndexBy': [2, 1, 0], 'sortedLastIndexBy': [2, 1, 0], 'unionBy': [1, 2, 0], 'unionWith': [1, 2, 0], 'updateWith': [3, 1, 2, 0], 'xorBy': [1, 2, 0], 'xorWith': [1, 2, 0], 'zipWith': [1, 2, 0] }; /** Used to map method names to spread configs. */ exports.methodSpread = { 'assignAll': { 'start': 0 }, 'assignAllWith': { 'start': 0 }, 'assignInAll': { 'start': 0 }, 'assignInAllWith': { 'start': 0 }, 'defaultsAll': { 'start': 0 }, 'defaultsDeepAll': { 'start': 0 }, 'invokeArgs': { 'start': 2 }, 'invokeArgsMap': { 'start': 2 }, 'mergeAll': { 'start': 0 }, 'mergeAllWith': { 'start': 0 }, 'partial': { 'start': 1 }, 'partialRight': { 'start': 1 }, 'without': { 'start': 1 }, 'zipAll': { 'start': 0 } }; /** Used to identify methods which mutate arrays or objects. */ exports.mutate = { 'array': { 'fill': true, 'pull': true, 'pullAll': true, 'pullAllBy': true, 'pullAllWith': true, 'pullAt': true, 'remove': true, 'reverse': true }, 'object': { 'assign': true, 'assignAll': true, 'assignAllWith': true, 'assignIn': true, 'assignInAll': true, 'assignInAllWith': true, 'assignInWith': true, 'assignWith': true, 'defaults': true, 'defaultsAll': true, 'defaultsDeep': true, 'defaultsDeepAll': true, 'merge': true, 'mergeAll': true, 'mergeAllWith': true, 'mergeWith': true, }, 'set': { 'set': true, 'setWith': true, 'unset': true, 'update': true, 'updateWith': true } }; /** Used to map real names to their aliases. */ exports.realToAlias = (function() { var hasOwnProperty = Object.prototype.hasOwnProperty, object = exports.aliasToReal, result = {}; for (var key in object) { var value = object[key]; if (hasOwnProperty.call(result, value)) { result[value].push(key); } else { result[value] = [key]; } } return result; }()); /** Used to map method names to other names. */ exports.remap = { 'assignAll': 'assign', 'assignAllWith': 'assignWith', 'assignInAll': 'assignIn', 'assignInAllWith': 'assignInWith', 'curryN': 'curry', 'curryRightN': 'curryRight', 'defaultsAll': 'defaults', 'defaultsDeepAll': 'defaultsDeep', 'findFrom': 'find', 'findIndexFrom': 'findIndex', 'findLastFrom': 'findLast', 'findLastIndexFrom': 'findLastIndex', 'getOr': 'get', 'includesFrom': 'includes', 'indexOfFrom': 'indexOf', 'invokeArgs': 'invoke', 'invokeArgsMap': 'invokeMap', 'lastIndexOfFrom': 'lastIndexOf', 'mergeAll': 'merge', 'mergeAllWith': 'mergeWith', 'padChars': 'pad', 'padCharsEnd': 'padEnd', 'padCharsStart': 'padStart', 'propertyOf': 'get', 'rangeStep': 'range', 'rangeStepRight': 'rangeRight', 'restFrom': 'rest', 'spreadFrom': 'spread', 'trimChars': 'trim', 'trimCharsEnd': 'trimEnd', 'trimCharsStart': 'trimStart', 'zipAll': 'zip' }; /** Used to track methods that skip fixing their arity. */ exports.skipFixed = { 'castArray': true, 'flow': true, 'flowRight': true, 'iteratee': true, 'mixin': true, 'rearg': true, 'runInContext': true }; /** Used to track methods that skip rearranging arguments. */ exports.skipRearg = { 'add': true, 'assign': true, 'assignIn': true, 'bind': true, 'bindKey': true, 'concat': true, 'difference': true, 'divide': true, 'eq': true, 'gt': true, 'gte': true, 'isEqual': true, 'lt': true, 'lte': true, 'matchesProperty': true, 'merge': true, 'multiply': true, 'overArgs': true, 'partial': true, 'partialRight': true, 'propertyOf': true, 'random': true, 'range': true, 'rangeRight': true, 'subtract': true, 'zip': true, 'zipObject': true, 'zipObjectDeep': true }; /***/ }), /***/ "./node_modules/lodash/fp/placeholder.js": /*!***********************************************!*\ !*** ./node_modules/lodash/fp/placeholder.js ***! \***********************************************/ /***/ ((module) => { /** * The default argument placeholder value for methods. * * @type {Object} */ module.exports = {}; /***/ }), /***/ "./node_modules/lodash/lodash.min.js": /*!*******************************************!*\ !*** ./node_modules/lodash/lodash.min.js ***! \*******************************************/ /***/ (function(module, exports, __webpack_require__) { /* module decorator */ module = __webpack_require__.nmd(module); var __WEBPACK_AMD_DEFINE_RESULT__;/** * @license * Lodash * Copyright OpenJS Foundation and other contributors * Released under MIT license * Based on Underscore.js 1.8.3 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors */ (function(){function n(n,t,r){switch(r.length){case 0:return n.call(t);case 1:return n.call(t,r[0]);case 2:return n.call(t,r[0],r[1]);case 3:return n.call(t,r[0],r[1],r[2])}return n.apply(t,r)}function t(n,t,r,e){for(var u=-1,i=null==n?0:n.length;++u-1}function f(n,t,r){for(var e=-1,u=null==n?0:n.length;++e-1;);return r}function L(n,t){for(var r=n.length;r--&&y(t,n[r],0)>-1;);return r}function C(n,t){for(var r=n.length,e=0;r--;)n[r]===t&&++e; return e}function U(n){return"\\"+Yr[n]}function B(n,t){return null==n?X:n[t]}function T(n){return Nr.test(n)}function $(n){return Pr.test(n)}function D(n){for(var t,r=[];!(t=n.next()).done;)r.push(t.value);return r}function M(n){var t=-1,r=Array(n.size);return n.forEach(function(n,e){r[++t]=[e,n]}),r}function F(n,t){return function(r){return n(t(r))}}function N(n,t){for(var r=-1,e=n.length,u=0,i=[];++r>>1,$n=[["ary",mn],["bind",_n],["bindKey",vn],["curry",yn],["curryRight",dn],["flip",jn],["partial",bn],["partialRight",wn],["rearg",xn]],Dn="[object Arguments]",Mn="[object Array]",Fn="[object AsyncFunction]",Nn="[object Boolean]",Pn="[object Date]",qn="[object DOMException]",Zn="[object Error]",Kn="[object Function]",Vn="[object GeneratorFunction]",Gn="[object Map]",Hn="[object Number]",Jn="[object Null]",Yn="[object Object]",Qn="[object Promise]",Xn="[object Proxy]",nt="[object RegExp]",tt="[object Set]",rt="[object String]",et="[object Symbol]",ut="[object Undefined]",it="[object WeakMap]",ot="[object WeakSet]",ft="[object ArrayBuffer]",ct="[object DataView]",at="[object Float32Array]",lt="[object Float64Array]",st="[object Int8Array]",ht="[object Int16Array]",pt="[object Int32Array]",_t="[object Uint8Array]",vt="[object Uint8ClampedArray]",gt="[object Uint16Array]",yt="[object Uint32Array]",dt=/\b__p \+= '';/g,bt=/\b(__p \+=) '' \+/g,wt=/(__e\(.*?\)|\b__t\)) \+\n'';/g,mt=/&(?:amp|lt|gt|quot|#39);/g,xt=/[&<>"']/g,jt=RegExp(mt.source),At=RegExp(xt.source),kt=/<%-([\s\S]+?)%>/g,Ot=/<%([\s\S]+?)%>/g,It=/<%=([\s\S]+?)%>/g,Rt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,zt=/^\w*$/,Et=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,St=/[\\^$.*+?()[\]{}|]/g,Wt=RegExp(St.source),Lt=/^\s+/,Ct=/\s/,Ut=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Bt=/\{\n\/\* \[wrapped with (.+)\] \*/,Tt=/,? & /,$t=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Dt=/[()=,{}\[\]\/\s]/,Mt=/\\(\\)?/g,Ft=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Nt=/\w*$/,Pt=/^[-+]0x[0-9a-f]+$/i,qt=/^0b[01]+$/i,Zt=/^\[object .+?Constructor\]$/,Kt=/^0o[0-7]+$/i,Vt=/^(?:0|[1-9]\d*)$/,Gt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Ht=/($^)/,Jt=/['\n\r\u2028\u2029\\]/g,Yt="\\ud800-\\udfff",Qt="\\u0300-\\u036f",Xt="\\ufe20-\\ufe2f",nr="\\u20d0-\\u20ff",tr=Qt+Xt+nr,rr="\\u2700-\\u27bf",er="a-z\\xdf-\\xf6\\xf8-\\xff",ur="\\xac\\xb1\\xd7\\xf7",ir="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",or="\\u2000-\\u206f",fr=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",cr="A-Z\\xc0-\\xd6\\xd8-\\xde",ar="\\ufe0e\\ufe0f",lr=ur+ir+or+fr,sr="['\u2019]",hr="["+Yt+"]",pr="["+lr+"]",_r="["+tr+"]",vr="\\d+",gr="["+rr+"]",yr="["+er+"]",dr="[^"+Yt+lr+vr+rr+er+cr+"]",br="\\ud83c[\\udffb-\\udfff]",wr="(?:"+_r+"|"+br+")",mr="[^"+Yt+"]",xr="(?:\\ud83c[\\udde6-\\uddff]){2}",jr="[\\ud800-\\udbff][\\udc00-\\udfff]",Ar="["+cr+"]",kr="\\u200d",Or="(?:"+yr+"|"+dr+")",Ir="(?:"+Ar+"|"+dr+")",Rr="(?:"+sr+"(?:d|ll|m|re|s|t|ve))?",zr="(?:"+sr+"(?:D|LL|M|RE|S|T|VE))?",Er=wr+"?",Sr="["+ar+"]?",Wr="(?:"+kr+"(?:"+[mr,xr,jr].join("|")+")"+Sr+Er+")*",Lr="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Cr="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Ur=Sr+Er+Wr,Br="(?:"+[gr,xr,jr].join("|")+")"+Ur,Tr="(?:"+[mr+_r+"?",_r,xr,jr,hr].join("|")+")",$r=RegExp(sr,"g"),Dr=RegExp(_r,"g"),Mr=RegExp(br+"(?="+br+")|"+Tr+Ur,"g"),Fr=RegExp([Ar+"?"+yr+"+"+Rr+"(?="+[pr,Ar,"$"].join("|")+")",Ir+"+"+zr+"(?="+[pr,Ar+Or,"$"].join("|")+")",Ar+"?"+Or+"+"+Rr,Ar+"+"+zr,Cr,Lr,vr,Br].join("|"),"g"),Nr=RegExp("["+kr+Yt+tr+ar+"]"),Pr=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,qr=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Zr=-1,Kr={}; Kr[at]=Kr[lt]=Kr[st]=Kr[ht]=Kr[pt]=Kr[_t]=Kr[vt]=Kr[gt]=Kr[yt]=!0,Kr[Dn]=Kr[Mn]=Kr[ft]=Kr[Nn]=Kr[ct]=Kr[Pn]=Kr[Zn]=Kr[Kn]=Kr[Gn]=Kr[Hn]=Kr[Yn]=Kr[nt]=Kr[tt]=Kr[rt]=Kr[it]=!1;var Vr={};Vr[Dn]=Vr[Mn]=Vr[ft]=Vr[ct]=Vr[Nn]=Vr[Pn]=Vr[at]=Vr[lt]=Vr[st]=Vr[ht]=Vr[pt]=Vr[Gn]=Vr[Hn]=Vr[Yn]=Vr[nt]=Vr[tt]=Vr[rt]=Vr[et]=Vr[_t]=Vr[vt]=Vr[gt]=Vr[yt]=!0,Vr[Zn]=Vr[Kn]=Vr[it]=!1;var Gr={"\xc0":"A","\xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xe0":"a","\xe1":"a","\xe2":"a","\xe3":"a","\xe4":"a","\xe5":"a", "\xc7":"C","\xe7":"c","\xd0":"D","\xf0":"d","\xc8":"E","\xc9":"E","\xca":"E","\xcb":"E","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e","\xcc":"I","\xcd":"I","\xce":"I","\xcf":"I","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xd1":"N","\xf1":"n","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O","\xd8":"O","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xdd":"Y","\xfd":"y","\xff":"y","\xc6":"Ae", "\xe6":"ae","\xde":"Th","\xfe":"th","\xdf":"ss","\u0100":"A","\u0102":"A","\u0104":"A","\u0101":"a","\u0103":"a","\u0105":"a","\u0106":"C","\u0108":"C","\u010a":"C","\u010c":"C","\u0107":"c","\u0109":"c","\u010b":"c","\u010d":"c","\u010e":"D","\u0110":"D","\u010f":"d","\u0111":"d","\u0112":"E","\u0114":"E","\u0116":"E","\u0118":"E","\u011a":"E","\u0113":"e","\u0115":"e","\u0117":"e","\u0119":"e","\u011b":"e","\u011c":"G","\u011e":"G","\u0120":"G","\u0122":"G","\u011d":"g","\u011f":"g","\u0121":"g", "\u0123":"g","\u0124":"H","\u0126":"H","\u0125":"h","\u0127":"h","\u0128":"I","\u012a":"I","\u012c":"I","\u012e":"I","\u0130":"I","\u0129":"i","\u012b":"i","\u012d":"i","\u012f":"i","\u0131":"i","\u0134":"J","\u0135":"j","\u0136":"K","\u0137":"k","\u0138":"k","\u0139":"L","\u013b":"L","\u013d":"L","\u013f":"L","\u0141":"L","\u013a":"l","\u013c":"l","\u013e":"l","\u0140":"l","\u0142":"l","\u0143":"N","\u0145":"N","\u0147":"N","\u014a":"N","\u0144":"n","\u0146":"n","\u0148":"n","\u014b":"n","\u014c":"O", "\u014e":"O","\u0150":"O","\u014d":"o","\u014f":"o","\u0151":"o","\u0154":"R","\u0156":"R","\u0158":"R","\u0155":"r","\u0157":"r","\u0159":"r","\u015a":"S","\u015c":"S","\u015e":"S","\u0160":"S","\u015b":"s","\u015d":"s","\u015f":"s","\u0161":"s","\u0162":"T","\u0164":"T","\u0166":"T","\u0163":"t","\u0165":"t","\u0167":"t","\u0168":"U","\u016a":"U","\u016c":"U","\u016e":"U","\u0170":"U","\u0172":"U","\u0169":"u","\u016b":"u","\u016d":"u","\u016f":"u","\u0171":"u","\u0173":"u","\u0174":"W","\u0175":"w", "\u0176":"Y","\u0177":"y","\u0178":"Y","\u0179":"Z","\u017b":"Z","\u017d":"Z","\u017a":"z","\u017c":"z","\u017e":"z","\u0132":"IJ","\u0133":"ij","\u0152":"Oe","\u0153":"oe","\u0149":"'n","\u017f":"s"},Hr={"&":"&","<":"<",">":">",'"':""","'":"'"},Jr={"&":"&","<":"<",">":">",""":'"',"'":"'"},Yr={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Qr=parseFloat,Xr=parseInt,ne="object"==typeof __webpack_require__.g&&__webpack_require__.g&&__webpack_require__.g.Object===Object&&__webpack_require__.g,te="object"==typeof self&&self&&self.Object===Object&&self,re=ne||te||Function("return this")(),ee= true&&exports&&!exports.nodeType&&exports,ue=ee&&"object"=="object"&&module&&!module.nodeType&&module,ie=ue&&ue.exports===ee,oe=ie&&ne.process,fe=function(){ try{var n=ue&&ue.require&&ue.require("util").types;return n?n:oe&&oe.binding&&oe.binding("util")}catch(n){}}(),ce=fe&&fe.isArrayBuffer,ae=fe&&fe.isDate,le=fe&&fe.isMap,se=fe&&fe.isRegExp,he=fe&&fe.isSet,pe=fe&&fe.isTypedArray,_e=m("length"),ve=x(Gr),ge=x(Hr),ye=x(Jr),de=function p(x){function Z(n){if(cc(n)&&!bh(n)&&!(n instanceof Ct)){if(n instanceof Y)return n;if(bl.call(n,"__wrapped__"))return eo(n)}return new Y(n)}function J(){}function Y(n,t){this.__wrapped__=n,this.__actions__=[],this.__chain__=!!t, this.__index__=0,this.__values__=X}function Ct(n){this.__wrapped__=n,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Un,this.__views__=[]}function $t(){var n=new Ct(this.__wrapped__);return n.__actions__=Tu(this.__actions__),n.__dir__=this.__dir__,n.__filtered__=this.__filtered__,n.__iteratees__=Tu(this.__iteratees__),n.__takeCount__=this.__takeCount__,n.__views__=Tu(this.__views__),n}function Yt(){if(this.__filtered__){var n=new Ct(this);n.__dir__=-1, n.__filtered__=!0}else n=this.clone(),n.__dir__*=-1;return n}function Qt(){var n=this.__wrapped__.value(),t=this.__dir__,r=bh(n),e=t<0,u=r?n.length:0,i=Oi(0,u,this.__views__),o=i.start,f=i.end,c=f-o,a=e?f:o-1,l=this.__iteratees__,s=l.length,h=0,p=Hl(c,this.__takeCount__);if(!r||!e&&u==c&&p==c)return wu(n,this.__actions__);var _=[];n:for(;c--&&h-1}function lr(n,t){var r=this.__data__,e=Wr(r,n);return e<0?(++this.size,r.push([n,t])):r[e][1]=t,this}function sr(n){var t=-1,r=null==n?0:n.length;for(this.clear();++t=t?n:t)),n}function Fr(n,t,e,u,i,o){var f,c=t&an,a=t&ln,l=t&sn;if(e&&(f=i?e(n,u,i,o):e(n)),f!==X)return f;if(!fc(n))return n;var s=bh(n);if(s){if(f=zi(n),!c)return Tu(n,f)}else{var h=zs(n),p=h==Kn||h==Vn;if(mh(n))return Iu(n,c);if(h==Yn||h==Dn||p&&!i){if(f=a||p?{}:Ei(n),!c)return a?Mu(n,Ur(f,n)):Du(n,Cr(f,n))}else{if(!Vr[h])return i?n:{};f=Si(n,h,c)}}o||(o=new wr);var _=o.get(n);if(_)return _;o.set(n,f),kh(n)?n.forEach(function(r){f.add(Fr(r,t,e,r,n,o))}):jh(n)&&n.forEach(function(r,u){ f.set(u,Fr(r,t,e,u,n,o))});var v=l?a?di:yi:a?qc:Pc,g=s?X:v(n);return r(g||n,function(r,u){g&&(u=r,r=n[u]),Sr(f,u,Fr(r,t,e,u,n,o))}),f}function Nr(n){var t=Pc(n);return function(r){return Pr(r,n,t)}}function Pr(n,t,r){var e=r.length;if(null==n)return!e;for(n=ll(n);e--;){var u=r[e],i=t[u],o=n[u];if(o===X&&!(u in n)||!i(o))return!1}return!0}function Gr(n,t,r){if("function"!=typeof n)throw new pl(en);return Ws(function(){n.apply(X,r)},t)}function Hr(n,t,r,e){var u=-1,i=o,a=!0,l=n.length,s=[],h=t.length; if(!l)return s;r&&(t=c(t,z(r))),e?(i=f,a=!1):t.length>=tn&&(i=S,a=!1,t=new yr(t));n:for(;++uu?0:u+r), e=e===X||e>u?u:kc(e),e<0&&(e+=u),e=r>e?0:Oc(e);r0&&r(f)?t>1?ee(f,t-1,r,e,u):a(u,f):e||(u[u.length]=f)}return u}function ue(n,t){return n&&bs(n,t,Pc)}function oe(n,t){return n&&ws(n,t,Pc)}function fe(n,t){return i(t,function(t){return uc(n[t])})}function _e(n,t){t=ku(t,n);for(var r=0,e=t.length;null!=n&&rt}function xe(n,t){return null!=n&&bl.call(n,t)}function je(n,t){return null!=n&&t in ll(n)}function Ae(n,t,r){return n>=Hl(t,r)&&n=120&&p.length>=120)?new yr(a&&p):X}p=n[0]; var _=-1,v=l[0];n:for(;++_-1;)f!==n&&Ll.call(f,a,1),Ll.call(n,a,1);return n}function nu(n,t){for(var r=n?t.length:0,e=r-1;r--;){ var u=t[r];if(r==e||u!==i){var i=u;Ci(u)?Ll.call(n,u,1):yu(n,u)}}return n}function tu(n,t){return n+Nl(Ql()*(t-n+1))}function ru(n,t,r,e){for(var u=-1,i=Gl(Fl((t-n)/(r||1)),0),o=il(i);i--;)o[e?i:++u]=n,n+=r;return o}function eu(n,t){var r="";if(!n||t<1||t>Wn)return r;do t%2&&(r+=n),t=Nl(t/2),t&&(n+=n);while(t);return r}function uu(n,t){return Ls(Vi(n,t,La),n+"")}function iu(n){return Ir(ra(n))}function ou(n,t){var r=ra(n);return Xi(r,Mr(t,0,r.length))}function fu(n,t,r,e){if(!fc(n))return n;t=ku(t,n); for(var u=-1,i=t.length,o=i-1,f=n;null!=f&&++uu?0:u+t),r=r>u?u:r,r<0&&(r+=u),u=t>r?0:r-t>>>0,t>>>=0;for(var i=il(u);++e>>1,o=n[i];null!==o&&!bc(o)&&(r?o<=t:o=tn){var s=t?null:ks(n);if(s)return P(s);c=!1,u=S,l=new yr}else l=t?[]:a;n:for(;++e=e?n:au(n,t,r)}function Iu(n,t){if(t)return n.slice();var r=n.length,e=zl?zl(r):new n.constructor(r); return n.copy(e),e}function Ru(n){var t=new n.constructor(n.byteLength);return new Rl(t).set(new Rl(n)),t}function zu(n,t){return new n.constructor(t?Ru(n.buffer):n.buffer,n.byteOffset,n.byteLength)}function Eu(n){var t=new n.constructor(n.source,Nt.exec(n));return t.lastIndex=n.lastIndex,t}function Su(n){return _s?ll(_s.call(n)):{}}function Wu(n,t){return new n.constructor(t?Ru(n.buffer):n.buffer,n.byteOffset,n.length)}function Lu(n,t){if(n!==t){var r=n!==X,e=null===n,u=n===n,i=bc(n),o=t!==X,f=null===t,c=t===t,a=bc(t); if(!f&&!a&&!i&&n>t||i&&o&&c&&!f&&!a||e&&o&&c||!r&&c||!u)return 1;if(!e&&!i&&!a&&n=f)return c;return c*("desc"==r[e]?-1:1)}}return n.index-t.index}function Uu(n,t,r,e){for(var u=-1,i=n.length,o=r.length,f=-1,c=t.length,a=Gl(i-o,0),l=il(c+a),s=!e;++f1?r[u-1]:X,o=u>2?r[2]:X;for(i=n.length>3&&"function"==typeof i?(u--,i):X,o&&Ui(r[0],r[1],o)&&(i=u<3?X:i,u=1),t=ll(t);++e-1?u[i?t[o]:o]:X}}function Yu(n){return gi(function(t){var r=t.length,e=r,u=Y.prototype.thru;for(n&&t.reverse();e--;){var i=t[e];if("function"!=typeof i)throw new pl(en);if(u&&!o&&"wrapper"==bi(i))var o=new Y([],!0)}for(e=o?e:r;++e1&&d.reverse(),s&&cf))return!1;var a=i.get(n),l=i.get(t);if(a&&l)return a==t&&l==n;var s=-1,p=!0,_=r&pn?new yr:X;for(i.set(n,t),i.set(t,n);++s1?"& ":"")+t[e],t=t.join(r>2?", ":" "),n.replace(Ut,"{\n/* [wrapped with "+t+"] */\n")}function Li(n){return bh(n)||dh(n)||!!(Cl&&n&&n[Cl])}function Ci(n,t){var r=typeof n; return t=null==t?Wn:t,!!t&&("number"==r||"symbol"!=r&&Vt.test(n))&&n>-1&&n%1==0&&n0){if(++t>=On)return arguments[0]}else t=0; return n.apply(X,arguments)}}function Xi(n,t){var r=-1,e=n.length,u=e-1;for(t=t===X?e:t;++r=this.__values__.length;return{done:n,value:n?X:this.__values__[this.__index__++]}}function uf(){return this}function of(n){for(var t,r=this;r instanceof J;){var e=eo(r);e.__index__=0,e.__values__=X,t?u.__wrapped__=e:t=e;var u=e;r=r.__wrapped__}return u.__wrapped__=n,t}function ff(){var n=this.__wrapped__;if(n instanceof Ct){var t=n;return this.__actions__.length&&(t=new Ct(this)),t=t.reverse(),t.__actions__.push({func:nf,args:[Eo],thisArg:X}),new Y(t,this.__chain__)}return this.thru(Eo); }function cf(){return wu(this.__wrapped__,this.__actions__)}function af(n,t,r){var e=bh(n)?u:Jr;return r&&Ui(n,t,r)&&(t=X),e(n,mi(t,3))}function lf(n,t){return(bh(n)?i:te)(n,mi(t,3))}function sf(n,t){return ee(yf(n,t),1)}function hf(n,t){return ee(yf(n,t),Sn)}function pf(n,t,r){return r=r===X?1:kc(r),ee(yf(n,t),r)}function _f(n,t){return(bh(n)?r:ys)(n,mi(t,3))}function vf(n,t){return(bh(n)?e:ds)(n,mi(t,3))}function gf(n,t,r,e){n=Hf(n)?n:ra(n),r=r&&!e?kc(r):0;var u=n.length;return r<0&&(r=Gl(u+r,0)), dc(n)?r<=u&&n.indexOf(t,r)>-1:!!u&&y(n,t,r)>-1}function yf(n,t){return(bh(n)?c:Pe)(n,mi(t,3))}function df(n,t,r,e){return null==n?[]:(bh(t)||(t=null==t?[]:[t]),r=e?X:r,bh(r)||(r=null==r?[]:[r]),He(n,t,r))}function bf(n,t,r){var e=bh(n)?l:j,u=arguments.length<3;return e(n,mi(t,4),r,u,ys)}function wf(n,t,r){var e=bh(n)?s:j,u=arguments.length<3;return e(n,mi(t,4),r,u,ds)}function mf(n,t){return(bh(n)?i:te)(n,Uf(mi(t,3)))}function xf(n){return(bh(n)?Ir:iu)(n)}function jf(n,t,r){return t=(r?Ui(n,t,r):t===X)?1:kc(t), (bh(n)?Rr:ou)(n,t)}function Af(n){return(bh(n)?zr:cu)(n)}function kf(n){if(null==n)return 0;if(Hf(n))return dc(n)?V(n):n.length;var t=zs(n);return t==Gn||t==tt?n.size:Me(n).length}function Of(n,t,r){var e=bh(n)?h:lu;return r&&Ui(n,t,r)&&(t=X),e(n,mi(t,3))}function If(n,t){if("function"!=typeof t)throw new pl(en);return n=kc(n),function(){if(--n<1)return t.apply(this,arguments)}}function Rf(n,t,r){return t=r?X:t,t=n&&null==t?n.length:t,ai(n,mn,X,X,X,X,t)}function zf(n,t){var r;if("function"!=typeof t)throw new pl(en); return n=kc(n),function(){return--n>0&&(r=t.apply(this,arguments)),n<=1&&(t=X),r}}function Ef(n,t,r){t=r?X:t;var e=ai(n,yn,X,X,X,X,X,t);return e.placeholder=Ef.placeholder,e}function Sf(n,t,r){t=r?X:t;var e=ai(n,dn,X,X,X,X,X,t);return e.placeholder=Sf.placeholder,e}function Wf(n,t,r){function e(t){var r=h,e=p;return h=p=X,d=t,v=n.apply(e,r)}function u(n){return d=n,g=Ws(f,t),b?e(n):v}function i(n){var r=n-y,e=n-d,u=t-r;return w?Hl(u,_-e):u}function o(n){var r=n-y,e=n-d;return y===X||r>=t||r<0||w&&e>=_; }function f(){var n=fh();return o(n)?c(n):(g=Ws(f,i(n)),X)}function c(n){return g=X,m&&h?e(n):(h=p=X,v)}function a(){g!==X&&As(g),d=0,h=y=p=g=X}function l(){return g===X?v:c(fh())}function s(){var n=fh(),r=o(n);if(h=arguments,p=this,y=n,r){if(g===X)return u(y);if(w)return As(g),g=Ws(f,t),e(y)}return g===X&&(g=Ws(f,t)),v}var h,p,_,v,g,y,d=0,b=!1,w=!1,m=!0;if("function"!=typeof n)throw new pl(en);return t=Ic(t)||0,fc(r)&&(b=!!r.leading,w="maxWait"in r,_=w?Gl(Ic(r.maxWait)||0,t):_,m="trailing"in r?!!r.trailing:m), s.cancel=a,s.flush=l,s}function Lf(n){return ai(n,jn)}function Cf(n,t){if("function"!=typeof n||null!=t&&"function"!=typeof t)throw new pl(en);var r=function(){var e=arguments,u=t?t.apply(this,e):e[0],i=r.cache;if(i.has(u))return i.get(u);var o=n.apply(this,e);return r.cache=i.set(u,o)||i,o};return r.cache=new(Cf.Cache||sr),r}function Uf(n){if("function"!=typeof n)throw new pl(en);return function(){var t=arguments;switch(t.length){case 0:return!n.call(this);case 1:return!n.call(this,t[0]);case 2: return!n.call(this,t[0],t[1]);case 3:return!n.call(this,t[0],t[1],t[2])}return!n.apply(this,t)}}function Bf(n){return zf(2,n)}function Tf(n,t){if("function"!=typeof n)throw new pl(en);return t=t===X?t:kc(t),uu(n,t)}function $f(t,r){if("function"!=typeof t)throw new pl(en);return r=null==r?0:Gl(kc(r),0),uu(function(e){var u=e[r],i=Ou(e,0,r);return u&&a(i,u),n(t,this,i)})}function Df(n,t,r){var e=!0,u=!0;if("function"!=typeof n)throw new pl(en);return fc(r)&&(e="leading"in r?!!r.leading:e,u="trailing"in r?!!r.trailing:u), Wf(n,t,{leading:e,maxWait:t,trailing:u})}function Mf(n){return Rf(n,1)}function Ff(n,t){return ph(Au(t),n)}function Nf(){if(!arguments.length)return[];var n=arguments[0];return bh(n)?n:[n]}function Pf(n){return Fr(n,sn)}function qf(n,t){return t="function"==typeof t?t:X,Fr(n,sn,t)}function Zf(n){return Fr(n,an|sn)}function Kf(n,t){return t="function"==typeof t?t:X,Fr(n,an|sn,t)}function Vf(n,t){return null==t||Pr(n,t,Pc(t))}function Gf(n,t){return n===t||n!==n&&t!==t}function Hf(n){return null!=n&&oc(n.length)&&!uc(n); }function Jf(n){return cc(n)&&Hf(n)}function Yf(n){return n===!0||n===!1||cc(n)&&we(n)==Nn}function Qf(n){return cc(n)&&1===n.nodeType&&!gc(n)}function Xf(n){if(null==n)return!0;if(Hf(n)&&(bh(n)||"string"==typeof n||"function"==typeof n.splice||mh(n)||Oh(n)||dh(n)))return!n.length;var t=zs(n);if(t==Gn||t==tt)return!n.size;if(Mi(n))return!Me(n).length;for(var r in n)if(bl.call(n,r))return!1;return!0}function nc(n,t){return Se(n,t)}function tc(n,t,r){r="function"==typeof r?r:X;var e=r?r(n,t):X;return e===X?Se(n,t,X,r):!!e; }function rc(n){if(!cc(n))return!1;var t=we(n);return t==Zn||t==qn||"string"==typeof n.message&&"string"==typeof n.name&&!gc(n)}function ec(n){return"number"==typeof n&&Zl(n)}function uc(n){if(!fc(n))return!1;var t=we(n);return t==Kn||t==Vn||t==Fn||t==Xn}function ic(n){return"number"==typeof n&&n==kc(n)}function oc(n){return"number"==typeof n&&n>-1&&n%1==0&&n<=Wn}function fc(n){var t=typeof n;return null!=n&&("object"==t||"function"==t)}function cc(n){return null!=n&&"object"==typeof n}function ac(n,t){ return n===t||Ce(n,t,ji(t))}function lc(n,t,r){return r="function"==typeof r?r:X,Ce(n,t,ji(t),r)}function sc(n){return vc(n)&&n!=+n}function hc(n){if(Es(n))throw new fl(rn);return Ue(n)}function pc(n){return null===n}function _c(n){return null==n}function vc(n){return"number"==typeof n||cc(n)&&we(n)==Hn}function gc(n){if(!cc(n)||we(n)!=Yn)return!1;var t=El(n);if(null===t)return!0;var r=bl.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&dl.call(r)==jl}function yc(n){ return ic(n)&&n>=-Wn&&n<=Wn}function dc(n){return"string"==typeof n||!bh(n)&&cc(n)&&we(n)==rt}function bc(n){return"symbol"==typeof n||cc(n)&&we(n)==et}function wc(n){return n===X}function mc(n){return cc(n)&&zs(n)==it}function xc(n){return cc(n)&&we(n)==ot}function jc(n){if(!n)return[];if(Hf(n))return dc(n)?G(n):Tu(n);if(Ul&&n[Ul])return D(n[Ul]());var t=zs(n);return(t==Gn?M:t==tt?P:ra)(n)}function Ac(n){if(!n)return 0===n?n:0;if(n=Ic(n),n===Sn||n===-Sn){return(n<0?-1:1)*Ln}return n===n?n:0}function kc(n){ var t=Ac(n),r=t%1;return t===t?r?t-r:t:0}function Oc(n){return n?Mr(kc(n),0,Un):0}function Ic(n){if("number"==typeof n)return n;if(bc(n))return Cn;if(fc(n)){var t="function"==typeof n.valueOf?n.valueOf():n;n=fc(t)?t+"":t}if("string"!=typeof n)return 0===n?n:+n;n=R(n);var r=qt.test(n);return r||Kt.test(n)?Xr(n.slice(2),r?2:8):Pt.test(n)?Cn:+n}function Rc(n){return $u(n,qc(n))}function zc(n){return n?Mr(kc(n),-Wn,Wn):0===n?n:0}function Ec(n){return null==n?"":vu(n)}function Sc(n,t){var r=gs(n);return null==t?r:Cr(r,t); }function Wc(n,t){return v(n,mi(t,3),ue)}function Lc(n,t){return v(n,mi(t,3),oe)}function Cc(n,t){return null==n?n:bs(n,mi(t,3),qc)}function Uc(n,t){return null==n?n:ws(n,mi(t,3),qc)}function Bc(n,t){return n&&ue(n,mi(t,3))}function Tc(n,t){return n&&oe(n,mi(t,3))}function $c(n){return null==n?[]:fe(n,Pc(n))}function Dc(n){return null==n?[]:fe(n,qc(n))}function Mc(n,t,r){var e=null==n?X:_e(n,t);return e===X?r:e}function Fc(n,t){return null!=n&&Ri(n,t,xe)}function Nc(n,t){return null!=n&&Ri(n,t,je); }function Pc(n){return Hf(n)?Or(n):Me(n)}function qc(n){return Hf(n)?Or(n,!0):Fe(n)}function Zc(n,t){var r={};return t=mi(t,3),ue(n,function(n,e,u){Br(r,t(n,e,u),n)}),r}function Kc(n,t){var r={};return t=mi(t,3),ue(n,function(n,e,u){Br(r,e,t(n,e,u))}),r}function Vc(n,t){return Gc(n,Uf(mi(t)))}function Gc(n,t){if(null==n)return{};var r=c(di(n),function(n){return[n]});return t=mi(t),Ye(n,r,function(n,r){return t(n,r[0])})}function Hc(n,t,r){t=ku(t,n);var e=-1,u=t.length;for(u||(u=1,n=X);++et){ var e=n;n=t,t=e}if(r||n%1||t%1){var u=Ql();return Hl(n+u*(t-n+Qr("1e-"+((u+"").length-1))),t)}return tu(n,t)}function fa(n){return Qh(Ec(n).toLowerCase())}function ca(n){return n=Ec(n),n&&n.replace(Gt,ve).replace(Dr,"")}function aa(n,t,r){n=Ec(n),t=vu(t);var e=n.length;r=r===X?e:Mr(kc(r),0,e);var u=r;return r-=t.length,r>=0&&n.slice(r,u)==t}function la(n){return n=Ec(n),n&&At.test(n)?n.replace(xt,ge):n}function sa(n){return n=Ec(n),n&&Wt.test(n)?n.replace(St,"\\$&"):n}function ha(n,t,r){n=Ec(n),t=kc(t); var e=t?V(n):0;if(!t||e>=t)return n;var u=(t-e)/2;return ri(Nl(u),r)+n+ri(Fl(u),r)}function pa(n,t,r){n=Ec(n),t=kc(t);var e=t?V(n):0;return t&&e>>0)?(n=Ec(n),n&&("string"==typeof t||null!=t&&!Ah(t))&&(t=vu(t),!t&&T(n))?Ou(G(n),0,r):n.split(t,r)):[]}function ba(n,t,r){return n=Ec(n),r=null==r?0:Mr(kc(r),0,n.length),t=vu(t),n.slice(r,r+t.length)==t}function wa(n,t,r){var e=Z.templateSettings;r&&Ui(n,t,r)&&(t=X),n=Ec(n),t=Sh({},t,e,li);var u,i,o=Sh({},t.imports,e.imports,li),f=Pc(o),c=E(o,f),a=0,l=t.interpolate||Ht,s="__p += '",h=sl((t.escape||Ht).source+"|"+l.source+"|"+(l===It?Ft:Ht).source+"|"+(t.evaluate||Ht).source+"|$","g"),p="//# sourceURL="+(bl.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Zr+"]")+"\n"; n.replace(h,function(t,r,e,o,f,c){return e||(e=o),s+=n.slice(a,c).replace(Jt,U),r&&(u=!0,s+="' +\n__e("+r+") +\n'"),f&&(i=!0,s+="';\n"+f+";\n__p += '"),e&&(s+="' +\n((__t = ("+e+")) == null ? '' : __t) +\n'"),a=c+t.length,t}),s+="';\n";var _=bl.call(t,"variable")&&t.variable;if(_){if(Dt.test(_))throw new fl(un)}else s="with (obj) {\n"+s+"\n}\n";s=(i?s.replace(dt,""):s).replace(bt,"$1").replace(wt,"$1;"),s="function("+(_||"obj")+") {\n"+(_?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(u?", __e = _.escape":"")+(i?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+s+"return __p\n}"; var v=Xh(function(){return cl(f,p+"return "+s).apply(X,c)});if(v.source=s,rc(v))throw v;return v}function ma(n){return Ec(n).toLowerCase()}function xa(n){return Ec(n).toUpperCase()}function ja(n,t,r){if(n=Ec(n),n&&(r||t===X))return R(n);if(!n||!(t=vu(t)))return n;var e=G(n),u=G(t);return Ou(e,W(e,u),L(e,u)+1).join("")}function Aa(n,t,r){if(n=Ec(n),n&&(r||t===X))return n.slice(0,H(n)+1);if(!n||!(t=vu(t)))return n;var e=G(n);return Ou(e,0,L(e,G(t))+1).join("")}function ka(n,t,r){if(n=Ec(n),n&&(r||t===X))return n.replace(Lt,""); if(!n||!(t=vu(t)))return n;var e=G(n);return Ou(e,W(e,G(t))).join("")}function Oa(n,t){var r=An,e=kn;if(fc(t)){var u="separator"in t?t.separator:u;r="length"in t?kc(t.length):r,e="omission"in t?vu(t.omission):e}n=Ec(n);var i=n.length;if(T(n)){var o=G(n);i=o.length}if(r>=i)return n;var f=r-V(e);if(f<1)return e;var c=o?Ou(o,0,f).join(""):n.slice(0,f);if(u===X)return c+e;if(o&&(f+=c.length-f),Ah(u)){if(n.slice(f).search(u)){var a,l=c;for(u.global||(u=sl(u.source,Ec(Nt.exec(u))+"g")),u.lastIndex=0;a=u.exec(l);)var s=a.index; c=c.slice(0,s===X?f:s)}}else if(n.indexOf(vu(u),f)!=f){var h=c.lastIndexOf(u);h>-1&&(c=c.slice(0,h))}return c+e}function Ia(n){return n=Ec(n),n&&jt.test(n)?n.replace(mt,ye):n}function Ra(n,t,r){return n=Ec(n),t=r?X:t,t===X?$(n)?Q(n):_(n):n.match(t)||[]}function za(t){var r=null==t?0:t.length,e=mi();return t=r?c(t,function(n){if("function"!=typeof n[1])throw new pl(en);return[e(n[0]),n[1]]}):[],uu(function(e){for(var u=-1;++uWn)return[];var r=Un,e=Hl(n,Un);t=mi(t),n-=Un;for(var u=O(e,t);++r1?n[t-1]:X;return r="function"==typeof r?(n.pop(), r):X,Ho(n,r)}),Qs=gi(function(n){var t=n.length,r=t?n[0]:0,e=this.__wrapped__,u=function(t){return Tr(t,n)};return!(t>1||this.__actions__.length)&&e instanceof Ct&&Ci(r)?(e=e.slice(r,+r+(t?1:0)),e.__actions__.push({func:nf,args:[u],thisArg:X}),new Y(e,this.__chain__).thru(function(n){return t&&!n.length&&n.push(X),n})):this.thru(u)}),Xs=Fu(function(n,t,r){bl.call(n,r)?++n[r]:Br(n,r,1)}),nh=Ju(ho),th=Ju(po),rh=Fu(function(n,t,r){bl.call(n,r)?n[r].push(t):Br(n,r,[t])}),eh=uu(function(t,r,e){var u=-1,i="function"==typeof r,o=Hf(t)?il(t.length):[]; return ys(t,function(t){o[++u]=i?n(r,t,e):Ie(t,r,e)}),o}),uh=Fu(function(n,t,r){Br(n,r,t)}),ih=Fu(function(n,t,r){n[r?0:1].push(t)},function(){return[[],[]]}),oh=uu(function(n,t){if(null==n)return[];var r=t.length;return r>1&&Ui(n,t[0],t[1])?t=[]:r>2&&Ui(t[0],t[1],t[2])&&(t=[t[0]]),He(n,ee(t,1),[])}),fh=Dl||function(){return re.Date.now()},ch=uu(function(n,t,r){var e=_n;if(r.length){var u=N(r,wi(ch));e|=bn}return ai(n,e,t,r,u)}),ah=uu(function(n,t,r){var e=_n|vn;if(r.length){var u=N(r,wi(ah));e|=bn; }return ai(t,e,n,r,u)}),lh=uu(function(n,t){return Gr(n,1,t)}),sh=uu(function(n,t,r){return Gr(n,Ic(t)||0,r)});Cf.Cache=sr;var hh=js(function(t,r){r=1==r.length&&bh(r[0])?c(r[0],z(mi())):c(ee(r,1),z(mi()));var e=r.length;return uu(function(u){for(var i=-1,o=Hl(u.length,e);++i=t}),dh=Re(function(){return arguments}())?Re:function(n){return cc(n)&&bl.call(n,"callee")&&!Wl.call(n,"callee")},bh=il.isArray,wh=ce?z(ce):ze,mh=ql||qa,xh=ae?z(ae):Ee,jh=le?z(le):Le,Ah=se?z(se):Be,kh=he?z(he):Te,Oh=pe?z(pe):$e,Ih=ii(Ne),Rh=ii(function(n,t){return n<=t}),zh=Nu(function(n,t){if(Mi(t)||Hf(t))return $u(t,Pc(t),n),X;for(var r in t)bl.call(t,r)&&Sr(n,r,t[r])}),Eh=Nu(function(n,t){$u(t,qc(t),n)}),Sh=Nu(function(n,t,r,e){$u(t,qc(t),n,e)}),Wh=Nu(function(n,t,r,e){$u(t,Pc(t),n,e); }),Lh=gi(Tr),Ch=uu(function(n,t){n=ll(n);var r=-1,e=t.length,u=e>2?t[2]:X;for(u&&Ui(t[0],t[1],u)&&(e=1);++r1),t}),$u(n,di(n),r),e&&(r=Fr(r,an|ln|sn,hi));for(var u=t.length;u--;)yu(r,t[u]);return r}),Nh=gi(function(n,t){return null==n?{}:Je(n,t)}),Ph=ci(Pc),qh=ci(qc),Zh=Vu(function(n,t,r){return t=t.toLowerCase(),n+(r?fa(t):t)}),Kh=Vu(function(n,t,r){return n+(r?"-":"")+t.toLowerCase()}),Vh=Vu(function(n,t,r){return n+(r?" ":"")+t.toLowerCase()}),Gh=Ku("toLowerCase"),Hh=Vu(function(n,t,r){ return n+(r?"_":"")+t.toLowerCase()}),Jh=Vu(function(n,t,r){return n+(r?" ":"")+Qh(t)}),Yh=Vu(function(n,t,r){return n+(r?" ":"")+t.toUpperCase()}),Qh=Ku("toUpperCase"),Xh=uu(function(t,r){try{return n(t,X,r)}catch(n){return rc(n)?n:new fl(n)}}),np=gi(function(n,t){return r(t,function(t){t=no(t),Br(n,t,ch(n[t],n))}),n}),tp=Yu(),rp=Yu(!0),ep=uu(function(n,t){return function(r){return Ie(r,n,t)}}),up=uu(function(n,t){return function(r){return Ie(n,r,t)}}),ip=ti(c),op=ti(u),fp=ti(h),cp=ui(),ap=ui(!0),lp=ni(function(n,t){ return n+t},0),sp=fi("ceil"),hp=ni(function(n,t){return n/t},1),pp=fi("floor"),_p=ni(function(n,t){return n*t},1),vp=fi("round"),gp=ni(function(n,t){return n-t},0);return Z.after=If,Z.ary=Rf,Z.assign=zh,Z.assignIn=Eh,Z.assignInWith=Sh,Z.assignWith=Wh,Z.at=Lh,Z.before=zf,Z.bind=ch,Z.bindAll=np,Z.bindKey=ah,Z.castArray=Nf,Z.chain=Qo,Z.chunk=uo,Z.compact=io,Z.concat=oo,Z.cond=za,Z.conforms=Ea,Z.constant=Sa,Z.countBy=Xs,Z.create=Sc,Z.curry=Ef,Z.curryRight=Sf,Z.debounce=Wf,Z.defaults=Ch,Z.defaultsDeep=Uh, Z.defer=lh,Z.delay=sh,Z.difference=Us,Z.differenceBy=Bs,Z.differenceWith=Ts,Z.drop=fo,Z.dropRight=co,Z.dropRightWhile=ao,Z.dropWhile=lo,Z.fill=so,Z.filter=lf,Z.flatMap=sf,Z.flatMapDeep=hf,Z.flatMapDepth=pf,Z.flatten=_o,Z.flattenDeep=vo,Z.flattenDepth=go,Z.flip=Lf,Z.flow=tp,Z.flowRight=rp,Z.fromPairs=yo,Z.functions=$c,Z.functionsIn=Dc,Z.groupBy=rh,Z.initial=mo,Z.intersection=$s,Z.intersectionBy=Ds,Z.intersectionWith=Ms,Z.invert=Bh,Z.invertBy=Th,Z.invokeMap=eh,Z.iteratee=Ca,Z.keyBy=uh,Z.keys=Pc,Z.keysIn=qc, Z.map=yf,Z.mapKeys=Zc,Z.mapValues=Kc,Z.matches=Ua,Z.matchesProperty=Ba,Z.memoize=Cf,Z.merge=Dh,Z.mergeWith=Mh,Z.method=ep,Z.methodOf=up,Z.mixin=Ta,Z.negate=Uf,Z.nthArg=Ma,Z.omit=Fh,Z.omitBy=Vc,Z.once=Bf,Z.orderBy=df,Z.over=ip,Z.overArgs=hh,Z.overEvery=op,Z.overSome=fp,Z.partial=ph,Z.partialRight=_h,Z.partition=ih,Z.pick=Nh,Z.pickBy=Gc,Z.property=Fa,Z.propertyOf=Na,Z.pull=Fs,Z.pullAll=Oo,Z.pullAllBy=Io,Z.pullAllWith=Ro,Z.pullAt=Ns,Z.range=cp,Z.rangeRight=ap,Z.rearg=vh,Z.reject=mf,Z.remove=zo,Z.rest=Tf, Z.reverse=Eo,Z.sampleSize=jf,Z.set=Jc,Z.setWith=Yc,Z.shuffle=Af,Z.slice=So,Z.sortBy=oh,Z.sortedUniq=$o,Z.sortedUniqBy=Do,Z.split=da,Z.spread=$f,Z.tail=Mo,Z.take=Fo,Z.takeRight=No,Z.takeRightWhile=Po,Z.takeWhile=qo,Z.tap=Xo,Z.throttle=Df,Z.thru=nf,Z.toArray=jc,Z.toPairs=Ph,Z.toPairsIn=qh,Z.toPath=Ha,Z.toPlainObject=Rc,Z.transform=Qc,Z.unary=Mf,Z.union=Ps,Z.unionBy=qs,Z.unionWith=Zs,Z.uniq=Zo,Z.uniqBy=Ko,Z.uniqWith=Vo,Z.unset=Xc,Z.unzip=Go,Z.unzipWith=Ho,Z.update=na,Z.updateWith=ta,Z.values=ra,Z.valuesIn=ea, Z.without=Ks,Z.words=Ra,Z.wrap=Ff,Z.xor=Vs,Z.xorBy=Gs,Z.xorWith=Hs,Z.zip=Js,Z.zipObject=Jo,Z.zipObjectDeep=Yo,Z.zipWith=Ys,Z.entries=Ph,Z.entriesIn=qh,Z.extend=Eh,Z.extendWith=Sh,Ta(Z,Z),Z.add=lp,Z.attempt=Xh,Z.camelCase=Zh,Z.capitalize=fa,Z.ceil=sp,Z.clamp=ua,Z.clone=Pf,Z.cloneDeep=Zf,Z.cloneDeepWith=Kf,Z.cloneWith=qf,Z.conformsTo=Vf,Z.deburr=ca,Z.defaultTo=Wa,Z.divide=hp,Z.endsWith=aa,Z.eq=Gf,Z.escape=la,Z.escapeRegExp=sa,Z.every=af,Z.find=nh,Z.findIndex=ho,Z.findKey=Wc,Z.findLast=th,Z.findLastIndex=po, Z.findLastKey=Lc,Z.floor=pp,Z.forEach=_f,Z.forEachRight=vf,Z.forIn=Cc,Z.forInRight=Uc,Z.forOwn=Bc,Z.forOwnRight=Tc,Z.get=Mc,Z.gt=gh,Z.gte=yh,Z.has=Fc,Z.hasIn=Nc,Z.head=bo,Z.identity=La,Z.includes=gf,Z.indexOf=wo,Z.inRange=ia,Z.invoke=$h,Z.isArguments=dh,Z.isArray=bh,Z.isArrayBuffer=wh,Z.isArrayLike=Hf,Z.isArrayLikeObject=Jf,Z.isBoolean=Yf,Z.isBuffer=mh,Z.isDate=xh,Z.isElement=Qf,Z.isEmpty=Xf,Z.isEqual=nc,Z.isEqualWith=tc,Z.isError=rc,Z.isFinite=ec,Z.isFunction=uc,Z.isInteger=ic,Z.isLength=oc,Z.isMap=jh, Z.isMatch=ac,Z.isMatchWith=lc,Z.isNaN=sc,Z.isNative=hc,Z.isNil=_c,Z.isNull=pc,Z.isNumber=vc,Z.isObject=fc,Z.isObjectLike=cc,Z.isPlainObject=gc,Z.isRegExp=Ah,Z.isSafeInteger=yc,Z.isSet=kh,Z.isString=dc,Z.isSymbol=bc,Z.isTypedArray=Oh,Z.isUndefined=wc,Z.isWeakMap=mc,Z.isWeakSet=xc,Z.join=xo,Z.kebabCase=Kh,Z.last=jo,Z.lastIndexOf=Ao,Z.lowerCase=Vh,Z.lowerFirst=Gh,Z.lt=Ih,Z.lte=Rh,Z.max=Ya,Z.maxBy=Qa,Z.mean=Xa,Z.meanBy=nl,Z.min=tl,Z.minBy=rl,Z.stubArray=Pa,Z.stubFalse=qa,Z.stubObject=Za,Z.stubString=Ka, Z.stubTrue=Va,Z.multiply=_p,Z.nth=ko,Z.noConflict=$a,Z.noop=Da,Z.now=fh,Z.pad=ha,Z.padEnd=pa,Z.padStart=_a,Z.parseInt=va,Z.random=oa,Z.reduce=bf,Z.reduceRight=wf,Z.repeat=ga,Z.replace=ya,Z.result=Hc,Z.round=vp,Z.runInContext=p,Z.sample=xf,Z.size=kf,Z.snakeCase=Hh,Z.some=Of,Z.sortedIndex=Wo,Z.sortedIndexBy=Lo,Z.sortedIndexOf=Co,Z.sortedLastIndex=Uo,Z.sortedLastIndexBy=Bo,Z.sortedLastIndexOf=To,Z.startCase=Jh,Z.startsWith=ba,Z.subtract=gp,Z.sum=el,Z.sumBy=ul,Z.template=wa,Z.times=Ga,Z.toFinite=Ac,Z.toInteger=kc, Z.toLength=Oc,Z.toLower=ma,Z.toNumber=Ic,Z.toSafeInteger=zc,Z.toString=Ec,Z.toUpper=xa,Z.trim=ja,Z.trimEnd=Aa,Z.trimStart=ka,Z.truncate=Oa,Z.unescape=Ia,Z.uniqueId=Ja,Z.upperCase=Yh,Z.upperFirst=Qh,Z.each=_f,Z.eachRight=vf,Z.first=bo,Ta(Z,function(){var n={};return ue(Z,function(t,r){bl.call(Z.prototype,r)||(n[r]=t)}),n}(),{chain:!1}),Z.VERSION=nn,r(["bind","bindKey","curry","curryRight","partial","partialRight"],function(n){Z[n].placeholder=Z}),r(["drop","take"],function(n,t){Ct.prototype[n]=function(r){ r=r===X?1:Gl(kc(r),0);var e=this.__filtered__&&!t?new Ct(this):this.clone();return e.__filtered__?e.__takeCount__=Hl(r,e.__takeCount__):e.__views__.push({size:Hl(r,Un),type:n+(e.__dir__<0?"Right":"")}),e},Ct.prototype[n+"Right"]=function(t){return this.reverse()[n](t).reverse()}}),r(["filter","map","takeWhile"],function(n,t){var r=t+1,e=r==Rn||r==En;Ct.prototype[n]=function(n){var t=this.clone();return t.__iteratees__.push({iteratee:mi(n,3),type:r}),t.__filtered__=t.__filtered__||e,t}}),r(["head","last"],function(n,t){ var r="take"+(t?"Right":"");Ct.prototype[n]=function(){return this[r](1).value()[0]}}),r(["initial","tail"],function(n,t){var r="drop"+(t?"":"Right");Ct.prototype[n]=function(){return this.__filtered__?new Ct(this):this[r](1)}}),Ct.prototype.compact=function(){return this.filter(La)},Ct.prototype.find=function(n){return this.filter(n).head()},Ct.prototype.findLast=function(n){return this.reverse().find(n)},Ct.prototype.invokeMap=uu(function(n,t){return"function"==typeof n?new Ct(this):this.map(function(r){ return Ie(r,n,t)})}),Ct.prototype.reject=function(n){return this.filter(Uf(mi(n)))},Ct.prototype.slice=function(n,t){n=kc(n);var r=this;return r.__filtered__&&(n>0||t<0)?new Ct(r):(n<0?r=r.takeRight(-n):n&&(r=r.drop(n)),t!==X&&(t=kc(t),r=t<0?r.dropRight(-t):r.take(t-n)),r)},Ct.prototype.takeRightWhile=function(n){return this.reverse().takeWhile(n).reverse()},Ct.prototype.toArray=function(){return this.take(Un)},ue(Ct.prototype,function(n,t){var r=/^(?:filter|find|map|reject)|While$/.test(t),e=/^(?:head|last)$/.test(t),u=Z[e?"take"+("last"==t?"Right":""):t],i=e||/^find/.test(t); u&&(Z.prototype[t]=function(){var t=this.__wrapped__,o=e?[1]:arguments,f=t instanceof Ct,c=o[0],l=f||bh(t),s=function(n){var t=u.apply(Z,a([n],o));return e&&h?t[0]:t};l&&r&&"function"==typeof c&&1!=c.length&&(f=l=!1);var h=this.__chain__,p=!!this.__actions__.length,_=i&&!h,v=f&&!p;if(!i&&l){t=v?t:new Ct(this);var g=n.apply(t,o);return g.__actions__.push({func:nf,args:[s],thisArg:X}),new Y(g,h)}return _&&v?n.apply(this,o):(g=this.thru(s),_?e?g.value()[0]:g.value():g)})}),r(["pop","push","shift","sort","splice","unshift"],function(n){ var t=_l[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:pop|shift)$/.test(n);Z.prototype[n]=function(){var n=arguments;if(e&&!this.__chain__){var u=this.value();return t.apply(bh(u)?u:[],n)}return this[r](function(r){return t.apply(bh(r)?r:[],n)})}}),ue(Ct.prototype,function(n,t){var r=Z[t];if(r){var e=r.name+"";bl.call(fs,e)||(fs[e]=[]),fs[e].push({name:t,func:r})}}),fs[Qu(X,vn).name]=[{name:"wrapper",func:X}],Ct.prototype.clone=$t,Ct.prototype.reverse=Yt,Ct.prototype.value=Qt,Z.prototype.at=Qs, Z.prototype.chain=tf,Z.prototype.commit=rf,Z.prototype.next=ef,Z.prototype.plant=of,Z.prototype.reverse=ff,Z.prototype.toJSON=Z.prototype.valueOf=Z.prototype.value=cf,Z.prototype.first=Z.prototype.head,Ul&&(Z.prototype[Ul]=uf),Z},be=de(); true?(re._=be,!(__WEBPACK_AMD_DEFINE_RESULT__ = (function(){return be}).call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__))):0}).call(this); /***/ }), /***/ "./node_modules/math-intrinsics/abs.js": /*!*********************************************!*\ !*** ./node_modules/math-intrinsics/abs.js ***! \*********************************************/ /***/ ((module) => { "use strict"; /** @type {import('./abs')} */ module.exports = Math.abs; /***/ }), /***/ "./node_modules/math-intrinsics/floor.js": /*!***********************************************!*\ !*** ./node_modules/math-intrinsics/floor.js ***! \***********************************************/ /***/ ((module) => { "use strict"; /** @type {import('./floor')} */ module.exports = Math.floor; /***/ }), /***/ "./node_modules/math-intrinsics/isNaN.js": /*!***********************************************!*\ !*** ./node_modules/math-intrinsics/isNaN.js ***! \***********************************************/ /***/ ((module) => { "use strict"; /** @type {import('./isNaN')} */ module.exports = Number.isNaN || function isNaN(a) { return a !== a; }; /***/ }), /***/ "./node_modules/math-intrinsics/max.js": /*!*********************************************!*\ !*** ./node_modules/math-intrinsics/max.js ***! \*********************************************/ /***/ ((module) => { "use strict"; /** @type {import('./max')} */ module.exports = Math.max; /***/ }), /***/ "./node_modules/math-intrinsics/min.js": /*!*********************************************!*\ !*** ./node_modules/math-intrinsics/min.js ***! \*********************************************/ /***/ ((module) => { "use strict"; /** @type {import('./min')} */ module.exports = Math.min; /***/ }), /***/ "./node_modules/math-intrinsics/pow.js": /*!*********************************************!*\ !*** ./node_modules/math-intrinsics/pow.js ***! \*********************************************/ /***/ ((module) => { "use strict"; /** @type {import('./pow')} */ module.exports = Math.pow; /***/ }), /***/ "./node_modules/math-intrinsics/round.js": /*!***********************************************!*\ !*** ./node_modules/math-intrinsics/round.js ***! \***********************************************/ /***/ ((module) => { "use strict"; /** @type {import('./round')} */ module.exports = Math.round; /***/ }), /***/ "./node_modules/math-intrinsics/sign.js": /*!**********************************************!*\ !*** ./node_modules/math-intrinsics/sign.js ***! \**********************************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; var $isNaN = __webpack_require__(/*! ./isNaN */ "./node_modules/math-intrinsics/isNaN.js"); /** @type {import('./sign')} */ module.exports = function sign(number) { if ($isNaN(number) || number === 0) { return number; } return number < 0 ? -1 : +1; }; /***/ }), /***/ "./node_modules/object-is/implementation.js": /*!**************************************************!*\ !*** ./node_modules/object-is/implementation.js ***! \**************************************************/ /***/ ((module) => { "use strict"; var numberIsNaN = function (value) { return value !== value; }; module.exports = function is(a, b) { if (a === 0 && b === 0) { return 1 / a === 1 / b; } if (a === b) { return true; } if (numberIsNaN(a) && numberIsNaN(b)) { return true; } return false; }; /***/ }), /***/ "./node_modules/object-is/index.js": /*!*****************************************!*\ !*** ./node_modules/object-is/index.js ***! \*****************************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; var define = __webpack_require__(/*! define-properties */ "./node_modules/define-properties/index.js"); var callBind = __webpack_require__(/*! call-bind */ "./node_modules/call-bind/index.js"); var implementation = __webpack_require__(/*! ./implementation */ "./node_modules/object-is/implementation.js"); var getPolyfill = __webpack_require__(/*! ./polyfill */ "./node_modules/object-is/polyfill.js"); var shim = __webpack_require__(/*! ./shim */ "./node_modules/object-is/shim.js"); var polyfill = callBind(getPolyfill(), Object); define(polyfill, { getPolyfill: getPolyfill, implementation: implementation, shim: shim }); module.exports = polyfill; /***/ }), /***/ "./node_modules/object-is/polyfill.js": /*!********************************************!*\ !*** ./node_modules/object-is/polyfill.js ***! \********************************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; var implementation = __webpack_require__(/*! ./implementation */ "./node_modules/object-is/implementation.js"); module.exports = function getPolyfill() { return typeof Object.is === 'function' ? Object.is : implementation; }; /***/ }), /***/ "./node_modules/object-is/shim.js": /*!****************************************!*\ !*** ./node_modules/object-is/shim.js ***! \****************************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; var getPolyfill = __webpack_require__(/*! ./polyfill */ "./node_modules/object-is/polyfill.js"); var define = __webpack_require__(/*! define-properties */ "./node_modules/define-properties/index.js"); module.exports = function shimObjectIs() { var polyfill = getPolyfill(); define(Object, { is: polyfill }, { is: function testObjectIs() { return Object.is !== polyfill; } }); return polyfill; }; /***/ }), /***/ "./node_modules/object-keys/implementation.js": /*!****************************************************!*\ !*** ./node_modules/object-keys/implementation.js ***! \****************************************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; var keysShim; if (!Object.keys) { // modified from https://github.com/es-shims/es5-shim var has = Object.prototype.hasOwnProperty; var toStr = Object.prototype.toString; var isArgs = __webpack_require__(/*! ./isArguments */ "./node_modules/object-keys/isArguments.js"); // eslint-disable-line global-require var isEnumerable = Object.prototype.propertyIsEnumerable; var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString'); var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype'); var dontEnums = [ 'toString', 'toLocaleString', 'valueOf', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'constructor' ]; var equalsConstructorPrototype = function (o) { var ctor = o.constructor; return ctor && ctor.prototype === o; }; var excludedKeys = { $applicationCache: true, $console: true, $external: true, $frame: true, $frameElement: true, $frames: true, $innerHeight: true, $innerWidth: true, $onmozfullscreenchange: true, $onmozfullscreenerror: true, $outerHeight: true, $outerWidth: true, $pageXOffset: true, $pageYOffset: true, $parent: true, $scrollLeft: true, $scrollTop: true, $scrollX: true, $scrollY: true, $self: true, $webkitIndexedDB: true, $webkitStorageInfo: true, $window: true }; var hasAutomationEqualityBug = (function () { /* global window */ if (typeof window === 'undefined') { return false; } for (var k in window) { try { if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') { try { equalsConstructorPrototype(window[k]); } catch (e) { return true; } } } catch (e) { return true; } } return false; }()); var equalsConstructorPrototypeIfNotBuggy = function (o) { /* global window */ if (typeof window === 'undefined' || !hasAutomationEqualityBug) { return equalsConstructorPrototype(o); } try { return equalsConstructorPrototype(o); } catch (e) { return false; } }; keysShim = function keys(object) { var isObject = object !== null && typeof object === 'object'; var isFunction = toStr.call(object) === '[object Function]'; var isArguments = isArgs(object); var isString = isObject && toStr.call(object) === '[object String]'; var theKeys = []; if (!isObject && !isFunction && !isArguments) { throw new TypeError('Object.keys called on a non-object'); } var skipProto = hasProtoEnumBug && isFunction; if (isString && object.length > 0 && !has.call(object, 0)) { for (var i = 0; i < object.length; ++i) { theKeys.push(String(i)); } } if (isArguments && object.length > 0) { for (var j = 0; j < object.length; ++j) { theKeys.push(String(j)); } } else { for (var name in object) { if (!(skipProto && name === 'prototype') && has.call(object, name)) { theKeys.push(String(name)); } } } if (hasDontEnumBug) { var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object); for (var k = 0; k < dontEnums.length; ++k) { if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) { theKeys.push(dontEnums[k]); } } } return theKeys; }; } module.exports = keysShim; /***/ }), /***/ "./node_modules/object-keys/index.js": /*!*******************************************!*\ !*** ./node_modules/object-keys/index.js ***! \*******************************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; var slice = Array.prototype.slice; var isArgs = __webpack_require__(/*! ./isArguments */ "./node_modules/object-keys/isArguments.js"); var origKeys = Object.keys; var keysShim = origKeys ? function keys(o) { return origKeys(o); } : __webpack_require__(/*! ./implementation */ "./node_modules/object-keys/implementation.js"); var originalKeys = Object.keys; keysShim.shim = function shimObjectKeys() { if (Object.keys) { var keysWorksWithArguments = (function () { // Safari 5.0 bug var args = Object.keys(arguments); return args && args.length === arguments.length; }(1, 2)); if (!keysWorksWithArguments) { Object.keys = function keys(object) { // eslint-disable-line func-name-matching if (isArgs(object)) { return originalKeys(slice.call(object)); } return originalKeys(object); }; } } else { Object.keys = keysShim; } return Object.keys || keysShim; }; module.exports = keysShim; /***/ }), /***/ "./node_modules/object-keys/isArguments.js": /*!*************************************************!*\ !*** ./node_modules/object-keys/isArguments.js ***! \*************************************************/ /***/ ((module) => { "use strict"; var toStr = Object.prototype.toString; module.exports = function isArguments(value) { var str = toStr.call(value); var isArgs = str === '[object Arguments]'; if (!isArgs) { isArgs = str !== '[object Array]' && value !== null && typeof value === 'object' && typeof value.length === 'number' && value.length >= 0 && toStr.call(value.callee) === '[object Function]'; } return isArgs; }; /***/ }), /***/ "./node_modules/object.assign/implementation.js": /*!******************************************************!*\ !*** ./node_modules/object.assign/implementation.js ***! \******************************************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; // modified from https://github.com/es-shims/es6-shim var objectKeys = __webpack_require__(/*! object-keys */ "./node_modules/object-keys/index.js"); var hasSymbols = __webpack_require__(/*! has-symbols/shams */ "./node_modules/has-symbols/shams.js")(); var callBound = __webpack_require__(/*! call-bound */ "./node_modules/call-bound/index.js"); var $Object = __webpack_require__(/*! es-object-atoms */ "./node_modules/es-object-atoms/index.js"); var $push = callBound('Array.prototype.push'); var $propIsEnumerable = callBound('Object.prototype.propertyIsEnumerable'); var originalGetSymbols = hasSymbols ? $Object.getOwnPropertySymbols : null; // eslint-disable-next-line no-unused-vars module.exports = function assign(target, source1) { if (target == null) { throw new TypeError('target must be an object'); } var to = $Object(target); // step 1 if (arguments.length === 1) { return to; // step 2 } for (var s = 1; s < arguments.length; ++s) { var from = $Object(arguments[s]); // step 3.a.i // step 3.a.ii: var keys = objectKeys(from); var getSymbols = hasSymbols && ($Object.getOwnPropertySymbols || originalGetSymbols); if (getSymbols) { var syms = getSymbols(from); for (var j = 0; j < syms.length; ++j) { var key = syms[j]; if ($propIsEnumerable(from, key)) { $push(keys, key); } } } // step 3.a.iii: for (var i = 0; i < keys.length; ++i) { var nextKey = keys[i]; if ($propIsEnumerable(from, nextKey)) { // step 3.a.iii.2 var propValue = from[nextKey]; // step 3.a.iii.2.a to[nextKey] = propValue; // step 3.a.iii.2.b } } } return to; // step 4 }; /***/ }), /***/ "./node_modules/object.assign/polyfill.js": /*!************************************************!*\ !*** ./node_modules/object.assign/polyfill.js ***! \************************************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; var implementation = __webpack_require__(/*! ./implementation */ "./node_modules/object.assign/implementation.js"); var lacksProperEnumerationOrder = function () { if (!Object.assign) { return false; } /* * v8, specifically in node 4.x, has a bug with incorrect property enumeration order * note: this does not detect the bug unless there's 20 characters */ var str = 'abcdefghijklmnopqrst'; var letters = str.split(''); var map = {}; for (var i = 0; i < letters.length; ++i) { map[letters[i]] = letters[i]; } var obj = Object.assign({}, map); var actual = ''; for (var k in obj) { actual += k; } return str !== actual; }; var assignHasPendingExceptions = function () { if (!Object.assign || !Object.preventExtensions) { return false; } /* * Firefox 37 still has "pending exception" logic in its Object.assign implementation, * which is 72% slower than our shim, and Firefox 40's native implementation. */ var thrower = Object.preventExtensions({ 1: 2 }); try { Object.assign(thrower, 'xy'); } catch (e) { return thrower[1] === 'y'; } return false; }; module.exports = function getPolyfill() { if (!Object.assign) { return implementation; } if (lacksProperEnumerationOrder()) { return implementation; } if (assignHasPendingExceptions()) { return implementation; } return Object.assign; }; /***/ }), /***/ "./node_modules/os-browserify/browser.js": /*!***********************************************!*\ !*** ./node_modules/os-browserify/browser.js ***! \***********************************************/ /***/ ((__unused_webpack_module, exports) => { exports.endianness = function () { return 'LE' }; exports.hostname = function () { if (typeof location !== 'undefined') { return location.hostname } else return ''; }; exports.loadavg = function () { return [] }; exports.uptime = function () { return 0 }; exports.freemem = function () { return Number.MAX_VALUE; }; exports.totalmem = function () { return Number.MAX_VALUE; }; exports.cpus = function () { return [] }; exports.type = function () { return 'Browser' }; exports.release = function () { if (typeof navigator !== 'undefined') { return navigator.appVersion; } return ''; }; exports.networkInterfaces = exports.getNetworkInterfaces = function () { return {} }; exports.arch = function () { return 'javascript' }; exports.platform = function () { return 'browser' }; exports.tmpdir = exports.tmpDir = function () { return '/tmp'; }; exports.EOL = '\n'; exports.homedir = function () { return '/' }; /***/ }), /***/ "./node_modules/possible-typed-array-names/index.js": /*!**********************************************************!*\ !*** ./node_modules/possible-typed-array-names/index.js ***! \**********************************************************/ /***/ ((module) => { "use strict"; /** @type {import('.')} */ module.exports = [ 'Float16Array', 'Float32Array', 'Float64Array', 'Int8Array', 'Int16Array', 'Int32Array', 'Uint8Array', 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'BigInt64Array', 'BigUint64Array' ]; /***/ }), /***/ "./node_modules/process/browser.js": /*!*****************************************!*\ !*** ./node_modules/process/browser.js ***! \*****************************************/ /***/ ((module) => { // shim for using process in browser var process = module.exports = {}; // cached from whatever global is present so that test runners that stub it // don't break things. But we need to wrap it in a try catch in case it is // wrapped in strict mode code which doesn't define any globals. It's inside a // function because try/catches deoptimize in certain engines. var cachedSetTimeout; var cachedClearTimeout; function defaultSetTimout() { throw new Error('setTimeout has not been defined'); } function defaultClearTimeout () { throw new Error('clearTimeout has not been defined'); } (function () { try { if (typeof setTimeout === 'function') { cachedSetTimeout = setTimeout; } else { cachedSetTimeout = defaultSetTimout; } } catch (e) { cachedSetTimeout = defaultSetTimout; } try { if (typeof clearTimeout === 'function') { cachedClearTimeout = clearTimeout; } else { cachedClearTimeout = defaultClearTimeout; } } catch (e) { cachedClearTimeout = defaultClearTimeout; } } ()) function runTimeout(fun) { if (cachedSetTimeout === setTimeout) { //normal enviroments in sane situations return setTimeout(fun, 0); } // if setTimeout wasn't available but was latter defined if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { cachedSetTimeout = setTimeout; return setTimeout(fun, 0); } try { // when when somebody has screwed with setTimeout but no I.E. maddness return cachedSetTimeout(fun, 0); } catch(e){ try { // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally return cachedSetTimeout.call(null, fun, 0); } catch(e){ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error return cachedSetTimeout.call(this, fun, 0); } } } function runClearTimeout(marker) { if (cachedClearTimeout === clearTimeout) { //normal enviroments in sane situations return clearTimeout(marker); } // if clearTimeout wasn't available but was latter defined if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { cachedClearTimeout = clearTimeout; return clearTimeout(marker); } try { // when when somebody has screwed with setTimeout but no I.E. maddness return cachedClearTimeout(marker); } catch (e){ try { // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally return cachedClearTimeout.call(null, marker); } catch (e){ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. // Some versions of I.E. have different rules for clearTimeout vs setTimeout return cachedClearTimeout.call(this, marker); } } } var queue = []; var draining = false; var currentQueue; var queueIndex = -1; function cleanUpNextTick() { if (!draining || !currentQueue) { return; } draining = false; if (currentQueue.length) { queue = currentQueue.concat(queue); } else { queueIndex = -1; } if (queue.length) { drainQueue(); } } function drainQueue() { if (draining) { return; } var timeout = runTimeout(cleanUpNextTick); draining = true; var len = queue.length; while(len) { currentQueue = queue; queue = []; while (++queueIndex < len) { if (currentQueue) { currentQueue[queueIndex].run(); } } queueIndex = -1; len = queue.length; } currentQueue = null; draining = false; runClearTimeout(timeout); } process.nextTick = function (fun) { var args = new Array(arguments.length - 1); if (arguments.length > 1) { for (var i = 1; i < arguments.length; i++) { args[i - 1] = arguments[i]; } } queue.push(new Item(fun, args)); if (queue.length === 1 && !draining) { runTimeout(drainQueue); } }; // v8 likes predictible objects function Item(fun, array) { this.fun = fun; this.array = array; } Item.prototype.run = function () { this.fun.apply(null, this.array); }; process.title = 'browser'; process.browser = true; process.env = {}; process.argv = []; process.version = ''; // empty string to avoid regexp issues process.versions = {}; function noop() {} process.on = noop; process.addListener = noop; process.once = noop; process.off = noop; process.removeListener = noop; process.removeAllListeners = noop; process.emit = noop; process.prependListener = noop; process.prependOnceListener = noop; process.listeners = function (name) { return [] } process.binding = function (name) { throw new Error('process.binding is not supported'); }; process.cwd = function () { return '/' }; process.chdir = function (dir) { throw new Error('process.chdir is not supported'); }; process.umask = function() { return 0; }; /***/ }), /***/ "./node_modules/recast/lib/comments.js": /*!*********************************************!*\ !*** ./node_modules/recast/lib/comments.js ***! \*********************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.printComments = exports.attach = void 0; var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.mjs"); var tiny_invariant_1 = tslib_1.__importDefault(__webpack_require__(/*! tiny-invariant */ "./node_modules/tiny-invariant/dist/tiny-invariant.cjs.js")); var types = tslib_1.__importStar(__webpack_require__(/*! ast-types */ "./node_modules/ast-types/lib/main.js")); var n = types.namedTypes; var isArray = types.builtInTypes.array; var isObject = types.builtInTypes.object; var lines_1 = __webpack_require__(/*! ./lines */ "./node_modules/recast/lib/lines.js"); var util_1 = __webpack_require__(/*! ./util */ "./node_modules/recast/lib/util.js"); var childNodesCache = new WeakMap(); // TODO Move a non-caching implementation of this function into ast-types, // and implement a caching wrapper function here. function getSortedChildNodes(node, lines, resultArray) { if (!node) { return resultArray; } // The .loc checks below are sensitive to some of the problems that // are fixed by this utility function. Specifically, if it decides to // set node.loc to null, indicating that the node's .loc information // is unreliable, then we don't want to add node to the resultArray. (0, util_1.fixFaultyLocations)(node, lines); if (resultArray) { if (n.Node.check(node) && n.SourceLocation.check(node.loc)) { // This reverse insertion sort almost always takes constant // time because we almost always (maybe always?) append the // nodes in order anyway. var i = resultArray.length - 1; for (; i >= 0; --i) { var child = resultArray[i]; if (child && child.loc && (0, util_1.comparePos)(child.loc.end, node.loc.start) <= 0) { break; } } resultArray.splice(i + 1, 0, node); return resultArray; } } else { var childNodes = childNodesCache.get(node); if (childNodes) { return childNodes; } } var names; if (isArray.check(node)) { names = Object.keys(node); } else if (isObject.check(node)) { names = types.getFieldNames(node); } else { return resultArray; } if (!resultArray) { childNodesCache.set(node, (resultArray = [])); } for (var i = 0, nameCount = names.length; i < nameCount; ++i) { getSortedChildNodes(node[names[i]], lines, resultArray); } return resultArray; } // As efficiently as possible, decorate the comment object with // .precedingNode, .enclosingNode, and/or .followingNode properties, at // least one of which is guaranteed to be defined. function decorateComment(node, comment, lines) { var childNodes = getSortedChildNodes(node, lines); // Time to dust off the old binary search robes and wizard hat. var left = 0; var right = childNodes && childNodes.length; var precedingNode; var followingNode; while (typeof right === "number" && left < right) { var middle = (left + right) >> 1; var child = childNodes[middle]; if ((0, util_1.comparePos)(child.loc.start, comment.loc.start) <= 0 && (0, util_1.comparePos)(comment.loc.end, child.loc.end) <= 0) { // The comment is completely contained by this child node. decorateComment((comment.enclosingNode = child), comment, lines); return; // Abandon the binary search at this level. } if ((0, util_1.comparePos)(child.loc.end, comment.loc.start) <= 0) { // This child node falls completely before the comment. // Because we will never consider this node or any nodes // before it again, this node must be the closest preceding // node we have encountered so far. precedingNode = child; left = middle + 1; continue; } if ((0, util_1.comparePos)(comment.loc.end, child.loc.start) <= 0) { // This child node falls completely after the comment. // Because we will never consider this node or any nodes after // it again, this node must be the closest following node we // have encountered so far. followingNode = child; right = middle; continue; } throw new Error("Comment location overlaps with node location"); } if (precedingNode) { comment.precedingNode = precedingNode; } if (followingNode) { comment.followingNode = followingNode; } } function attach(comments, ast, lines) { if (!isArray.check(comments)) { return; } var tiesToBreak = []; comments.forEach(function (comment) { comment.loc.lines = lines; decorateComment(ast, comment, lines); var pn = comment.precedingNode; var en = comment.enclosingNode; var fn = comment.followingNode; if (pn && fn) { var tieCount = tiesToBreak.length; if (tieCount > 0) { var lastTie = tiesToBreak[tieCount - 1]; (0, tiny_invariant_1.default)((lastTie.precedingNode === comment.precedingNode) === (lastTie.followingNode === comment.followingNode)); if (lastTie.followingNode !== comment.followingNode) { breakTies(tiesToBreak, lines); } } tiesToBreak.push(comment); } else if (pn) { // No contest: we have a trailing comment. breakTies(tiesToBreak, lines); addTrailingComment(pn, comment); } else if (fn) { // No contest: we have a leading comment. breakTies(tiesToBreak, lines); addLeadingComment(fn, comment); } else if (en) { // The enclosing node has no child nodes at all, so what we // have here is a dangling comment, e.g. [/* crickets */]. breakTies(tiesToBreak, lines); addDanglingComment(en, comment); } else { throw new Error("AST contains no nodes at all?"); } }); breakTies(tiesToBreak, lines); comments.forEach(function (comment) { // These node references were useful for breaking ties, but we // don't need them anymore, and they create cycles in the AST that // may lead to infinite recursion if we don't delete them here. delete comment.precedingNode; delete comment.enclosingNode; delete comment.followingNode; }); } exports.attach = attach; function breakTies(tiesToBreak, lines) { var tieCount = tiesToBreak.length; if (tieCount === 0) { return; } var pn = tiesToBreak[0].precedingNode; var fn = tiesToBreak[0].followingNode; var gapEndPos = fn.loc.start; // Iterate backwards through tiesToBreak, examining the gaps // between the tied comments. In order to qualify as leading, a // comment must be separated from fn by an unbroken series of // whitespace-only gaps (or other comments). var indexOfFirstLeadingComment = tieCount; var comment; for (; indexOfFirstLeadingComment > 0; --indexOfFirstLeadingComment) { comment = tiesToBreak[indexOfFirstLeadingComment - 1]; (0, tiny_invariant_1.default)(comment.precedingNode === pn); (0, tiny_invariant_1.default)(comment.followingNode === fn); var gap = lines.sliceString(comment.loc.end, gapEndPos); if (/\S/.test(gap)) { // The gap string contained something other than whitespace. break; } gapEndPos = comment.loc.start; } while (indexOfFirstLeadingComment <= tieCount && (comment = tiesToBreak[indexOfFirstLeadingComment]) && // If the comment is a //-style comment and indented more // deeply than the node itself, reconsider it as trailing. (comment.type === "Line" || comment.type === "CommentLine") && comment.loc.start.column > fn.loc.start.column) { ++indexOfFirstLeadingComment; } if (indexOfFirstLeadingComment) { var enclosingNode = tiesToBreak[indexOfFirstLeadingComment - 1].enclosingNode; if ((enclosingNode === null || enclosingNode === void 0 ? void 0 : enclosingNode.type) === "CallExpression") { --indexOfFirstLeadingComment; } } tiesToBreak.forEach(function (comment, i) { if (i < indexOfFirstLeadingComment) { addTrailingComment(pn, comment); } else { addLeadingComment(fn, comment); } }); tiesToBreak.length = 0; } function addCommentHelper(node, comment) { var comments = node.comments || (node.comments = []); comments.push(comment); } function addLeadingComment(node, comment) { comment.leading = true; comment.trailing = false; addCommentHelper(node, comment); } function addDanglingComment(node, comment) { comment.leading = false; comment.trailing = false; addCommentHelper(node, comment); } function addTrailingComment(node, comment) { comment.leading = false; comment.trailing = true; addCommentHelper(node, comment); } function printLeadingComment(commentPath, print) { var comment = commentPath.getValue(); n.Comment.assert(comment); var loc = comment.loc; var lines = loc && loc.lines; var parts = [print(commentPath)]; if (comment.trailing) { // When we print trailing comments as leading comments, we don't // want to bring any trailing spaces along. parts.push("\n"); } else if (lines instanceof lines_1.Lines) { var trailingSpace = lines.slice(loc.end, lines.skipSpaces(loc.end) || lines.lastPos()); if (trailingSpace.length === 1) { // If the trailing space contains no newlines, then we want to // preserve it exactly as we found it. parts.push(trailingSpace); } else { // If the trailing space contains newlines, then replace it // with just that many newlines, with all other spaces removed. parts.push(new Array(trailingSpace.length).join("\n")); } } else { parts.push("\n"); } return (0, lines_1.concat)(parts); } function printTrailingComment(commentPath, print) { var comment = commentPath.getValue(commentPath); n.Comment.assert(comment); var loc = comment.loc; var lines = loc && loc.lines; var parts = []; if (lines instanceof lines_1.Lines) { var fromPos = lines.skipSpaces(loc.start, true) || lines.firstPos(); var leadingSpace = lines.slice(fromPos, loc.start); if (leadingSpace.length === 1) { // If the leading space contains no newlines, then we want to // preserve it exactly as we found it. parts.push(leadingSpace); } else { // If the leading space contains newlines, then replace it // with just that many newlines, sans all other spaces. parts.push(new Array(leadingSpace.length).join("\n")); } } parts.push(print(commentPath)); return (0, lines_1.concat)(parts); } function printComments(path, print) { var value = path.getValue(); var innerLines = print(path); var comments = n.Node.check(value) && types.getFieldValue(value, "comments"); if (!comments || comments.length === 0) { return innerLines; } var leadingParts = []; var trailingParts = [innerLines]; path.each(function (commentPath) { var comment = commentPath.getValue(); var leading = types.getFieldValue(comment, "leading"); var trailing = types.getFieldValue(comment, "trailing"); if (leading || (trailing && !(n.Statement.check(value) || comment.type === "Block" || comment.type === "CommentBlock"))) { leadingParts.push(printLeadingComment(commentPath, print)); } else if (trailing) { trailingParts.push(printTrailingComment(commentPath, print)); } }, "comments"); leadingParts.push.apply(leadingParts, trailingParts); return (0, lines_1.concat)(leadingParts); } exports.printComments = printComments; /***/ }), /***/ "./node_modules/recast/lib/fast-path.js": /*!**********************************************!*\ !*** ./node_modules/recast/lib/fast-path.js ***! \**********************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.mjs"); var tiny_invariant_1 = tslib_1.__importDefault(__webpack_require__(/*! tiny-invariant */ "./node_modules/tiny-invariant/dist/tiny-invariant.cjs.js")); var types = tslib_1.__importStar(__webpack_require__(/*! ast-types */ "./node_modules/ast-types/lib/main.js")); var util = tslib_1.__importStar(__webpack_require__(/*! ./util */ "./node_modules/recast/lib/util.js")); var n = types.namedTypes; var isArray = types.builtInTypes.array; var isNumber = types.builtInTypes.number; var PRECEDENCE = {}; [ ["??"], ["||"], ["&&"], ["|"], ["^"], ["&"], ["==", "===", "!=", "!=="], ["<", ">", "<=", ">=", "in", "instanceof"], [">>", "<<", ">>>"], ["+", "-"], ["*", "/", "%"], ["**"], ].forEach(function (tier, i) { tier.forEach(function (op) { PRECEDENCE[op] = i; }); }); var FastPath = function FastPath(value) { (0, tiny_invariant_1.default)(this instanceof FastPath); this.stack = [value]; }; var FPp = FastPath.prototype; // Static convenience function for coercing a value to a FastPath. FastPath.from = function (obj) { if (obj instanceof FastPath) { // Return a defensive copy of any existing FastPath instances. return obj.copy(); } if (obj instanceof types.NodePath) { // For backwards compatibility, unroll NodePath instances into // lightweight FastPath [..., name, value] stacks. var copy = Object.create(FastPath.prototype); var stack = [obj.value]; for (var pp = void 0; (pp = obj.parentPath); obj = pp) stack.push(obj.name, pp.value); copy.stack = stack.reverse(); return copy; } // Otherwise use obj as the value of the new FastPath instance. return new FastPath(obj); }; FPp.copy = function copy() { var copy = Object.create(FastPath.prototype); copy.stack = this.stack.slice(0); return copy; }; // The name of the current property is always the penultimate element of // this.stack, and always a String. FPp.getName = function getName() { var s = this.stack; var len = s.length; if (len > 1) { return s[len - 2]; } // Since the name is always a string, null is a safe sentinel value to // return if we do not know the name of the (root) value. return null; }; // The value of the current property is always the final element of // this.stack. FPp.getValue = function getValue() { var s = this.stack; return s[s.length - 1]; }; FPp.valueIsDuplicate = function () { var s = this.stack; var valueIndex = s.length - 1; return s.lastIndexOf(s[valueIndex], valueIndex - 1) >= 0; }; function getNodeHelper(path, count) { var s = path.stack; for (var i = s.length - 1; i >= 0; i -= 2) { var value = s[i]; if (n.Node.check(value) && --count < 0) { return value; } } return null; } FPp.getNode = function getNode(count) { if (count === void 0) { count = 0; } return getNodeHelper(this, ~~count); }; FPp.getParentNode = function getParentNode(count) { if (count === void 0) { count = 0; } return getNodeHelper(this, ~~count + 1); }; // The length of the stack can be either even or odd, depending on whether // or not we have a name for the root value. The difference between the // index of the root value and the index of the final value is always // even, though, which allows us to return the root value in constant time // (i.e. without iterating backwards through the stack). FPp.getRootValue = function getRootValue() { var s = this.stack; if (s.length % 2 === 0) { return s[1]; } return s[0]; }; // Temporarily push properties named by string arguments given after the // callback function onto this.stack, then call the callback with a // reference to this (modified) FastPath object. Note that the stack will // be restored to its original state after the callback is finished, so it // is probably a mistake to retain a reference to the path. FPp.call = function call(callback /*, name1, name2, ... */) { var s = this.stack; var origLen = s.length; var value = s[origLen - 1]; var argc = arguments.length; for (var i = 1; i < argc; ++i) { var name = arguments[i]; value = value[name]; s.push(name, value); } var result = callback(this); s.length = origLen; return result; }; // Similar to FastPath.prototype.call, except that the value obtained by // accessing this.getValue()[name1][name2]... should be array-like. The // callback will be called with a reference to this path object for each // element of the array. FPp.each = function each(callback /*, name1, name2, ... */) { var s = this.stack; var origLen = s.length; var value = s[origLen - 1]; var argc = arguments.length; for (var i = 1; i < argc; ++i) { var name = arguments[i]; value = value[name]; s.push(name, value); } for (var i = 0; i < value.length; ++i) { if (i in value) { s.push(i, value[i]); // If the callback needs to know the value of i, call // path.getName(), assuming path is the parameter name. callback(this); s.length -= 2; } } s.length = origLen; }; // Similar to FastPath.prototype.each, except that the results of the // callback function invocations are stored in an array and returned at // the end of the iteration. FPp.map = function map(callback /*, name1, name2, ... */) { var s = this.stack; var origLen = s.length; var value = s[origLen - 1]; var argc = arguments.length; for (var i = 1; i < argc; ++i) { var name = arguments[i]; value = value[name]; s.push(name, value); } var result = new Array(value.length); for (var i = 0; i < value.length; ++i) { if (i in value) { s.push(i, value[i]); result[i] = callback(this, i); s.length -= 2; } } s.length = origLen; return result; }; // Returns true if the node at the tip of the path is wrapped with // parentheses, OR if the only reason the node needed parentheses was that // it couldn't be the first expression in the enclosing statement (see // FastPath#canBeFirstInStatement), and it has an opening `(` character. // For example, the FunctionExpression in `(function(){}())` appears to // need parentheses only because it's the first expression in the AST, but // since it happens to be preceded by a `(` (which is not apparent from // the AST but can be determined using FastPath#getPrevToken), there is no // ambiguity about how to parse it, so it counts as having parentheses, // even though it is not immediately followed by a `)`. FPp.hasParens = function () { var node = this.getNode(); var prevToken = this.getPrevToken(node); if (!prevToken) { return false; } var nextToken = this.getNextToken(node); if (!nextToken) { return false; } if (prevToken.value === "(") { if (nextToken.value === ")") { // If the node preceded by a `(` token and followed by a `)` token, // then of course it has parentheses. return true; } // If this is one of the few Expression types that can't come first in // the enclosing statement because of parsing ambiguities (namely, // FunctionExpression, ObjectExpression, and ClassExpression) and // this.firstInStatement() returns true, and the node would not need // parentheses in an expression context because this.needsParens(true) // returns false, then it just needs an opening parenthesis to resolve // the parsing ambiguity that made it appear to need parentheses. var justNeedsOpeningParen = !this.canBeFirstInStatement() && this.firstInStatement() && !this.needsParens(true); if (justNeedsOpeningParen) { return true; } } return false; }; FPp.getPrevToken = function (node) { node = node || this.getNode(); var loc = node && node.loc; var tokens = loc && loc.tokens; if (tokens && loc.start.token > 0) { var token = tokens[loc.start.token - 1]; if (token) { // Do not return tokens that fall outside the root subtree. var rootLoc = this.getRootValue().loc; if (util.comparePos(rootLoc.start, token.loc.start) <= 0) { return token; } } } return null; }; FPp.getNextToken = function (node) { node = node || this.getNode(); var loc = node && node.loc; var tokens = loc && loc.tokens; if (tokens && loc.end.token < tokens.length) { var token = tokens[loc.end.token]; if (token) { // Do not return tokens that fall outside the root subtree. var rootLoc = this.getRootValue().loc; if (util.comparePos(token.loc.end, rootLoc.end) <= 0) { return token; } } } return null; }; // Inspired by require("ast-types").NodePath.prototype.needsParens, but // more efficient because we're iterating backwards through a stack. FPp.needsParens = function (assumeExpressionContext) { var node = this.getNode(); // This needs to come before `if (!parent) { return false }` because // an object destructuring assignment requires parens for // correctness even when it's the topmost expression. if (node.type === "AssignmentExpression" && node.left.type === "ObjectPattern") { return true; } var parent = this.getParentNode(); var name = this.getName(); // If the value of this path is some child of a Node and not a Node // itself, then it doesn't need parentheses. Only Node objects (in fact, // only Expression nodes) need parentheses. if (this.getValue() !== node) { return false; } // Only statements don't need parentheses. if (n.Statement.check(node)) { return false; } // Identifiers never need parentheses. if (node.type === "Identifier") { return false; } if (parent && parent.type === "ParenthesizedExpression") { return false; } if (node.extra && node.extra.parenthesized) { return true; } if (!parent) return false; // Wrap e.g. `-1` in parentheses inside `(-1) ** 2`. if (node.type === "UnaryExpression" && parent.type === "BinaryExpression" && name === "left" && parent.left === node && parent.operator === "**") { return true; } switch (node.type) { case "UnaryExpression": case "SpreadElement": case "SpreadProperty": return (parent.type === "MemberExpression" && name === "object" && parent.object === node); case "BinaryExpression": case "LogicalExpression": switch (parent.type) { case "CallExpression": return name === "callee" && parent.callee === node; case "UnaryExpression": case "SpreadElement": case "SpreadProperty": return true; case "MemberExpression": return name === "object" && parent.object === node; case "BinaryExpression": case "LogicalExpression": { var po = parent.operator; var pp = PRECEDENCE[po]; var no = node.operator; var np = PRECEDENCE[no]; if (pp > np) { return true; } if (pp === np && name === "right") { (0, tiny_invariant_1.default)(parent.right === node); return true; } break; } default: return false; } break; case "SequenceExpression": switch (parent.type) { case "ReturnStatement": return false; case "ForStatement": // Although parentheses wouldn't hurt around sequence expressions in // the head of for loops, traditional style dictates that e.g. i++, // j++ should not be wrapped with parentheses. return false; case "ExpressionStatement": return name !== "expression"; default: // Otherwise err on the side of overparenthesization, adding // explicit exceptions above if this proves overzealous. return true; } case "OptionalIndexedAccessType": return node.optional && parent.type === "IndexedAccessType"; case "IntersectionTypeAnnotation": case "UnionTypeAnnotation": return parent.type === "NullableTypeAnnotation"; case "Literal": return (parent.type === "MemberExpression" && isNumber.check(node.value) && name === "object" && parent.object === node); // Babel 6 Literal split case "NumericLiteral": return (parent.type === "MemberExpression" && name === "object" && parent.object === node); case "YieldExpression": case "AwaitExpression": case "AssignmentExpression": case "ConditionalExpression": switch (parent.type) { case "UnaryExpression": case "SpreadElement": case "SpreadProperty": case "BinaryExpression": case "LogicalExpression": return true; case "CallExpression": case "NewExpression": return name === "callee" && parent.callee === node; case "ConditionalExpression": return name === "test" && parent.test === node; case "MemberExpression": return name === "object" && parent.object === node; default: return false; } case "ArrowFunctionExpression": if (n.CallExpression.check(parent) && name === "callee" && parent.callee === node) { return true; } if (n.MemberExpression.check(parent) && name === "object" && parent.object === node) { return true; } if (n.TSAsExpression && n.TSAsExpression.check(parent) && name === "expression" && parent.expression === node) { return true; } return isBinary(parent); case "ObjectExpression": if (parent.type === "ArrowFunctionExpression" && name === "body" && parent.body === node) { return true; } break; case "TSAsExpression": if (parent.type === "ArrowFunctionExpression" && name === "body" && parent.body === node && node.expression.type === "ObjectExpression") { return true; } break; case "CallExpression": if (name === "declaration" && n.ExportDefaultDeclaration.check(parent) && n.FunctionExpression.check(node.callee)) { return true; } } if (parent.type === "NewExpression" && name === "callee" && parent.callee === node) { return containsCallExpression(node); } if (assumeExpressionContext !== true && !this.canBeFirstInStatement() && this.firstInStatement()) { return true; } return false; }; function isBinary(node) { return n.BinaryExpression.check(node) || n.LogicalExpression.check(node); } // @ts-ignore 'isUnaryLike' is declared but its value is never read. [6133] function isUnaryLike(node) { return (n.UnaryExpression.check(node) || // I considered making SpreadElement and SpreadProperty subtypes of // UnaryExpression, but they're not really Expression nodes. (n.SpreadElement && n.SpreadElement.check(node)) || (n.SpreadProperty && n.SpreadProperty.check(node))); } function containsCallExpression(node) { if (n.CallExpression.check(node)) { return true; } if (isArray.check(node)) { return node.some(containsCallExpression); } if (n.Node.check(node)) { return types.someField(node, function (_name, child) { return containsCallExpression(child); }); } return false; } FPp.canBeFirstInStatement = function () { var node = this.getNode(); if (n.FunctionExpression.check(node)) { return false; } if (n.ObjectExpression.check(node)) { return false; } if (n.ClassExpression.check(node)) { return false; } return true; }; FPp.firstInStatement = function () { var s = this.stack; var parentName, parent; var childName, child; for (var i = s.length - 1; i >= 0; i -= 2) { if (n.Node.check(s[i])) { childName = parentName; child = parent; parentName = s[i - 1]; parent = s[i]; } if (!parent || !child) { continue; } if (n.BlockStatement.check(parent) && parentName === "body" && childName === 0) { (0, tiny_invariant_1.default)(parent.body[0] === child); return true; } if (n.ExpressionStatement.check(parent) && childName === "expression") { (0, tiny_invariant_1.default)(parent.expression === child); return true; } if (n.AssignmentExpression.check(parent) && childName === "left") { (0, tiny_invariant_1.default)(parent.left === child); return true; } if (n.ArrowFunctionExpression.check(parent) && childName === "body") { (0, tiny_invariant_1.default)(parent.body === child); return true; } // s[i + 1] and s[i + 2] represent the array between the parent // SequenceExpression node and its child nodes if (n.SequenceExpression.check(parent) && s[i + 1] === "expressions" && childName === 0) { (0, tiny_invariant_1.default)(parent.expressions[0] === child); continue; } if (n.CallExpression.check(parent) && childName === "callee") { (0, tiny_invariant_1.default)(parent.callee === child); continue; } if (n.MemberExpression.check(parent) && childName === "object") { (0, tiny_invariant_1.default)(parent.object === child); continue; } if (n.ConditionalExpression.check(parent) && childName === "test") { (0, tiny_invariant_1.default)(parent.test === child); continue; } if (isBinary(parent) && childName === "left") { (0, tiny_invariant_1.default)(parent.left === child); continue; } if (n.UnaryExpression.check(parent) && !parent.prefix && childName === "argument") { (0, tiny_invariant_1.default)(parent.argument === child); continue; } return false; } return true; }; exports["default"] = FastPath; /***/ }), /***/ "./node_modules/recast/lib/lines.js": /*!******************************************!*\ !*** ./node_modules/recast/lib/lines.js ***! \******************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.concat = exports.fromString = exports.countSpaces = exports.Lines = void 0; var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.mjs"); var tiny_invariant_1 = tslib_1.__importDefault(__webpack_require__(/*! tiny-invariant */ "./node_modules/tiny-invariant/dist/tiny-invariant.cjs.js")); var source_map_1 = tslib_1.__importDefault(__webpack_require__(/*! source-map */ "./node_modules/recast/node_modules/source-map/source-map.js")); var options_1 = __webpack_require__(/*! ./options */ "./node_modules/recast/lib/options.js"); var util_1 = __webpack_require__(/*! ./util */ "./node_modules/recast/lib/util.js"); var mapping_1 = tslib_1.__importDefault(__webpack_require__(/*! ./mapping */ "./node_modules/recast/lib/mapping.js")); var Lines = /** @class */ (function () { function Lines(infos, sourceFileName) { if (sourceFileName === void 0) { sourceFileName = null; } this.infos = infos; this.mappings = []; this.cachedSourceMap = null; this.cachedTabWidth = void 0; (0, tiny_invariant_1.default)(infos.length > 0); this.length = infos.length; this.name = sourceFileName || null; if (this.name) { this.mappings.push(new mapping_1.default(this, { start: this.firstPos(), end: this.lastPos(), })); } } Lines.prototype.toString = function (options) { return this.sliceString(this.firstPos(), this.lastPos(), options); }; Lines.prototype.getSourceMap = function (sourceMapName, sourceRoot) { if (!sourceMapName) { // Although we could make up a name or generate an anonymous // source map, instead we assume that any consumer who does not // provide a name does not actually want a source map. return null; } var targetLines = this; function updateJSON(json) { json = json || {}; json.file = sourceMapName; if (sourceRoot) { json.sourceRoot = sourceRoot; } return json; } if (targetLines.cachedSourceMap) { // Since Lines objects are immutable, we can reuse any source map // that was previously generated. Nevertheless, we return a new // JSON object here to protect the cached source map from outside // modification. return updateJSON(targetLines.cachedSourceMap.toJSON()); } var smg = new source_map_1.default.SourceMapGenerator(updateJSON()); var sourcesToContents = {}; targetLines.mappings.forEach(function (mapping) { var sourceCursor = mapping.sourceLines.skipSpaces(mapping.sourceLoc.start) || mapping.sourceLines.lastPos(); var targetCursor = targetLines.skipSpaces(mapping.targetLoc.start) || targetLines.lastPos(); while ((0, util_1.comparePos)(sourceCursor, mapping.sourceLoc.end) < 0 && (0, util_1.comparePos)(targetCursor, mapping.targetLoc.end) < 0) { var sourceChar = mapping.sourceLines.charAt(sourceCursor); var targetChar = targetLines.charAt(targetCursor); (0, tiny_invariant_1.default)(sourceChar === targetChar); var sourceName = mapping.sourceLines.name; // Add mappings one character at a time for maximum resolution. smg.addMapping({ source: sourceName, original: { line: sourceCursor.line, column: sourceCursor.column }, generated: { line: targetCursor.line, column: targetCursor.column }, }); if (!hasOwn.call(sourcesToContents, sourceName)) { var sourceContent = mapping.sourceLines.toString(); smg.setSourceContent(sourceName, sourceContent); sourcesToContents[sourceName] = sourceContent; } targetLines.nextPos(targetCursor, true); mapping.sourceLines.nextPos(sourceCursor, true); } }); targetLines.cachedSourceMap = smg; return smg.toJSON(); }; Lines.prototype.bootstrapCharAt = function (pos) { (0, tiny_invariant_1.default)(typeof pos === "object"); (0, tiny_invariant_1.default)(typeof pos.line === "number"); (0, tiny_invariant_1.default)(typeof pos.column === "number"); var line = pos.line, column = pos.column, strings = this.toString().split(lineTerminatorSeqExp), string = strings[line - 1]; if (typeof string === "undefined") return ""; if (column === string.length && line < strings.length) return "\n"; if (column >= string.length) return ""; return string.charAt(column); }; Lines.prototype.charAt = function (pos) { (0, tiny_invariant_1.default)(typeof pos === "object"); (0, tiny_invariant_1.default)(typeof pos.line === "number"); (0, tiny_invariant_1.default)(typeof pos.column === "number"); var line = pos.line, column = pos.column, secret = this, infos = secret.infos, info = infos[line - 1], c = column; if (typeof info === "undefined" || c < 0) return ""; var indent = this.getIndentAt(line); if (c < indent) return " "; c += info.sliceStart - indent; if (c === info.sliceEnd && line < this.length) return "\n"; if (c >= info.sliceEnd) return ""; return info.line.charAt(c); }; Lines.prototype.stripMargin = function (width, skipFirstLine) { if (width === 0) return this; (0, tiny_invariant_1.default)(width > 0, "negative margin: " + width); if (skipFirstLine && this.length === 1) return this; var lines = new Lines(this.infos.map(function (info, i) { if (info.line && (i > 0 || !skipFirstLine)) { info = tslib_1.__assign(tslib_1.__assign({}, info), { indent: Math.max(0, info.indent - width) }); } return info; })); if (this.mappings.length > 0) { var newMappings_1 = lines.mappings; (0, tiny_invariant_1.default)(newMappings_1.length === 0); this.mappings.forEach(function (mapping) { newMappings_1.push(mapping.indent(width, skipFirstLine, true)); }); } return lines; }; Lines.prototype.indent = function (by) { if (by === 0) { return this; } var lines = new Lines(this.infos.map(function (info) { if (info.line && !info.locked) { info = tslib_1.__assign(tslib_1.__assign({}, info), { indent: info.indent + by }); } return info; })); if (this.mappings.length > 0) { var newMappings_2 = lines.mappings; (0, tiny_invariant_1.default)(newMappings_2.length === 0); this.mappings.forEach(function (mapping) { newMappings_2.push(mapping.indent(by)); }); } return lines; }; Lines.prototype.indentTail = function (by) { if (by === 0) { return this; } if (this.length < 2) { return this; } var lines = new Lines(this.infos.map(function (info, i) { if (i > 0 && info.line && !info.locked) { info = tslib_1.__assign(tslib_1.__assign({}, info), { indent: info.indent + by }); } return info; })); if (this.mappings.length > 0) { var newMappings_3 = lines.mappings; (0, tiny_invariant_1.default)(newMappings_3.length === 0); this.mappings.forEach(function (mapping) { newMappings_3.push(mapping.indent(by, true)); }); } return lines; }; Lines.prototype.lockIndentTail = function () { if (this.length < 2) { return this; } return new Lines(this.infos.map(function (info, i) { return (tslib_1.__assign(tslib_1.__assign({}, info), { locked: i > 0 })); })); }; Lines.prototype.getIndentAt = function (line) { (0, tiny_invariant_1.default)(line >= 1, "no line " + line + " (line numbers start from 1)"); return Math.max(this.infos[line - 1].indent, 0); }; Lines.prototype.guessTabWidth = function () { if (typeof this.cachedTabWidth === "number") { return this.cachedTabWidth; } var counts = []; // Sparse array. var lastIndent = 0; for (var line = 1, last = this.length; line <= last; ++line) { var info = this.infos[line - 1]; var sliced = info.line.slice(info.sliceStart, info.sliceEnd); // Whitespace-only lines don't tell us much about the likely tab // width of this code. if (isOnlyWhitespace(sliced)) { continue; } var diff = Math.abs(info.indent - lastIndent); counts[diff] = ~~counts[diff] + 1; lastIndent = info.indent; } var maxCount = -1; var result = 2; for (var tabWidth = 1; tabWidth < counts.length; tabWidth += 1) { if (hasOwn.call(counts, tabWidth) && counts[tabWidth] > maxCount) { maxCount = counts[tabWidth]; result = tabWidth; } } return (this.cachedTabWidth = result); }; // Determine if the list of lines has a first line that starts with a // // or /* comment. If this is the case, the code may need to be wrapped in // parens to avoid ASI issues. Lines.prototype.startsWithComment = function () { if (this.infos.length === 0) { return false; } var firstLineInfo = this.infos[0], sliceStart = firstLineInfo.sliceStart, sliceEnd = firstLineInfo.sliceEnd, firstLine = firstLineInfo.line.slice(sliceStart, sliceEnd).trim(); return (firstLine.length === 0 || firstLine.slice(0, 2) === "//" || firstLine.slice(0, 2) === "/*"); }; Lines.prototype.isOnlyWhitespace = function () { return isOnlyWhitespace(this.toString()); }; Lines.prototype.isPrecededOnlyByWhitespace = function (pos) { var info = this.infos[pos.line - 1]; var indent = Math.max(info.indent, 0); var diff = pos.column - indent; if (diff <= 0) { // If pos.column does not exceed the indentation amount, then // there must be only whitespace before it. return true; } var start = info.sliceStart; var end = Math.min(start + diff, info.sliceEnd); var prefix = info.line.slice(start, end); return isOnlyWhitespace(prefix); }; Lines.prototype.getLineLength = function (line) { var info = this.infos[line - 1]; return this.getIndentAt(line) + info.sliceEnd - info.sliceStart; }; Lines.prototype.nextPos = function (pos, skipSpaces) { if (skipSpaces === void 0) { skipSpaces = false; } var l = Math.max(pos.line, 0), c = Math.max(pos.column, 0); if (c < this.getLineLength(l)) { pos.column += 1; return skipSpaces ? !!this.skipSpaces(pos, false, true) : true; } if (l < this.length) { pos.line += 1; pos.column = 0; return skipSpaces ? !!this.skipSpaces(pos, false, true) : true; } return false; }; Lines.prototype.prevPos = function (pos, skipSpaces) { if (skipSpaces === void 0) { skipSpaces = false; } var l = pos.line, c = pos.column; if (c < 1) { l -= 1; if (l < 1) return false; c = this.getLineLength(l); } else { c = Math.min(c - 1, this.getLineLength(l)); } pos.line = l; pos.column = c; return skipSpaces ? !!this.skipSpaces(pos, true, true) : true; }; Lines.prototype.firstPos = function () { // Trivial, but provided for completeness. return { line: 1, column: 0 }; }; Lines.prototype.lastPos = function () { return { line: this.length, column: this.getLineLength(this.length), }; }; Lines.prototype.skipSpaces = function (pos, backward, modifyInPlace) { if (backward === void 0) { backward = false; } if (modifyInPlace === void 0) { modifyInPlace = false; } if (pos) { pos = modifyInPlace ? pos : { line: pos.line, column: pos.column, }; } else if (backward) { pos = this.lastPos(); } else { pos = this.firstPos(); } if (backward) { while (this.prevPos(pos)) { if (!isOnlyWhitespace(this.charAt(pos)) && this.nextPos(pos)) { return pos; } } return null; } else { while (isOnlyWhitespace(this.charAt(pos))) { if (!this.nextPos(pos)) { return null; } } return pos; } }; Lines.prototype.trimLeft = function () { var pos = this.skipSpaces(this.firstPos(), false, true); return pos ? this.slice(pos) : emptyLines; }; Lines.prototype.trimRight = function () { var pos = this.skipSpaces(this.lastPos(), true, true); return pos ? this.slice(this.firstPos(), pos) : emptyLines; }; Lines.prototype.trim = function () { var start = this.skipSpaces(this.firstPos(), false, true); if (start === null) { return emptyLines; } var end = this.skipSpaces(this.lastPos(), true, true); if (end === null) { return emptyLines; } return this.slice(start, end); }; Lines.prototype.eachPos = function (callback, startPos, skipSpaces) { if (startPos === void 0) { startPos = this.firstPos(); } if (skipSpaces === void 0) { skipSpaces = false; } var pos = this.firstPos(); if (startPos) { (pos.line = startPos.line), (pos.column = startPos.column); } if (skipSpaces && !this.skipSpaces(pos, false, true)) { return; // Encountered nothing but spaces. } do callback.call(this, pos); while (this.nextPos(pos, skipSpaces)); }; Lines.prototype.bootstrapSlice = function (start, end) { var strings = this.toString() .split(lineTerminatorSeqExp) .slice(start.line - 1, end.line); if (strings.length > 0) { strings.push(strings.pop().slice(0, end.column)); strings[0] = strings[0].slice(start.column); } return fromString(strings.join("\n")); }; Lines.prototype.slice = function (start, end) { if (!end) { if (!start) { // The client seems to want a copy of this Lines object, but // Lines objects are immutable, so it's perfectly adequate to // return the same object. return this; } // Slice to the end if no end position was provided. end = this.lastPos(); } if (!start) { throw new Error("cannot slice with end but not start"); } var sliced = this.infos.slice(start.line - 1, end.line); if (start.line === end.line) { sliced[0] = sliceInfo(sliced[0], start.column, end.column); } else { (0, tiny_invariant_1.default)(start.line < end.line); sliced[0] = sliceInfo(sliced[0], start.column); sliced.push(sliceInfo(sliced.pop(), 0, end.column)); } var lines = new Lines(sliced); if (this.mappings.length > 0) { var newMappings_4 = lines.mappings; (0, tiny_invariant_1.default)(newMappings_4.length === 0); this.mappings.forEach(function (mapping) { var sliced = mapping.slice(this, start, end); if (sliced) { newMappings_4.push(sliced); } }, this); } return lines; }; Lines.prototype.bootstrapSliceString = function (start, end, options) { return this.slice(start, end).toString(options); }; Lines.prototype.sliceString = function (start, end, options) { if (start === void 0) { start = this.firstPos(); } if (end === void 0) { end = this.lastPos(); } var _a = (0, options_1.normalize)(options), tabWidth = _a.tabWidth, useTabs = _a.useTabs, reuseWhitespace = _a.reuseWhitespace, lineTerminator = _a.lineTerminator; var parts = []; for (var line = start.line; line <= end.line; ++line) { var info = this.infos[line - 1]; if (line === start.line) { if (line === end.line) { info = sliceInfo(info, start.column, end.column); } else { info = sliceInfo(info, start.column); } } else if (line === end.line) { info = sliceInfo(info, 0, end.column); } var indent = Math.max(info.indent, 0); var before_1 = info.line.slice(0, info.sliceStart); if (reuseWhitespace && isOnlyWhitespace(before_1) && countSpaces(before_1, tabWidth) === indent) { // Reuse original spaces if the indentation is correct. parts.push(info.line.slice(0, info.sliceEnd)); continue; } var tabs = 0; var spaces = indent; if (useTabs) { tabs = Math.floor(indent / tabWidth); spaces -= tabs * tabWidth; } var result = ""; if (tabs > 0) { result += new Array(tabs + 1).join("\t"); } if (spaces > 0) { result += new Array(spaces + 1).join(" "); } result += info.line.slice(info.sliceStart, info.sliceEnd); parts.push(result); } return parts.join(lineTerminator); }; Lines.prototype.isEmpty = function () { return this.length < 2 && this.getLineLength(1) < 1; }; Lines.prototype.join = function (elements) { var separator = this; var infos = []; var mappings = []; var prevInfo; function appendLines(linesOrNull) { if (linesOrNull === null) { return; } if (prevInfo) { var info = linesOrNull.infos[0]; var indent = new Array(info.indent + 1).join(" "); var prevLine_1 = infos.length; var prevColumn_1 = Math.max(prevInfo.indent, 0) + prevInfo.sliceEnd - prevInfo.sliceStart; prevInfo.line = prevInfo.line.slice(0, prevInfo.sliceEnd) + indent + info.line.slice(info.sliceStart, info.sliceEnd); // If any part of a line is indentation-locked, the whole line // will be indentation-locked. prevInfo.locked = prevInfo.locked || info.locked; prevInfo.sliceEnd = prevInfo.line.length; if (linesOrNull.mappings.length > 0) { linesOrNull.mappings.forEach(function (mapping) { mappings.push(mapping.add(prevLine_1, prevColumn_1)); }); } } else if (linesOrNull.mappings.length > 0) { mappings.push.apply(mappings, linesOrNull.mappings); } linesOrNull.infos.forEach(function (info, i) { if (!prevInfo || i > 0) { prevInfo = tslib_1.__assign({}, info); infos.push(prevInfo); } }); } function appendWithSeparator(linesOrNull, i) { if (i > 0) appendLines(separator); appendLines(linesOrNull); } elements .map(function (elem) { var lines = fromString(elem); if (lines.isEmpty()) return null; return lines; }) .forEach(function (linesOrNull, i) { if (separator.isEmpty()) { appendLines(linesOrNull); } else { appendWithSeparator(linesOrNull, i); } }); if (infos.length < 1) return emptyLines; var lines = new Lines(infos); lines.mappings = mappings; return lines; }; Lines.prototype.concat = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } var list = [this]; list.push.apply(list, args); (0, tiny_invariant_1.default)(list.length === args.length + 1); return emptyLines.join(list); }; return Lines; }()); exports.Lines = Lines; var fromStringCache = {}; var hasOwn = fromStringCache.hasOwnProperty; var maxCacheKeyLen = 10; function countSpaces(spaces, tabWidth) { var count = 0; var len = spaces.length; for (var i = 0; i < len; ++i) { switch (spaces.charCodeAt(i)) { case 9: { // '\t' (0, tiny_invariant_1.default)(typeof tabWidth === "number"); (0, tiny_invariant_1.default)(tabWidth > 0); var next = Math.ceil(count / tabWidth) * tabWidth; if (next === count) { count += tabWidth; } else { count = next; } break; } case 11: // '\v' case 12: // '\f' case 13: // '\r' case 0xfeff: // zero-width non-breaking space // These characters contribute nothing to indentation. break; case 32: // ' ' default: // Treat all other whitespace like ' '. count += 1; break; } } return count; } exports.countSpaces = countSpaces; var leadingSpaceExp = /^\s*/; // As specified here: http://www.ecma-international.org/ecma-262/6.0/#sec-line-terminators var lineTerminatorSeqExp = /\u000D\u000A|\u000D(?!\u000A)|\u000A|\u2028|\u2029/; /** * @param {Object} options - Options object that configures printing. */ function fromString(string, options) { if (string instanceof Lines) return string; string += ""; var tabWidth = options && options.tabWidth; var tabless = string.indexOf("\t") < 0; var cacheable = !options && tabless && string.length <= maxCacheKeyLen; (0, tiny_invariant_1.default)(tabWidth || tabless, "No tab width specified but encountered tabs in string\n" + string); if (cacheable && hasOwn.call(fromStringCache, string)) return fromStringCache[string]; var lines = new Lines(string.split(lineTerminatorSeqExp).map(function (line) { // TODO: handle null exec result var spaces = leadingSpaceExp.exec(line)[0]; return { line: line, indent: countSpaces(spaces, tabWidth), // Boolean indicating whether this line can be reindented. locked: false, sliceStart: spaces.length, sliceEnd: line.length, }; }), (0, options_1.normalize)(options).sourceFileName); if (cacheable) fromStringCache[string] = lines; return lines; } exports.fromString = fromString; function isOnlyWhitespace(string) { return !/\S/.test(string); } function sliceInfo(info, startCol, endCol) { var sliceStart = info.sliceStart; var sliceEnd = info.sliceEnd; var indent = Math.max(info.indent, 0); var lineLength = indent + sliceEnd - sliceStart; if (typeof endCol === "undefined") { endCol = lineLength; } startCol = Math.max(startCol, 0); endCol = Math.min(endCol, lineLength); endCol = Math.max(endCol, startCol); if (endCol < indent) { indent = endCol; sliceEnd = sliceStart; } else { sliceEnd -= lineLength - endCol; } lineLength = endCol; lineLength -= startCol; if (startCol < indent) { indent -= startCol; } else { startCol -= indent; indent = 0; sliceStart += startCol; } (0, tiny_invariant_1.default)(indent >= 0); (0, tiny_invariant_1.default)(sliceStart <= sliceEnd); (0, tiny_invariant_1.default)(lineLength === indent + sliceEnd - sliceStart); if (info.indent === indent && info.sliceStart === sliceStart && info.sliceEnd === sliceEnd) { return info; } return { line: info.line, indent: indent, // A destructive slice always unlocks indentation. locked: false, sliceStart: sliceStart, sliceEnd: sliceEnd, }; } function concat(elements) { return emptyLines.join(elements); } exports.concat = concat; // The emptyLines object needs to be created all the way down here so that // Lines.prototype will be fully populated. var emptyLines = fromString(""); /***/ }), /***/ "./node_modules/recast/lib/mapping.js": /*!********************************************!*\ !*** ./node_modules/recast/lib/mapping.js ***! \********************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.mjs"); var tiny_invariant_1 = tslib_1.__importDefault(__webpack_require__(/*! tiny-invariant */ "./node_modules/tiny-invariant/dist/tiny-invariant.cjs.js")); var util_1 = __webpack_require__(/*! ./util */ "./node_modules/recast/lib/util.js"); var Mapping = /** @class */ (function () { function Mapping(sourceLines, sourceLoc, targetLoc) { if (targetLoc === void 0) { targetLoc = sourceLoc; } this.sourceLines = sourceLines; this.sourceLoc = sourceLoc; this.targetLoc = targetLoc; } Mapping.prototype.slice = function (lines, start, end) { if (end === void 0) { end = lines.lastPos(); } var sourceLines = this.sourceLines; var sourceLoc = this.sourceLoc; var targetLoc = this.targetLoc; function skip(name) { var sourceFromPos = sourceLoc[name]; var targetFromPos = targetLoc[name]; var targetToPos = start; if (name === "end") { targetToPos = end; } else { (0, tiny_invariant_1.default)(name === "start"); } return skipChars(sourceLines, sourceFromPos, lines, targetFromPos, targetToPos); } if ((0, util_1.comparePos)(start, targetLoc.start) <= 0) { if ((0, util_1.comparePos)(targetLoc.end, end) <= 0) { targetLoc = { start: subtractPos(targetLoc.start, start.line, start.column), end: subtractPos(targetLoc.end, start.line, start.column), }; // The sourceLoc can stay the same because the contents of the // targetLoc have not changed. } else if ((0, util_1.comparePos)(end, targetLoc.start) <= 0) { return null; } else { sourceLoc = { start: sourceLoc.start, end: skip("end"), }; targetLoc = { start: subtractPos(targetLoc.start, start.line, start.column), end: subtractPos(end, start.line, start.column), }; } } else { if ((0, util_1.comparePos)(targetLoc.end, start) <= 0) { return null; } if ((0, util_1.comparePos)(targetLoc.end, end) <= 0) { sourceLoc = { start: skip("start"), end: sourceLoc.end, }; targetLoc = { // Same as subtractPos(start, start.line, start.column): start: { line: 1, column: 0 }, end: subtractPos(targetLoc.end, start.line, start.column), }; } else { sourceLoc = { start: skip("start"), end: skip("end"), }; targetLoc = { // Same as subtractPos(start, start.line, start.column): start: { line: 1, column: 0 }, end: subtractPos(end, start.line, start.column), }; } } return new Mapping(this.sourceLines, sourceLoc, targetLoc); }; Mapping.prototype.add = function (line, column) { return new Mapping(this.sourceLines, this.sourceLoc, { start: addPos(this.targetLoc.start, line, column), end: addPos(this.targetLoc.end, line, column), }); }; Mapping.prototype.subtract = function (line, column) { return new Mapping(this.sourceLines, this.sourceLoc, { start: subtractPos(this.targetLoc.start, line, column), end: subtractPos(this.targetLoc.end, line, column), }); }; Mapping.prototype.indent = function (by, skipFirstLine, noNegativeColumns) { if (skipFirstLine === void 0) { skipFirstLine = false; } if (noNegativeColumns === void 0) { noNegativeColumns = false; } if (by === 0) { return this; } var targetLoc = this.targetLoc; var startLine = targetLoc.start.line; var endLine = targetLoc.end.line; if (skipFirstLine && startLine === 1 && endLine === 1) { return this; } targetLoc = { start: targetLoc.start, end: targetLoc.end, }; if (!skipFirstLine || startLine > 1) { var startColumn = targetLoc.start.column + by; targetLoc.start = { line: startLine, column: noNegativeColumns ? Math.max(0, startColumn) : startColumn, }; } if (!skipFirstLine || endLine > 1) { var endColumn = targetLoc.end.column + by; targetLoc.end = { line: endLine, column: noNegativeColumns ? Math.max(0, endColumn) : endColumn, }; } return new Mapping(this.sourceLines, this.sourceLoc, targetLoc); }; return Mapping; }()); exports["default"] = Mapping; function addPos(toPos, line, column) { return { line: toPos.line + line - 1, column: toPos.line === 1 ? toPos.column + column : toPos.column, }; } function subtractPos(fromPos, line, column) { return { line: fromPos.line - line + 1, column: fromPos.line === line ? fromPos.column - column : fromPos.column, }; } function skipChars(sourceLines, sourceFromPos, targetLines, targetFromPos, targetToPos) { var targetComparison = (0, util_1.comparePos)(targetFromPos, targetToPos); if (targetComparison === 0) { // Trivial case: no characters to skip. return sourceFromPos; } var sourceCursor, targetCursor; if (targetComparison < 0) { // Skipping forward. sourceCursor = sourceLines.skipSpaces(sourceFromPos) || sourceLines.lastPos(); targetCursor = targetLines.skipSpaces(targetFromPos) || targetLines.lastPos(); var lineDiff = targetToPos.line - targetCursor.line; sourceCursor.line += lineDiff; targetCursor.line += lineDiff; if (lineDiff > 0) { // If jumping to later lines, reset columns to the beginnings // of those lines. sourceCursor.column = 0; targetCursor.column = 0; } else { (0, tiny_invariant_1.default)(lineDiff === 0); } while ((0, util_1.comparePos)(targetCursor, targetToPos) < 0 && targetLines.nextPos(targetCursor, true)) { (0, tiny_invariant_1.default)(sourceLines.nextPos(sourceCursor, true)); (0, tiny_invariant_1.default)(sourceLines.charAt(sourceCursor) === targetLines.charAt(targetCursor)); } } else { // Skipping backward. sourceCursor = sourceLines.skipSpaces(sourceFromPos, true) || sourceLines.firstPos(); targetCursor = targetLines.skipSpaces(targetFromPos, true) || targetLines.firstPos(); var lineDiff = targetToPos.line - targetCursor.line; sourceCursor.line += lineDiff; targetCursor.line += lineDiff; if (lineDiff < 0) { // If jumping to earlier lines, reset columns to the ends of // those lines. sourceCursor.column = sourceLines.getLineLength(sourceCursor.line); targetCursor.column = targetLines.getLineLength(targetCursor.line); } else { (0, tiny_invariant_1.default)(lineDiff === 0); } while ((0, util_1.comparePos)(targetToPos, targetCursor) < 0 && targetLines.prevPos(targetCursor, true)) { (0, tiny_invariant_1.default)(sourceLines.prevPos(sourceCursor, true)); (0, tiny_invariant_1.default)(sourceLines.charAt(sourceCursor) === targetLines.charAt(targetCursor)); } } return sourceCursor; } /***/ }), /***/ "./node_modules/recast/lib/options.js": /*!********************************************!*\ !*** ./node_modules/recast/lib/options.js ***! \********************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.normalize = void 0; var util_1 = __webpack_require__(/*! ./util */ "./node_modules/recast/lib/util.js"); var defaults = { parser: __webpack_require__(/*! ../parsers/esprima */ "./node_modules/recast/parsers/esprima.js"), tabWidth: 4, useTabs: false, reuseWhitespace: true, lineTerminator: (0, util_1.getLineTerminator)(), wrapColumn: 74, sourceFileName: null, sourceMapName: null, sourceRoot: null, inputSourceMap: null, range: false, tolerant: true, quote: null, trailingComma: false, arrayBracketSpacing: false, objectCurlySpacing: true, arrowParensAlways: false, flowObjectCommas: true, tokens: true, }; var hasOwn = defaults.hasOwnProperty; // Copy options and fill in default values. function normalize(opts) { var options = opts || defaults; function get(key) { return hasOwn.call(options, key) ? options[key] : defaults[key]; } return { tabWidth: +get("tabWidth"), useTabs: !!get("useTabs"), reuseWhitespace: !!get("reuseWhitespace"), lineTerminator: get("lineTerminator"), wrapColumn: Math.max(get("wrapColumn"), 0), sourceFileName: get("sourceFileName"), sourceMapName: get("sourceMapName"), sourceRoot: get("sourceRoot"), inputSourceMap: get("inputSourceMap"), parser: get("esprima") || get("parser"), range: get("range"), tolerant: get("tolerant"), quote: get("quote"), trailingComma: get("trailingComma"), arrayBracketSpacing: get("arrayBracketSpacing"), objectCurlySpacing: get("objectCurlySpacing"), arrowParensAlways: get("arrowParensAlways"), flowObjectCommas: get("flowObjectCommas"), tokens: !!get("tokens"), }; } exports.normalize = normalize; /***/ }), /***/ "./node_modules/recast/lib/parser.js": /*!*******************************************!*\ !*** ./node_modules/recast/lib/parser.js ***! \*******************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.parse = void 0; var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.mjs"); var tiny_invariant_1 = tslib_1.__importDefault(__webpack_require__(/*! tiny-invariant */ "./node_modules/tiny-invariant/dist/tiny-invariant.cjs.js")); var types = tslib_1.__importStar(__webpack_require__(/*! ast-types */ "./node_modules/ast-types/lib/main.js")); var b = types.builders; var isObject = types.builtInTypes.object; var isArray = types.builtInTypes.array; var options_1 = __webpack_require__(/*! ./options */ "./node_modules/recast/lib/options.js"); var lines_1 = __webpack_require__(/*! ./lines */ "./node_modules/recast/lib/lines.js"); var comments_1 = __webpack_require__(/*! ./comments */ "./node_modules/recast/lib/comments.js"); var util = tslib_1.__importStar(__webpack_require__(/*! ./util */ "./node_modules/recast/lib/util.js")); function parse(source, options) { options = (0, options_1.normalize)(options); var lines = (0, lines_1.fromString)(source, options); var sourceWithoutTabs = lines.toString({ tabWidth: options.tabWidth, reuseWhitespace: false, useTabs: false, }); var comments = []; var ast = options.parser.parse(sourceWithoutTabs, { jsx: true, loc: true, locations: true, range: options.range, comment: true, onComment: comments, tolerant: util.getOption(options, "tolerant", true), ecmaVersion: 6, sourceType: util.getOption(options, "sourceType", "module"), }); // Use ast.tokens if possible, and otherwise fall back to the Esprima // tokenizer. All the preconfigured ../parsers/* expose ast.tokens // automatically, but custom parsers might need additional configuration // to avoid this fallback. var tokens = Array.isArray(ast.tokens) ? ast.tokens : (__webpack_require__(/*! esprima */ "./node_modules/esprima/dist/esprima.js").tokenize)(sourceWithoutTabs, { loc: true, }); // We will reattach the tokens array to the file object below. delete ast.tokens; // Make sure every token has a token.value string. tokens.forEach(function (token) { if (typeof token.value !== "string") { token.value = lines.sliceString(token.loc.start, token.loc.end); } }); if (Array.isArray(ast.comments)) { comments = ast.comments; delete ast.comments; } if (ast.loc) { // If the source was empty, some parsers give loc.{start,end}.line // values of 0, instead of the minimum of 1. util.fixFaultyLocations(ast, lines); } else { ast.loc = { start: lines.firstPos(), end: lines.lastPos(), }; } ast.loc.lines = lines; ast.loc.indent = 0; var file; var program; if (ast.type === "Program") { program = ast; // In order to ensure we reprint leading and trailing program // comments, wrap the original Program node with a File node. Only // ESTree parsers (Acorn and Esprima) return a Program as the root AST // node. Most other (Babylon-like) parsers return a File. file = b.file(ast, options.sourceFileName || null); file.loc = { start: lines.firstPos(), end: lines.lastPos(), lines: lines, indent: 0, }; } else if (ast.type === "File") { file = ast; program = file.program; } // Expose file.tokens unless the caller passed false for options.tokens. if (options.tokens) { file.tokens = tokens; } // Expand the Program's .loc to include all comments (not just those // attached to the Program node, as its children may have comments as // well), since sometimes program.loc.{start,end} will coincide with the // .loc.{start,end} of the first and last *statements*, mistakenly // excluding comments that fall outside that region. var trueProgramLoc = util.getTrueLoc({ type: program.type, loc: program.loc, body: [], comments: comments, }, lines); program.loc.start = trueProgramLoc.start; program.loc.end = trueProgramLoc.end; // Passing file.program here instead of just file means that initial // comments will be attached to program.body[0] instead of program. (0, comments_1.attach)(comments, program.body.length ? file.program : file, lines); // Return a copy of the original AST so that any changes made may be // compared to the original. return new TreeCopier(lines, tokens).copy(file); } exports.parse = parse; var TreeCopier = function TreeCopier(lines, tokens) { (0, tiny_invariant_1.default)(this instanceof TreeCopier); this.lines = lines; this.tokens = tokens; this.startTokenIndex = 0; this.endTokenIndex = tokens.length; this.indent = 0; this.seen = new Map(); }; var TCp = TreeCopier.prototype; TCp.copy = function (node) { if (this.seen.has(node)) { return this.seen.get(node); } if (isArray.check(node)) { var copy_1 = new Array(node.length); this.seen.set(node, copy_1); node.forEach(function (item, i) { copy_1[i] = this.copy(item); }, this); return copy_1; } if (!isObject.check(node)) { return node; } util.fixFaultyLocations(node, this.lines); var copy = Object.create(Object.getPrototypeOf(node), { original: { // Provide a link from the copy to the original. value: node, configurable: false, enumerable: false, writable: true, }, }); this.seen.set(node, copy); var loc = node.loc; var oldIndent = this.indent; var newIndent = oldIndent; var oldStartTokenIndex = this.startTokenIndex; var oldEndTokenIndex = this.endTokenIndex; if (loc) { // When node is a comment, we set node.loc.indent to // node.loc.start.column so that, when/if we print the comment by // itself, we can strip that much whitespace from the left margin of // the comment. This only really matters for multiline Block comments, // but it doesn't hurt for Line comments. if (node.type === "Block" || node.type === "Line" || node.type === "CommentBlock" || node.type === "CommentLine" || this.lines.isPrecededOnlyByWhitespace(loc.start)) { newIndent = this.indent = loc.start.column; } // Every node.loc has a reference to the original source lines as well // as a complete list of source tokens. loc.lines = this.lines; loc.tokens = this.tokens; loc.indent = newIndent; // Set loc.start.token and loc.end.token such that // loc.tokens.slice(loc.start.token, loc.end.token) returns a list of // all the tokens that make up this node. this.findTokenRange(loc); } var keys = Object.keys(node); var keyCount = keys.length; for (var i = 0; i < keyCount; ++i) { var key = keys[i]; if (key === "loc") { copy[key] = node[key]; } else if (key === "tokens" && node.type === "File") { // Preserve file.tokens (uncopied) in case client code cares about // it, even though Recast ignores it when reprinting. copy[key] = node[key]; } else { copy[key] = this.copy(node[key]); } } this.indent = oldIndent; this.startTokenIndex = oldStartTokenIndex; this.endTokenIndex = oldEndTokenIndex; return copy; }; // If we didn't have any idea where in loc.tokens to look for tokens // contained by this loc, a binary search would be appropriate, but // because we maintain this.startTokenIndex and this.endTokenIndex as we // traverse the AST, we only need to make small (linear) adjustments to // those indexes with each recursive iteration. TCp.findTokenRange = function (loc) { // In the unlikely event that loc.tokens[this.startTokenIndex] starts // *after* loc.start, we need to rewind this.startTokenIndex first. while (this.startTokenIndex > 0) { var token = loc.tokens[this.startTokenIndex]; if (util.comparePos(loc.start, token.loc.start) < 0) { --this.startTokenIndex; } else break; } // In the unlikely event that loc.tokens[this.endTokenIndex - 1] ends // *before* loc.end, we need to fast-forward this.endTokenIndex first. while (this.endTokenIndex < loc.tokens.length) { var token = loc.tokens[this.endTokenIndex]; if (util.comparePos(token.loc.end, loc.end) < 0) { ++this.endTokenIndex; } else break; } // Increment this.startTokenIndex until we've found the first token // contained by this node. while (this.startTokenIndex < this.endTokenIndex) { var token = loc.tokens[this.startTokenIndex]; if (util.comparePos(token.loc.start, loc.start) < 0) { ++this.startTokenIndex; } else break; } // Index into loc.tokens of the first token within this node. loc.start.token = this.startTokenIndex; // Decrement this.endTokenIndex until we've found the first token after // this node (not contained by the node). while (this.endTokenIndex > this.startTokenIndex) { var token = loc.tokens[this.endTokenIndex - 1]; if (util.comparePos(loc.end, token.loc.end) < 0) { --this.endTokenIndex; } else break; } // Index into loc.tokens of the first token *after* this node. // If loc.start.token === loc.end.token, the node contains no tokens, // and the index is that of the next token following this node. loc.end.token = this.endTokenIndex; }; /***/ }), /***/ "./node_modules/recast/lib/patcher.js": /*!********************************************!*\ !*** ./node_modules/recast/lib/patcher.js ***! \********************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.getReprinter = exports.Patcher = void 0; var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.mjs"); var tiny_invariant_1 = tslib_1.__importDefault(__webpack_require__(/*! tiny-invariant */ "./node_modules/tiny-invariant/dist/tiny-invariant.cjs.js")); var linesModule = tslib_1.__importStar(__webpack_require__(/*! ./lines */ "./node_modules/recast/lib/lines.js")); var types = tslib_1.__importStar(__webpack_require__(/*! ast-types */ "./node_modules/ast-types/lib/main.js")); var Printable = types.namedTypes.Printable; var Expression = types.namedTypes.Expression; var ReturnStatement = types.namedTypes.ReturnStatement; var SourceLocation = types.namedTypes.SourceLocation; var util_1 = __webpack_require__(/*! ./util */ "./node_modules/recast/lib/util.js"); var fast_path_1 = tslib_1.__importDefault(__webpack_require__(/*! ./fast-path */ "./node_modules/recast/lib/fast-path.js")); var isObject = types.builtInTypes.object; var isArray = types.builtInTypes.array; var isString = types.builtInTypes.string; var riskyAdjoiningCharExp = /[0-9a-z_$]/i; var Patcher = function Patcher(lines) { (0, tiny_invariant_1.default)(this instanceof Patcher); (0, tiny_invariant_1.default)(lines instanceof linesModule.Lines); var self = this, replacements = []; self.replace = function (loc, lines) { if (isString.check(lines)) lines = linesModule.fromString(lines); replacements.push({ lines: lines, start: loc.start, end: loc.end, }); }; self.get = function (loc) { // If no location is provided, return the complete Lines object. loc = loc || { start: { line: 1, column: 0 }, end: { line: lines.length, column: lines.getLineLength(lines.length) }, }; var sliceFrom = loc.start, toConcat = []; function pushSlice(from, to) { (0, tiny_invariant_1.default)((0, util_1.comparePos)(from, to) <= 0); toConcat.push(lines.slice(from, to)); } replacements .sort(function (a, b) { return (0, util_1.comparePos)(a.start, b.start); }) .forEach(function (rep) { if ((0, util_1.comparePos)(sliceFrom, rep.start) > 0) { // Ignore nested replacement ranges. } else { pushSlice(sliceFrom, rep.start); toConcat.push(rep.lines); sliceFrom = rep.end; } }); pushSlice(sliceFrom, loc.end); return linesModule.concat(toConcat); }; }; exports.Patcher = Patcher; var Pp = Patcher.prototype; Pp.tryToReprintComments = function (newNode, oldNode, print) { var patcher = this; if (!newNode.comments && !oldNode.comments) { // We were (vacuously) able to reprint all the comments! return true; } var newPath = fast_path_1.default.from(newNode); var oldPath = fast_path_1.default.from(oldNode); newPath.stack.push("comments", getSurroundingComments(newNode)); oldPath.stack.push("comments", getSurroundingComments(oldNode)); var reprints = []; var ableToReprintComments = findArrayReprints(newPath, oldPath, reprints); // No need to pop anything from newPath.stack or oldPath.stack, since // newPath and oldPath are fresh local variables. if (ableToReprintComments && reprints.length > 0) { reprints.forEach(function (reprint) { var oldComment = reprint.oldPath.getValue(); (0, tiny_invariant_1.default)(oldComment.leading || oldComment.trailing); patcher.replace(oldComment.loc, // Comments can't have .comments, so it doesn't matter whether we // print with comments or without. print(reprint.newPath).indentTail(oldComment.loc.indent)); }); } return ableToReprintComments; }; // Get all comments that are either leading or trailing, ignoring any // comments that occur inside node.loc. Returns an empty array for nodes // with no leading or trailing comments. function getSurroundingComments(node) { var result = []; if (node.comments && node.comments.length > 0) { node.comments.forEach(function (comment) { if (comment.leading || comment.trailing) { result.push(comment); } }); } return result; } Pp.deleteComments = function (node) { if (!node.comments) { return; } var patcher = this; node.comments.forEach(function (comment) { if (comment.leading) { // Delete leading comments along with any trailing whitespace they // might have. patcher.replace({ start: comment.loc.start, end: node.loc.lines.skipSpaces(comment.loc.end, false, false), }, ""); } else if (comment.trailing) { // Delete trailing comments along with any leading whitespace they // might have. patcher.replace({ start: node.loc.lines.skipSpaces(comment.loc.start, true, false), end: comment.loc.end, }, ""); } }); }; function getReprinter(path) { (0, tiny_invariant_1.default)(path instanceof fast_path_1.default); // Make sure that this path refers specifically to a Node, rather than // some non-Node subproperty of a Node. var node = path.getValue(); if (!Printable.check(node)) return; var orig = node.original; var origLoc = orig && orig.loc; var lines = origLoc && origLoc.lines; var reprints = []; if (!lines || !findReprints(path, reprints)) return; return function (print) { var patcher = new Patcher(lines); reprints.forEach(function (reprint) { var newNode = reprint.newPath.getValue(); var oldNode = reprint.oldPath.getValue(); SourceLocation.assert(oldNode.loc, true); var needToPrintNewPathWithComments = !patcher.tryToReprintComments(newNode, oldNode, print); if (needToPrintNewPathWithComments) { // Since we were not able to preserve all leading/trailing // comments, we delete oldNode's comments, print newPath with // comments, and then patch the resulting lines where oldNode used // to be. patcher.deleteComments(oldNode); } var newLines = print(reprint.newPath, { includeComments: needToPrintNewPathWithComments, // If the oldNode we're replacing already had parentheses, we may // not need to print the new node with any extra parentheses, // because the existing parentheses will suffice. However, if the // newNode has a different type than the oldNode, let the printer // decide if reprint.newPath needs parentheses, as usual. avoidRootParens: oldNode.type === newNode.type && reprint.oldPath.hasParens(), }).indentTail(oldNode.loc.indent); var nls = needsLeadingSpace(lines, oldNode.loc, newLines); var nts = needsTrailingSpace(lines, oldNode.loc, newLines); // If we try to replace the argument of a ReturnStatement like // return"asdf" with e.g. a literal null expression, we run the risk // of ending up with returnnull, so we need to add an extra leading // space in situations where that might happen. Likewise for // "asdf"in obj. See #170. if (nls || nts) { var newParts = []; nls && newParts.push(" "); newParts.push(newLines); nts && newParts.push(" "); newLines = linesModule.concat(newParts); } patcher.replace(oldNode.loc, newLines); }); // Recall that origLoc is the .loc of an ancestor node that is // guaranteed to contain all the reprinted nodes and comments. var patchedLines = patcher.get(origLoc).indentTail(-orig.loc.indent); if (path.needsParens()) { return linesModule.concat(["(", patchedLines, ")"]); } return patchedLines; }; } exports.getReprinter = getReprinter; // If the last character before oldLoc and the first character of newLines // are both identifier characters, they must be separated by a space, // otherwise they will most likely get fused together into a single token. function needsLeadingSpace(oldLines, oldLoc, newLines) { var posBeforeOldLoc = (0, util_1.copyPos)(oldLoc.start); // The character just before the location occupied by oldNode. var charBeforeOldLoc = oldLines.prevPos(posBeforeOldLoc) && oldLines.charAt(posBeforeOldLoc); // First character of the reprinted node. var newFirstChar = newLines.charAt(newLines.firstPos()); return (charBeforeOldLoc && riskyAdjoiningCharExp.test(charBeforeOldLoc) && newFirstChar && riskyAdjoiningCharExp.test(newFirstChar)); } // If the last character of newLines and the first character after oldLoc // are both identifier characters, they must be separated by a space, // otherwise they will most likely get fused together into a single token. function needsTrailingSpace(oldLines, oldLoc, newLines) { // The character just after the location occupied by oldNode. var charAfterOldLoc = oldLines.charAt(oldLoc.end); var newLastPos = newLines.lastPos(); // Last character of the reprinted node. var newLastChar = newLines.prevPos(newLastPos) && newLines.charAt(newLastPos); return (newLastChar && riskyAdjoiningCharExp.test(newLastChar) && charAfterOldLoc && riskyAdjoiningCharExp.test(charAfterOldLoc)); } function findReprints(newPath, reprints) { var newNode = newPath.getValue(); Printable.assert(newNode); var oldNode = newNode.original; Printable.assert(oldNode); (0, tiny_invariant_1.default)(reprints.length === 0); if (newNode.type !== oldNode.type) { return false; } var oldPath = new fast_path_1.default(oldNode); var canReprint = findChildReprints(newPath, oldPath, reprints); if (!canReprint) { // Make absolutely sure the calling code does not attempt to reprint // any nodes. reprints.length = 0; } return canReprint; } function findAnyReprints(newPath, oldPath, reprints) { var newNode = newPath.getValue(); var oldNode = oldPath.getValue(); if (newNode === oldNode) return true; if (isArray.check(newNode)) return findArrayReprints(newPath, oldPath, reprints); if (isObject.check(newNode)) return findObjectReprints(newPath, oldPath, reprints); return false; } function findArrayReprints(newPath, oldPath, reprints) { var newNode = newPath.getValue(); var oldNode = oldPath.getValue(); if (newNode === oldNode || newPath.valueIsDuplicate() || oldPath.valueIsDuplicate()) { return true; } isArray.assert(newNode); var len = newNode.length; if (!(isArray.check(oldNode) && oldNode.length === len)) return false; for (var i = 0; i < len; ++i) { newPath.stack.push(i, newNode[i]); oldPath.stack.push(i, oldNode[i]); var canReprint = findAnyReprints(newPath, oldPath, reprints); newPath.stack.length -= 2; oldPath.stack.length -= 2; if (!canReprint) { return false; } } return true; } function findObjectReprints(newPath, oldPath, reprints) { var newNode = newPath.getValue(); isObject.assert(newNode); if (newNode.original === null) { // If newNode.original node was set to null, reprint the node. return false; } var oldNode = oldPath.getValue(); if (!isObject.check(oldNode)) return false; if (newNode === oldNode || newPath.valueIsDuplicate() || oldPath.valueIsDuplicate()) { return true; } if (Printable.check(newNode)) { if (!Printable.check(oldNode)) { return false; } var newParentNode = newPath.getParentNode(); var oldParentNode = oldPath.getParentNode(); if (oldParentNode !== null && oldParentNode.type === "FunctionTypeAnnotation" && newParentNode !== null && newParentNode.type === "FunctionTypeAnnotation") { var oldNeedsParens = oldParentNode.params.length !== 1 || !!oldParentNode.params[0].name; var newNeedParens = newParentNode.params.length !== 1 || !!newParentNode.params[0].name; if (!oldNeedsParens && newNeedParens) { return false; } } // Here we need to decide whether the reprinted code for newNode is // appropriate for patching into the location of oldNode. if (newNode.type === oldNode.type) { var childReprints = []; if (findChildReprints(newPath, oldPath, childReprints)) { reprints.push.apply(reprints, childReprints); } else if (oldNode.loc) { // If we have no .loc information for oldNode, then we won't be // able to reprint it. reprints.push({ oldPath: oldPath.copy(), newPath: newPath.copy(), }); } else { return false; } return true; } if (Expression.check(newNode) && Expression.check(oldNode) && // If we have no .loc information for oldNode, then we won't be // able to reprint it. oldNode.loc) { // If both nodes are subtypes of Expression, then we should be able // to fill the location occupied by the old node with code printed // for the new node with no ill consequences. reprints.push({ oldPath: oldPath.copy(), newPath: newPath.copy(), }); return true; } // The nodes have different types, and at least one of the types is // not a subtype of the Expression type, so we cannot safely assume // the nodes are syntactically interchangeable. return false; } return findChildReprints(newPath, oldPath, reprints); } function findChildReprints(newPath, oldPath, reprints) { var newNode = newPath.getValue(); var oldNode = oldPath.getValue(); isObject.assert(newNode); isObject.assert(oldNode); if (newNode.original === null) { // If newNode.original node was set to null, reprint the node. return false; } // If this node needs parentheses and will not be wrapped with // parentheses when reprinted, then return false to skip reprinting and // let it be printed generically. if (newPath.needsParens() && !oldPath.hasParens()) { return false; } var keys = (0, util_1.getUnionOfKeys)(oldNode, newNode); if (oldNode.type === "File" || newNode.type === "File") { // Don't bother traversing file.tokens, an often very large array // returned by Babylon, and useless for our purposes. delete keys.tokens; } // Don't bother traversing .loc objects looking for reprintable nodes. delete keys.loc; var originalReprintCount = reprints.length; for (var k in keys) { if (k.charAt(0) === "_") { // Ignore "private" AST properties added by e.g. Babel plugins and // parsers like Babylon. continue; } newPath.stack.push(k, types.getFieldValue(newNode, k)); oldPath.stack.push(k, types.getFieldValue(oldNode, k)); var canReprint = findAnyReprints(newPath, oldPath, reprints); newPath.stack.length -= 2; oldPath.stack.length -= 2; if (!canReprint) { return false; } } // Return statements might end up running into ASI issues due to // comments inserted deep within the tree, so reprint them if anything // changed within them. if (ReturnStatement.check(newPath.getNode()) && reprints.length > originalReprintCount) { return false; } return true; } /***/ }), /***/ "./node_modules/recast/lib/printer.js": /*!********************************************!*\ !*** ./node_modules/recast/lib/printer.js ***! \********************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.Printer = void 0; var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.mjs"); var tiny_invariant_1 = tslib_1.__importDefault(__webpack_require__(/*! tiny-invariant */ "./node_modules/tiny-invariant/dist/tiny-invariant.cjs.js")); var types = tslib_1.__importStar(__webpack_require__(/*! ast-types */ "./node_modules/ast-types/lib/main.js")); var comments_1 = __webpack_require__(/*! ./comments */ "./node_modules/recast/lib/comments.js"); var fast_path_1 = tslib_1.__importDefault(__webpack_require__(/*! ./fast-path */ "./node_modules/recast/lib/fast-path.js")); var lines_1 = __webpack_require__(/*! ./lines */ "./node_modules/recast/lib/lines.js"); var options_1 = __webpack_require__(/*! ./options */ "./node_modules/recast/lib/options.js"); var patcher_1 = __webpack_require__(/*! ./patcher */ "./node_modules/recast/lib/patcher.js"); var util = tslib_1.__importStar(__webpack_require__(/*! ./util */ "./node_modules/recast/lib/util.js")); var namedTypes = types.namedTypes; var isString = types.builtInTypes.string; var isObject = types.builtInTypes.object; var PrintResult = function PrintResult(code, sourceMap) { (0, tiny_invariant_1.default)(this instanceof PrintResult); isString.assert(code); this.code = code; if (sourceMap) { isObject.assert(sourceMap); this.map = sourceMap; } }; var PRp = PrintResult.prototype; var warnedAboutToString = false; PRp.toString = function () { if (!warnedAboutToString) { console.warn("Deprecation warning: recast.print now returns an object with " + "a .code property. You appear to be treating the object as a " + "string, which might still work but is strongly discouraged."); warnedAboutToString = true; } return this.code; }; var emptyPrintResult = new PrintResult(""); var Printer = function Printer(config) { (0, tiny_invariant_1.default)(this instanceof Printer); var explicitTabWidth = config && config.tabWidth; config = (0, options_1.normalize)(config); // It's common for client code to pass the same options into both // recast.parse and recast.print, but the Printer doesn't need (and // can be confused by) config.sourceFileName, so we null it out. config.sourceFileName = null; // Non-destructively modifies options with overrides, and returns a // new print function that uses the modified options. function makePrintFunctionWith(options, overrides) { options = Object.assign({}, options, overrides); return function (path) { return print(path, options); }; } function print(path, options) { (0, tiny_invariant_1.default)(path instanceof fast_path_1.default); options = options || {}; if (options.includeComments) { return (0, comments_1.printComments)(path, makePrintFunctionWith(options, { includeComments: false, })); } var oldTabWidth = config.tabWidth; if (!explicitTabWidth) { var loc = path.getNode().loc; if (loc && loc.lines && loc.lines.guessTabWidth) { config.tabWidth = loc.lines.guessTabWidth(); } } var reprinter = (0, patcher_1.getReprinter)(path); var lines = reprinter ? // Since the print function that we pass to the reprinter will // be used to print "new" nodes, it's tempting to think we // should pass printRootGenerically instead of print, to avoid // calling maybeReprint again, but that would be a mistake // because the new nodes might not be entirely new, but merely // moved from elsewhere in the AST. The print function is the // right choice because it gives us the opportunity to reprint // such nodes using their original source. reprinter(print) : genericPrint(path, config, options, makePrintFunctionWith(options, { includeComments: true, avoidRootParens: false, })); config.tabWidth = oldTabWidth; return lines; } this.print = function (ast) { if (!ast) { return emptyPrintResult; } var lines = print(fast_path_1.default.from(ast), { includeComments: true, avoidRootParens: false, }); return new PrintResult(lines.toString(config), util.composeSourceMaps(config.inputSourceMap, lines.getSourceMap(config.sourceMapName, config.sourceRoot))); }; this.printGenerically = function (ast) { if (!ast) { return emptyPrintResult; } // Print the entire AST generically. function printGenerically(path) { return (0, comments_1.printComments)(path, function (path) { return genericPrint(path, config, { includeComments: true, avoidRootParens: false, }, printGenerically); }); } var path = fast_path_1.default.from(ast); var oldReuseWhitespace = config.reuseWhitespace; // Do not reuse whitespace (or anything else, for that matter) // when printing generically. config.reuseWhitespace = false; // TODO Allow printing of comments? var pr = new PrintResult(printGenerically(path).toString(config)); config.reuseWhitespace = oldReuseWhitespace; return pr; }; }; exports.Printer = Printer; function genericPrint(path, config, options, printPath) { (0, tiny_invariant_1.default)(path instanceof fast_path_1.default); var node = path.getValue(); var parts = []; var linesWithoutParens = genericPrintNoParens(path, config, printPath); if (!node || linesWithoutParens.isEmpty()) { return linesWithoutParens; } var shouldAddParens = false; var decoratorsLines = printDecorators(path, printPath); if (decoratorsLines.isEmpty()) { // Nodes with decorators can't have parentheses, so we can avoid // computing path.needsParens() except in this case. if (!options.avoidRootParens) { shouldAddParens = path.needsParens(); } } else { parts.push(decoratorsLines); } if (shouldAddParens) { parts.unshift("("); } parts.push(linesWithoutParens); if (shouldAddParens) { parts.push(")"); } return (0, lines_1.concat)(parts); } // Note that the `options` parameter of this function is what other // functions in this file call the `config` object (that is, the // configuration object originally passed into the Printer constructor). // Its properties are documented in lib/options.js. function genericPrintNoParens(path, options, print) { var _a, _b, _c; var n = path.getValue(); if (!n) { return (0, lines_1.fromString)(""); } if (typeof n === "string") { return (0, lines_1.fromString)(n, options); } namedTypes.Printable.assert(n); var parts = []; switch (n.type) { case "File": return path.call(print, "program"); case "Program": // Babel 6 if (n.directives) { path.each(function (childPath) { parts.push(print(childPath), ";\n"); }, "directives"); } if (n.interpreter) { parts.push(path.call(print, "interpreter")); } parts.push(path.call(function (bodyPath) { return printStatementSequence(bodyPath, options, print); }, "body")); return (0, lines_1.concat)(parts); case "Noop": // Babel extension. case "EmptyStatement": return (0, lines_1.fromString)(""); case "ExpressionStatement": return (0, lines_1.concat)([path.call(print, "expression"), ";"]); case "ParenthesizedExpression": // Babel extension. return (0, lines_1.concat)(["(", path.call(print, "expression"), ")"]); case "BinaryExpression": case "LogicalExpression": case "AssignmentExpression": return (0, lines_1.fromString)(" ").join([ path.call(print, "left"), n.operator, path.call(print, "right"), ]); case "AssignmentPattern": return (0, lines_1.concat)([ path.call(print, "left"), " = ", path.call(print, "right"), ]); case "MemberExpression": case "OptionalMemberExpression": { parts.push(path.call(print, "object")); var property = path.call(print, "property"); // Like n.optional, except with defaults applied, so optional // defaults to true for OptionalMemberExpression nodes. var optional = types.getFieldValue(n, "optional"); if (n.computed) { parts.push(optional ? "?.[" : "[", property, "]"); } else { parts.push(optional ? "?." : ".", property); } return (0, lines_1.concat)(parts); } case "ChainExpression": return path.call(print, "expression"); case "MetaProperty": return (0, lines_1.concat)([ path.call(print, "meta"), ".", path.call(print, "property"), ]); case "BindExpression": if (n.object) { parts.push(path.call(print, "object")); } parts.push("::", path.call(print, "callee")); return (0, lines_1.concat)(parts); case "Path": return (0, lines_1.fromString)(".").join(n.body); case "Identifier": return (0, lines_1.concat)([ (0, lines_1.fromString)(n.name, options), n.optional ? "?" : "", path.call(print, "typeAnnotation"), ]); case "SpreadElement": case "SpreadElementPattern": case "RestProperty": // Babel 6 for ObjectPattern case "SpreadProperty": case "SpreadPropertyPattern": case "ObjectTypeSpreadProperty": case "RestElement": return (0, lines_1.concat)([ "...", path.call(print, "argument"), path.call(print, "typeAnnotation"), ]); case "FunctionDeclaration": case "FunctionExpression": case "TSDeclareFunction": if (n.declare) { parts.push("declare "); } if (n.async) { parts.push("async "); } parts.push("function"); if (n.generator) parts.push("*"); if (n.id) { parts.push(" ", path.call(print, "id"), path.call(print, "typeParameters")); } else { if (n.typeParameters) { parts.push(path.call(print, "typeParameters")); } } parts.push("(", printFunctionParams(path, options, print), ")", path.call(print, "returnType")); if (n.body) { parts.push(" ", path.call(print, "body")); } return (0, lines_1.concat)(parts); case "ArrowFunctionExpression": if (n.async) { parts.push("async "); } if (n.typeParameters) { parts.push(path.call(print, "typeParameters")); } if (!options.arrowParensAlways && n.params.length === 1 && !n.rest && n.params[0].type === "Identifier" && !n.params[0].typeAnnotation && !n.returnType) { parts.push(path.call(print, "params", 0)); } else { parts.push("(", printFunctionParams(path, options, print), ")", path.call(print, "returnType")); } parts.push(" => ", path.call(print, "body")); return (0, lines_1.concat)(parts); case "MethodDefinition": return printMethod(path, options, print); case "YieldExpression": parts.push("yield"); if (n.delegate) parts.push("*"); if (n.argument) parts.push(" ", path.call(print, "argument")); return (0, lines_1.concat)(parts); case "AwaitExpression": parts.push("await"); if (n.all) parts.push("*"); if (n.argument) parts.push(" ", path.call(print, "argument")); return (0, lines_1.concat)(parts); case "ModuleExpression": return (0, lines_1.concat)([ "module {\n", path.call(print, "body").indent(options.tabWidth), "\n}", ]); case "ModuleDeclaration": parts.push("module", path.call(print, "id")); if (n.source) { (0, tiny_invariant_1.default)(!n.body); parts.push("from", path.call(print, "source")); } else { parts.push(path.call(print, "body")); } return (0, lines_1.fromString)(" ").join(parts); case "ImportSpecifier": if (n.importKind && n.importKind !== "value") { parts.push(n.importKind + " "); } if (n.imported) { parts.push(path.call(print, "imported")); if (n.local && n.local.name !== n.imported.name) { parts.push(" as ", path.call(print, "local")); } } else if (n.id) { parts.push(path.call(print, "id")); if (n.name) { parts.push(" as ", path.call(print, "name")); } } return (0, lines_1.concat)(parts); case "ExportSpecifier": if (n.exportKind && n.exportKind !== "value") { parts.push(n.exportKind + " "); } if (n.local) { parts.push(path.call(print, "local")); if (n.exported && n.exported.name !== n.local.name) { parts.push(" as ", path.call(print, "exported")); } } else if (n.id) { parts.push(path.call(print, "id")); if (n.name) { parts.push(" as ", path.call(print, "name")); } } return (0, lines_1.concat)(parts); case "ExportBatchSpecifier": return (0, lines_1.fromString)("*"); case "ImportNamespaceSpecifier": parts.push("* as "); if (n.local) { parts.push(path.call(print, "local")); } else if (n.id) { parts.push(path.call(print, "id")); } return (0, lines_1.concat)(parts); case "ImportDefaultSpecifier": if (n.local) { return path.call(print, "local"); } return path.call(print, "id"); case "TSExportAssignment": return (0, lines_1.concat)(["export = ", path.call(print, "expression")]); case "ExportDeclaration": case "ExportDefaultDeclaration": case "ExportNamedDeclaration": return printExportDeclaration(path, options, print); case "ExportAllDeclaration": parts.push("export *"); if (n.exported) { parts.push(" as ", path.call(print, "exported")); } parts.push(" from ", path.call(print, "source"), ";"); return (0, lines_1.concat)(parts); case "TSNamespaceExportDeclaration": parts.push("export as namespace ", path.call(print, "id")); return maybeAddSemicolon((0, lines_1.concat)(parts)); case "ExportNamespaceSpecifier": return (0, lines_1.concat)(["* as ", path.call(print, "exported")]); case "ExportDefaultSpecifier": return path.call(print, "exported"); case "Import": return (0, lines_1.fromString)("import", options); // Recast and ast-types currently support dynamic import(...) using // either this dedicated ImportExpression type or a CallExpression // whose callee has type Import. // https://github.com/benjamn/ast-types/pull/365#issuecomment-605214486 case "ImportExpression": return (0, lines_1.concat)(["import(", path.call(print, "source"), ")"]); case "ImportDeclaration": { parts.push("import "); if (n.importKind && n.importKind !== "value") { parts.push(n.importKind + " "); } if (n.specifiers && n.specifiers.length > 0) { var unbracedSpecifiers_1 = []; var bracedSpecifiers_1 = []; path.each(function (specifierPath) { var spec = specifierPath.getValue(); if (spec.type === "ImportSpecifier") { bracedSpecifiers_1.push(print(specifierPath)); } else if (spec.type === "ImportDefaultSpecifier" || spec.type === "ImportNamespaceSpecifier") { unbracedSpecifiers_1.push(print(specifierPath)); } }, "specifiers"); unbracedSpecifiers_1.forEach(function (lines, i) { if (i > 0) { parts.push(", "); } parts.push(lines); }); if (bracedSpecifiers_1.length > 0) { var lines = (0, lines_1.fromString)(", ").join(bracedSpecifiers_1); if (lines.getLineLength(1) > options.wrapColumn) { lines = (0, lines_1.concat)([ (0, lines_1.fromString)(",\n").join(bracedSpecifiers_1).indent(options.tabWidth), ",", ]); } if (unbracedSpecifiers_1.length > 0) { parts.push(", "); } if (lines.length > 1) { parts.push("{\n", lines, "\n}"); } else if (options.objectCurlySpacing) { parts.push("{ ", lines, " }"); } else { parts.push("{", lines, "}"); } } parts.push(" from "); } parts.push(path.call(print, "source"), maybePrintImportAssertions(path, options, print), ";"); return (0, lines_1.concat)(parts); } case "ImportAttribute": return (0, lines_1.concat)([path.call(print, "key"), ": ", path.call(print, "value")]); case "StaticBlock": parts.push("static "); // Intentionally fall through to BlockStatement below. case "BlockStatement": { var naked_1 = path.call(function (bodyPath) { return printStatementSequence(bodyPath, options, print); }, "body"); if (naked_1.isEmpty()) { if (!n.directives || n.directives.length === 0) { parts.push("{}"); return (0, lines_1.concat)(parts); } } parts.push("{\n"); // Babel 6 if (n.directives) { path.each(function (childPath) { parts.push(maybeAddSemicolon(print(childPath).indent(options.tabWidth)), n.directives.length > 1 || !naked_1.isEmpty() ? "\n" : ""); }, "directives"); } parts.push(naked_1.indent(options.tabWidth)); parts.push("\n}"); return (0, lines_1.concat)(parts); } case "ReturnStatement": { parts.push("return"); if (n.argument) { var argIsJsxElement = ((_a = namedTypes.JSXElement) === null || _a === void 0 ? void 0 : _a.check(n.argument)) || ((_b = namedTypes.JSXFragment) === null || _b === void 0 ? void 0 : _b.check(n.argument)); var argLines = path.call(print, "argument"); if (argLines.startsWithComment() || (argLines.length > 1 && argIsJsxElement)) { // Babel: regenerate parenthesized jsxElements so we don't double parentheses if (argIsJsxElement && ((_c = n.argument.extra) === null || _c === void 0 ? void 0 : _c.parenthesized)) { n.argument.extra.parenthesized = false; argLines = path.call(print, "argument"); n.argument.extra.parenthesized = true; } parts.push(" ", (0, lines_1.concat)(["(\n", argLines]).indentTail(options.tabWidth), "\n)"); } else { parts.push(" ", argLines); } } parts.push(";"); return (0, lines_1.concat)(parts); } case "CallExpression": case "OptionalCallExpression": parts.push(path.call(print, "callee")); if (n.typeParameters) { parts.push(path.call(print, "typeParameters")); } if (n.typeArguments) { parts.push(path.call(print, "typeArguments")); } // Like n.optional, but defaults to true for OptionalCallExpression // nodes that are missing an n.optional property (unusual), // according to the OptionalCallExpression definition in ast-types. if (types.getFieldValue(n, "optional")) { parts.push("?."); } parts.push(printArgumentsList(path, options, print)); return (0, lines_1.concat)(parts); case "RecordExpression": parts.push("#"); // Intentionally fall through to printing the object literal... case "ObjectExpression": case "ObjectPattern": case "ObjectTypeAnnotation": { var isTypeAnnotation_1 = n.type === "ObjectTypeAnnotation"; var separator_1 = options.flowObjectCommas ? "," : isTypeAnnotation_1 ? ";" : ","; var fields = []; var allowBreak_1 = false; if (isTypeAnnotation_1) { fields.push("indexers", "callProperties"); if (n.internalSlots != null) { fields.push("internalSlots"); } } fields.push("properties"); var len_1 = 0; fields.forEach(function (field) { len_1 += n[field].length; }); var oneLine_1 = (isTypeAnnotation_1 && len_1 === 1) || len_1 === 0; var leftBrace = n.exact ? "{|" : "{"; var rightBrace = n.exact ? "|}" : "}"; parts.push(oneLine_1 ? leftBrace : leftBrace + "\n"); var leftBraceIndex = parts.length - 1; var i_1 = 0; fields.forEach(function (field) { path.each(function (childPath) { var lines = print(childPath); if (!oneLine_1) { lines = lines.indent(options.tabWidth); } var multiLine = !isTypeAnnotation_1 && lines.length > 1; if (multiLine && allowBreak_1) { // Similar to the logic for BlockStatement. parts.push("\n"); } parts.push(lines); if (i_1 < len_1 - 1) { // Add an extra line break if the previous object property // had a multi-line value. parts.push(separator_1 + (multiLine ? "\n\n" : "\n")); allowBreak_1 = !multiLine; } else if (len_1 !== 1 && isTypeAnnotation_1) { parts.push(separator_1); } else if (!oneLine_1 && util.isTrailingCommaEnabled(options, "objects") && childPath.getValue().type !== "RestElement") { parts.push(separator_1); } i_1++; }, field); }); if (n.inexact) { var line = (0, lines_1.fromString)("...", options); if (oneLine_1) { if (len_1 > 0) { parts.push(separator_1, " "); } parts.push(line); } else { // No trailing separator after ... to maintain parity with prettier. parts.push("\n", line.indent(options.tabWidth)); } } parts.push(oneLine_1 ? rightBrace : "\n" + rightBrace); if (i_1 !== 0 && oneLine_1 && options.objectCurlySpacing) { parts[leftBraceIndex] = leftBrace + " "; parts[parts.length - 1] = " " + rightBrace; } if (n.typeAnnotation) { parts.push(path.call(print, "typeAnnotation")); } return (0, lines_1.concat)(parts); } case "PropertyPattern": return (0, lines_1.concat)([ path.call(print, "key"), ": ", path.call(print, "pattern"), ]); case "ObjectProperty": // Babel 6 case "Property": { // Non-standard AST node type. if (n.method || n.kind === "get" || n.kind === "set") { return printMethod(path, options, print); } if (n.shorthand && n.value.type === "AssignmentPattern") { return path.call(print, "value"); } var key = path.call(print, "key"); if (n.computed) { parts.push("[", key, "]"); } else { parts.push(key); } if (!n.shorthand || n.key.name !== n.value.name) { parts.push(": ", path.call(print, "value")); } return (0, lines_1.concat)(parts); } case "ClassMethod": // Babel 6 case "ObjectMethod": // Babel 6 case "ClassPrivateMethod": case "TSDeclareMethod": return printMethod(path, options, print); case "PrivateName": return (0, lines_1.concat)(["#", path.call(print, "id")]); case "Decorator": return (0, lines_1.concat)(["@", path.call(print, "expression")]); case "TupleExpression": parts.push("#"); // Intentionally fall through to printing the tuple elements... case "ArrayExpression": case "ArrayPattern": { var elems = n.elements; var len_2 = elems.length; var printed_1 = path.map(print, "elements"); var joined = (0, lines_1.fromString)(", ").join(printed_1); var oneLine_2 = joined.getLineLength(1) <= options.wrapColumn; if (oneLine_2) { if (options.arrayBracketSpacing) { parts.push("[ "); } else { parts.push("["); } } else { parts.push("[\n"); } path.each(function (elemPath) { var i = elemPath.getName(); var elem = elemPath.getValue(); if (!elem) { // If the array expression ends with a hole, that hole // will be ignored by the interpreter, but if it ends with // two (or more) holes, we need to write out two (or more) // commas so that the resulting code is interpreted with // both (all) of the holes. parts.push(","); } else { var lines = printed_1[i]; if (oneLine_2) { if (i > 0) parts.push(" "); } else { lines = lines.indent(options.tabWidth); } parts.push(lines); if (i < len_2 - 1 || (!oneLine_2 && util.isTrailingCommaEnabled(options, "arrays"))) parts.push(","); if (!oneLine_2) parts.push("\n"); } }, "elements"); if (oneLine_2 && options.arrayBracketSpacing) { parts.push(" ]"); } else { parts.push("]"); } if (n.typeAnnotation) { parts.push(path.call(print, "typeAnnotation")); } return (0, lines_1.concat)(parts); } case "SequenceExpression": return (0, lines_1.fromString)(", ").join(path.map(print, "expressions")); case "ThisExpression": return (0, lines_1.fromString)("this"); case "Super": return (0, lines_1.fromString)("super"); case "NullLiteral": // Babel 6 Literal split return (0, lines_1.fromString)("null"); case "RegExpLiteral": // Babel 6 Literal split return (0, lines_1.fromString)(getPossibleRaw(n) || "/".concat(n.pattern, "/").concat(n.flags || ""), options); case "BigIntLiteral": // Babel 7 Literal split return (0, lines_1.fromString)(getPossibleRaw(n) || n.value + "n", options); case "NumericLiteral": // Babel 6 Literal Split return (0, lines_1.fromString)(getPossibleRaw(n) || n.value, options); case "DecimalLiteral": return (0, lines_1.fromString)(getPossibleRaw(n) || n.value + "m", options); case "StringLiteral": return (0, lines_1.fromString)(nodeStr(n.value, options)); case "BooleanLiteral": // Babel 6 Literal split case "Literal": return (0, lines_1.fromString)(getPossibleRaw(n) || (typeof n.value === "string" ? nodeStr(n.value, options) : n.value), options); case "Directive": // Babel 6 return path.call(print, "value"); case "DirectiveLiteral": // Babel 6 return (0, lines_1.fromString)(getPossibleRaw(n) || nodeStr(n.value, options), options); case "InterpreterDirective": return (0, lines_1.fromString)("#!".concat(n.value, "\n"), options); case "ModuleSpecifier": if (n.local) { throw new Error("The ESTree ModuleSpecifier type should be abstract"); } // The Esprima ModuleSpecifier type is just a string-valued // Literal identifying the imported-from module. return (0, lines_1.fromString)(nodeStr(n.value, options), options); case "UnaryExpression": parts.push(n.operator); if (/[a-z]$/.test(n.operator)) parts.push(" "); parts.push(path.call(print, "argument")); return (0, lines_1.concat)(parts); case "UpdateExpression": parts.push(path.call(print, "argument"), n.operator); if (n.prefix) parts.reverse(); return (0, lines_1.concat)(parts); case "ConditionalExpression": return (0, lines_1.concat)([ path.call(print, "test"), " ? ", path.call(print, "consequent"), " : ", path.call(print, "alternate"), ]); case "NewExpression": { parts.push("new ", path.call(print, "callee")); if (n.typeParameters) { parts.push(path.call(print, "typeParameters")); } if (n.typeArguments) { parts.push(path.call(print, "typeArguments")); } var args = n.arguments; if (args) { parts.push(printArgumentsList(path, options, print)); } return (0, lines_1.concat)(parts); } case "VariableDeclaration": { if (n.declare) { parts.push("declare "); } parts.push(n.kind, " "); var maxLen_1 = 0; var printed = path.map(function (childPath) { var lines = print(childPath); maxLen_1 = Math.max(lines.length, maxLen_1); return lines; }, "declarations"); if (maxLen_1 === 1) { parts.push((0, lines_1.fromString)(", ").join(printed)); } else if (printed.length > 1) { parts.push((0, lines_1.fromString)(",\n") .join(printed) .indentTail(n.kind.length + 1)); } else { parts.push(printed[0]); } // We generally want to terminate all variable declarations with a // semicolon, except when they are children of for loops. var parentNode = path.getParentNode(); if (!namedTypes.ForStatement.check(parentNode) && !namedTypes.ForInStatement.check(parentNode) && !(namedTypes.ForOfStatement && namedTypes.ForOfStatement.check(parentNode)) && !(namedTypes.ForAwaitStatement && namedTypes.ForAwaitStatement.check(parentNode))) { parts.push(";"); } return (0, lines_1.concat)(parts); } case "VariableDeclarator": return n.init ? (0, lines_1.fromString)(" = ").join([ path.call(print, "id"), path.call(print, "init"), ]) : path.call(print, "id"); case "WithStatement": return (0, lines_1.concat)([ "with (", path.call(print, "object"), ") ", path.call(print, "body"), ]); case "IfStatement": { var con = adjustClause(path.call(print, "consequent"), options); parts.push("if (", path.call(print, "test"), ")", con); if (n.alternate) parts.push(endsWithBrace(con) ? " else" : "\nelse", adjustClause(path.call(print, "alternate"), options)); return (0, lines_1.concat)(parts); } case "ForStatement": { // TODO Get the for (;;) case right. var init = path.call(print, "init"); var sep = init.length > 1 ? ";\n" : "; "; var forParen = "for ("; var indented = (0, lines_1.fromString)(sep) .join([init, path.call(print, "test"), path.call(print, "update")]) .indentTail(forParen.length); var head = (0, lines_1.concat)([forParen, indented, ")"]); var clause = adjustClause(path.call(print, "body"), options); parts.push(head); if (head.length > 1) { parts.push("\n"); clause = clause.trimLeft(); } parts.push(clause); return (0, lines_1.concat)(parts); } case "WhileStatement": return (0, lines_1.concat)([ "while (", path.call(print, "test"), ")", adjustClause(path.call(print, "body"), options), ]); case "ForInStatement": // Note: esprima can't actually parse "for each (". return (0, lines_1.concat)([ n.each ? "for each (" : "for (", path.call(print, "left"), " in ", path.call(print, "right"), ")", adjustClause(path.call(print, "body"), options), ]); case "ForOfStatement": case "ForAwaitStatement": parts.push("for "); if (n.await || n.type === "ForAwaitStatement") { parts.push("await "); } parts.push("(", path.call(print, "left"), " of ", path.call(print, "right"), ")", adjustClause(path.call(print, "body"), options)); return (0, lines_1.concat)(parts); case "DoWhileStatement": { var doBody = (0, lines_1.concat)([ "do", adjustClause(path.call(print, "body"), options), ]); parts.push(doBody); if (endsWithBrace(doBody)) parts.push(" while"); else parts.push("\nwhile"); parts.push(" (", path.call(print, "test"), ");"); return (0, lines_1.concat)(parts); } case "DoExpression": { var statements = path.call(function (bodyPath) { return printStatementSequence(bodyPath, options, print); }, "body"); return (0, lines_1.concat)(["do {\n", statements.indent(options.tabWidth), "\n}"]); } case "BreakStatement": parts.push("break"); if (n.label) parts.push(" ", path.call(print, "label")); parts.push(";"); return (0, lines_1.concat)(parts); case "ContinueStatement": parts.push("continue"); if (n.label) parts.push(" ", path.call(print, "label")); parts.push(";"); return (0, lines_1.concat)(parts); case "LabeledStatement": return (0, lines_1.concat)([ path.call(print, "label"), ":\n", path.call(print, "body"), ]); case "TryStatement": parts.push("try ", path.call(print, "block")); if (n.handler) { parts.push(" ", path.call(print, "handler")); } else if (n.handlers) { path.each(function (handlerPath) { parts.push(" ", print(handlerPath)); }, "handlers"); } if (n.finalizer) { parts.push(" finally ", path.call(print, "finalizer")); } return (0, lines_1.concat)(parts); case "CatchClause": parts.push("catch "); if (n.param) { parts.push("(", path.call(print, "param")); } if (n.guard) { // Note: esprima does not recognize conditional catch clauses. parts.push(" if ", path.call(print, "guard")); } if (n.param) { parts.push(") "); } parts.push(path.call(print, "body")); return (0, lines_1.concat)(parts); case "ThrowStatement": return (0, lines_1.concat)(["throw ", path.call(print, "argument"), ";"]); case "SwitchStatement": return (0, lines_1.concat)([ "switch (", path.call(print, "discriminant"), ") {\n", (0, lines_1.fromString)("\n").join(path.map(print, "cases")), "\n}", ]); // Note: ignoring n.lexical because it has no printing consequences. case "SwitchCase": if (n.test) parts.push("case ", path.call(print, "test"), ":"); else parts.push("default:"); if (n.consequent.length > 0) { parts.push("\n", path .call(function (consequentPath) { return printStatementSequence(consequentPath, options, print); }, "consequent") .indent(options.tabWidth)); } return (0, lines_1.concat)(parts); case "DebuggerStatement": return (0, lines_1.fromString)("debugger;"); // JSX extensions below. case "JSXAttribute": parts.push(path.call(print, "name")); if (n.value) parts.push("=", path.call(print, "value")); return (0, lines_1.concat)(parts); case "JSXIdentifier": return (0, lines_1.fromString)(n.name, options); case "JSXNamespacedName": return (0, lines_1.fromString)(":").join([ path.call(print, "namespace"), path.call(print, "name"), ]); case "JSXMemberExpression": return (0, lines_1.fromString)(".").join([ path.call(print, "object"), path.call(print, "property"), ]); case "JSXSpreadAttribute": return (0, lines_1.concat)(["{...", path.call(print, "argument"), "}"]); case "JSXSpreadChild": return (0, lines_1.concat)(["{...", path.call(print, "expression"), "}"]); case "JSXExpressionContainer": return (0, lines_1.concat)(["{", path.call(print, "expression"), "}"]); case "JSXElement": case "JSXFragment": { var openingPropName = "opening" + (n.type === "JSXElement" ? "Element" : "Fragment"); var closingPropName = "closing" + (n.type === "JSXElement" ? "Element" : "Fragment"); var openingLines = path.call(print, openingPropName); if (n[openingPropName].selfClosing) { (0, tiny_invariant_1.default)(!n[closingPropName], "unexpected " + closingPropName + " element in self-closing " + n.type); return openingLines; } var childLines = (0, lines_1.concat)(path.map(function (childPath) { var child = childPath.getValue(); if (namedTypes.Literal.check(child) && typeof child.value === "string") { if (/\S/.test(child.value)) { return child.value.replace(/^\s+/g, ""); } else if (/\n/.test(child.value)) { return "\n"; } } return print(childPath); }, "children")).indentTail(options.tabWidth); var closingLines = path.call(print, closingPropName); return (0, lines_1.concat)([openingLines, childLines, closingLines]); } case "JSXOpeningElement": { parts.push("<", path.call(print, "name")); var typeDefPart = path.call(print, "typeParameters"); if (typeDefPart.length) parts.push(typeDefPart); var attrParts_1 = []; path.each(function (attrPath) { attrParts_1.push(" ", print(attrPath)); }, "attributes"); var attrLines = (0, lines_1.concat)(attrParts_1); var needLineWrap = attrLines.length > 1 || attrLines.getLineLength(1) > options.wrapColumn; if (needLineWrap) { attrParts_1.forEach(function (part, i) { if (part === " ") { (0, tiny_invariant_1.default)(i % 2 === 0); attrParts_1[i] = "\n"; } }); attrLines = (0, lines_1.concat)(attrParts_1).indentTail(options.tabWidth); } parts.push(attrLines, n.selfClosing ? " />" : ">"); return (0, lines_1.concat)(parts); } case "JSXClosingElement": return (0, lines_1.concat)([""]); case "JSXOpeningFragment": return (0, lines_1.fromString)("<>"); case "JSXClosingFragment": return (0, lines_1.fromString)(""); case "JSXText": return (0, lines_1.fromString)(n.value, options); case "JSXEmptyExpression": return (0, lines_1.fromString)(""); case "TypeAnnotatedIdentifier": return (0, lines_1.concat)([ path.call(print, "annotation"), " ", path.call(print, "identifier"), ]); case "ClassBody": if (n.body.length === 0) { return (0, lines_1.fromString)("{}"); } return (0, lines_1.concat)([ "{\n", path .call(function (bodyPath) { return printStatementSequence(bodyPath, options, print); }, "body") .indent(options.tabWidth), "\n}", ]); case "ClassPropertyDefinition": parts.push("static ", path.call(print, "definition")); if (!namedTypes.MethodDefinition.check(n.definition)) parts.push(";"); return (0, lines_1.concat)(parts); case "ClassProperty": { if (n.declare) { parts.push("declare "); } var access = n.accessibility || n.access; if (typeof access === "string") { parts.push(access, " "); } if (n.static) { parts.push("static "); } if (n.abstract) { parts.push("abstract "); } if (n.readonly) { parts.push("readonly "); } var key = path.call(print, "key"); if (n.computed) { key = (0, lines_1.concat)(["[", key, "]"]); } if (n.variance) { key = (0, lines_1.concat)([printVariance(path, print), key]); } parts.push(key); if (n.optional) { parts.push("?"); } if (n.definite) { parts.push("!"); } if (n.typeAnnotation) { parts.push(path.call(print, "typeAnnotation")); } if (n.value) { parts.push(" = ", path.call(print, "value")); } parts.push(";"); return (0, lines_1.concat)(parts); } case "ClassPrivateProperty": if (n.static) { parts.push("static "); } parts.push(path.call(print, "key")); if (n.typeAnnotation) { parts.push(path.call(print, "typeAnnotation")); } if (n.value) { parts.push(" = ", path.call(print, "value")); } parts.push(";"); return (0, lines_1.concat)(parts); case "ClassAccessorProperty": { parts.push.apply(parts, tslib_1.__spreadArray(tslib_1.__spreadArray([], printClassMemberModifiers(n), false), ["accessor "], false)); if (n.computed) { parts.push("[", path.call(print, "key"), "]"); } else { parts.push(path.call(print, "key")); } if (n.optional) { parts.push("?"); } if (n.definite) { parts.push("!"); } if (n.typeAnnotation) { parts.push(path.call(print, "typeAnnotation")); } if (n.value) { parts.push(" = ", path.call(print, "value")); } parts.push(";"); return (0, lines_1.concat)(parts); } case "ClassDeclaration": case "ClassExpression": case "DeclareClass": if (n.declare) { parts.push("declare "); } if (n.abstract) { parts.push("abstract "); } parts.push("class"); if (n.id) { parts.push(" ", path.call(print, "id")); } if (n.typeParameters) { parts.push(path.call(print, "typeParameters")); } if (n.superClass) { // ClassDeclaration and ClassExpression only parts.push(" extends ", path.call(print, "superClass"), path.call(print, "superTypeParameters")); } if (n.extends && n.extends.length > 0) { // DeclareClass only parts.push(" extends ", (0, lines_1.fromString)(", ").join(path.map(print, "extends"))); } if (n["implements"] && n["implements"].length > 0) { parts.push(" implements ", (0, lines_1.fromString)(", ").join(path.map(print, "implements"))); } parts.push(" ", path.call(print, "body")); if (n.type === "DeclareClass") { return printFlowDeclaration(path, parts); } else { return (0, lines_1.concat)(parts); } case "TemplateElement": return (0, lines_1.fromString)(n.value.raw, options).lockIndentTail(); case "TemplateLiteral": { var expressions_1 = path.map(print, "expressions"); parts.push("`"); path.each(function (childPath) { var i = childPath.getName(); parts.push(print(childPath)); if (i < expressions_1.length) { parts.push("${", expressions_1[i], "}"); } }, "quasis"); parts.push("`"); return (0, lines_1.concat)(parts).lockIndentTail(); } case "TaggedTemplateExpression": parts.push(path.call(print, "tag")); if (n.typeParameters) { parts.push(path.call(print, "typeParameters")); } parts.push(path.call(print, "quasi")); return (0, lines_1.concat)(parts); // These types are unprintable because they serve as abstract // supertypes for other (printable) types. case "Node": case "Printable": case "SourceLocation": case "Position": case "Statement": case "Function": case "Pattern": case "Expression": case "Declaration": case "Specifier": case "NamedSpecifier": case "Comment": // Supertype of Block and Line case "Flow": // Supertype of all Flow AST node types case "FlowType": // Supertype of all Flow types case "FlowPredicate": // Supertype of InferredPredicate and DeclaredPredicate case "MemberTypeAnnotation": // Flow case "Type": // Flow case "TSHasOptionalTypeParameterInstantiation": case "TSHasOptionalTypeParameters": case "TSHasOptionalTypeAnnotation": case "ChainElement": // Supertype of MemberExpression and CallExpression throw new Error("unprintable type: " + JSON.stringify(n.type)); case "CommentBlock": // Babel block comment. case "Block": // Esprima block comment. return (0, lines_1.concat)(["/*", (0, lines_1.fromString)(n.value, options), "*/"]); case "CommentLine": // Babel line comment. case "Line": // Esprima line comment. return (0, lines_1.concat)(["//", (0, lines_1.fromString)(n.value, options)]); // Type Annotations for Facebook Flow, typically stripped out or // transformed away before printing. case "TypeAnnotation": if (n.typeAnnotation) { if (n.typeAnnotation.type !== "FunctionTypeAnnotation") { parts.push(": "); } parts.push(path.call(print, "typeAnnotation")); return (0, lines_1.concat)(parts); } return (0, lines_1.fromString)(""); case "ExistentialTypeParam": case "ExistsTypeAnnotation": return (0, lines_1.fromString)("*", options); case "EmptyTypeAnnotation": return (0, lines_1.fromString)("empty", options); case "AnyTypeAnnotation": return (0, lines_1.fromString)("any", options); case "MixedTypeAnnotation": return (0, lines_1.fromString)("mixed", options); case "ArrayTypeAnnotation": return (0, lines_1.concat)([path.call(print, "elementType"), "[]"]); case "TupleTypeAnnotation": { var printed_2 = path.map(print, "types"); var joined = (0, lines_1.fromString)(", ").join(printed_2); var oneLine_3 = joined.getLineLength(1) <= options.wrapColumn; if (oneLine_3) { if (options.arrayBracketSpacing) { parts.push("[ "); } else { parts.push("["); } } else { parts.push("[\n"); } path.each(function (elemPath) { var i = elemPath.getName(); var elem = elemPath.getValue(); if (!elem) { // If the array expression ends with a hole, that hole // will be ignored by the interpreter, but if it ends with // two (or more) holes, we need to write out two (or more) // commas so that the resulting code is interpreted with // both (all) of the holes. parts.push(","); } else { var lines = printed_2[i]; if (oneLine_3) { if (i > 0) parts.push(" "); } else { lines = lines.indent(options.tabWidth); } parts.push(lines); if (i < n.types.length - 1 || (!oneLine_3 && util.isTrailingCommaEnabled(options, "arrays"))) parts.push(","); if (!oneLine_3) parts.push("\n"); } }, "types"); if (oneLine_3 && options.arrayBracketSpacing) { parts.push(" ]"); } else { parts.push("]"); } return (0, lines_1.concat)(parts); } case "BooleanTypeAnnotation": return (0, lines_1.fromString)("boolean", options); case "BooleanLiteralTypeAnnotation": (0, tiny_invariant_1.default)(typeof n.value === "boolean"); return (0, lines_1.fromString)("" + n.value, options); case "InterfaceTypeAnnotation": parts.push("interface"); if (n.extends && n.extends.length > 0) { parts.push(" extends ", (0, lines_1.fromString)(", ").join(path.map(print, "extends"))); } parts.push(" ", path.call(print, "body")); return (0, lines_1.concat)(parts); case "DeclareFunction": return printFlowDeclaration(path, [ "function ", path.call(print, "id"), ";", ]); case "DeclareModule": return printFlowDeclaration(path, [ "module ", path.call(print, "id"), " ", path.call(print, "body"), ]); case "DeclareModuleExports": return printFlowDeclaration(path, [ "module.exports", path.call(print, "typeAnnotation"), ]); case "DeclareVariable": return printFlowDeclaration(path, ["var ", path.call(print, "id"), ";"]); case "DeclareExportDeclaration": case "DeclareExportAllDeclaration": return (0, lines_1.concat)(["declare ", printExportDeclaration(path, options, print)]); case "EnumDeclaration": return (0, lines_1.concat)([ "enum ", path.call(print, "id"), path.call(print, "body"), ]); case "EnumBooleanBody": case "EnumNumberBody": case "EnumStringBody": case "EnumSymbolBody": { if (n.type === "EnumSymbolBody" || n.explicitType) { parts.push(" of ", // EnumBooleanBody => boolean, etc. n.type.slice(4, -4).toLowerCase()); } parts.push(" {\n", (0, lines_1.fromString)("\n") .join(path.map(print, "members")) .indent(options.tabWidth), "\n}"); return (0, lines_1.concat)(parts); } case "EnumDefaultedMember": return (0, lines_1.concat)([path.call(print, "id"), ","]); case "EnumBooleanMember": case "EnumNumberMember": case "EnumStringMember": return (0, lines_1.concat)([ path.call(print, "id"), " = ", path.call(print, "init"), ",", ]); case "InferredPredicate": return (0, lines_1.fromString)("%checks", options); case "DeclaredPredicate": return (0, lines_1.concat)(["%checks(", path.call(print, "value"), ")"]); case "FunctionTypeAnnotation": { // FunctionTypeAnnotation is ambiguous: // declare function(a: B): void; OR // const A: (a: B) => void; var parent = path.getParentNode(0); var isArrowFunctionTypeAnnotation = !(namedTypes.ObjectTypeCallProperty.check(parent) || (namedTypes.ObjectTypeInternalSlot.check(parent) && parent.method) || namedTypes.DeclareFunction.check(path.getParentNode(2))); var needsColon = isArrowFunctionTypeAnnotation && !namedTypes.FunctionTypeParam.check(parent) && !namedTypes.TypeAlias.check(parent); if (needsColon) { parts.push(": "); } var hasTypeParameters = !!n.typeParameters; var needsParens = hasTypeParameters || n.params.length !== 1 || n.params[0].name; parts.push(hasTypeParameters ? path.call(print, "typeParameters") : "", needsParens ? "(" : "", printFunctionParams(path, options, print), needsParens ? ")" : ""); // The returnType is not wrapped in a TypeAnnotation, so the colon // needs to be added separately. if (n.returnType) { parts.push(isArrowFunctionTypeAnnotation ? " => " : ": ", path.call(print, "returnType")); } return (0, lines_1.concat)(parts); } case "FunctionTypeParam": { var name = path.call(print, "name"); parts.push(name); if (n.optional) { parts.push("?"); } if (name.infos[0].line) { parts.push(": "); } parts.push(path.call(print, "typeAnnotation")); return (0, lines_1.concat)(parts); } case "GenericTypeAnnotation": return (0, lines_1.concat)([ path.call(print, "id"), path.call(print, "typeParameters"), ]); case "DeclareInterface": parts.push("declare "); // Fall through to InterfaceDeclaration... case "InterfaceDeclaration": case "TSInterfaceDeclaration": if (n.declare) { parts.push("declare "); } parts.push("interface ", path.call(print, "id"), path.call(print, "typeParameters"), " "); if (n["extends"] && n["extends"].length > 0) { parts.push("extends ", (0, lines_1.fromString)(", ").join(path.map(print, "extends")), " "); } if (n.body) { parts.push(path.call(print, "body")); } return (0, lines_1.concat)(parts); case "ClassImplements": case "InterfaceExtends": return (0, lines_1.concat)([ path.call(print, "id"), path.call(print, "typeParameters"), ]); case "IntersectionTypeAnnotation": return (0, lines_1.fromString)(" & ").join(path.map(print, "types")); case "NullableTypeAnnotation": return (0, lines_1.concat)(["?", path.call(print, "typeAnnotation")]); case "NullLiteralTypeAnnotation": return (0, lines_1.fromString)("null", options); case "ThisTypeAnnotation": return (0, lines_1.fromString)("this", options); case "NumberTypeAnnotation": return (0, lines_1.fromString)("number", options); case "ObjectTypeCallProperty": return path.call(print, "value"); case "ObjectTypeIndexer": if (n.static) { parts.push("static "); } parts.push(printVariance(path, print), "["); if (n.id) { parts.push(path.call(print, "id"), ": "); } parts.push(path.call(print, "key"), "]: ", path.call(print, "value")); return (0, lines_1.concat)(parts); case "ObjectTypeProperty": return (0, lines_1.concat)([ printVariance(path, print), path.call(print, "key"), n.optional ? "?" : "", ": ", path.call(print, "value"), ]); case "ObjectTypeInternalSlot": return (0, lines_1.concat)([ n.static ? "static " : "", "[[", path.call(print, "id"), "]]", n.optional ? "?" : "", n.value.type !== "FunctionTypeAnnotation" ? ": " : "", path.call(print, "value"), ]); case "QualifiedTypeIdentifier": return (0, lines_1.concat)([ path.call(print, "qualification"), ".", path.call(print, "id"), ]); case "StringLiteralTypeAnnotation": return (0, lines_1.fromString)(nodeStr(n.value, options), options); case "NumberLiteralTypeAnnotation": case "NumericLiteralTypeAnnotation": (0, tiny_invariant_1.default)(typeof n.value === "number"); return (0, lines_1.fromString)(JSON.stringify(n.value), options); case "BigIntLiteralTypeAnnotation": return (0, lines_1.fromString)(n.raw, options); case "StringTypeAnnotation": return (0, lines_1.fromString)("string", options); case "DeclareTypeAlias": parts.push("declare "); // Fall through to TypeAlias... case "TypeAlias": return (0, lines_1.concat)([ "type ", path.call(print, "id"), path.call(print, "typeParameters"), " = ", path.call(print, "right"), ";", ]); case "DeclareOpaqueType": parts.push("declare "); // Fall through to OpaqueType... case "OpaqueType": parts.push("opaque type ", path.call(print, "id"), path.call(print, "typeParameters")); if (n["supertype"]) { parts.push(": ", path.call(print, "supertype")); } if (n["impltype"]) { parts.push(" = ", path.call(print, "impltype")); } parts.push(";"); return (0, lines_1.concat)(parts); case "TypeCastExpression": return (0, lines_1.concat)([ "(", path.call(print, "expression"), path.call(print, "typeAnnotation"), ")", ]); case "TypeParameterDeclaration": case "TypeParameterInstantiation": return (0, lines_1.concat)([ "<", (0, lines_1.fromString)(", ").join(path.map(print, "params")), ">", ]); case "Variance": if (n.kind === "plus") { return (0, lines_1.fromString)("+"); } if (n.kind === "minus") { return (0, lines_1.fromString)("-"); } return (0, lines_1.fromString)(""); case "TypeParameter": if (n.variance) { parts.push(printVariance(path, print)); } parts.push(path.call(print, "name")); if (n.bound) { parts.push(path.call(print, "bound")); } if (n["default"]) { parts.push("=", path.call(print, "default")); } return (0, lines_1.concat)(parts); case "TypeofTypeAnnotation": return (0, lines_1.concat)([ (0, lines_1.fromString)("typeof ", options), path.call(print, "argument"), ]); case "IndexedAccessType": case "OptionalIndexedAccessType": return (0, lines_1.concat)([ path.call(print, "objectType"), n.optional ? "?." : "", "[", path.call(print, "indexType"), "]", ]); case "UnionTypeAnnotation": return (0, lines_1.fromString)(" | ").join(path.map(print, "types")); case "VoidTypeAnnotation": return (0, lines_1.fromString)("void", options); case "NullTypeAnnotation": return (0, lines_1.fromString)("null", options); case "SymbolTypeAnnotation": return (0, lines_1.fromString)("symbol", options); case "BigIntTypeAnnotation": return (0, lines_1.fromString)("bigint", options); // Type Annotations for TypeScript (when using Babylon as parser) case "TSType": throw new Error("unprintable type: " + JSON.stringify(n.type)); case "TSNumberKeyword": return (0, lines_1.fromString)("number", options); case "TSBigIntKeyword": return (0, lines_1.fromString)("bigint", options); case "TSObjectKeyword": return (0, lines_1.fromString)("object", options); case "TSBooleanKeyword": return (0, lines_1.fromString)("boolean", options); case "TSStringKeyword": return (0, lines_1.fromString)("string", options); case "TSSymbolKeyword": return (0, lines_1.fromString)("symbol", options); case "TSAnyKeyword": return (0, lines_1.fromString)("any", options); case "TSVoidKeyword": return (0, lines_1.fromString)("void", options); case "TSIntrinsicKeyword": return (0, lines_1.fromString)("intrinsic", options); case "TSThisType": return (0, lines_1.fromString)("this", options); case "TSNullKeyword": return (0, lines_1.fromString)("null", options); case "TSUndefinedKeyword": return (0, lines_1.fromString)("undefined", options); case "TSUnknownKeyword": return (0, lines_1.fromString)("unknown", options); case "TSNeverKeyword": return (0, lines_1.fromString)("never", options); case "TSArrayType": return (0, lines_1.concat)([path.call(print, "elementType"), "[]"]); case "TSLiteralType": return path.call(print, "literal"); case "TSUnionType": return (0, lines_1.fromString)(" | ").join(path.map(print, "types")); case "TSIntersectionType": return (0, lines_1.fromString)(" & ").join(path.map(print, "types")); case "TSConditionalType": parts.push(path.call(print, "checkType"), " extends ", path.call(print, "extendsType"), " ? ", path.call(print, "trueType"), " : ", path.call(print, "falseType")); return (0, lines_1.concat)(parts); case "TSInferType": parts.push("infer ", path.call(print, "typeParameter")); return (0, lines_1.concat)(parts); case "TSParenthesizedType": return (0, lines_1.concat)(["(", path.call(print, "typeAnnotation"), ")"]); case "TSFunctionType": return (0, lines_1.concat)([ path.call(print, "typeParameters"), "(", printFunctionParams(path, options, print), ") => ", path.call(print, "typeAnnotation", "typeAnnotation"), ]); case "TSConstructorType": return (0, lines_1.concat)([ "new ", path.call(print, "typeParameters"), "(", printFunctionParams(path, options, print), ") => ", path.call(print, "typeAnnotation", "typeAnnotation"), ]); case "TSMappedType": { parts.push(n.readonly ? "readonly " : "", "[", path.call(print, "typeParameter"), "]", n.optional ? "?" : ""); if (n.typeAnnotation) { parts.push(": ", path.call(print, "typeAnnotation"), ";"); } return (0, lines_1.concat)(["{\n", (0, lines_1.concat)(parts).indent(options.tabWidth), "\n}"]); } case "TSTupleType": return (0, lines_1.concat)([ "[", (0, lines_1.fromString)(", ").join(path.map(print, "elementTypes")), "]", ]); case "TSNamedTupleMember": parts.push(path.call(print, "label")); if (n.optional) { parts.push("?"); } parts.push(": ", path.call(print, "elementType")); return (0, lines_1.concat)(parts); case "TSRestType": return (0, lines_1.concat)(["...", path.call(print, "typeAnnotation")]); case "TSOptionalType": return (0, lines_1.concat)([path.call(print, "typeAnnotation"), "?"]); case "TSIndexedAccessType": return (0, lines_1.concat)([ path.call(print, "objectType"), "[", path.call(print, "indexType"), "]", ]); case "TSTypeOperator": return (0, lines_1.concat)([ path.call(print, "operator"), " ", path.call(print, "typeAnnotation"), ]); case "TSTypeLiteral": { var members = (0, lines_1.fromString)("\n").join(path.map(print, "members").map(function (member) { if (lastNonSpaceCharacter(member) !== ";") { return member.concat(";"); } return member; })); if (members.isEmpty()) { return (0, lines_1.fromString)("{}", options); } parts.push("{\n", members.indent(options.tabWidth), "\n}"); return (0, lines_1.concat)(parts); } case "TSEnumMember": parts.push(path.call(print, "id")); if (n.initializer) { parts.push(" = ", path.call(print, "initializer")); } return (0, lines_1.concat)(parts); case "TSTypeQuery": return (0, lines_1.concat)(["typeof ", path.call(print, "exprName")]); case "TSParameterProperty": if (n.accessibility) { parts.push(n.accessibility, " "); } if (n.export) { parts.push("export "); } if (n.static) { parts.push("static "); } if (n.readonly) { parts.push("readonly "); } parts.push(path.call(print, "parameter")); return (0, lines_1.concat)(parts); case "TSTypeReference": return (0, lines_1.concat)([ path.call(print, "typeName"), path.call(print, "typeParameters"), ]); case "TSQualifiedName": return (0, lines_1.concat)([path.call(print, "left"), ".", path.call(print, "right")]); case "TSAsExpression": case "TSSatisfiesExpression": { var expression = path.call(print, "expression"); parts.push(expression, n.type === "TSSatisfiesExpression" ? " satisfies " : " as ", path.call(print, "typeAnnotation")); return (0, lines_1.concat)(parts); } case "TSTypeCastExpression": return (0, lines_1.concat)([ path.call(print, "expression"), path.call(print, "typeAnnotation"), ]); case "TSNonNullExpression": return (0, lines_1.concat)([path.call(print, "expression"), "!"]); case "TSTypeAnnotation": return (0, lines_1.concat)([": ", path.call(print, "typeAnnotation")]); case "TSIndexSignature": return (0, lines_1.concat)([ n.readonly ? "readonly " : "", "[", path.map(print, "parameters"), "]", path.call(print, "typeAnnotation"), ]); case "TSPropertySignature": parts.push(printVariance(path, print), n.readonly ? "readonly " : ""); if (n.computed) { parts.push("[", path.call(print, "key"), "]"); } else { parts.push(path.call(print, "key")); } parts.push(n.optional ? "?" : "", path.call(print, "typeAnnotation")); return (0, lines_1.concat)(parts); case "TSMethodSignature": if (n.kind === "get") { parts.push("get "); } else if (n.kind === "set") { parts.push("set "); } if (n.computed) { parts.push("[", path.call(print, "key"), "]"); } else { parts.push(path.call(print, "key")); } if (n.optional) { parts.push("?"); } parts.push(path.call(print, "typeParameters"), "(", printFunctionParams(path, options, print), ")", path.call(print, "typeAnnotation")); return (0, lines_1.concat)(parts); case "TSTypePredicate": if (n.asserts) { parts.push("asserts "); } parts.push(path.call(print, "parameterName")); if (n.typeAnnotation) { parts.push(" is ", path.call(print, "typeAnnotation", "typeAnnotation")); } return (0, lines_1.concat)(parts); case "TSCallSignatureDeclaration": return (0, lines_1.concat)([ path.call(print, "typeParameters"), "(", printFunctionParams(path, options, print), ")", path.call(print, "typeAnnotation"), ]); case "TSConstructSignatureDeclaration": if (n.typeParameters) { parts.push("new", path.call(print, "typeParameters")); } else { parts.push("new "); } parts.push("(", printFunctionParams(path, options, print), ")", path.call(print, "typeAnnotation")); return (0, lines_1.concat)(parts); case "TSTypeAliasDeclaration": return (0, lines_1.concat)([ n.declare ? "declare " : "", "type ", path.call(print, "id"), path.call(print, "typeParameters"), " = ", path.call(print, "typeAnnotation"), ";", ]); case "TSTypeParameter": { parts.push(path.call(print, "name")); // ambiguous because of TSMappedType var parent = path.getParentNode(0); var isInMappedType = namedTypes.TSMappedType.check(parent); if (n.constraint) { parts.push(isInMappedType ? " in " : " extends ", path.call(print, "constraint")); } if (n["default"]) { parts.push(" = ", path.call(print, "default")); } return (0, lines_1.concat)(parts); } case "TSTypeAssertion": { parts.push("<", path.call(print, "typeAnnotation"), "> ", path.call(print, "expression")); return (0, lines_1.concat)(parts); } case "TSTypeParameterDeclaration": case "TSTypeParameterInstantiation": return (0, lines_1.concat)([ "<", (0, lines_1.fromString)(", ").join(path.map(print, "params")), ">", ]); case "TSEnumDeclaration": { parts.push(n.declare ? "declare " : "", n.const ? "const " : "", "enum ", path.call(print, "id")); var memberLines = (0, lines_1.fromString)(",\n").join(path.map(print, "members")); if (memberLines.isEmpty()) { parts.push(" {}"); } else { parts.push(" {\n", memberLines.indent(options.tabWidth), "\n}"); } return (0, lines_1.concat)(parts); } case "TSExpressionWithTypeArguments": return (0, lines_1.concat)([ path.call(print, "expression"), path.call(print, "typeParameters"), ]); case "TSInterfaceBody": { var lines = (0, lines_1.fromString)("\n").join(path.map(print, "body").map(function (element) { if (lastNonSpaceCharacter(element) !== ";") { return element.concat(";"); } return element; })); if (lines.isEmpty()) { return (0, lines_1.fromString)("{}", options); } return (0, lines_1.concat)(["{\n", lines.indent(options.tabWidth), "\n}"]); } case "TSImportType": parts.push("import(", path.call(print, "argument"), ")"); if (n.qualifier) { parts.push(".", path.call(print, "qualifier")); } if (n.typeParameters) { parts.push(path.call(print, "typeParameters")); } return (0, lines_1.concat)(parts); case "TSImportEqualsDeclaration": if (n.isExport) { parts.push("export "); } parts.push("import ", path.call(print, "id"), " = ", path.call(print, "moduleReference")); return maybeAddSemicolon((0, lines_1.concat)(parts)); case "TSExternalModuleReference": return (0, lines_1.concat)(["require(", path.call(print, "expression"), ")"]); case "TSModuleDeclaration": { var parent = path.getParentNode(); if (parent.type === "TSModuleDeclaration") { parts.push("."); } else { if (n.declare) { parts.push("declare "); } if (!n.global) { var isExternal = n.id.type === "StringLiteral" || (n.id.type === "Literal" && typeof n.id.value === "string"); if (isExternal) { parts.push("module "); } else if (n.loc && n.loc.lines && n.id.loc) { var prefix = n.loc.lines.sliceString(n.loc.start, n.id.loc.start); // These keywords are fundamentally ambiguous in the // Babylon parser, and not reflected in the AST, so // the best we can do is to match the original code, // when possible. if (prefix.indexOf("module") >= 0) { parts.push("module "); } else { parts.push("namespace "); } } else { parts.push("namespace "); } } } parts.push(path.call(print, "id")); if (n.body) { parts.push(" "); parts.push(path.call(print, "body")); } return (0, lines_1.concat)(parts); } case "TSModuleBlock": { var naked = path.call(function (bodyPath) { return printStatementSequence(bodyPath, options, print); }, "body"); if (naked.isEmpty()) { parts.push("{}"); } else { parts.push("{\n", naked.indent(options.tabWidth), "\n}"); } return (0, lines_1.concat)(parts); } case "TSInstantiationExpression": { parts.push(path.call(print, "expression"), path.call(print, "typeParameters")); return (0, lines_1.concat)(parts); } // https://github.com/babel/babel/pull/10148 case "V8IntrinsicIdentifier": return (0, lines_1.concat)(["%", path.call(print, "name")]); // https://github.com/babel/babel/pull/13191 case "TopicReference": return (0, lines_1.fromString)("#"); // Unhandled types below. If encountered, nodes of these types should // be either left alone or desugared into AST types that are fully // supported by the pretty-printer. case "ClassHeritage": // TODO case "ComprehensionBlock": // TODO case "ComprehensionExpression": // TODO case "Glob": // TODO case "GeneratorExpression": // TODO case "LetStatement": // TODO case "LetExpression": // TODO case "GraphExpression": // TODO case "GraphIndexExpression": // TODO case "XMLDefaultDeclaration": case "XMLAnyName": case "XMLQualifiedIdentifier": case "XMLFunctionQualifiedIdentifier": case "XMLAttributeSelector": case "XMLFilterExpression": case "XML": case "XMLElement": case "XMLList": case "XMLEscape": case "XMLText": case "XMLStartTag": case "XMLEndTag": case "XMLPointTag": case "XMLName": case "XMLAttribute": case "XMLCdata": case "XMLComment": case "XMLProcessingInstruction": default: debugger; throw new Error("unknown type: " + JSON.stringify(n.type)); } } function printDecorators(path, printPath) { var parts = []; var node = path.getValue(); if (node.decorators && node.decorators.length > 0 && // If the parent node is an export declaration, it will be // responsible for printing node.decorators. !util.getParentExportDeclaration(path)) { path.each(function (decoratorPath) { parts.push(printPath(decoratorPath), "\n"); }, "decorators"); } else if (util.isExportDeclaration(node) && node.declaration && node.declaration.decorators) { // Export declarations are responsible for printing any decorators // that logically apply to node.declaration. path.each(function (decoratorPath) { parts.push(printPath(decoratorPath), "\n"); }, "declaration", "decorators"); } return (0, lines_1.concat)(parts); } function printStatementSequence(path, options, print) { var filtered = []; var sawComment = false; var sawStatement = false; path.each(function (stmtPath) { var stmt = stmtPath.getValue(); // Just in case the AST has been modified to contain falsy // "statements," it's safer simply to skip them. if (!stmt) { return; } // Skip printing EmptyStatement nodes to avoid leaving stray // semicolons lying around. if (stmt.type === "EmptyStatement" && !(stmt.comments && stmt.comments.length > 0)) { return; } if (namedTypes.Comment.check(stmt)) { // The pretty printer allows a dangling Comment node to act as // a Statement when the Comment can't be attached to any other // non-Comment node in the tree. sawComment = true; } else if (namedTypes.Statement.check(stmt)) { sawStatement = true; } else { // When the pretty printer encounters a string instead of an // AST node, it just prints the string. This behavior can be // useful for fine-grained formatting decisions like inserting // blank lines. isString.assert(stmt); } // We can't hang onto stmtPath outside of this function, because // it's just a reference to a mutable FastPath object, so we have // to go ahead and print it here. filtered.push({ node: stmt, printed: print(stmtPath), }); }); if (sawComment) { (0, tiny_invariant_1.default)(sawStatement === false, "Comments may appear as statements in otherwise empty statement " + "lists, but may not coexist with non-Comment nodes."); } var prevTrailingSpace = null; var len = filtered.length; var parts = []; filtered.forEach(function (info, i) { var printed = info.printed; var stmt = info.node; var multiLine = printed.length > 1; var notFirst = i > 0; var notLast = i < len - 1; var leadingSpace; var trailingSpace; var lines = stmt && stmt.loc && stmt.loc.lines; var trueLoc = lines && options.reuseWhitespace && util.getTrueLoc(stmt, lines); if (notFirst) { if (trueLoc) { var beforeStart = lines.skipSpaces(trueLoc.start, true); var beforeStartLine = beforeStart ? beforeStart.line : 1; var leadingGap = trueLoc.start.line - beforeStartLine; leadingSpace = Array(leadingGap + 1).join("\n"); } else { leadingSpace = multiLine ? "\n\n" : "\n"; } } else { leadingSpace = ""; } if (notLast) { if (trueLoc) { var afterEnd = lines.skipSpaces(trueLoc.end); var afterEndLine = afterEnd ? afterEnd.line : lines.length; var trailingGap = afterEndLine - trueLoc.end.line; trailingSpace = Array(trailingGap + 1).join("\n"); } else { trailingSpace = multiLine ? "\n\n" : "\n"; } } else { trailingSpace = ""; } parts.push(maxSpace(prevTrailingSpace, leadingSpace), printed); if (notLast) { prevTrailingSpace = trailingSpace; } else if (trailingSpace) { parts.push(trailingSpace); } }); return (0, lines_1.concat)(parts); } function maxSpace(s1, s2) { if (!s1 && !s2) { return (0, lines_1.fromString)(""); } if (!s1) { return (0, lines_1.fromString)(s2); } if (!s2) { return (0, lines_1.fromString)(s1); } var spaceLines1 = (0, lines_1.fromString)(s1); var spaceLines2 = (0, lines_1.fromString)(s2); if (spaceLines2.length > spaceLines1.length) { return spaceLines2; } return spaceLines1; } function printClassMemberModifiers(node) { var parts = []; if (node.declare) { parts.push("declare "); } var access = node.accessibility || node.access; if (typeof access === "string") { parts.push(access, " "); } if (node.static) { parts.push("static "); } if (node.override) { parts.push("override "); } if (node.abstract) { parts.push("abstract "); } if (node.readonly) { parts.push("readonly "); } return parts; } function printMethod(path, options, print) { var node = path.getNode(); var kind = node.kind; var parts = []; var nodeValue = node.value; if (!namedTypes.FunctionExpression.check(nodeValue)) { nodeValue = node; } parts.push.apply(parts, printClassMemberModifiers(node)); if (nodeValue.async) { parts.push("async "); } if (nodeValue.generator) { parts.push("*"); } if (kind === "get" || kind === "set") { parts.push(kind, " "); } var key = path.call(print, "key"); if (node.computed) { key = (0, lines_1.concat)(["[", key, "]"]); } parts.push(key); if (node.optional) { parts.push("?"); } if (node === nodeValue) { parts.push(path.call(print, "typeParameters"), "(", printFunctionParams(path, options, print), ")", path.call(print, "returnType")); if (node.body) { parts.push(" ", path.call(print, "body")); } else { parts.push(";"); } } else { parts.push(path.call(print, "value", "typeParameters"), "(", path.call(function (valuePath) { return printFunctionParams(valuePath, options, print); }, "value"), ")", path.call(print, "value", "returnType")); if (nodeValue.body) { parts.push(" ", path.call(print, "value", "body")); } else { parts.push(";"); } } return (0, lines_1.concat)(parts); } function printArgumentsList(path, options, print) { var printed = path.map(print, "arguments"); var trailingComma = util.isTrailingCommaEnabled(options, "parameters"); var joined = (0, lines_1.fromString)(", ").join(printed); if (joined.getLineLength(1) > options.wrapColumn) { joined = (0, lines_1.fromString)(",\n").join(printed); return (0, lines_1.concat)([ "(\n", joined.indent(options.tabWidth), trailingComma ? ",\n)" : "\n)", ]); } return (0, lines_1.concat)(["(", joined, ")"]); } function printFunctionParams(path, options, print) { var fun = path.getValue(); var params; var printed = []; if (fun.params) { params = fun.params; printed = path.map(print, "params"); } else if (fun.parameters) { params = fun.parameters; printed = path.map(print, "parameters"); } if (fun.defaults) { path.each(function (defExprPath) { var i = defExprPath.getName(); var p = printed[i]; if (p && defExprPath.getValue()) { printed[i] = (0, lines_1.concat)([p, " = ", print(defExprPath)]); } }, "defaults"); } if (fun.rest) { printed.push((0, lines_1.concat)(["...", path.call(print, "rest")])); } var joined = (0, lines_1.fromString)(", ").join(printed); if (joined.length > 1 || joined.getLineLength(1) > options.wrapColumn) { joined = (0, lines_1.fromString)(",\n").join(printed); if (util.isTrailingCommaEnabled(options, "parameters") && !fun.rest && params[params.length - 1].type !== "RestElement") { joined = (0, lines_1.concat)([joined, ",\n"]); } else { joined = (0, lines_1.concat)([joined, "\n"]); } return (0, lines_1.concat)(["\n", joined.indent(options.tabWidth)]); } return joined; } function maybePrintImportAssertions(path, options, print) { var n = path.getValue(); if (n.assertions && n.assertions.length > 0) { var parts = [" assert {"]; var printed = path.map(print, "assertions"); var flat = (0, lines_1.fromString)(", ").join(printed); if (flat.length > 1 || flat.getLineLength(1) > options.wrapColumn) { parts.push("\n", (0, lines_1.fromString)(",\n").join(printed).indent(options.tabWidth), "\n}"); } else { parts.push(" ", flat, " }"); } return (0, lines_1.concat)(parts); } return (0, lines_1.fromString)(""); } function printExportDeclaration(path, options, print) { var decl = path.getValue(); var parts = ["export "]; if (decl.exportKind && decl.exportKind === "type") { if (!decl.declaration) { parts.push("type "); } } var shouldPrintSpaces = options.objectCurlySpacing; namedTypes.Declaration.assert(decl); if (decl["default"] || decl.type === "ExportDefaultDeclaration") { parts.push("default "); } if (decl.declaration) { parts.push(path.call(print, "declaration")); } else if (decl.specifiers) { if (decl.specifiers.length === 1 && decl.specifiers[0].type === "ExportBatchSpecifier") { parts.push("*"); } else if (decl.specifiers.length === 0) { parts.push("{}"); } else if (decl.specifiers[0].type === "ExportDefaultSpecifier" || decl.specifiers[0].type === "ExportNamespaceSpecifier") { var unbracedSpecifiers_2 = []; var bracedSpecifiers_2 = []; path.each(function (specifierPath) { var spec = specifierPath.getValue(); if (spec.type === "ExportDefaultSpecifier" || spec.type === "ExportNamespaceSpecifier") { unbracedSpecifiers_2.push(print(specifierPath)); } else { bracedSpecifiers_2.push(print(specifierPath)); } }, "specifiers"); unbracedSpecifiers_2.forEach(function (lines, i) { if (i > 0) { parts.push(", "); } parts.push(lines); }); if (bracedSpecifiers_2.length > 0) { var lines_2 = (0, lines_1.fromString)(", ").join(bracedSpecifiers_2); if (lines_2.getLineLength(1) > options.wrapColumn) { lines_2 = (0, lines_1.concat)([ (0, lines_1.fromString)(",\n").join(bracedSpecifiers_2).indent(options.tabWidth), ",", ]); } if (unbracedSpecifiers_2.length > 0) { parts.push(", "); } if (lines_2.length > 1) { parts.push("{\n", lines_2, "\n}"); } else if (options.objectCurlySpacing) { parts.push("{ ", lines_2, " }"); } else { parts.push("{", lines_2, "}"); } } } else { parts.push(shouldPrintSpaces ? "{ " : "{", (0, lines_1.fromString)(", ").join(path.map(print, "specifiers")), shouldPrintSpaces ? " }" : "}"); } if (decl.source) { parts.push(" from ", path.call(print, "source"), maybePrintImportAssertions(path, options, print)); } } var lines = (0, lines_1.concat)(parts); if (lastNonSpaceCharacter(lines) !== ";" && !(decl.declaration && (decl.declaration.type === "FunctionDeclaration" || decl.declaration.type === "ClassDeclaration" || decl.declaration.type === "TSModuleDeclaration" || decl.declaration.type === "TSInterfaceDeclaration" || decl.declaration.type === "TSEnumDeclaration"))) { lines = (0, lines_1.concat)([lines, ";"]); } return lines; } function printFlowDeclaration(path, parts) { var parentExportDecl = util.getParentExportDeclaration(path); if (parentExportDecl) { (0, tiny_invariant_1.default)(parentExportDecl.type === "DeclareExportDeclaration"); } else { // If the parent node has type DeclareExportDeclaration, then it // will be responsible for printing the "declare" token. Otherwise // it needs to be printed with this non-exported declaration node. parts.unshift("declare "); } return (0, lines_1.concat)(parts); } function printVariance(path, print) { return path.call(function (variancePath) { var value = variancePath.getValue(); if (value) { if (value === "plus") { return (0, lines_1.fromString)("+"); } if (value === "minus") { return (0, lines_1.fromString)("-"); } return print(variancePath); } return (0, lines_1.fromString)(""); }, "variance"); } function adjustClause(clause, options) { if (clause.length > 1) return (0, lines_1.concat)([" ", clause]); return (0, lines_1.concat)(["\n", maybeAddSemicolon(clause).indent(options.tabWidth)]); } function lastNonSpaceCharacter(lines) { var pos = lines.lastPos(); do { var ch = lines.charAt(pos); if (/\S/.test(ch)) return ch; } while (lines.prevPos(pos)); } function endsWithBrace(lines) { return lastNonSpaceCharacter(lines) === "}"; } function swapQuotes(str) { return str.replace(/['"]/g, function (m) { return (m === '"' ? "'" : '"'); }); } function getPossibleRaw(node) { var value = types.getFieldValue(node, "value"); var extra = types.getFieldValue(node, "extra"); if (extra && typeof extra.raw === "string" && value == extra.rawValue) { return extra.raw; } if (node.type === "Literal") { var raw = node.raw; if (typeof raw === "string" && value == raw) { return raw; } } } function jsSafeStringify(str) { return JSON.stringify(str).replace(/[\u2028\u2029]/g, function (m) { return "\\u" + m.charCodeAt(0).toString(16); }); } function nodeStr(str, options) { isString.assert(str); switch (options.quote) { case "auto": { var double = jsSafeStringify(str); var single = swapQuotes(jsSafeStringify(swapQuotes(str))); return double.length > single.length ? single : double; } case "single": return swapQuotes(jsSafeStringify(swapQuotes(str))); case "double": default: return jsSafeStringify(str); } } function maybeAddSemicolon(lines) { var eoc = lastNonSpaceCharacter(lines); if (!eoc || "\n};".indexOf(eoc) < 0) return (0, lines_1.concat)([lines, ";"]); return lines; } /***/ }), /***/ "./node_modules/recast/lib/util.js": /*!*****************************************!*\ !*** ./node_modules/recast/lib/util.js ***! \*****************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.isTrailingCommaEnabled = exports.getParentExportDeclaration = exports.isExportDeclaration = exports.fixFaultyLocations = exports.getTrueLoc = exports.composeSourceMaps = exports.copyPos = exports.comparePos = exports.getUnionOfKeys = exports.getOption = exports.isBrowser = exports.getLineTerminator = void 0; var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.mjs"); var tiny_invariant_1 = tslib_1.__importDefault(__webpack_require__(/*! tiny-invariant */ "./node_modules/tiny-invariant/dist/tiny-invariant.cjs.js")); var types = tslib_1.__importStar(__webpack_require__(/*! ast-types */ "./node_modules/ast-types/lib/main.js")); var n = types.namedTypes; var source_map_1 = tslib_1.__importDefault(__webpack_require__(/*! source-map */ "./node_modules/recast/node_modules/source-map/source-map.js")); var SourceMapConsumer = source_map_1.default.SourceMapConsumer; var SourceMapGenerator = source_map_1.default.SourceMapGenerator; var hasOwn = Object.prototype.hasOwnProperty; function getLineTerminator() { return isBrowser() ? "\n" : (__webpack_require__(/*! os */ "./node_modules/os-browserify/browser.js").EOL) || "\n"; } exports.getLineTerminator = getLineTerminator; function isBrowser() { return (typeof window !== "undefined" && typeof window.document !== "undefined"); } exports.isBrowser = isBrowser; function getOption(options, key, defaultValue) { if (options && hasOwn.call(options, key)) { return options[key]; } return defaultValue; } exports.getOption = getOption; function getUnionOfKeys() { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } var result = {}; var argc = args.length; for (var i = 0; i < argc; ++i) { var keys = Object.keys(args[i]); var keyCount = keys.length; for (var j = 0; j < keyCount; ++j) { result[keys[j]] = true; } } return result; } exports.getUnionOfKeys = getUnionOfKeys; function comparePos(pos1, pos2) { return pos1.line - pos2.line || pos1.column - pos2.column; } exports.comparePos = comparePos; function copyPos(pos) { return { line: pos.line, column: pos.column, }; } exports.copyPos = copyPos; function composeSourceMaps(formerMap, latterMap) { if (formerMap) { if (!latterMap) { return formerMap; } } else { return latterMap || null; } var smcFormer = new SourceMapConsumer(formerMap); var smcLatter = new SourceMapConsumer(latterMap); var smg = new SourceMapGenerator({ file: latterMap.file, sourceRoot: latterMap.sourceRoot, }); var sourcesToContents = {}; smcLatter.eachMapping(function (mapping) { var origPos = smcFormer.originalPositionFor({ line: mapping.originalLine, column: mapping.originalColumn, }); var sourceName = origPos.source; if (sourceName === null) { return; } smg.addMapping({ source: sourceName, original: copyPos(origPos), generated: { line: mapping.generatedLine, column: mapping.generatedColumn, }, name: mapping.name, }); var sourceContent = smcFormer.sourceContentFor(sourceName); if (sourceContent && !hasOwn.call(sourcesToContents, sourceName)) { sourcesToContents[sourceName] = sourceContent; smg.setSourceContent(sourceName, sourceContent); } }); return smg.toJSON(); } exports.composeSourceMaps = composeSourceMaps; function getTrueLoc(node, lines) { // It's possible that node is newly-created (not parsed by Esprima), // in which case it probably won't have a .loc property (or an // .original property for that matter). That's fine; we'll just // pretty-print it as usual. if (!node.loc) { return null; } var result = { start: node.loc.start, end: node.loc.end, }; function include(node) { expandLoc(result, node.loc); } // If the node is an export declaration and its .declaration has any // decorators, their locations might contribute to the true start/end // positions of the export declaration node. if (node.declaration && node.declaration.decorators && isExportDeclaration(node)) { node.declaration.decorators.forEach(include); } if (comparePos(result.start, result.end) < 0) { // Trim leading whitespace. result.start = copyPos(result.start); lines.skipSpaces(result.start, false, true); if (comparePos(result.start, result.end) < 0) { // Trim trailing whitespace, if the end location is not already the // same as the start location. result.end = copyPos(result.end); lines.skipSpaces(result.end, true, true); } } // If the node has any comments, their locations might contribute to // the true start/end positions of the node. if (node.comments) { node.comments.forEach(include); } return result; } exports.getTrueLoc = getTrueLoc; function expandLoc(parentLoc, childLoc) { if (parentLoc && childLoc) { if (comparePos(childLoc.start, parentLoc.start) < 0) { parentLoc.start = childLoc.start; } if (comparePos(parentLoc.end, childLoc.end) < 0) { parentLoc.end = childLoc.end; } } } function fixFaultyLocations(node, lines) { var loc = node.loc; if (loc) { if (loc.start.line < 1) { loc.start.line = 1; } if (loc.end.line < 1) { loc.end.line = 1; } } if (node.type === "File") { // Babylon returns File nodes whose .loc.{start,end} do not include // leading or trailing whitespace. loc.start = lines.firstPos(); loc.end = lines.lastPos(); } fixForLoopHead(node, lines); fixTemplateLiteral(node, lines); if (loc && node.decorators) { // Expand the .loc of the node responsible for printing the decorators // (here, the decorated node) so that it includes node.decorators. node.decorators.forEach(function (decorator) { expandLoc(loc, decorator.loc); }); } else if (node.declaration && isExportDeclaration(node)) { // Nullify .loc information for the child declaration so that we never // try to reprint it without also reprinting the export declaration. node.declaration.loc = null; // Expand the .loc of the node responsible for printing the decorators // (here, the export declaration) so that it includes node.decorators. var decorators = node.declaration.decorators; if (decorators) { decorators.forEach(function (decorator) { expandLoc(loc, decorator.loc); }); } } else if ((n.MethodDefinition && n.MethodDefinition.check(node)) || (n.Property.check(node) && (node.method || node.shorthand))) { // If the node is a MethodDefinition or a .method or .shorthand // Property, then the location information stored in // node.value.loc is very likely untrustworthy (just the {body} // part of a method, or nothing in the case of shorthand // properties), so we null out that information to prevent // accidental reuse of bogus source code during reprinting. node.value.loc = null; if (n.FunctionExpression.check(node.value)) { // FunctionExpression method values should be anonymous, // because their .id fields are ignored anyway. node.value.id = null; } } else if (node.type === "ObjectTypeProperty") { var loc_1 = node.loc; var end = loc_1 && loc_1.end; if (end) { end = copyPos(end); if (lines.prevPos(end) && lines.charAt(end) === ",") { // Some parsers accidentally include trailing commas in the // .loc.end information for ObjectTypeProperty nodes. if ((end = lines.skipSpaces(end, true, true))) { loc_1.end = end; } } } } } exports.fixFaultyLocations = fixFaultyLocations; function fixForLoopHead(node, lines) { if (node.type !== "ForStatement") { return; } function fix(child) { var loc = child && child.loc; var start = loc && loc.start; var end = loc && copyPos(loc.end); while (start && end && comparePos(start, end) < 0) { lines.prevPos(end); if (lines.charAt(end) === ";") { // Update child.loc.end to *exclude* the ';' character. loc.end.line = end.line; loc.end.column = end.column; } else { break; } } } fix(node.init); fix(node.test); fix(node.update); } function fixTemplateLiteral(node, lines) { if (node.type !== "TemplateLiteral") { return; } if (node.quasis.length === 0) { // If there are no quasi elements, then there is nothing to fix. return; } // node.loc is not present when using export default with a template literal if (node.loc) { // First we need to exclude the opening ` from the .loc of the first // quasi element, in case the parser accidentally decided to include it. var afterLeftBackTickPos = copyPos(node.loc.start); (0, tiny_invariant_1.default)(lines.charAt(afterLeftBackTickPos) === "`"); (0, tiny_invariant_1.default)(lines.nextPos(afterLeftBackTickPos)); var firstQuasi = node.quasis[0]; if (comparePos(firstQuasi.loc.start, afterLeftBackTickPos) < 0) { firstQuasi.loc.start = afterLeftBackTickPos; } // Next we need to exclude the closing ` from the .loc of the last quasi // element, in case the parser accidentally decided to include it. var rightBackTickPos = copyPos(node.loc.end); (0, tiny_invariant_1.default)(lines.prevPos(rightBackTickPos)); (0, tiny_invariant_1.default)(lines.charAt(rightBackTickPos) === "`"); var lastQuasi = node.quasis[node.quasis.length - 1]; if (comparePos(rightBackTickPos, lastQuasi.loc.end) < 0) { lastQuasi.loc.end = rightBackTickPos; } } // Now we need to exclude ${ and } characters from the .loc's of all // quasi elements, since some parsers accidentally include them. node.expressions.forEach(function (expr, i) { // Rewind from expr.loc.start over any whitespace and the ${ that // precedes the expression. The position of the $ should be the same // as the .loc.end of the preceding quasi element, but some parsers // accidentally include the ${ in the .loc of the quasi element. var dollarCurlyPos = lines.skipSpaces(expr.loc.start, true, false); if (lines.prevPos(dollarCurlyPos) && lines.charAt(dollarCurlyPos) === "{" && lines.prevPos(dollarCurlyPos) && lines.charAt(dollarCurlyPos) === "$") { var quasiBefore = node.quasis[i]; if (comparePos(dollarCurlyPos, quasiBefore.loc.end) < 0) { quasiBefore.loc.end = dollarCurlyPos; } } // Likewise, some parsers accidentally include the } that follows // the expression in the .loc of the following quasi element. var rightCurlyPos = lines.skipSpaces(expr.loc.end, false, false); if (lines.charAt(rightCurlyPos) === "}") { (0, tiny_invariant_1.default)(lines.nextPos(rightCurlyPos)); // Now rightCurlyPos is technically the position just after the }. var quasiAfter = node.quasis[i + 1]; if (comparePos(quasiAfter.loc.start, rightCurlyPos) < 0) { quasiAfter.loc.start = rightCurlyPos; } } }); } function isExportDeclaration(node) { if (node) switch (node.type) { case "ExportDeclaration": case "ExportDefaultDeclaration": case "ExportDefaultSpecifier": case "DeclareExportDeclaration": case "ExportNamedDeclaration": case "ExportAllDeclaration": return true; } return false; } exports.isExportDeclaration = isExportDeclaration; function getParentExportDeclaration(path) { var parentNode = path.getParentNode(); if (path.getName() === "declaration" && isExportDeclaration(parentNode)) { return parentNode; } return null; } exports.getParentExportDeclaration = getParentExportDeclaration; function isTrailingCommaEnabled(options, context) { var trailingComma = options.trailingComma; if (typeof trailingComma === "object") { return !!trailingComma[context]; } return !!trailingComma; } exports.isTrailingCommaEnabled = isTrailingCommaEnabled; /***/ }), /***/ "./node_modules/recast/main.js": /*!*************************************!*\ !*** ./node_modules/recast/main.js ***! \*************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; /* provided dependency */ var process = __webpack_require__(/*! process/browser.js */ "./node_modules/process/browser.js"); Object.defineProperty(exports, "__esModule", ({ value: true })); exports.run = exports.prettyPrint = exports.print = exports.visit = exports.types = exports.parse = void 0; var tslib_1 = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.mjs"); var fs_1 = tslib_1.__importDefault(__webpack_require__(/*! fs */ "?5042")); var types = tslib_1.__importStar(__webpack_require__(/*! ast-types */ "./node_modules/ast-types/lib/main.js")); exports.types = types; var parser_1 = __webpack_require__(/*! ./lib/parser */ "./node_modules/recast/lib/parser.js"); Object.defineProperty(exports, "parse", ({ enumerable: true, get: function () { return parser_1.parse; } })); var printer_1 = __webpack_require__(/*! ./lib/printer */ "./node_modules/recast/lib/printer.js"); /** * Traverse and potentially modify an abstract syntax tree using a * convenient visitor syntax: * * recast.visit(ast, { * names: [], * visitIdentifier: function(path) { * var node = path.value; * this.visitor.names.push(node.name); * this.traverse(path); * } * }); */ var ast_types_1 = __webpack_require__(/*! ast-types */ "./node_modules/ast-types/lib/main.js"); Object.defineProperty(exports, "visit", ({ enumerable: true, get: function () { return ast_types_1.visit; } })); /** * Reprint a modified syntax tree using as much of the original source * code as possible. */ function print(node, options) { return new printer_1.Printer(options).print(node); } exports.print = print; /** * Print without attempting to reuse any original source code. */ function prettyPrint(node, options) { return new printer_1.Printer(options).printGenerically(node); } exports.prettyPrint = prettyPrint; /** * Convenient command-line interface (see e.g. example/add-braces). */ function run(transformer, options) { return runFile(process.argv[2], transformer, options); } exports.run = run; function runFile(path, transformer, options) { fs_1.default.readFile(path, "utf-8", function (err, code) { if (err) { console.error(err); return; } runString(code, transformer, options); }); } function defaultWriteback(output) { process.stdout.write(output); } function runString(code, transformer, options) { var writeback = (options && options.writeback) || defaultWriteback; transformer((0, parser_1.parse)(code, options), function (node) { writeback(print(node, options).code); }); } /***/ }), /***/ "./node_modules/recast/node_modules/source-map/lib/array-set.js": /*!**********************************************************************!*\ !*** ./node_modules/recast/node_modules/source-map/lib/array-set.js ***! \**********************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { /* -*- Mode: js; js-indent-level: 2; -*- */ /* * Copyright 2011 Mozilla Foundation and contributors * Licensed under the New BSD license. See LICENSE or: * http://opensource.org/licenses/BSD-3-Clause */ var util = __webpack_require__(/*! ./util */ "./node_modules/recast/node_modules/source-map/lib/util.js"); var has = Object.prototype.hasOwnProperty; var hasNativeMap = typeof Map !== "undefined"; /** * A data structure which is a combination of an array and a set. Adding a new * member is O(1), testing for membership is O(1), and finding the index of an * element is O(1). Removing elements from the set is not supported. Only * strings are supported for membership. */ function ArraySet() { this._array = []; this._set = hasNativeMap ? new Map() : Object.create(null); } /** * Static method for creating ArraySet instances from an existing array. */ ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) { var set = new ArraySet(); for (var i = 0, len = aArray.length; i < len; i++) { set.add(aArray[i], aAllowDuplicates); } return set; }; /** * Return how many unique items are in this ArraySet. If duplicates have been * added, than those do not count towards the size. * * @returns Number */ ArraySet.prototype.size = function ArraySet_size() { return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length; }; /** * Add the given string to this set. * * @param String aStr */ ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) { var sStr = hasNativeMap ? aStr : util.toSetString(aStr); var isDuplicate = hasNativeMap ? this.has(aStr) : has.call(this._set, sStr); var idx = this._array.length; if (!isDuplicate || aAllowDuplicates) { this._array.push(aStr); } if (!isDuplicate) { if (hasNativeMap) { this._set.set(aStr, idx); } else { this._set[sStr] = idx; } } }; /** * Is the given string a member of this set? * * @param String aStr */ ArraySet.prototype.has = function ArraySet_has(aStr) { if (hasNativeMap) { return this._set.has(aStr); } else { var sStr = util.toSetString(aStr); return has.call(this._set, sStr); } }; /** * What is the index of the given string in the array? * * @param String aStr */ ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) { if (hasNativeMap) { var idx = this._set.get(aStr); if (idx >= 0) { return idx; } } else { var sStr = util.toSetString(aStr); if (has.call(this._set, sStr)) { return this._set[sStr]; } } throw new Error('"' + aStr + '" is not in the set.'); }; /** * What is the element at the given index? * * @param Number aIdx */ ArraySet.prototype.at = function ArraySet_at(aIdx) { if (aIdx >= 0 && aIdx < this._array.length) { return this._array[aIdx]; } throw new Error('No element indexed by ' + aIdx); }; /** * Returns the array representation of this set (which has the proper indices * indicated by indexOf). Note that this is a copy of the internal array used * for storing the members so that no one can mess with internal state. */ ArraySet.prototype.toArray = function ArraySet_toArray() { return this._array.slice(); }; exports.ArraySet = ArraySet; /***/ }), /***/ "./node_modules/recast/node_modules/source-map/lib/base64-vlq.js": /*!***********************************************************************!*\ !*** ./node_modules/recast/node_modules/source-map/lib/base64-vlq.js ***! \***********************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { /* -*- Mode: js; js-indent-level: 2; -*- */ /* * Copyright 2011 Mozilla Foundation and contributors * Licensed under the New BSD license. See LICENSE or: * http://opensource.org/licenses/BSD-3-Clause * * Based on the Base 64 VLQ implementation in Closure Compiler: * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java * * Copyright 2011 The Closure Compiler Authors. All rights reserved. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ var base64 = __webpack_require__(/*! ./base64 */ "./node_modules/recast/node_modules/source-map/lib/base64.js"); // A single base 64 digit can contain 6 bits of data. For the base 64 variable // length quantities we use in the source map spec, the first bit is the sign, // the next four bits are the actual value, and the 6th bit is the // continuation bit. The continuation bit tells us whether there are more // digits in this value following this digit. // // Continuation // | Sign // | | // V V // 101011 var VLQ_BASE_SHIFT = 5; // binary: 100000 var VLQ_BASE = 1 << VLQ_BASE_SHIFT; // binary: 011111 var VLQ_BASE_MASK = VLQ_BASE - 1; // binary: 100000 var VLQ_CONTINUATION_BIT = VLQ_BASE; /** * Converts from a two-complement value to a value where the sign bit is * placed in the least significant bit. For example, as decimals: * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary) * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary) */ function toVLQSigned(aValue) { return aValue < 0 ? ((-aValue) << 1) + 1 : (aValue << 1) + 0; } /** * Converts to a two-complement value from a value where the sign bit is * placed in the least significant bit. For example, as decimals: * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1 * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2 */ function fromVLQSigned(aValue) { var isNegative = (aValue & 1) === 1; var shifted = aValue >> 1; return isNegative ? -shifted : shifted; } /** * Returns the base 64 VLQ encoded value. */ exports.encode = function base64VLQ_encode(aValue) { var encoded = ""; var digit; var vlq = toVLQSigned(aValue); do { digit = vlq & VLQ_BASE_MASK; vlq >>>= VLQ_BASE_SHIFT; if (vlq > 0) { // There are still more digits in this value, so we must make sure the // continuation bit is marked. digit |= VLQ_CONTINUATION_BIT; } encoded += base64.encode(digit); } while (vlq > 0); return encoded; }; /** * Decodes the next base 64 VLQ value from the given string and returns the * value and the rest of the string via the out parameter. */ exports.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) { var strLen = aStr.length; var result = 0; var shift = 0; var continuation, digit; do { if (aIndex >= strLen) { throw new Error("Expected more digits in base 64 VLQ value."); } digit = base64.decode(aStr.charCodeAt(aIndex++)); if (digit === -1) { throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1)); } continuation = !!(digit & VLQ_CONTINUATION_BIT); digit &= VLQ_BASE_MASK; result = result + (digit << shift); shift += VLQ_BASE_SHIFT; } while (continuation); aOutParam.value = fromVLQSigned(result); aOutParam.rest = aIndex; }; /***/ }), /***/ "./node_modules/recast/node_modules/source-map/lib/base64.js": /*!*******************************************************************!*\ !*** ./node_modules/recast/node_modules/source-map/lib/base64.js ***! \*******************************************************************/ /***/ ((__unused_webpack_module, exports) => { /* -*- Mode: js; js-indent-level: 2; -*- */ /* * Copyright 2011 Mozilla Foundation and contributors * Licensed under the New BSD license. See LICENSE or: * http://opensource.org/licenses/BSD-3-Clause */ var intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split(''); /** * Encode an integer in the range of 0 to 63 to a single base 64 digit. */ exports.encode = function (number) { if (0 <= number && number < intToCharMap.length) { return intToCharMap[number]; } throw new TypeError("Must be between 0 and 63: " + number); }; /** * Decode a single base 64 character code digit to an integer. Returns -1 on * failure. */ exports.decode = function (charCode) { var bigA = 65; // 'A' var bigZ = 90; // 'Z' var littleA = 97; // 'a' var littleZ = 122; // 'z' var zero = 48; // '0' var nine = 57; // '9' var plus = 43; // '+' var slash = 47; // '/' var littleOffset = 26; var numberOffset = 52; // 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ if (bigA <= charCode && charCode <= bigZ) { return (charCode - bigA); } // 26 - 51: abcdefghijklmnopqrstuvwxyz if (littleA <= charCode && charCode <= littleZ) { return (charCode - littleA + littleOffset); } // 52 - 61: 0123456789 if (zero <= charCode && charCode <= nine) { return (charCode - zero + numberOffset); } // 62: + if (charCode == plus) { return 62; } // 63: / if (charCode == slash) { return 63; } // Invalid base64 digit. return -1; }; /***/ }), /***/ "./node_modules/recast/node_modules/source-map/lib/binary-search.js": /*!**************************************************************************!*\ !*** ./node_modules/recast/node_modules/source-map/lib/binary-search.js ***! \**************************************************************************/ /***/ ((__unused_webpack_module, exports) => { /* -*- Mode: js; js-indent-level: 2; -*- */ /* * Copyright 2011 Mozilla Foundation and contributors * Licensed under the New BSD license. See LICENSE or: * http://opensource.org/licenses/BSD-3-Clause */ exports.GREATEST_LOWER_BOUND = 1; exports.LEAST_UPPER_BOUND = 2; /** * Recursive implementation of binary search. * * @param aLow Indices here and lower do not contain the needle. * @param aHigh Indices here and higher do not contain the needle. * @param aNeedle The element being searched for. * @param aHaystack The non-empty array being searched. * @param aCompare Function which takes two elements and returns -1, 0, or 1. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the * closest element that is smaller than or greater than the one we are * searching for, respectively, if the exact element cannot be found. */ function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) { // This function terminates when one of the following is true: // // 1. We find the exact element we are looking for. // // 2. We did not find the exact element, but we can return the index of // the next-closest element. // // 3. We did not find the exact element, and there is no next-closest // element than the one we are searching for, so we return -1. var mid = Math.floor((aHigh - aLow) / 2) + aLow; var cmp = aCompare(aNeedle, aHaystack[mid], true); if (cmp === 0) { // Found the element we are looking for. return mid; } else if (cmp > 0) { // Our needle is greater than aHaystack[mid]. if (aHigh - mid > 1) { // The element is in the upper half. return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias); } // The exact needle element was not found in this haystack. Determine if // we are in termination case (3) or (2) and return the appropriate thing. if (aBias == exports.LEAST_UPPER_BOUND) { return aHigh < aHaystack.length ? aHigh : -1; } else { return mid; } } else { // Our needle is less than aHaystack[mid]. if (mid - aLow > 1) { // The element is in the lower half. return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias); } // we are in termination case (3) or (2) and return the appropriate thing. if (aBias == exports.LEAST_UPPER_BOUND) { return mid; } else { return aLow < 0 ? -1 : aLow; } } } /** * This is an implementation of binary search which will always try and return * the index of the closest element if there is no exact hit. This is because * mappings between original and generated line/col pairs are single points, * and there is an implicit region between each of them, so a miss just means * that you aren't on the very start of a region. * * @param aNeedle The element you are looking for. * @param aHaystack The array that is being searched. * @param aCompare A function which takes the needle and an element in the * array and returns -1, 0, or 1 depending on whether the needle is less * than, equal to, or greater than the element, respectively. * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the * closest element that is smaller than or greater than the one we are * searching for, respectively, if the exact element cannot be found. * Defaults to 'binarySearch.GREATEST_LOWER_BOUND'. */ exports.search = function search(aNeedle, aHaystack, aCompare, aBias) { if (aHaystack.length === 0) { return -1; } var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack, aCompare, aBias || exports.GREATEST_LOWER_BOUND); if (index < 0) { return -1; } // We have found either the exact element, or the next-closest element than // the one we are searching for. However, there may be more than one such // element. Make sure we always return the smallest of these. while (index - 1 >= 0) { if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) { break; } --index; } return index; }; /***/ }), /***/ "./node_modules/recast/node_modules/source-map/lib/mapping-list.js": /*!*************************************************************************!*\ !*** ./node_modules/recast/node_modules/source-map/lib/mapping-list.js ***! \*************************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { /* -*- Mode: js; js-indent-level: 2; -*- */ /* * Copyright 2014 Mozilla Foundation and contributors * Licensed under the New BSD license. See LICENSE or: * http://opensource.org/licenses/BSD-3-Clause */ var util = __webpack_require__(/*! ./util */ "./node_modules/recast/node_modules/source-map/lib/util.js"); /** * Determine whether mappingB is after mappingA with respect to generated * position. */ function generatedPositionAfter(mappingA, mappingB) { // Optimized for most common case var lineA = mappingA.generatedLine; var lineB = mappingB.generatedLine; var columnA = mappingA.generatedColumn; var columnB = mappingB.generatedColumn; return lineB > lineA || lineB == lineA && columnB >= columnA || util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0; } /** * A data structure to provide a sorted view of accumulated mappings in a * performance conscious manner. It trades a neglibable overhead in general * case for a large speedup in case of mappings being added in order. */ function MappingList() { this._array = []; this._sorted = true; // Serves as infimum this._last = {generatedLine: -1, generatedColumn: 0}; } /** * Iterate through internal items. This method takes the same arguments that * `Array.prototype.forEach` takes. * * NOTE: The order of the mappings is NOT guaranteed. */ MappingList.prototype.unsortedForEach = function MappingList_forEach(aCallback, aThisArg) { this._array.forEach(aCallback, aThisArg); }; /** * Add the given source mapping. * * @param Object aMapping */ MappingList.prototype.add = function MappingList_add(aMapping) { if (generatedPositionAfter(this._last, aMapping)) { this._last = aMapping; this._array.push(aMapping); } else { this._sorted = false; this._array.push(aMapping); } }; /** * Returns the flat, sorted array of mappings. The mappings are sorted by * generated position. * * WARNING: This method returns internal data without copying, for * performance. The return value must NOT be mutated, and should be treated as * an immutable borrow. If you want to take ownership, you must make your own * copy. */ MappingList.prototype.toArray = function MappingList_toArray() { if (!this._sorted) { this._array.sort(util.compareByGeneratedPositionsInflated); this._sorted = true; } return this._array; }; exports.MappingList = MappingList; /***/ }), /***/ "./node_modules/recast/node_modules/source-map/lib/quick-sort.js": /*!***********************************************************************!*\ !*** ./node_modules/recast/node_modules/source-map/lib/quick-sort.js ***! \***********************************************************************/ /***/ ((__unused_webpack_module, exports) => { /* -*- Mode: js; js-indent-level: 2; -*- */ /* * Copyright 2011 Mozilla Foundation and contributors * Licensed under the New BSD license. See LICENSE or: * http://opensource.org/licenses/BSD-3-Clause */ // It turns out that some (most?) JavaScript engines don't self-host // `Array.prototype.sort`. This makes sense because C++ will likely remain // faster than JS when doing raw CPU-intensive sorting. However, when using a // custom comparator function, calling back and forth between the VM's C++ and // JIT'd JS is rather slow *and* loses JIT type information, resulting in // worse generated code for the comparator function than would be optimal. In // fact, when sorting with a comparator, these costs outweigh the benefits of // sorting in C++. By using our own JS-implemented Quick Sort (below), we get // a ~3500ms mean speed-up in `bench/bench.html`. /** * Swap the elements indexed by `x` and `y` in the array `ary`. * * @param {Array} ary * The array. * @param {Number} x * The index of the first item. * @param {Number} y * The index of the second item. */ function swap(ary, x, y) { var temp = ary[x]; ary[x] = ary[y]; ary[y] = temp; } /** * Returns a random integer within the range `low .. high` inclusive. * * @param {Number} low * The lower bound on the range. * @param {Number} high * The upper bound on the range. */ function randomIntInRange(low, high) { return Math.round(low + (Math.random() * (high - low))); } /** * The Quick Sort algorithm. * * @param {Array} ary * An array to sort. * @param {function} comparator * Function to use to compare two items. * @param {Number} p * Start index of the array * @param {Number} r * End index of the array */ function doQuickSort(ary, comparator, p, r) { // If our lower bound is less than our upper bound, we (1) partition the // array into two pieces and (2) recurse on each half. If it is not, this is // the empty array and our base case. if (p < r) { // (1) Partitioning. // // The partitioning chooses a pivot between `p` and `r` and moves all // elements that are less than or equal to the pivot to the before it, and // all the elements that are greater than it after it. The effect is that // once partition is done, the pivot is in the exact place it will be when // the array is put in sorted order, and it will not need to be moved // again. This runs in O(n) time. // Always choose a random pivot so that an input array which is reverse // sorted does not cause O(n^2) running time. var pivotIndex = randomIntInRange(p, r); var i = p - 1; swap(ary, pivotIndex, r); var pivot = ary[r]; // Immediately after `j` is incremented in this loop, the following hold // true: // // * Every element in `ary[p .. i]` is less than or equal to the pivot. // // * Every element in `ary[i+1 .. j-1]` is greater than the pivot. for (var j = p; j < r; j++) { if (comparator(ary[j], pivot) <= 0) { i += 1; swap(ary, i, j); } } swap(ary, i + 1, j); var q = i + 1; // (2) Recurse on each half. doQuickSort(ary, comparator, p, q - 1); doQuickSort(ary, comparator, q + 1, r); } } /** * Sort the given array in-place with the given comparator function. * * @param {Array} ary * An array to sort. * @param {function} comparator * Function to use to compare two items. */ exports.quickSort = function (ary, comparator) { doQuickSort(ary, comparator, 0, ary.length - 1); }; /***/ }), /***/ "./node_modules/recast/node_modules/source-map/lib/source-map-consumer.js": /*!********************************************************************************!*\ !*** ./node_modules/recast/node_modules/source-map/lib/source-map-consumer.js ***! \********************************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { /* -*- Mode: js; js-indent-level: 2; -*- */ /* * Copyright 2011 Mozilla Foundation and contributors * Licensed under the New BSD license. See LICENSE or: * http://opensource.org/licenses/BSD-3-Clause */ var util = __webpack_require__(/*! ./util */ "./node_modules/recast/node_modules/source-map/lib/util.js"); var binarySearch = __webpack_require__(/*! ./binary-search */ "./node_modules/recast/node_modules/source-map/lib/binary-search.js"); var ArraySet = (__webpack_require__(/*! ./array-set */ "./node_modules/recast/node_modules/source-map/lib/array-set.js").ArraySet); var base64VLQ = __webpack_require__(/*! ./base64-vlq */ "./node_modules/recast/node_modules/source-map/lib/base64-vlq.js"); var quickSort = (__webpack_require__(/*! ./quick-sort */ "./node_modules/recast/node_modules/source-map/lib/quick-sort.js").quickSort); function SourceMapConsumer(aSourceMap, aSourceMapURL) { var sourceMap = aSourceMap; if (typeof aSourceMap === 'string') { sourceMap = util.parseSourceMapInput(aSourceMap); } return sourceMap.sections != null ? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL) : new BasicSourceMapConsumer(sourceMap, aSourceMapURL); } SourceMapConsumer.fromSourceMap = function(aSourceMap, aSourceMapURL) { return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL); } /** * The version of the source mapping spec that we are consuming. */ SourceMapConsumer.prototype._version = 3; // `__generatedMappings` and `__originalMappings` are arrays that hold the // parsed mapping coordinates from the source map's "mappings" attribute. They // are lazily instantiated, accessed via the `_generatedMappings` and // `_originalMappings` getters respectively, and we only parse the mappings // and create these arrays once queried for a source location. We jump through // these hoops because there can be many thousands of mappings, and parsing // them is expensive, so we only want to do it if we must. // // Each object in the arrays is of the form: // // { // generatedLine: The line number in the generated code, // generatedColumn: The column number in the generated code, // source: The path to the original source file that generated this // chunk of code, // originalLine: The line number in the original source that // corresponds to this chunk of generated code, // originalColumn: The column number in the original source that // corresponds to this chunk of generated code, // name: The name of the original symbol which generated this chunk of // code. // } // // All properties except for `generatedLine` and `generatedColumn` can be // `null`. // // `_generatedMappings` is ordered by the generated positions. // // `_originalMappings` is ordered by the original positions. SourceMapConsumer.prototype.__generatedMappings = null; Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', { configurable: true, enumerable: true, get: function () { if (!this.__generatedMappings) { this._parseMappings(this._mappings, this.sourceRoot); } return this.__generatedMappings; } }); SourceMapConsumer.prototype.__originalMappings = null; Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', { configurable: true, enumerable: true, get: function () { if (!this.__originalMappings) { this._parseMappings(this._mappings, this.sourceRoot); } return this.__originalMappings; } }); SourceMapConsumer.prototype._charIsMappingSeparator = function SourceMapConsumer_charIsMappingSeparator(aStr, index) { var c = aStr.charAt(index); return c === ";" || c === ","; }; /** * Parse the mappings in a string in to a data structure which we can easily * query (the ordered arrays in the `this.__generatedMappings` and * `this.__originalMappings` properties). */ SourceMapConsumer.prototype._parseMappings = function SourceMapConsumer_parseMappings(aStr, aSourceRoot) { throw new Error("Subclasses must implement _parseMappings"); }; SourceMapConsumer.GENERATED_ORDER = 1; SourceMapConsumer.ORIGINAL_ORDER = 2; SourceMapConsumer.GREATEST_LOWER_BOUND = 1; SourceMapConsumer.LEAST_UPPER_BOUND = 2; /** * Iterate over each mapping between an original source/line/column and a * generated line/column in this source map. * * @param Function aCallback * The function that is called with each mapping. * @param Object aContext * Optional. If specified, this object will be the value of `this` every * time that `aCallback` is called. * @param aOrder * Either `SourceMapConsumer.GENERATED_ORDER` or * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to * iterate over the mappings sorted by the generated file's line/column * order or the original's source/line/column order, respectively. Defaults to * `SourceMapConsumer.GENERATED_ORDER`. */ SourceMapConsumer.prototype.eachMapping = function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) { var context = aContext || null; var order = aOrder || SourceMapConsumer.GENERATED_ORDER; var mappings; switch (order) { case SourceMapConsumer.GENERATED_ORDER: mappings = this._generatedMappings; break; case SourceMapConsumer.ORIGINAL_ORDER: mappings = this._originalMappings; break; default: throw new Error("Unknown order of iteration."); } var sourceRoot = this.sourceRoot; mappings.map(function (mapping) { var source = mapping.source === null ? null : this._sources.at(mapping.source); source = util.computeSourceURL(sourceRoot, source, this._sourceMapURL); return { source: source, generatedLine: mapping.generatedLine, generatedColumn: mapping.generatedColumn, originalLine: mapping.originalLine, originalColumn: mapping.originalColumn, name: mapping.name === null ? null : this._names.at(mapping.name) }; }, this).forEach(aCallback, context); }; /** * Returns all generated line and column information for the original source, * line, and column provided. If no column is provided, returns all mappings * corresponding to a either the line we are searching for or the next * closest line that has any mappings. Otherwise, returns all mappings * corresponding to the given line and either the column we are searching for * or the next closest column that has any offsets. * * The only argument is an object with the following properties: * * - source: The filename of the original source. * - line: The line number in the original source. The line number is 1-based. * - column: Optional. the column number in the original source. * The column number is 0-based. * * and an array of objects is returned, each with the following properties: * * - line: The line number in the generated source, or null. The * line number is 1-based. * - column: The column number in the generated source, or null. * The column number is 0-based. */ SourceMapConsumer.prototype.allGeneratedPositionsFor = function SourceMapConsumer_allGeneratedPositionsFor(aArgs) { var line = util.getArg(aArgs, 'line'); // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping // returns the index of the closest mapping less than the needle. By // setting needle.originalColumn to 0, we thus find the last mapping for // the given line, provided such a mapping exists. var needle = { source: util.getArg(aArgs, 'source'), originalLine: line, originalColumn: util.getArg(aArgs, 'column', 0) }; needle.source = this._findSourceIndex(needle.source); if (needle.source < 0) { return []; } var mappings = []; var index = this._findMapping(needle, this._originalMappings, "originalLine", "originalColumn", util.compareByOriginalPositions, binarySearch.LEAST_UPPER_BOUND); if (index >= 0) { var mapping = this._originalMappings[index]; if (aArgs.column === undefined) { var originalLine = mapping.originalLine; // Iterate until either we run out of mappings, or we run into // a mapping for a different line than the one we found. Since // mappings are sorted, this is guaranteed to find all mappings for // the line we found. while (mapping && mapping.originalLine === originalLine) { mappings.push({ line: util.getArg(mapping, 'generatedLine', null), column: util.getArg(mapping, 'generatedColumn', null), lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null) }); mapping = this._originalMappings[++index]; } } else { var originalColumn = mapping.originalColumn; // Iterate until either we run out of mappings, or we run into // a mapping for a different line than the one we were searching for. // Since mappings are sorted, this is guaranteed to find all mappings for // the line we are searching for. while (mapping && mapping.originalLine === line && mapping.originalColumn == originalColumn) { mappings.push({ line: util.getArg(mapping, 'generatedLine', null), column: util.getArg(mapping, 'generatedColumn', null), lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null) }); mapping = this._originalMappings[++index]; } } } return mappings; }; exports.SourceMapConsumer = SourceMapConsumer; /** * A BasicSourceMapConsumer instance represents a parsed source map which we can * query for information about the original file positions by giving it a file * position in the generated source. * * The first parameter is the raw source map (either as a JSON string, or * already parsed to an object). According to the spec, source maps have the * following attributes: * * - version: Which version of the source map spec this map is following. * - sources: An array of URLs to the original source files. * - names: An array of identifiers which can be referrenced by individual mappings. * - sourceRoot: Optional. The URL root from which all sources are relative. * - sourcesContent: Optional. An array of contents of the original source files. * - mappings: A string of base64 VLQs which contain the actual mappings. * - file: Optional. The generated file this source map is associated with. * * Here is an example source map, taken from the source map spec[0]: * * { * version : 3, * file: "out.js", * sourceRoot : "", * sources: ["foo.js", "bar.js"], * names: ["src", "maps", "are", "fun"], * mappings: "AA,AB;;ABCDE;" * } * * The second parameter, if given, is a string whose value is the URL * at which the source map was found. This URL is used to compute the * sources array. * * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1# */ function BasicSourceMapConsumer(aSourceMap, aSourceMapURL) { var sourceMap = aSourceMap; if (typeof aSourceMap === 'string') { sourceMap = util.parseSourceMapInput(aSourceMap); } var version = util.getArg(sourceMap, 'version'); var sources = util.getArg(sourceMap, 'sources'); // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which // requires the array) to play nice here. var names = util.getArg(sourceMap, 'names', []); var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null); var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null); var mappings = util.getArg(sourceMap, 'mappings'); var file = util.getArg(sourceMap, 'file', null); // Once again, Sass deviates from the spec and supplies the version as a // string rather than a number, so we use loose equality checking here. if (version != this._version) { throw new Error('Unsupported version: ' + version); } if (sourceRoot) { sourceRoot = util.normalize(sourceRoot); } sources = sources .map(String) // Some source maps produce relative source paths like "./foo.js" instead of // "foo.js". Normalize these first so that future comparisons will succeed. // See bugzil.la/1090768. .map(util.normalize) // Always ensure that absolute sources are internally stored relative to // the source root, if the source root is absolute. Not doing this would // be particularly problematic when the source root is a prefix of the // source (valid, but why??). See github issue #199 and bugzil.la/1188982. .map(function (source) { return sourceRoot && util.isAbsolute(sourceRoot) && util.isAbsolute(source) ? util.relative(sourceRoot, source) : source; }); // Pass `true` below to allow duplicate names and sources. While source maps // are intended to be compressed and deduplicated, the TypeScript compiler // sometimes generates source maps with duplicates in them. See Github issue // #72 and bugzil.la/889492. this._names = ArraySet.fromArray(names.map(String), true); this._sources = ArraySet.fromArray(sources, true); this._absoluteSources = this._sources.toArray().map(function (s) { return util.computeSourceURL(sourceRoot, s, aSourceMapURL); }); this.sourceRoot = sourceRoot; this.sourcesContent = sourcesContent; this._mappings = mappings; this._sourceMapURL = aSourceMapURL; this.file = file; } BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype); BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer; /** * Utility function to find the index of a source. Returns -1 if not * found. */ BasicSourceMapConsumer.prototype._findSourceIndex = function(aSource) { var relativeSource = aSource; if (this.sourceRoot != null) { relativeSource = util.relative(this.sourceRoot, relativeSource); } if (this._sources.has(relativeSource)) { return this._sources.indexOf(relativeSource); } // Maybe aSource is an absolute URL as returned by |sources|. In // this case we can't simply undo the transform. var i; for (i = 0; i < this._absoluteSources.length; ++i) { if (this._absoluteSources[i] == aSource) { return i; } } return -1; }; /** * Create a BasicSourceMapConsumer from a SourceMapGenerator. * * @param SourceMapGenerator aSourceMap * The source map that will be consumed. * @param String aSourceMapURL * The URL at which the source map can be found (optional) * @returns BasicSourceMapConsumer */ BasicSourceMapConsumer.fromSourceMap = function SourceMapConsumer_fromSourceMap(aSourceMap, aSourceMapURL) { var smc = Object.create(BasicSourceMapConsumer.prototype); var names = smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true); var sources = smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true); smc.sourceRoot = aSourceMap._sourceRoot; smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(), smc.sourceRoot); smc.file = aSourceMap._file; smc._sourceMapURL = aSourceMapURL; smc._absoluteSources = smc._sources.toArray().map(function (s) { return util.computeSourceURL(smc.sourceRoot, s, aSourceMapURL); }); // Because we are modifying the entries (by converting string sources and // names to indices into the sources and names ArraySets), we have to make // a copy of the entry or else bad things happen. Shared mutable state // strikes again! See github issue #191. var generatedMappings = aSourceMap._mappings.toArray().slice(); var destGeneratedMappings = smc.__generatedMappings = []; var destOriginalMappings = smc.__originalMappings = []; for (var i = 0, length = generatedMappings.length; i < length; i++) { var srcMapping = generatedMappings[i]; var destMapping = new Mapping; destMapping.generatedLine = srcMapping.generatedLine; destMapping.generatedColumn = srcMapping.generatedColumn; if (srcMapping.source) { destMapping.source = sources.indexOf(srcMapping.source); destMapping.originalLine = srcMapping.originalLine; destMapping.originalColumn = srcMapping.originalColumn; if (srcMapping.name) { destMapping.name = names.indexOf(srcMapping.name); } destOriginalMappings.push(destMapping); } destGeneratedMappings.push(destMapping); } quickSort(smc.__originalMappings, util.compareByOriginalPositions); return smc; }; /** * The version of the source mapping spec that we are consuming. */ BasicSourceMapConsumer.prototype._version = 3; /** * The list of original sources. */ Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', { get: function () { return this._absoluteSources.slice(); } }); /** * Provide the JIT with a nice shape / hidden class. */ function Mapping() { this.generatedLine = 0; this.generatedColumn = 0; this.source = null; this.originalLine = null; this.originalColumn = null; this.name = null; } /** * Parse the mappings in a string in to a data structure which we can easily * query (the ordered arrays in the `this.__generatedMappings` and * `this.__originalMappings` properties). */ BasicSourceMapConsumer.prototype._parseMappings = function SourceMapConsumer_parseMappings(aStr, aSourceRoot) { var generatedLine = 1; var previousGeneratedColumn = 0; var previousOriginalLine = 0; var previousOriginalColumn = 0; var previousSource = 0; var previousName = 0; var length = aStr.length; var index = 0; var cachedSegments = {}; var temp = {}; var originalMappings = []; var generatedMappings = []; var mapping, str, segment, end, value; while (index < length) { if (aStr.charAt(index) === ';') { generatedLine++; index++; previousGeneratedColumn = 0; } else if (aStr.charAt(index) === ',') { index++; } else { mapping = new Mapping(); mapping.generatedLine = generatedLine; // Because each offset is encoded relative to the previous one, // many segments often have the same encoding. We can exploit this // fact by caching the parsed variable length fields of each segment, // allowing us to avoid a second parse if we encounter the same // segment again. for (end = index; end < length; end++) { if (this._charIsMappingSeparator(aStr, end)) { break; } } str = aStr.slice(index, end); segment = cachedSegments[str]; if (segment) { index += str.length; } else { segment = []; while (index < end) { base64VLQ.decode(aStr, index, temp); value = temp.value; index = temp.rest; segment.push(value); } if (segment.length === 2) { throw new Error('Found a source, but no line and column'); } if (segment.length === 3) { throw new Error('Found a source and line, but no column'); } cachedSegments[str] = segment; } // Generated column. mapping.generatedColumn = previousGeneratedColumn + segment[0]; previousGeneratedColumn = mapping.generatedColumn; if (segment.length > 1) { // Original source. mapping.source = previousSource + segment[1]; previousSource += segment[1]; // Original line. mapping.originalLine = previousOriginalLine + segment[2]; previousOriginalLine = mapping.originalLine; // Lines are stored 0-based mapping.originalLine += 1; // Original column. mapping.originalColumn = previousOriginalColumn + segment[3]; previousOriginalColumn = mapping.originalColumn; if (segment.length > 4) { // Original name. mapping.name = previousName + segment[4]; previousName += segment[4]; } } generatedMappings.push(mapping); if (typeof mapping.originalLine === 'number') { originalMappings.push(mapping); } } } quickSort(generatedMappings, util.compareByGeneratedPositionsDeflated); this.__generatedMappings = generatedMappings; quickSort(originalMappings, util.compareByOriginalPositions); this.__originalMappings = originalMappings; }; /** * Find the mapping that best matches the hypothetical "needle" mapping that * we are searching for in the given "haystack" of mappings. */ BasicSourceMapConsumer.prototype._findMapping = function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName, aColumnName, aComparator, aBias) { // To return the position we are searching for, we must first find the // mapping for the given position and then return the opposite position it // points to. Because the mappings are sorted, we can use binary search to // find the best mapping. if (aNeedle[aLineName] <= 0) { throw new TypeError('Line must be greater than or equal to 1, got ' + aNeedle[aLineName]); } if (aNeedle[aColumnName] < 0) { throw new TypeError('Column must be greater than or equal to 0, got ' + aNeedle[aColumnName]); } return binarySearch.search(aNeedle, aMappings, aComparator, aBias); }; /** * Compute the last column for each generated mapping. The last column is * inclusive. */ BasicSourceMapConsumer.prototype.computeColumnSpans = function SourceMapConsumer_computeColumnSpans() { for (var index = 0; index < this._generatedMappings.length; ++index) { var mapping = this._generatedMappings[index]; // Mappings do not contain a field for the last generated columnt. We // can come up with an optimistic estimate, however, by assuming that // mappings are contiguous (i.e. given two consecutive mappings, the // first mapping ends where the second one starts). if (index + 1 < this._generatedMappings.length) { var nextMapping = this._generatedMappings[index + 1]; if (mapping.generatedLine === nextMapping.generatedLine) { mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1; continue; } } // The last mapping for each line spans the entire line. mapping.lastGeneratedColumn = Infinity; } }; /** * Returns the original source, line, and column information for the generated * source's line and column positions provided. The only argument is an object * with the following properties: * * - line: The line number in the generated source. The line number * is 1-based. * - column: The column number in the generated source. The column * number is 0-based. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the * closest element that is smaller than or greater than the one we are * searching for, respectively, if the exact element cannot be found. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'. * * and an object is returned with the following properties: * * - source: The original source file, or null. * - line: The line number in the original source, or null. The * line number is 1-based. * - column: The column number in the original source, or null. The * column number is 0-based. * - name: The original identifier, or null. */ BasicSourceMapConsumer.prototype.originalPositionFor = function SourceMapConsumer_originalPositionFor(aArgs) { var needle = { generatedLine: util.getArg(aArgs, 'line'), generatedColumn: util.getArg(aArgs, 'column') }; var index = this._findMapping( needle, this._generatedMappings, "generatedLine", "generatedColumn", util.compareByGeneratedPositionsDeflated, util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND) ); if (index >= 0) { var mapping = this._generatedMappings[index]; if (mapping.generatedLine === needle.generatedLine) { var source = util.getArg(mapping, 'source', null); if (source !== null) { source = this._sources.at(source); source = util.computeSourceURL(this.sourceRoot, source, this._sourceMapURL); } var name = util.getArg(mapping, 'name', null); if (name !== null) { name = this._names.at(name); } return { source: source, line: util.getArg(mapping, 'originalLine', null), column: util.getArg(mapping, 'originalColumn', null), name: name }; } } return { source: null, line: null, column: null, name: null }; }; /** * Return true if we have the source content for every source in the source * map, false otherwise. */ BasicSourceMapConsumer.prototype.hasContentsOfAllSources = function BasicSourceMapConsumer_hasContentsOfAllSources() { if (!this.sourcesContent) { return false; } return this.sourcesContent.length >= this._sources.size() && !this.sourcesContent.some(function (sc) { return sc == null; }); }; /** * Returns the original source content. The only argument is the url of the * original source file. Returns null if no original source content is * available. */ BasicSourceMapConsumer.prototype.sourceContentFor = function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) { if (!this.sourcesContent) { return null; } var index = this._findSourceIndex(aSource); if (index >= 0) { return this.sourcesContent[index]; } var relativeSource = aSource; if (this.sourceRoot != null) { relativeSource = util.relative(this.sourceRoot, relativeSource); } var url; if (this.sourceRoot != null && (url = util.urlParse(this.sourceRoot))) { // XXX: file:// URIs and absolute paths lead to unexpected behavior for // many users. We can help them out when they expect file:// URIs to // behave like it would if they were running a local HTTP server. See // https://bugzilla.mozilla.org/show_bug.cgi?id=885597. var fileUriAbsPath = relativeSource.replace(/^file:\/\//, ""); if (url.scheme == "file" && this._sources.has(fileUriAbsPath)) { return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)] } if ((!url.path || url.path == "/") && this._sources.has("/" + relativeSource)) { return this.sourcesContent[this._sources.indexOf("/" + relativeSource)]; } } // This function is used recursively from // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we // don't want to throw if we can't find the source - we just want to // return null, so we provide a flag to exit gracefully. if (nullOnMissing) { return null; } else { throw new Error('"' + relativeSource + '" is not in the SourceMap.'); } }; /** * Returns the generated line and column information for the original source, * line, and column positions provided. The only argument is an object with * the following properties: * * - source: The filename of the original source. * - line: The line number in the original source. The line number * is 1-based. * - column: The column number in the original source. The column * number is 0-based. * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the * closest element that is smaller than or greater than the one we are * searching for, respectively, if the exact element cannot be found. * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'. * * and an object is returned with the following properties: * * - line: The line number in the generated source, or null. The * line number is 1-based. * - column: The column number in the generated source, or null. * The column number is 0-based. */ BasicSourceMapConsumer.prototype.generatedPositionFor = function SourceMapConsumer_generatedPositionFor(aArgs) { var source = util.getArg(aArgs, 'source'); source = this._findSourceIndex(source); if (source < 0) { return { line: null, column: null, lastColumn: null }; } var needle = { source: source, originalLine: util.getArg(aArgs, 'line'), originalColumn: util.getArg(aArgs, 'column') }; var index = this._findMapping( needle, this._originalMappings, "originalLine", "originalColumn", util.compareByOriginalPositions, util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND) ); if (index >= 0) { var mapping = this._originalMappings[index]; if (mapping.source === needle.source) { return { line: util.getArg(mapping, 'generatedLine', null), column: util.getArg(mapping, 'generatedColumn', null), lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null) }; } } return { line: null, column: null, lastColumn: null }; }; exports.BasicSourceMapConsumer = BasicSourceMapConsumer; /** * An IndexedSourceMapConsumer instance represents a parsed source map which * we can query for information. It differs from BasicSourceMapConsumer in * that it takes "indexed" source maps (i.e. ones with a "sections" field) as * input. * * The first parameter is a raw source map (either as a JSON string, or already * parsed to an object). According to the spec for indexed source maps, they * have the following attributes: * * - version: Which version of the source map spec this map is following. * - file: Optional. The generated file this source map is associated with. * - sections: A list of section definitions. * * Each value under the "sections" field has two fields: * - offset: The offset into the original specified at which this section * begins to apply, defined as an object with a "line" and "column" * field. * - map: A source map definition. This source map could also be indexed, * but doesn't have to be. * * Instead of the "map" field, it's also possible to have a "url" field * specifying a URL to retrieve a source map from, but that's currently * unsupported. * * Here's an example source map, taken from the source map spec[0], but * modified to omit a section which uses the "url" field. * * { * version : 3, * file: "app.js", * sections: [{ * offset: {line:100, column:10}, * map: { * version : 3, * file: "section.js", * sources: ["foo.js", "bar.js"], * names: ["src", "maps", "are", "fun"], * mappings: "AAAA,E;;ABCDE;" * } * }], * } * * The second parameter, if given, is a string whose value is the URL * at which the source map was found. This URL is used to compute the * sources array. * * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt */ function IndexedSourceMapConsumer(aSourceMap, aSourceMapURL) { var sourceMap = aSourceMap; if (typeof aSourceMap === 'string') { sourceMap = util.parseSourceMapInput(aSourceMap); } var version = util.getArg(sourceMap, 'version'); var sections = util.getArg(sourceMap, 'sections'); if (version != this._version) { throw new Error('Unsupported version: ' + version); } this._sources = new ArraySet(); this._names = new ArraySet(); var lastOffset = { line: -1, column: 0 }; this._sections = sections.map(function (s) { if (s.url) { // The url field will require support for asynchronicity. // See https://github.com/mozilla/source-map/issues/16 throw new Error('Support for url field in sections not implemented.'); } var offset = util.getArg(s, 'offset'); var offsetLine = util.getArg(offset, 'line'); var offsetColumn = util.getArg(offset, 'column'); if (offsetLine < lastOffset.line || (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) { throw new Error('Section offsets must be ordered and non-overlapping.'); } lastOffset = offset; return { generatedOffset: { // The offset fields are 0-based, but we use 1-based indices when // encoding/decoding from VLQ. generatedLine: offsetLine + 1, generatedColumn: offsetColumn + 1 }, consumer: new SourceMapConsumer(util.getArg(s, 'map'), aSourceMapURL) } }); } IndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype); IndexedSourceMapConsumer.prototype.constructor = SourceMapConsumer; /** * The version of the source mapping spec that we are consuming. */ IndexedSourceMapConsumer.prototype._version = 3; /** * The list of original sources. */ Object.defineProperty(IndexedSourceMapConsumer.prototype, 'sources', { get: function () { var sources = []; for (var i = 0; i < this._sections.length; i++) { for (var j = 0; j < this._sections[i].consumer.sources.length; j++) { sources.push(this._sections[i].consumer.sources[j]); } } return sources; } }); /** * Returns the original source, line, and column information for the generated * source's line and column positions provided. The only argument is an object * with the following properties: * * - line: The line number in the generated source. The line number * is 1-based. * - column: The column number in the generated source. The column * number is 0-based. * * and an object is returned with the following properties: * * - source: The original source file, or null. * - line: The line number in the original source, or null. The * line number is 1-based. * - column: The column number in the original source, or null. The * column number is 0-based. * - name: The original identifier, or null. */ IndexedSourceMapConsumer.prototype.originalPositionFor = function IndexedSourceMapConsumer_originalPositionFor(aArgs) { var needle = { generatedLine: util.getArg(aArgs, 'line'), generatedColumn: util.getArg(aArgs, 'column') }; // Find the section containing the generated position we're trying to map // to an original position. var sectionIndex = binarySearch.search(needle, this._sections, function(needle, section) { var cmp = needle.generatedLine - section.generatedOffset.generatedLine; if (cmp) { return cmp; } return (needle.generatedColumn - section.generatedOffset.generatedColumn); }); var section = this._sections[sectionIndex]; if (!section) { return { source: null, line: null, column: null, name: null }; } return section.consumer.originalPositionFor({ line: needle.generatedLine - (section.generatedOffset.generatedLine - 1), column: needle.generatedColumn - (section.generatedOffset.generatedLine === needle.generatedLine ? section.generatedOffset.generatedColumn - 1 : 0), bias: aArgs.bias }); }; /** * Return true if we have the source content for every source in the source * map, false otherwise. */ IndexedSourceMapConsumer.prototype.hasContentsOfAllSources = function IndexedSourceMapConsumer_hasContentsOfAllSources() { return this._sections.every(function (s) { return s.consumer.hasContentsOfAllSources(); }); }; /** * Returns the original source content. The only argument is the url of the * original source file. Returns null if no original source content is * available. */ IndexedSourceMapConsumer.prototype.sourceContentFor = function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) { for (var i = 0; i < this._sections.length; i++) { var section = this._sections[i]; var content = section.consumer.sourceContentFor(aSource, true); if (content) { return content; } } if (nullOnMissing) { return null; } else { throw new Error('"' + aSource + '" is not in the SourceMap.'); } }; /** * Returns the generated line and column information for the original source, * line, and column positions provided. The only argument is an object with * the following properties: * * - source: The filename of the original source. * - line: The line number in the original source. The line number * is 1-based. * - column: The column number in the original source. The column * number is 0-based. * * and an object is returned with the following properties: * * - line: The line number in the generated source, or null. The * line number is 1-based. * - column: The column number in the generated source, or null. * The column number is 0-based. */ IndexedSourceMapConsumer.prototype.generatedPositionFor = function IndexedSourceMapConsumer_generatedPositionFor(aArgs) { for (var i = 0; i < this._sections.length; i++) { var section = this._sections[i]; // Only consider this section if the requested source is in the list of // sources of the consumer. if (section.consumer._findSourceIndex(util.getArg(aArgs, 'source')) === -1) { continue; } var generatedPosition = section.consumer.generatedPositionFor(aArgs); if (generatedPosition) { var ret = { line: generatedPosition.line + (section.generatedOffset.generatedLine - 1), column: generatedPosition.column + (section.generatedOffset.generatedLine === generatedPosition.line ? section.generatedOffset.generatedColumn - 1 : 0) }; return ret; } } return { line: null, column: null }; }; /** * Parse the mappings in a string in to a data structure which we can easily * query (the ordered arrays in the `this.__generatedMappings` and * `this.__originalMappings` properties). */ IndexedSourceMapConsumer.prototype._parseMappings = function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) { this.__generatedMappings = []; this.__originalMappings = []; for (var i = 0; i < this._sections.length; i++) { var section = this._sections[i]; var sectionMappings = section.consumer._generatedMappings; for (var j = 0; j < sectionMappings.length; j++) { var mapping = sectionMappings[j]; var source = section.consumer._sources.at(mapping.source); source = util.computeSourceURL(section.consumer.sourceRoot, source, this._sourceMapURL); this._sources.add(source); source = this._sources.indexOf(source); var name = null; if (mapping.name) { name = section.consumer._names.at(mapping.name); this._names.add(name); name = this._names.indexOf(name); } // The mappings coming from the consumer for the section have // generated positions relative to the start of the section, so we // need to offset them to be relative to the start of the concatenated // generated file. var adjustedMapping = { source: source, generatedLine: mapping.generatedLine + (section.generatedOffset.generatedLine - 1), generatedColumn: mapping.generatedColumn + (section.generatedOffset.generatedLine === mapping.generatedLine ? section.generatedOffset.generatedColumn - 1 : 0), originalLine: mapping.originalLine, originalColumn: mapping.originalColumn, name: name }; this.__generatedMappings.push(adjustedMapping); if (typeof adjustedMapping.originalLine === 'number') { this.__originalMappings.push(adjustedMapping); } } } quickSort(this.__generatedMappings, util.compareByGeneratedPositionsDeflated); quickSort(this.__originalMappings, util.compareByOriginalPositions); }; exports.IndexedSourceMapConsumer = IndexedSourceMapConsumer; /***/ }), /***/ "./node_modules/recast/node_modules/source-map/lib/source-map-generator.js": /*!*********************************************************************************!*\ !*** ./node_modules/recast/node_modules/source-map/lib/source-map-generator.js ***! \*********************************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { /* -*- Mode: js; js-indent-level: 2; -*- */ /* * Copyright 2011 Mozilla Foundation and contributors * Licensed under the New BSD license. See LICENSE or: * http://opensource.org/licenses/BSD-3-Clause */ var base64VLQ = __webpack_require__(/*! ./base64-vlq */ "./node_modules/recast/node_modules/source-map/lib/base64-vlq.js"); var util = __webpack_require__(/*! ./util */ "./node_modules/recast/node_modules/source-map/lib/util.js"); var ArraySet = (__webpack_require__(/*! ./array-set */ "./node_modules/recast/node_modules/source-map/lib/array-set.js").ArraySet); var MappingList = (__webpack_require__(/*! ./mapping-list */ "./node_modules/recast/node_modules/source-map/lib/mapping-list.js").MappingList); /** * An instance of the SourceMapGenerator represents a source map which is * being built incrementally. You may pass an object with the following * properties: * * - file: The filename of the generated source. * - sourceRoot: A root for all relative URLs in this source map. */ function SourceMapGenerator(aArgs) { if (!aArgs) { aArgs = {}; } this._file = util.getArg(aArgs, 'file', null); this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null); this._skipValidation = util.getArg(aArgs, 'skipValidation', false); this._sources = new ArraySet(); this._names = new ArraySet(); this._mappings = new MappingList(); this._sourcesContents = null; } SourceMapGenerator.prototype._version = 3; /** * Creates a new SourceMapGenerator based on a SourceMapConsumer * * @param aSourceMapConsumer The SourceMap. */ SourceMapGenerator.fromSourceMap = function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) { var sourceRoot = aSourceMapConsumer.sourceRoot; var generator = new SourceMapGenerator({ file: aSourceMapConsumer.file, sourceRoot: sourceRoot }); aSourceMapConsumer.eachMapping(function (mapping) { var newMapping = { generated: { line: mapping.generatedLine, column: mapping.generatedColumn } }; if (mapping.source != null) { newMapping.source = mapping.source; if (sourceRoot != null) { newMapping.source = util.relative(sourceRoot, newMapping.source); } newMapping.original = { line: mapping.originalLine, column: mapping.originalColumn }; if (mapping.name != null) { newMapping.name = mapping.name; } } generator.addMapping(newMapping); }); aSourceMapConsumer.sources.forEach(function (sourceFile) { var sourceRelative = sourceFile; if (sourceRoot !== null) { sourceRelative = util.relative(sourceRoot, sourceFile); } if (!generator._sources.has(sourceRelative)) { generator._sources.add(sourceRelative); } var content = aSourceMapConsumer.sourceContentFor(sourceFile); if (content != null) { generator.setSourceContent(sourceFile, content); } }); return generator; }; /** * Add a single mapping from original source line and column to the generated * source's line and column for this source map being created. The mapping * object should have the following properties: * * - generated: An object with the generated line and column positions. * - original: An object with the original line and column positions. * - source: The original source file (relative to the sourceRoot). * - name: An optional original token name for this mapping. */ SourceMapGenerator.prototype.addMapping = function SourceMapGenerator_addMapping(aArgs) { var generated = util.getArg(aArgs, 'generated'); var original = util.getArg(aArgs, 'original', null); var source = util.getArg(aArgs, 'source', null); var name = util.getArg(aArgs, 'name', null); if (!this._skipValidation) { this._validateMapping(generated, original, source, name); } if (source != null) { source = String(source); if (!this._sources.has(source)) { this._sources.add(source); } } if (name != null) { name = String(name); if (!this._names.has(name)) { this._names.add(name); } } this._mappings.add({ generatedLine: generated.line, generatedColumn: generated.column, originalLine: original != null && original.line, originalColumn: original != null && original.column, source: source, name: name }); }; /** * Set the source content for a source file. */ SourceMapGenerator.prototype.setSourceContent = function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) { var source = aSourceFile; if (this._sourceRoot != null) { source = util.relative(this._sourceRoot, source); } if (aSourceContent != null) { // Add the source content to the _sourcesContents map. // Create a new _sourcesContents map if the property is null. if (!this._sourcesContents) { this._sourcesContents = Object.create(null); } this._sourcesContents[util.toSetString(source)] = aSourceContent; } else if (this._sourcesContents) { // Remove the source file from the _sourcesContents map. // If the _sourcesContents map is empty, set the property to null. delete this._sourcesContents[util.toSetString(source)]; if (Object.keys(this._sourcesContents).length === 0) { this._sourcesContents = null; } } }; /** * Applies the mappings of a sub-source-map for a specific source file to the * source map being generated. Each mapping to the supplied source file is * rewritten using the supplied source map. Note: The resolution for the * resulting mappings is the minimium of this map and the supplied map. * * @param aSourceMapConsumer The source map to be applied. * @param aSourceFile Optional. The filename of the source file. * If omitted, SourceMapConsumer's file property will be used. * @param aSourceMapPath Optional. The dirname of the path to the source map * to be applied. If relative, it is relative to the SourceMapConsumer. * This parameter is needed when the two source maps aren't in the same * directory, and the source map to be applied contains relative source * paths. If so, those relative source paths need to be rewritten * relative to the SourceMapGenerator. */ SourceMapGenerator.prototype.applySourceMap = function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) { var sourceFile = aSourceFile; // If aSourceFile is omitted, we will use the file property of the SourceMap if (aSourceFile == null) { if (aSourceMapConsumer.file == null) { throw new Error( 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' + 'or the source map\'s "file" property. Both were omitted.' ); } sourceFile = aSourceMapConsumer.file; } var sourceRoot = this._sourceRoot; // Make "sourceFile" relative if an absolute Url is passed. if (sourceRoot != null) { sourceFile = util.relative(sourceRoot, sourceFile); } // Applying the SourceMap can add and remove items from the sources and // the names array. var newSources = new ArraySet(); var newNames = new ArraySet(); // Find mappings for the "sourceFile" this._mappings.unsortedForEach(function (mapping) { if (mapping.source === sourceFile && mapping.originalLine != null) { // Check if it can be mapped by the source map, then update the mapping. var original = aSourceMapConsumer.originalPositionFor({ line: mapping.originalLine, column: mapping.originalColumn }); if (original.source != null) { // Copy mapping mapping.source = original.source; if (aSourceMapPath != null) { mapping.source = util.join(aSourceMapPath, mapping.source) } if (sourceRoot != null) { mapping.source = util.relative(sourceRoot, mapping.source); } mapping.originalLine = original.line; mapping.originalColumn = original.column; if (original.name != null) { mapping.name = original.name; } } } var source = mapping.source; if (source != null && !newSources.has(source)) { newSources.add(source); } var name = mapping.name; if (name != null && !newNames.has(name)) { newNames.add(name); } }, this); this._sources = newSources; this._names = newNames; // Copy sourcesContents of applied map. aSourceMapConsumer.sources.forEach(function (sourceFile) { var content = aSourceMapConsumer.sourceContentFor(sourceFile); if (content != null) { if (aSourceMapPath != null) { sourceFile = util.join(aSourceMapPath, sourceFile); } if (sourceRoot != null) { sourceFile = util.relative(sourceRoot, sourceFile); } this.setSourceContent(sourceFile, content); } }, this); }; /** * A mapping can have one of the three levels of data: * * 1. Just the generated position. * 2. The Generated position, original position, and original source. * 3. Generated and original position, original source, as well as a name * token. * * To maintain consistency, we validate that any new mapping being added falls * in to one of these categories. */ SourceMapGenerator.prototype._validateMapping = function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource, aName) { // When aOriginal is truthy but has empty values for .line and .column, // it is most likely a programmer error. In this case we throw a very // specific error message to try to guide them the right way. // For example: https://github.com/Polymer/polymer-bundler/pull/519 if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') { throw new Error( 'original.line and original.column are not numbers -- you probably meant to omit ' + 'the original mapping entirely and only map the generated position. If so, pass ' + 'null for the original mapping instead of an object with empty or null values.' ); } if (aGenerated && 'line' in aGenerated && 'column' in aGenerated && aGenerated.line > 0 && aGenerated.column >= 0 && !aOriginal && !aSource && !aName) { // Case 1. return; } else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated && aOriginal && 'line' in aOriginal && 'column' in aOriginal && aGenerated.line > 0 && aGenerated.column >= 0 && aOriginal.line > 0 && aOriginal.column >= 0 && aSource) { // Cases 2 and 3. return; } else { throw new Error('Invalid mapping: ' + JSON.stringify({ generated: aGenerated, source: aSource, original: aOriginal, name: aName })); } }; /** * Serialize the accumulated mappings in to the stream of base 64 VLQs * specified by the source map format. */ SourceMapGenerator.prototype._serializeMappings = function SourceMapGenerator_serializeMappings() { var previousGeneratedColumn = 0; var previousGeneratedLine = 1; var previousOriginalColumn = 0; var previousOriginalLine = 0; var previousName = 0; var previousSource = 0; var result = ''; var next; var mapping; var nameIdx; var sourceIdx; var mappings = this._mappings.toArray(); for (var i = 0, len = mappings.length; i < len; i++) { mapping = mappings[i]; next = '' if (mapping.generatedLine !== previousGeneratedLine) { previousGeneratedColumn = 0; while (mapping.generatedLine !== previousGeneratedLine) { next += ';'; previousGeneratedLine++; } } else { if (i > 0) { if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) { continue; } next += ','; } } next += base64VLQ.encode(mapping.generatedColumn - previousGeneratedColumn); previousGeneratedColumn = mapping.generatedColumn; if (mapping.source != null) { sourceIdx = this._sources.indexOf(mapping.source); next += base64VLQ.encode(sourceIdx - previousSource); previousSource = sourceIdx; // lines are stored 0-based in SourceMap spec version 3 next += base64VLQ.encode(mapping.originalLine - 1 - previousOriginalLine); previousOriginalLine = mapping.originalLine - 1; next += base64VLQ.encode(mapping.originalColumn - previousOriginalColumn); previousOriginalColumn = mapping.originalColumn; if (mapping.name != null) { nameIdx = this._names.indexOf(mapping.name); next += base64VLQ.encode(nameIdx - previousName); previousName = nameIdx; } } result += next; } return result; }; SourceMapGenerator.prototype._generateSourcesContent = function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) { return aSources.map(function (source) { if (!this._sourcesContents) { return null; } if (aSourceRoot != null) { source = util.relative(aSourceRoot, source); } var key = util.toSetString(source); return Object.prototype.hasOwnProperty.call(this._sourcesContents, key) ? this._sourcesContents[key] : null; }, this); }; /** * Externalize the source map. */ SourceMapGenerator.prototype.toJSON = function SourceMapGenerator_toJSON() { var map = { version: this._version, sources: this._sources.toArray(), names: this._names.toArray(), mappings: this._serializeMappings() }; if (this._file != null) { map.file = this._file; } if (this._sourceRoot != null) { map.sourceRoot = this._sourceRoot; } if (this._sourcesContents) { map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot); } return map; }; /** * Render the source map being generated to a string. */ SourceMapGenerator.prototype.toString = function SourceMapGenerator_toString() { return JSON.stringify(this.toJSON()); }; exports.SourceMapGenerator = SourceMapGenerator; /***/ }), /***/ "./node_modules/recast/node_modules/source-map/lib/source-node.js": /*!************************************************************************!*\ !*** ./node_modules/recast/node_modules/source-map/lib/source-node.js ***! \************************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { /* -*- Mode: js; js-indent-level: 2; -*- */ /* * Copyright 2011 Mozilla Foundation and contributors * Licensed under the New BSD license. See LICENSE or: * http://opensource.org/licenses/BSD-3-Clause */ var SourceMapGenerator = (__webpack_require__(/*! ./source-map-generator */ "./node_modules/recast/node_modules/source-map/lib/source-map-generator.js").SourceMapGenerator); var util = __webpack_require__(/*! ./util */ "./node_modules/recast/node_modules/source-map/lib/util.js"); // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other // operating systems these days (capturing the result). var REGEX_NEWLINE = /(\r?\n)/; // Newline character code for charCodeAt() comparisons var NEWLINE_CODE = 10; // Private symbol for identifying `SourceNode`s when multiple versions of // the source-map library are loaded. This MUST NOT CHANGE across // versions! var isSourceNode = "$$$isSourceNode$$$"; /** * SourceNodes provide a way to abstract over interpolating/concatenating * snippets of generated JavaScript source code while maintaining the line and * column information associated with the original source code. * * @param aLine The original line number. * @param aColumn The original column number. * @param aSource The original source's filename. * @param aChunks Optional. An array of strings which are snippets of * generated JS, or other SourceNodes. * @param aName The original identifier. */ function SourceNode(aLine, aColumn, aSource, aChunks, aName) { this.children = []; this.sourceContents = {}; this.line = aLine == null ? null : aLine; this.column = aColumn == null ? null : aColumn; this.source = aSource == null ? null : aSource; this.name = aName == null ? null : aName; this[isSourceNode] = true; if (aChunks != null) this.add(aChunks); } /** * Creates a SourceNode from generated code and a SourceMapConsumer. * * @param aGeneratedCode The generated code * @param aSourceMapConsumer The SourceMap for the generated code * @param aRelativePath Optional. The path that relative sources in the * SourceMapConsumer should be relative to. */ SourceNode.fromStringWithSourceMap = function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) { // The SourceNode we want to fill with the generated code // and the SourceMap var node = new SourceNode(); // All even indices of this array are one line of the generated code, // while all odd indices are the newlines between two adjacent lines // (since `REGEX_NEWLINE` captures its match). // Processed fragments are accessed by calling `shiftNextLine`. var remainingLines = aGeneratedCode.split(REGEX_NEWLINE); var remainingLinesIndex = 0; var shiftNextLine = function() { var lineContents = getNextLine(); // The last line of a file might not have a newline. var newLine = getNextLine() || ""; return lineContents + newLine; function getNextLine() { return remainingLinesIndex < remainingLines.length ? remainingLines[remainingLinesIndex++] : undefined; } }; // We need to remember the position of "remainingLines" var lastGeneratedLine = 1, lastGeneratedColumn = 0; // The generate SourceNodes we need a code range. // To extract it current and last mapping is used. // Here we store the last mapping. var lastMapping = null; aSourceMapConsumer.eachMapping(function (mapping) { if (lastMapping !== null) { // We add the code from "lastMapping" to "mapping": // First check if there is a new line in between. if (lastGeneratedLine < mapping.generatedLine) { // Associate first line with "lastMapping" addMappingWithCode(lastMapping, shiftNextLine()); lastGeneratedLine++; lastGeneratedColumn = 0; // The remaining code is added without mapping } else { // There is no new line in between. // Associate the code between "lastGeneratedColumn" and // "mapping.generatedColumn" with "lastMapping" var nextLine = remainingLines[remainingLinesIndex] || ''; var code = nextLine.substr(0, mapping.generatedColumn - lastGeneratedColumn); remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn - lastGeneratedColumn); lastGeneratedColumn = mapping.generatedColumn; addMappingWithCode(lastMapping, code); // No more remaining code, continue lastMapping = mapping; return; } } // We add the generated code until the first mapping // to the SourceNode without any mapping. // Each line is added as separate string. while (lastGeneratedLine < mapping.generatedLine) { node.add(shiftNextLine()); lastGeneratedLine++; } if (lastGeneratedColumn < mapping.generatedColumn) { var nextLine = remainingLines[remainingLinesIndex] || ''; node.add(nextLine.substr(0, mapping.generatedColumn)); remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn); lastGeneratedColumn = mapping.generatedColumn; } lastMapping = mapping; }, this); // We have processed all mappings. if (remainingLinesIndex < remainingLines.length) { if (lastMapping) { // Associate the remaining code in the current line with "lastMapping" addMappingWithCode(lastMapping, shiftNextLine()); } // and add the remaining lines without any mapping node.add(remainingLines.splice(remainingLinesIndex).join("")); } // Copy sourcesContent into SourceNode aSourceMapConsumer.sources.forEach(function (sourceFile) { var content = aSourceMapConsumer.sourceContentFor(sourceFile); if (content != null) { if (aRelativePath != null) { sourceFile = util.join(aRelativePath, sourceFile); } node.setSourceContent(sourceFile, content); } }); return node; function addMappingWithCode(mapping, code) { if (mapping === null || mapping.source === undefined) { node.add(code); } else { var source = aRelativePath ? util.join(aRelativePath, mapping.source) : mapping.source; node.add(new SourceNode(mapping.originalLine, mapping.originalColumn, source, code, mapping.name)); } } }; /** * Add a chunk of generated JS to this source node. * * @param aChunk A string snippet of generated JS code, another instance of * SourceNode, or an array where each member is one of those things. */ SourceNode.prototype.add = function SourceNode_add(aChunk) { if (Array.isArray(aChunk)) { aChunk.forEach(function (chunk) { this.add(chunk); }, this); } else if (aChunk[isSourceNode] || typeof aChunk === "string") { if (aChunk) { this.children.push(aChunk); } } else { throw new TypeError( "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk ); } return this; }; /** * Add a chunk of generated JS to the beginning of this source node. * * @param aChunk A string snippet of generated JS code, another instance of * SourceNode, or an array where each member is one of those things. */ SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) { if (Array.isArray(aChunk)) { for (var i = aChunk.length-1; i >= 0; i--) { this.prepend(aChunk[i]); } } else if (aChunk[isSourceNode] || typeof aChunk === "string") { this.children.unshift(aChunk); } else { throw new TypeError( "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk ); } return this; }; /** * Walk over the tree of JS snippets in this node and its children. The * walking function is called once for each snippet of JS and is passed that * snippet and the its original associated source's line/column location. * * @param aFn The traversal function. */ SourceNode.prototype.walk = function SourceNode_walk(aFn) { var chunk; for (var i = 0, len = this.children.length; i < len; i++) { chunk = this.children[i]; if (chunk[isSourceNode]) { chunk.walk(aFn); } else { if (chunk !== '') { aFn(chunk, { source: this.source, line: this.line, column: this.column, name: this.name }); } } } }; /** * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between * each of `this.children`. * * @param aSep The separator. */ SourceNode.prototype.join = function SourceNode_join(aSep) { var newChildren; var i; var len = this.children.length; if (len > 0) { newChildren = []; for (i = 0; i < len-1; i++) { newChildren.push(this.children[i]); newChildren.push(aSep); } newChildren.push(this.children[i]); this.children = newChildren; } return this; }; /** * Call String.prototype.replace on the very right-most source snippet. Useful * for trimming whitespace from the end of a source node, etc. * * @param aPattern The pattern to replace. * @param aReplacement The thing to replace the pattern with. */ SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) { var lastChild = this.children[this.children.length - 1]; if (lastChild[isSourceNode]) { lastChild.replaceRight(aPattern, aReplacement); } else if (typeof lastChild === 'string') { this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement); } else { this.children.push(''.replace(aPattern, aReplacement)); } return this; }; /** * Set the source content for a source file. This will be added to the SourceMapGenerator * in the sourcesContent field. * * @param aSourceFile The filename of the source file * @param aSourceContent The content of the source file */ SourceNode.prototype.setSourceContent = function SourceNode_setSourceContent(aSourceFile, aSourceContent) { this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent; }; /** * Walk over the tree of SourceNodes. The walking function is called for each * source file content and is passed the filename and source content. * * @param aFn The traversal function. */ SourceNode.prototype.walkSourceContents = function SourceNode_walkSourceContents(aFn) { for (var i = 0, len = this.children.length; i < len; i++) { if (this.children[i][isSourceNode]) { this.children[i].walkSourceContents(aFn); } } var sources = Object.keys(this.sourceContents); for (var i = 0, len = sources.length; i < len; i++) { aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]); } }; /** * Return the string representation of this source node. Walks over the tree * and concatenates all the various snippets together to one string. */ SourceNode.prototype.toString = function SourceNode_toString() { var str = ""; this.walk(function (chunk) { str += chunk; }); return str; }; /** * Returns the string representation of this source node along with a source * map. */ SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) { var generated = { code: "", line: 1, column: 0 }; var map = new SourceMapGenerator(aArgs); var sourceMappingActive = false; var lastOriginalSource = null; var lastOriginalLine = null; var lastOriginalColumn = null; var lastOriginalName = null; this.walk(function (chunk, original) { generated.code += chunk; if (original.source !== null && original.line !== null && original.column !== null) { if(lastOriginalSource !== original.source || lastOriginalLine !== original.line || lastOriginalColumn !== original.column || lastOriginalName !== original.name) { map.addMapping({ source: original.source, original: { line: original.line, column: original.column }, generated: { line: generated.line, column: generated.column }, name: original.name }); } lastOriginalSource = original.source; lastOriginalLine = original.line; lastOriginalColumn = original.column; lastOriginalName = original.name; sourceMappingActive = true; } else if (sourceMappingActive) { map.addMapping({ generated: { line: generated.line, column: generated.column } }); lastOriginalSource = null; sourceMappingActive = false; } for (var idx = 0, length = chunk.length; idx < length; idx++) { if (chunk.charCodeAt(idx) === NEWLINE_CODE) { generated.line++; generated.column = 0; // Mappings end at eol if (idx + 1 === length) { lastOriginalSource = null; sourceMappingActive = false; } else if (sourceMappingActive) { map.addMapping({ source: original.source, original: { line: original.line, column: original.column }, generated: { line: generated.line, column: generated.column }, name: original.name }); } } else { generated.column++; } } }); this.walkSourceContents(function (sourceFile, sourceContent) { map.setSourceContent(sourceFile, sourceContent); }); return { code: generated.code, map: map }; }; exports.SourceNode = SourceNode; /***/ }), /***/ "./node_modules/recast/node_modules/source-map/lib/util.js": /*!*****************************************************************!*\ !*** ./node_modules/recast/node_modules/source-map/lib/util.js ***! \*****************************************************************/ /***/ ((__unused_webpack_module, exports) => { /* -*- Mode: js; js-indent-level: 2; -*- */ /* * Copyright 2011 Mozilla Foundation and contributors * Licensed under the New BSD license. See LICENSE or: * http://opensource.org/licenses/BSD-3-Clause */ /** * This is a helper function for getting values from parameter/options * objects. * * @param args The object we are extracting values from * @param name The name of the property we are getting. * @param defaultValue An optional value to return if the property is missing * from the object. If this is not specified and the property is missing, an * error will be thrown. */ function getArg(aArgs, aName, aDefaultValue) { if (aName in aArgs) { return aArgs[aName]; } else if (arguments.length === 3) { return aDefaultValue; } else { throw new Error('"' + aName + '" is a required argument.'); } } exports.getArg = getArg; var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/; var dataUrlRegexp = /^data:.+\,.+$/; function urlParse(aUrl) { var match = aUrl.match(urlRegexp); if (!match) { return null; } return { scheme: match[1], auth: match[2], host: match[3], port: match[4], path: match[5] }; } exports.urlParse = urlParse; function urlGenerate(aParsedUrl) { var url = ''; if (aParsedUrl.scheme) { url += aParsedUrl.scheme + ':'; } url += '//'; if (aParsedUrl.auth) { url += aParsedUrl.auth + '@'; } if (aParsedUrl.host) { url += aParsedUrl.host; } if (aParsedUrl.port) { url += ":" + aParsedUrl.port } if (aParsedUrl.path) { url += aParsedUrl.path; } return url; } exports.urlGenerate = urlGenerate; /** * Normalizes a path, or the path portion of a URL: * * - Replaces consecutive slashes with one slash. * - Removes unnecessary '.' parts. * - Removes unnecessary '/..' parts. * * Based on code in the Node.js 'path' core module. * * @param aPath The path or url to normalize. */ function normalize(aPath) { var path = aPath; var url = urlParse(aPath); if (url) { if (!url.path) { return aPath; } path = url.path; } var isAbsolute = exports.isAbsolute(path); var parts = path.split(/\/+/); for (var part, up = 0, i = parts.length - 1; i >= 0; i--) { part = parts[i]; if (part === '.') { parts.splice(i, 1); } else if (part === '..') { up++; } else if (up > 0) { if (part === '') { // The first part is blank if the path is absolute. Trying to go // above the root is a no-op. Therefore we can remove all '..' parts // directly after the root. parts.splice(i + 1, up); up = 0; } else { parts.splice(i, 2); up--; } } } path = parts.join('/'); if (path === '') { path = isAbsolute ? '/' : '.'; } if (url) { url.path = path; return urlGenerate(url); } return path; } exports.normalize = normalize; /** * Joins two paths/URLs. * * @param aRoot The root path or URL. * @param aPath The path or URL to be joined with the root. * * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a * scheme-relative URL: Then the scheme of aRoot, if any, is prepended * first. * - Otherwise aPath is a path. If aRoot is a URL, then its path portion * is updated with the result and aRoot is returned. Otherwise the result * is returned. * - If aPath is absolute, the result is aPath. * - Otherwise the two paths are joined with a slash. * - Joining for example 'http://' and 'www.example.com' is also supported. */ function join(aRoot, aPath) { if (aRoot === "") { aRoot = "."; } if (aPath === "") { aPath = "."; } var aPathUrl = urlParse(aPath); var aRootUrl = urlParse(aRoot); if (aRootUrl) { aRoot = aRootUrl.path || '/'; } // `join(foo, '//www.example.org')` if (aPathUrl && !aPathUrl.scheme) { if (aRootUrl) { aPathUrl.scheme = aRootUrl.scheme; } return urlGenerate(aPathUrl); } if (aPathUrl || aPath.match(dataUrlRegexp)) { return aPath; } // `join('http://', 'www.example.com')` if (aRootUrl && !aRootUrl.host && !aRootUrl.path) { aRootUrl.host = aPath; return urlGenerate(aRootUrl); } var joined = aPath.charAt(0) === '/' ? aPath : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath); if (aRootUrl) { aRootUrl.path = joined; return urlGenerate(aRootUrl); } return joined; } exports.join = join; exports.isAbsolute = function (aPath) { return aPath.charAt(0) === '/' || urlRegexp.test(aPath); }; /** * Make a path relative to a URL or another path. * * @param aRoot The root path or URL. * @param aPath The path or URL to be made relative to aRoot. */ function relative(aRoot, aPath) { if (aRoot === "") { aRoot = "."; } aRoot = aRoot.replace(/\/$/, ''); // It is possible for the path to be above the root. In this case, simply // checking whether the root is a prefix of the path won't work. Instead, we // need to remove components from the root one by one, until either we find // a prefix that fits, or we run out of components to remove. var level = 0; while (aPath.indexOf(aRoot + '/') !== 0) { var index = aRoot.lastIndexOf("/"); if (index < 0) { return aPath; } // If the only part of the root that is left is the scheme (i.e. http://, // file:///, etc.), one or more slashes (/), or simply nothing at all, we // have exhausted all components, so the path is not relative to the root. aRoot = aRoot.slice(0, index); if (aRoot.match(/^([^\/]+:\/)?\/*$/)) { return aPath; } ++level; } // Make sure we add a "../" for each component we removed from the root. return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1); } exports.relative = relative; var supportsNullProto = (function () { var obj = Object.create(null); return !('__proto__' in obj); }()); function identity (s) { return s; } /** * Because behavior goes wacky when you set `__proto__` on objects, we * have to prefix all the strings in our set with an arbitrary character. * * See https://github.com/mozilla/source-map/pull/31 and * https://github.com/mozilla/source-map/issues/30 * * @param String aStr */ function toSetString(aStr) { if (isProtoString(aStr)) { return '$' + aStr; } return aStr; } exports.toSetString = supportsNullProto ? identity : toSetString; function fromSetString(aStr) { if (isProtoString(aStr)) { return aStr.slice(1); } return aStr; } exports.fromSetString = supportsNullProto ? identity : fromSetString; function isProtoString(s) { if (!s) { return false; } var length = s.length; if (length < 9 /* "__proto__".length */) { return false; } if (s.charCodeAt(length - 1) !== 95 /* '_' */ || s.charCodeAt(length - 2) !== 95 /* '_' */ || s.charCodeAt(length - 3) !== 111 /* 'o' */ || s.charCodeAt(length - 4) !== 116 /* 't' */ || s.charCodeAt(length - 5) !== 111 /* 'o' */ || s.charCodeAt(length - 6) !== 114 /* 'r' */ || s.charCodeAt(length - 7) !== 112 /* 'p' */ || s.charCodeAt(length - 8) !== 95 /* '_' */ || s.charCodeAt(length - 9) !== 95 /* '_' */) { return false; } for (var i = length - 10; i >= 0; i--) { if (s.charCodeAt(i) !== 36 /* '$' */) { return false; } } return true; } /** * Comparator between two mappings where the original positions are compared. * * Optionally pass in `true` as `onlyCompareGenerated` to consider two * mappings with the same original source/line/column, but different generated * line and column the same. Useful when searching for a mapping with a * stubbed out mapping. */ function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) { var cmp = strcmp(mappingA.source, mappingB.source); if (cmp !== 0) { return cmp; } cmp = mappingA.originalLine - mappingB.originalLine; if (cmp !== 0) { return cmp; } cmp = mappingA.originalColumn - mappingB.originalColumn; if (cmp !== 0 || onlyCompareOriginal) { return cmp; } cmp = mappingA.generatedColumn - mappingB.generatedColumn; if (cmp !== 0) { return cmp; } cmp = mappingA.generatedLine - mappingB.generatedLine; if (cmp !== 0) { return cmp; } return strcmp(mappingA.name, mappingB.name); } exports.compareByOriginalPositions = compareByOriginalPositions; /** * Comparator between two mappings with deflated source and name indices where * the generated positions are compared. * * Optionally pass in `true` as `onlyCompareGenerated` to consider two * mappings with the same generated line and column, but different * source/name/original line and column the same. Useful when searching for a * mapping with a stubbed out mapping. */ function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) { var cmp = mappingA.generatedLine - mappingB.generatedLine; if (cmp !== 0) { return cmp; } cmp = mappingA.generatedColumn - mappingB.generatedColumn; if (cmp !== 0 || onlyCompareGenerated) { return cmp; } cmp = strcmp(mappingA.source, mappingB.source); if (cmp !== 0) { return cmp; } cmp = mappingA.originalLine - mappingB.originalLine; if (cmp !== 0) { return cmp; } cmp = mappingA.originalColumn - mappingB.originalColumn; if (cmp !== 0) { return cmp; } return strcmp(mappingA.name, mappingB.name); } exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated; function strcmp(aStr1, aStr2) { if (aStr1 === aStr2) { return 0; } if (aStr1 === null) { return 1; // aStr2 !== null } if (aStr2 === null) { return -1; // aStr1 !== null } if (aStr1 > aStr2) { return 1; } return -1; } /** * Comparator between two mappings with inflated source and name strings where * the generated positions are compared. */ function compareByGeneratedPositionsInflated(mappingA, mappingB) { var cmp = mappingA.generatedLine - mappingB.generatedLine; if (cmp !== 0) { return cmp; } cmp = mappingA.generatedColumn - mappingB.generatedColumn; if (cmp !== 0) { return cmp; } cmp = strcmp(mappingA.source, mappingB.source); if (cmp !== 0) { return cmp; } cmp = mappingA.originalLine - mappingB.originalLine; if (cmp !== 0) { return cmp; } cmp = mappingA.originalColumn - mappingB.originalColumn; if (cmp !== 0) { return cmp; } return strcmp(mappingA.name, mappingB.name); } exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated; /** * Strip any JSON XSSI avoidance prefix from the string (as documented * in the source maps specification), and then parse the string as * JSON. */ function parseSourceMapInput(str) { return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, '')); } exports.parseSourceMapInput = parseSourceMapInput; /** * Compute the URL of a source given the the source root, the source's * URL, and the source map's URL. */ function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) { sourceURL = sourceURL || ''; if (sourceRoot) { // This follows what Chrome does. if (sourceRoot[sourceRoot.length - 1] !== '/' && sourceURL[0] !== '/') { sourceRoot += '/'; } // The spec says: // Line 4: An optional source root, useful for relocating source // files on a server or removing repeated values in the // “sources” entry. This value is prepended to the individual // entries in the “source” field. sourceURL = sourceRoot + sourceURL; } // Historically, SourceMapConsumer did not take the sourceMapURL as // a parameter. This mode is still somewhat supported, which is why // this code block is conditional. However, it's preferable to pass // the source map URL to SourceMapConsumer, so that this function // can implement the source URL resolution algorithm as outlined in // the spec. This block is basically the equivalent of: // new URL(sourceURL, sourceMapURL).toString() // ... except it avoids using URL, which wasn't available in the // older releases of node still supported by this library. // // The spec says: // If the sources are not absolute URLs after prepending of the // “sourceRoot”, the sources are resolved relative to the // SourceMap (like resolving script src in a html document). if (sourceMapURL) { var parsed = urlParse(sourceMapURL); if (!parsed) { throw new Error("sourceMapURL could not be parsed"); } if (parsed.path) { // Strip the last path component, but keep the "/". var index = parsed.path.lastIndexOf('/'); if (index >= 0) { parsed.path = parsed.path.substring(0, index + 1); } } sourceURL = join(urlGenerate(parsed), sourceURL); } return normalize(sourceURL); } exports.computeSourceURL = computeSourceURL; /***/ }), /***/ "./node_modules/recast/node_modules/source-map/source-map.js": /*!*******************************************************************!*\ !*** ./node_modules/recast/node_modules/source-map/source-map.js ***! \*******************************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { /* * Copyright 2009-2011 Mozilla Foundation and contributors * Licensed under the New BSD license. See LICENSE.txt or: * http://opensource.org/licenses/BSD-3-Clause */ exports.SourceMapGenerator = __webpack_require__(/*! ./lib/source-map-generator */ "./node_modules/recast/node_modules/source-map/lib/source-map-generator.js").SourceMapGenerator; exports.SourceMapConsumer = __webpack_require__(/*! ./lib/source-map-consumer */ "./node_modules/recast/node_modules/source-map/lib/source-map-consumer.js").SourceMapConsumer; exports.SourceNode = __webpack_require__(/*! ./lib/source-node */ "./node_modules/recast/node_modules/source-map/lib/source-node.js").SourceNode; /***/ }), /***/ "./node_modules/recast/parsers/esprima.js": /*!************************************************!*\ !*** ./node_modules/recast/parsers/esprima.js ***! \************************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.parse = void 0; // This module is suitable for passing as options.parser when calling // recast.parse to process ECMAScript code with Esprima: // // const ast = recast.parse(source, { // parser: require("recast/parsers/esprima") // }); // var util_1 = __webpack_require__(/*! ../lib/util */ "./node_modules/recast/lib/util.js"); function parse(source, options) { var comments = []; var ast = (__webpack_require__(/*! esprima */ "./node_modules/esprima/dist/esprima.js").parse)(source, { loc: true, locations: true, comment: true, onComment: comments, range: (0, util_1.getOption)(options, "range", false), tolerant: (0, util_1.getOption)(options, "tolerant", true), tokens: true, jsx: (0, util_1.getOption)(options, "jsx", false), sourceType: (0, util_1.getOption)(options, "sourceType", "module"), }); if (!Array.isArray(ast.comments)) { ast.comments = comments; } return ast; } exports.parse = parse; /***/ }), /***/ "./node_modules/safe-regex-test/index.js": /*!***********************************************!*\ !*** ./node_modules/safe-regex-test/index.js ***! \***********************************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; var callBound = __webpack_require__(/*! call-bound */ "./node_modules/call-bound/index.js"); var isRegex = __webpack_require__(/*! is-regex */ "./node_modules/is-regex/index.js"); var $exec = callBound('RegExp.prototype.exec'); var $TypeError = __webpack_require__(/*! es-errors/type */ "./node_modules/es-errors/type.js"); /** @type {import('.')} */ module.exports = function regexTester(regex) { if (!isRegex(regex)) { throw new $TypeError('`regex` must be a RegExp'); } return function test(s) { return $exec(regex, s) !== null; }; }; /***/ }), /***/ "./node_modules/set-function-length/index.js": /*!***************************************************!*\ !*** ./node_modules/set-function-length/index.js ***! \***************************************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; var GetIntrinsic = __webpack_require__(/*! get-intrinsic */ "./node_modules/get-intrinsic/index.js"); var define = __webpack_require__(/*! define-data-property */ "./node_modules/define-data-property/index.js"); var hasDescriptors = __webpack_require__(/*! has-property-descriptors */ "./node_modules/has-property-descriptors/index.js")(); var gOPD = __webpack_require__(/*! gopd */ "./node_modules/gopd/index.js"); var $TypeError = __webpack_require__(/*! es-errors/type */ "./node_modules/es-errors/type.js"); var $floor = GetIntrinsic('%Math.floor%'); /** @type {import('.')} */ module.exports = function setFunctionLength(fn, length) { if (typeof fn !== 'function') { throw new $TypeError('`fn` is not a function'); } if (typeof length !== 'number' || length < 0 || length > 0xFFFFFFFF || $floor(length) !== length) { throw new $TypeError('`length` must be a positive 32-bit integer'); } var loose = arguments.length > 2 && !!arguments[2]; var functionLengthIsConfigurable = true; var functionLengthIsWritable = true; if ('length' in fn && gOPD) { var desc = gOPD(fn, 'length'); if (desc && !desc.configurable) { functionLengthIsConfigurable = false; } if (desc && !desc.writable) { functionLengthIsWritable = false; } } if (functionLengthIsConfigurable || functionLengthIsWritable || !loose) { if (hasDescriptors) { define(/** @type {Parameters[0]} */ (fn), 'length', length, true, true); } else { define(/** @type {Parameters[0]} */ (fn), 'length', length); } } return fn; }; /***/ }), /***/ "./node_modules/tiny-invariant/dist/tiny-invariant.cjs.js": /*!****************************************************************!*\ !*** ./node_modules/tiny-invariant/dist/tiny-invariant.cjs.js ***! \****************************************************************/ /***/ ((module) => { "use strict"; var isProduction = "development" === 'production'; var prefix = 'Invariant failed'; function invariant(condition, message) { if (condition) { return; } if (isProduction) { throw new Error(prefix); } var provided = typeof message === 'function' ? message() : message; var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix; throw new Error(value); } module.exports = invariant; /***/ }), /***/ "./node_modules/tslib/tslib.es6.mjs": /*!******************************************!*\ !*** ./node_modules/tslib/tslib.es6.mjs ***! \******************************************/ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ __addDisposableResource: () => (/* binding */ __addDisposableResource), /* harmony export */ __assign: () => (/* binding */ __assign), /* harmony export */ __asyncDelegator: () => (/* binding */ __asyncDelegator), /* harmony export */ __asyncGenerator: () => (/* binding */ __asyncGenerator), /* harmony export */ __asyncValues: () => (/* binding */ __asyncValues), /* harmony export */ __await: () => (/* binding */ __await), /* harmony export */ __awaiter: () => (/* binding */ __awaiter), /* harmony export */ __classPrivateFieldGet: () => (/* binding */ __classPrivateFieldGet), /* harmony export */ __classPrivateFieldIn: () => (/* binding */ __classPrivateFieldIn), /* harmony export */ __classPrivateFieldSet: () => (/* binding */ __classPrivateFieldSet), /* harmony export */ __createBinding: () => (/* binding */ __createBinding), /* harmony export */ __decorate: () => (/* binding */ __decorate), /* harmony export */ __disposeResources: () => (/* binding */ __disposeResources), /* harmony export */ __esDecorate: () => (/* binding */ __esDecorate), /* harmony export */ __exportStar: () => (/* binding */ __exportStar), /* harmony export */ __extends: () => (/* binding */ __extends), /* harmony export */ __generator: () => (/* binding */ __generator), /* harmony export */ __importDefault: () => (/* binding */ __importDefault), /* harmony export */ __importStar: () => (/* binding */ __importStar), /* harmony export */ __makeTemplateObject: () => (/* binding */ __makeTemplateObject), /* harmony export */ __metadata: () => (/* binding */ __metadata), /* harmony export */ __param: () => (/* binding */ __param), /* harmony export */ __propKey: () => (/* binding */ __propKey), /* harmony export */ __read: () => (/* binding */ __read), /* harmony export */ __rest: () => (/* binding */ __rest), /* harmony export */ __rewriteRelativeImportExtension: () => (/* binding */ __rewriteRelativeImportExtension), /* harmony export */ __runInitializers: () => (/* binding */ __runInitializers), /* harmony export */ __setFunctionName: () => (/* binding */ __setFunctionName), /* harmony export */ __spread: () => (/* binding */ __spread), /* harmony export */ __spreadArray: () => (/* binding */ __spreadArray), /* harmony export */ __spreadArrays: () => (/* binding */ __spreadArrays), /* harmony export */ __values: () => (/* binding */ __values), /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) /* harmony export */ }); /****************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */ var extendStatics = function(d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; function __extends(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); } var __assign = function() { __assign = Object.assign || function __assign(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; } return __assign.apply(this, arguments); } function __rest(s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; } function __decorate(decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; } function __param(paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } } function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; } var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); var _, done = false; for (var i = decorators.length - 1; i >= 0; i--) { var context = {}; for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p]; for (var p in contextIn.access) context.access[p] = contextIn.access[p]; context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); }; var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context); if (kind === "accessor") { if (result === void 0) continue; if (result === null || typeof result !== "object") throw new TypeError("Object expected"); if (_ = accept(result.get)) descriptor.get = _; if (_ = accept(result.set)) descriptor.set = _; if (_ = accept(result.init)) initializers.unshift(_); } else if (_ = accept(result)) { if (kind === "field") initializers.unshift(_); else descriptor[key] = _; } } if (target) Object.defineProperty(target, contextIn.name, descriptor); done = true; }; function __runInitializers(thisArg, initializers, value) { var useValue = arguments.length > 2; for (var i = 0; i < initializers.length; i++) { value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg); } return useValue ? value : void 0; }; function __propKey(x) { return typeof x === "symbol" ? x : "".concat(x); }; function __setFunctionName(f, name, prefix) { if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : ""; return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name }); }; function __metadata(metadataKey, metadataValue) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); } function __awaiter(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); } function __generator(thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype); return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (g && (g = 0, op[0] && (_ = 0)), _) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } } var __createBinding = Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; }); function __exportStar(m, o) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p); } function __values(o) { var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; if (m) return m.call(o); if (o && typeof o.length === "number") return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); } function __read(o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; } /** @deprecated */ function __spread() { for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); return ar; } /** @deprecated */ function __spreadArrays() { for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j]; return r; } function __spreadArray(to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); } function __await(v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } function __asyncGenerator(thisArg, _arguments, generator) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), i, q = []; return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i; function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; } function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } } function __asyncDelegator(o) { var i, p; return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; } } function __asyncValues(o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var m = o[Symbol.asyncIterator], i; return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } } function __makeTemplateObject(cooked, raw) { if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } return cooked; }; var __setModuleDefault = Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }; var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; function __importStar(mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; } function __importDefault(mod) { return (mod && mod.__esModule) ? mod : { default: mod }; } function __classPrivateFieldGet(receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); } function __classPrivateFieldSet(receiver, state, value, kind, f) { if (kind === "m") throw new TypeError("Private method is not writable"); if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; } function __classPrivateFieldIn(state, receiver) { if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object"); return typeof state === "function" ? receiver === state : state.has(receiver); } function __addDisposableResource(env, value, async) { if (value !== null && value !== void 0) { if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected."); var dispose, inner; if (async) { if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); dispose = value[Symbol.asyncDispose]; } if (dispose === void 0) { if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); dispose = value[Symbol.dispose]; if (async) inner = dispose; } if (typeof dispose !== "function") throw new TypeError("Object not disposable."); if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } }; env.stack.push({ value: value, dispose: dispose, async: async }); } else if (async) { env.stack.push({ async: true }); } return value; } var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { var e = new Error(message); return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; }; function __disposeResources(env) { function fail(e) { env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; env.hasError = true; } var r, s = 0; function next() { while (r = env.stack.pop()) { try { if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next); if (r.dispose) { var result = r.dispose.call(r.value); if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); } else s |= 1; } catch (e) { fail(e); } } if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve(); if (env.hasError) throw env.error; } return next(); } function __rewriteRelativeImportExtension(path, preserveJsx) { if (typeof path === "string" && /^\.\.?\//.test(path)) { return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) { return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js"); }); } return path; } /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ __extends, __assign, __rest, __decorate, __param, __esDecorate, __runInitializers, __propKey, __setFunctionName, __metadata, __awaiter, __generator, __createBinding, __exportStar, __values, __read, __spread, __spreadArrays, __spreadArray, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault, __classPrivateFieldGet, __classPrivateFieldSet, __classPrivateFieldIn, __addDisposableResource, __disposeResources, __rewriteRelativeImportExtension, }); /***/ }), /***/ "./node_modules/util/support/isBufferBrowser.js": /*!******************************************************!*\ !*** ./node_modules/util/support/isBufferBrowser.js ***! \******************************************************/ /***/ ((module) => { module.exports = function isBuffer(arg) { return arg && typeof arg === 'object' && typeof arg.copy === 'function' && typeof arg.fill === 'function' && typeof arg.readUInt8 === 'function'; } /***/ }), /***/ "./node_modules/util/support/types.js": /*!********************************************!*\ !*** ./node_modules/util/support/types.js ***! \********************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; // Currently in sync with Node.js lib/internal/util/types.js // https://github.com/nodejs/node/commit/112cc7c27551254aa2b17098fb774867f05ed0d9 var isArgumentsObject = __webpack_require__(/*! is-arguments */ "./node_modules/is-arguments/index.js"); var isGeneratorFunction = __webpack_require__(/*! is-generator-function */ "./node_modules/is-generator-function/index.js"); var whichTypedArray = __webpack_require__(/*! which-typed-array */ "./node_modules/which-typed-array/index.js"); var isTypedArray = __webpack_require__(/*! is-typed-array */ "./node_modules/is-typed-array/index.js"); function uncurryThis(f) { return f.call.bind(f); } var BigIntSupported = typeof BigInt !== 'undefined'; var SymbolSupported = typeof Symbol !== 'undefined'; var ObjectToString = uncurryThis(Object.prototype.toString); var numberValue = uncurryThis(Number.prototype.valueOf); var stringValue = uncurryThis(String.prototype.valueOf); var booleanValue = uncurryThis(Boolean.prototype.valueOf); if (BigIntSupported) { var bigIntValue = uncurryThis(BigInt.prototype.valueOf); } if (SymbolSupported) { var symbolValue = uncurryThis(Symbol.prototype.valueOf); } function checkBoxedPrimitive(value, prototypeValueOf) { if (typeof value !== 'object') { return false; } try { prototypeValueOf(value); return true; } catch(e) { return false; } } exports.isArgumentsObject = isArgumentsObject; exports.isGeneratorFunction = isGeneratorFunction; exports.isTypedArray = isTypedArray; // Taken from here and modified for better browser support // https://github.com/sindresorhus/p-is-promise/blob/cda35a513bda03f977ad5cde3a079d237e82d7ef/index.js function isPromise(input) { return ( ( typeof Promise !== 'undefined' && input instanceof Promise ) || ( input !== null && typeof input === 'object' && typeof input.then === 'function' && typeof input.catch === 'function' ) ); } exports.isPromise = isPromise; function isArrayBufferView(value) { if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView) { return ArrayBuffer.isView(value); } return ( isTypedArray(value) || isDataView(value) ); } exports.isArrayBufferView = isArrayBufferView; function isUint8Array(value) { return whichTypedArray(value) === 'Uint8Array'; } exports.isUint8Array = isUint8Array; function isUint8ClampedArray(value) { return whichTypedArray(value) === 'Uint8ClampedArray'; } exports.isUint8ClampedArray = isUint8ClampedArray; function isUint16Array(value) { return whichTypedArray(value) === 'Uint16Array'; } exports.isUint16Array = isUint16Array; function isUint32Array(value) { return whichTypedArray(value) === 'Uint32Array'; } exports.isUint32Array = isUint32Array; function isInt8Array(value) { return whichTypedArray(value) === 'Int8Array'; } exports.isInt8Array = isInt8Array; function isInt16Array(value) { return whichTypedArray(value) === 'Int16Array'; } exports.isInt16Array = isInt16Array; function isInt32Array(value) { return whichTypedArray(value) === 'Int32Array'; } exports.isInt32Array = isInt32Array; function isFloat32Array(value) { return whichTypedArray(value) === 'Float32Array'; } exports.isFloat32Array = isFloat32Array; function isFloat64Array(value) { return whichTypedArray(value) === 'Float64Array'; } exports.isFloat64Array = isFloat64Array; function isBigInt64Array(value) { return whichTypedArray(value) === 'BigInt64Array'; } exports.isBigInt64Array = isBigInt64Array; function isBigUint64Array(value) { return whichTypedArray(value) === 'BigUint64Array'; } exports.isBigUint64Array = isBigUint64Array; function isMapToString(value) { return ObjectToString(value) === '[object Map]'; } isMapToString.working = ( typeof Map !== 'undefined' && isMapToString(new Map()) ); function isMap(value) { if (typeof Map === 'undefined') { return false; } return isMapToString.working ? isMapToString(value) : value instanceof Map; } exports.isMap = isMap; function isSetToString(value) { return ObjectToString(value) === '[object Set]'; } isSetToString.working = ( typeof Set !== 'undefined' && isSetToString(new Set()) ); function isSet(value) { if (typeof Set === 'undefined') { return false; } return isSetToString.working ? isSetToString(value) : value instanceof Set; } exports.isSet = isSet; function isWeakMapToString(value) { return ObjectToString(value) === '[object WeakMap]'; } isWeakMapToString.working = ( typeof WeakMap !== 'undefined' && isWeakMapToString(new WeakMap()) ); function isWeakMap(value) { if (typeof WeakMap === 'undefined') { return false; } return isWeakMapToString.working ? isWeakMapToString(value) : value instanceof WeakMap; } exports.isWeakMap = isWeakMap; function isWeakSetToString(value) { return ObjectToString(value) === '[object WeakSet]'; } isWeakSetToString.working = ( typeof WeakSet !== 'undefined' && isWeakSetToString(new WeakSet()) ); function isWeakSet(value) { return isWeakSetToString(value); } exports.isWeakSet = isWeakSet; function isArrayBufferToString(value) { return ObjectToString(value) === '[object ArrayBuffer]'; } isArrayBufferToString.working = ( typeof ArrayBuffer !== 'undefined' && isArrayBufferToString(new ArrayBuffer()) ); function isArrayBuffer(value) { if (typeof ArrayBuffer === 'undefined') { return false; } return isArrayBufferToString.working ? isArrayBufferToString(value) : value instanceof ArrayBuffer; } exports.isArrayBuffer = isArrayBuffer; function isDataViewToString(value) { return ObjectToString(value) === '[object DataView]'; } isDataViewToString.working = ( typeof ArrayBuffer !== 'undefined' && typeof DataView !== 'undefined' && isDataViewToString(new DataView(new ArrayBuffer(1), 0, 1)) ); function isDataView(value) { if (typeof DataView === 'undefined') { return false; } return isDataViewToString.working ? isDataViewToString(value) : value instanceof DataView; } exports.isDataView = isDataView; // Store a copy of SharedArrayBuffer in case it's deleted elsewhere var SharedArrayBufferCopy = typeof SharedArrayBuffer !== 'undefined' ? SharedArrayBuffer : undefined; function isSharedArrayBufferToString(value) { return ObjectToString(value) === '[object SharedArrayBuffer]'; } function isSharedArrayBuffer(value) { if (typeof SharedArrayBufferCopy === 'undefined') { return false; } if (typeof isSharedArrayBufferToString.working === 'undefined') { isSharedArrayBufferToString.working = isSharedArrayBufferToString(new SharedArrayBufferCopy()); } return isSharedArrayBufferToString.working ? isSharedArrayBufferToString(value) : value instanceof SharedArrayBufferCopy; } exports.isSharedArrayBuffer = isSharedArrayBuffer; function isAsyncFunction(value) { return ObjectToString(value) === '[object AsyncFunction]'; } exports.isAsyncFunction = isAsyncFunction; function isMapIterator(value) { return ObjectToString(value) === '[object Map Iterator]'; } exports.isMapIterator = isMapIterator; function isSetIterator(value) { return ObjectToString(value) === '[object Set Iterator]'; } exports.isSetIterator = isSetIterator; function isGeneratorObject(value) { return ObjectToString(value) === '[object Generator]'; } exports.isGeneratorObject = isGeneratorObject; function isWebAssemblyCompiledModule(value) { return ObjectToString(value) === '[object WebAssembly.Module]'; } exports.isWebAssemblyCompiledModule = isWebAssemblyCompiledModule; function isNumberObject(value) { return checkBoxedPrimitive(value, numberValue); } exports.isNumberObject = isNumberObject; function isStringObject(value) { return checkBoxedPrimitive(value, stringValue); } exports.isStringObject = isStringObject; function isBooleanObject(value) { return checkBoxedPrimitive(value, booleanValue); } exports.isBooleanObject = isBooleanObject; function isBigIntObject(value) { return BigIntSupported && checkBoxedPrimitive(value, bigIntValue); } exports.isBigIntObject = isBigIntObject; function isSymbolObject(value) { return SymbolSupported && checkBoxedPrimitive(value, symbolValue); } exports.isSymbolObject = isSymbolObject; function isBoxedPrimitive(value) { return ( isNumberObject(value) || isStringObject(value) || isBooleanObject(value) || isBigIntObject(value) || isSymbolObject(value) ); } exports.isBoxedPrimitive = isBoxedPrimitive; function isAnyArrayBuffer(value) { return typeof Uint8Array !== 'undefined' && ( isArrayBuffer(value) || isSharedArrayBuffer(value) ); } exports.isAnyArrayBuffer = isAnyArrayBuffer; ['isProxy', 'isExternal', 'isModuleNamespaceObject'].forEach(function(method) { Object.defineProperty(exports, method, { enumerable: false, value: function() { throw new Error(method + ' is not supported in userland'); } }); }); /***/ }), /***/ "./node_modules/util/util.js": /*!***********************************!*\ !*** ./node_modules/util/util.js ***! \***********************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { /* provided dependency */ var process = __webpack_require__(/*! process/browser.js */ "./node_modules/process/browser.js"); // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to permit // persons to whom the Software is furnished to do so, subject to the // following conditions: // // The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors || function getOwnPropertyDescriptors(obj) { var keys = Object.keys(obj); var descriptors = {}; for (var i = 0; i < keys.length; i++) { descriptors[keys[i]] = Object.getOwnPropertyDescriptor(obj, keys[i]); } return descriptors; }; var formatRegExp = /%[sdj%]/g; exports.format = function(f) { if (!isString(f)) { var objects = []; for (var i = 0; i < arguments.length; i++) { objects.push(inspect(arguments[i])); } return objects.join(' '); } var i = 1; var args = arguments; var len = args.length; var str = String(f).replace(formatRegExp, function(x) { if (x === '%%') return '%'; if (i >= len) return x; switch (x) { case '%s': return String(args[i++]); case '%d': return Number(args[i++]); case '%j': try { return JSON.stringify(args[i++]); } catch (_) { return '[Circular]'; } default: return x; } }); for (var x = args[i]; i < len; x = args[++i]) { if (isNull(x) || !isObject(x)) { str += ' ' + x; } else { str += ' ' + inspect(x); } } return str; }; // Mark that a method should not be used. // Returns a modified function which warns once by default. // If --no-deprecation is set, then it is a no-op. exports.deprecate = function(fn, msg) { if (typeof process !== 'undefined' && process.noDeprecation === true) { return fn; } // Allow for deprecating things in the process of starting up. if (typeof process === 'undefined') { return function() { return exports.deprecate(fn, msg).apply(this, arguments); }; } var warned = false; function deprecated() { if (!warned) { if (process.throwDeprecation) { throw new Error(msg); } else if (process.traceDeprecation) { console.trace(msg); } else { console.error(msg); } warned = true; } return fn.apply(this, arguments); } return deprecated; }; var debugs = {}; var debugEnvRegex = /^$/; if (process.env.NODE_DEBUG) { var debugEnv = process.env.NODE_DEBUG; debugEnv = debugEnv.replace(/[|\\{}()[\]^$+?.]/g, '\\$&') .replace(/\*/g, '.*') .replace(/,/g, '$|^') .toUpperCase(); debugEnvRegex = new RegExp('^' + debugEnv + '$', 'i'); } exports.debuglog = function(set) { set = set.toUpperCase(); if (!debugs[set]) { if (debugEnvRegex.test(set)) { var pid = process.pid; debugs[set] = function() { var msg = exports.format.apply(exports, arguments); console.error('%s %d: %s', set, pid, msg); }; } else { debugs[set] = function() {}; } } return debugs[set]; }; /** * Echos the value of a value. Trys to print the value out * in the best way possible given the different types. * * @param {Object} obj The object to print out. * @param {Object} opts Optional options object that alters the output. */ /* legacy: obj, showHidden, depth, colors*/ function inspect(obj, opts) { // default options var ctx = { seen: [], stylize: stylizeNoColor }; // legacy... if (arguments.length >= 3) ctx.depth = arguments[2]; if (arguments.length >= 4) ctx.colors = arguments[3]; if (isBoolean(opts)) { // legacy... ctx.showHidden = opts; } else if (opts) { // got an "options" object exports._extend(ctx, opts); } // set default options if (isUndefined(ctx.showHidden)) ctx.showHidden = false; if (isUndefined(ctx.depth)) ctx.depth = 2; if (isUndefined(ctx.colors)) ctx.colors = false; if (isUndefined(ctx.customInspect)) ctx.customInspect = true; if (ctx.colors) ctx.stylize = stylizeWithColor; return formatValue(ctx, obj, ctx.depth); } exports.inspect = inspect; // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics inspect.colors = { 'bold' : [1, 22], 'italic' : [3, 23], 'underline' : [4, 24], 'inverse' : [7, 27], 'white' : [37, 39], 'grey' : [90, 39], 'black' : [30, 39], 'blue' : [34, 39], 'cyan' : [36, 39], 'green' : [32, 39], 'magenta' : [35, 39], 'red' : [31, 39], 'yellow' : [33, 39] }; // Don't use 'blue' not visible on cmd.exe inspect.styles = { 'special': 'cyan', 'number': 'yellow', 'boolean': 'yellow', 'undefined': 'grey', 'null': 'bold', 'string': 'green', 'date': 'magenta', // "name": intentionally not styling 'regexp': 'red' }; function stylizeWithColor(str, styleType) { var style = inspect.styles[styleType]; if (style) { return '\u001b[' + inspect.colors[style][0] + 'm' + str + '\u001b[' + inspect.colors[style][1] + 'm'; } else { return str; } } function stylizeNoColor(str, styleType) { return str; } function arrayToHash(array) { var hash = {}; array.forEach(function(val, idx) { hash[val] = true; }); return hash; } function formatValue(ctx, value, recurseTimes) { // Provide a hook for user-specified inspect functions. // Check that value is an object with an inspect function on it if (ctx.customInspect && value && isFunction(value.inspect) && // Filter out the util module, it's inspect function is special value.inspect !== exports.inspect && // Also filter out any prototype objects using the circular check. !(value.constructor && value.constructor.prototype === value)) { var ret = value.inspect(recurseTimes, ctx); if (!isString(ret)) { ret = formatValue(ctx, ret, recurseTimes); } return ret; } // Primitive types cannot have properties var primitive = formatPrimitive(ctx, value); if (primitive) { return primitive; } // Look up the keys of the object. var keys = Object.keys(value); var visibleKeys = arrayToHash(keys); if (ctx.showHidden) { keys = Object.getOwnPropertyNames(value); } // IE doesn't make error fields non-enumerable // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx if (isError(value) && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) { return formatError(value); } // Some type of object without properties can be shortcutted. if (keys.length === 0) { if (isFunction(value)) { var name = value.name ? ': ' + value.name : ''; return ctx.stylize('[Function' + name + ']', 'special'); } if (isRegExp(value)) { return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); } if (isDate(value)) { return ctx.stylize(Date.prototype.toString.call(value), 'date'); } if (isError(value)) { return formatError(value); } } var base = '', array = false, braces = ['{', '}']; // Make Array say that they are Array if (isArray(value)) { array = true; braces = ['[', ']']; } // Make functions say that they are functions if (isFunction(value)) { var n = value.name ? ': ' + value.name : ''; base = ' [Function' + n + ']'; } // Make RegExps say that they are RegExps if (isRegExp(value)) { base = ' ' + RegExp.prototype.toString.call(value); } // Make dates with properties first say the date if (isDate(value)) { base = ' ' + Date.prototype.toUTCString.call(value); } // Make error with message first say the error if (isError(value)) { base = ' ' + formatError(value); } if (keys.length === 0 && (!array || value.length == 0)) { return braces[0] + base + braces[1]; } if (recurseTimes < 0) { if (isRegExp(value)) { return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); } else { return ctx.stylize('[Object]', 'special'); } } ctx.seen.push(value); var output; if (array) { output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); } else { output = keys.map(function(key) { return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); }); } ctx.seen.pop(); return reduceToSingleString(output, base, braces); } function formatPrimitive(ctx, value) { if (isUndefined(value)) return ctx.stylize('undefined', 'undefined'); if (isString(value)) { var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') .replace(/'/g, "\\'") .replace(/\\"/g, '"') + '\''; return ctx.stylize(simple, 'string'); } if (isNumber(value)) return ctx.stylize('' + value, 'number'); if (isBoolean(value)) return ctx.stylize('' + value, 'boolean'); // For some reason typeof null is "object", so special case here. if (isNull(value)) return ctx.stylize('null', 'null'); } function formatError(value) { return '[' + Error.prototype.toString.call(value) + ']'; } function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { var output = []; for (var i = 0, l = value.length; i < l; ++i) { if (hasOwnProperty(value, String(i))) { output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, String(i), true)); } else { output.push(''); } } keys.forEach(function(key) { if (!key.match(/^\d+$/)) { output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, key, true)); } }); return output; } function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { var name, str, desc; desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; if (desc.get) { if (desc.set) { str = ctx.stylize('[Getter/Setter]', 'special'); } else { str = ctx.stylize('[Getter]', 'special'); } } else { if (desc.set) { str = ctx.stylize('[Setter]', 'special'); } } if (!hasOwnProperty(visibleKeys, key)) { name = '[' + key + ']'; } if (!str) { if (ctx.seen.indexOf(desc.value) < 0) { if (isNull(recurseTimes)) { str = formatValue(ctx, desc.value, null); } else { str = formatValue(ctx, desc.value, recurseTimes - 1); } if (str.indexOf('\n') > -1) { if (array) { str = str.split('\n').map(function(line) { return ' ' + line; }).join('\n').slice(2); } else { str = '\n' + str.split('\n').map(function(line) { return ' ' + line; }).join('\n'); } } } else { str = ctx.stylize('[Circular]', 'special'); } } if (isUndefined(name)) { if (array && key.match(/^\d+$/)) { return str; } name = JSON.stringify('' + key); if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { name = name.slice(1, -1); name = ctx.stylize(name, 'name'); } else { name = name.replace(/'/g, "\\'") .replace(/\\"/g, '"') .replace(/(^"|"$)/g, "'"); name = ctx.stylize(name, 'string'); } } return name + ': ' + str; } function reduceToSingleString(output, base, braces) { var numLinesEst = 0; var length = output.reduce(function(prev, cur) { numLinesEst++; if (cur.indexOf('\n') >= 0) numLinesEst++; return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; }, 0); if (length > 60) { return braces[0] + (base === '' ? '' : base + '\n ') + ' ' + output.join(',\n ') + ' ' + braces[1]; } return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; } // NOTE: These type checking functions intentionally don't use `instanceof` // because it is fragile and can be easily faked with `Object.create()`. exports.types = __webpack_require__(/*! ./support/types */ "./node_modules/util/support/types.js"); function isArray(ar) { return Array.isArray(ar); } exports.isArray = isArray; function isBoolean(arg) { return typeof arg === 'boolean'; } exports.isBoolean = isBoolean; function isNull(arg) { return arg === null; } exports.isNull = isNull; function isNullOrUndefined(arg) { return arg == null; } exports.isNullOrUndefined = isNullOrUndefined; function isNumber(arg) { return typeof arg === 'number'; } exports.isNumber = isNumber; function isString(arg) { return typeof arg === 'string'; } exports.isString = isString; function isSymbol(arg) { return typeof arg === 'symbol'; } exports.isSymbol = isSymbol; function isUndefined(arg) { return arg === void 0; } exports.isUndefined = isUndefined; function isRegExp(re) { return isObject(re) && objectToString(re) === '[object RegExp]'; } exports.isRegExp = isRegExp; exports.types.isRegExp = isRegExp; function isObject(arg) { return typeof arg === 'object' && arg !== null; } exports.isObject = isObject; function isDate(d) { return isObject(d) && objectToString(d) === '[object Date]'; } exports.isDate = isDate; exports.types.isDate = isDate; function isError(e) { return isObject(e) && (objectToString(e) === '[object Error]' || e instanceof Error); } exports.isError = isError; exports.types.isNativeError = isError; function isFunction(arg) { return typeof arg === 'function'; } exports.isFunction = isFunction; function isPrimitive(arg) { return arg === null || typeof arg === 'boolean' || typeof arg === 'number' || typeof arg === 'string' || typeof arg === 'symbol' || // ES6 symbol typeof arg === 'undefined'; } exports.isPrimitive = isPrimitive; exports.isBuffer = __webpack_require__(/*! ./support/isBuffer */ "./node_modules/util/support/isBufferBrowser.js"); function objectToString(o) { return Object.prototype.toString.call(o); } function pad(n) { return n < 10 ? '0' + n.toString(10) : n.toString(10); } var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; // 26 Feb 16:19:34 function timestamp() { var d = new Date(); var time = [pad(d.getHours()), pad(d.getMinutes()), pad(d.getSeconds())].join(':'); return [d.getDate(), months[d.getMonth()], time].join(' '); } // log is just a thin wrapper to console.log that prepends a timestamp exports.log = function() { console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments)); }; /** * Inherit the prototype methods from one constructor into another. * * The Function.prototype.inherits from lang.js rewritten as a standalone * function (not on Function.prototype). NOTE: If this file is to be loaded * during bootstrapping this function needs to be rewritten using some native * functions as prototype setup using normal JavaScript does not work as * expected during bootstrapping (see mirror.js in r114903). * * @param {function} ctor Constructor function which needs to inherit the * prototype. * @param {function} superCtor Constructor function to inherit prototype from. */ exports.inherits = __webpack_require__(/*! inherits */ "./node_modules/inherits/inherits_browser.js"); exports._extend = function(origin, add) { // Don't do anything if add isn't an object if (!add || !isObject(add)) return origin; var keys = Object.keys(add); var i = keys.length; while (i--) { origin[keys[i]] = add[keys[i]]; } return origin; }; function hasOwnProperty(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } var kCustomPromisifiedSymbol = typeof Symbol !== 'undefined' ? Symbol('util.promisify.custom') : undefined; exports.promisify = function promisify(original) { if (typeof original !== 'function') throw new TypeError('The "original" argument must be of type Function'); if (kCustomPromisifiedSymbol && original[kCustomPromisifiedSymbol]) { var fn = original[kCustomPromisifiedSymbol]; if (typeof fn !== 'function') { throw new TypeError('The "util.promisify.custom" argument must be of type Function'); } Object.defineProperty(fn, kCustomPromisifiedSymbol, { value: fn, enumerable: false, writable: false, configurable: true }); return fn; } function fn() { var promiseResolve, promiseReject; var promise = new Promise(function (resolve, reject) { promiseResolve = resolve; promiseReject = reject; }); var args = []; for (var i = 0; i < arguments.length; i++) { args.push(arguments[i]); } args.push(function (err, value) { if (err) { promiseReject(err); } else { promiseResolve(value); } }); try { original.apply(this, args); } catch (err) { promiseReject(err); } return promise; } Object.setPrototypeOf(fn, Object.getPrototypeOf(original)); if (kCustomPromisifiedSymbol) Object.defineProperty(fn, kCustomPromisifiedSymbol, { value: fn, enumerable: false, writable: false, configurable: true }); return Object.defineProperties( fn, getOwnPropertyDescriptors(original) ); } exports.promisify.custom = kCustomPromisifiedSymbol function callbackifyOnRejected(reason, cb) { // `!reason` guard inspired by bluebird (Ref: https://goo.gl/t5IS6M). // Because `null` is a special error value in callbacks which means "no error // occurred", we error-wrap so the callback consumer can distinguish between // "the promise rejected with null" or "the promise fulfilled with undefined". if (!reason) { var newReason = new Error('Promise was rejected with a falsy value'); newReason.reason = reason; reason = newReason; } return cb(reason); } function callbackify(original) { if (typeof original !== 'function') { throw new TypeError('The "original" argument must be of type Function'); } // We DO NOT return the promise as it gives the user a false sense that // the promise is actually somehow related to the callback's execution // and that the callback throwing will reject the promise. function callbackified() { var args = []; for (var i = 0; i < arguments.length; i++) { args.push(arguments[i]); } var maybeCb = args.pop(); if (typeof maybeCb !== 'function') { throw new TypeError('The last argument must be of type Function'); } var self = this; var cb = function() { return maybeCb.apply(self, arguments); }; // In true node style we process the callback on `nextTick` with all the // implications (stack, `uncaughtException`, `async_hooks`) original.apply(this, args) .then(function(ret) { process.nextTick(cb.bind(null, null, ret)) }, function(rej) { process.nextTick(callbackifyOnRejected.bind(null, rej, cb)) }); } Object.setPrototypeOf(callbackified, Object.getPrototypeOf(original)); Object.defineProperties(callbackified, getOwnPropertyDescriptors(original)); return callbackified; } exports.callbackify = callbackify; /***/ }), /***/ "./node_modules/which-typed-array/index.js": /*!*************************************************!*\ !*** ./node_modules/which-typed-array/index.js ***! \*************************************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; var forEach = __webpack_require__(/*! for-each */ "./node_modules/for-each/index.js"); var availableTypedArrays = __webpack_require__(/*! available-typed-arrays */ "./node_modules/available-typed-arrays/index.js"); var callBind = __webpack_require__(/*! call-bind */ "./node_modules/call-bind/index.js"); var callBound = __webpack_require__(/*! call-bound */ "./node_modules/call-bound/index.js"); var gOPD = __webpack_require__(/*! gopd */ "./node_modules/gopd/index.js"); var getProto = __webpack_require__(/*! get-proto */ "./node_modules/get-proto/index.js"); var $toString = callBound('Object.prototype.toString'); var hasToStringTag = __webpack_require__(/*! has-tostringtag/shams */ "./node_modules/has-tostringtag/shams.js")(); var g = typeof globalThis === 'undefined' ? __webpack_require__.g : globalThis; var typedArrays = availableTypedArrays(); var $slice = callBound('String.prototype.slice'); /** @type {(array: readonly T[], value: unknown) => number} */ var $indexOf = callBound('Array.prototype.indexOf', true) || function indexOf(array, value) { for (var i = 0; i < array.length; i += 1) { if (array[i] === value) { return i; } } return -1; }; /** @typedef {import('./types').Getter} Getter */ /** @type {import('./types').Cache} */ var cache = { __proto__: null }; if (hasToStringTag && gOPD && getProto) { forEach(typedArrays, function (typedArray) { var arr = new g[typedArray](); if (Symbol.toStringTag in arr && getProto) { var proto = getProto(arr); // @ts-expect-error TS won't narrow inside a closure var descriptor = gOPD(proto, Symbol.toStringTag); if (!descriptor && proto) { var superProto = getProto(proto); // @ts-expect-error TS won't narrow inside a closure descriptor = gOPD(superProto, Symbol.toStringTag); } // @ts-expect-error TODO: fix cache['$' + typedArray] = callBind(descriptor.get); } }); } else { forEach(typedArrays, function (typedArray) { var arr = new g[typedArray](); var fn = arr.slice || arr.set; if (fn) { cache[ /** @type {`$${import('.').TypedArrayName}`} */ ('$' + typedArray) ] = /** @type {import('./types').BoundSlice | import('./types').BoundSet} */ ( // @ts-expect-error TODO FIXME callBind(fn) ); } }); } /** @type {(value: object) => false | import('.').TypedArrayName} */ var tryTypedArrays = function tryAllTypedArrays(value) { /** @type {ReturnType} */ var found = false; forEach( /** @type {Record<`\$${import('.').TypedArrayName}`, Getter>} */ (cache), /** @type {(getter: Getter, name: `\$${import('.').TypedArrayName}`) => void} */ function (getter, typedArray) { if (!found) { try { // @ts-expect-error a throw is fine here if ('$' + getter(value) === typedArray) { found = /** @type {import('.').TypedArrayName} */ ($slice(typedArray, 1)); } } catch (e) { /**/ } } } ); return found; }; /** @type {(value: object) => false | import('.').TypedArrayName} */ var trySlices = function tryAllSlices(value) { /** @type {ReturnType} */ var found = false; forEach( /** @type {Record<`\$${import('.').TypedArrayName}`, Getter>} */(cache), /** @type {(getter: Getter, name: `\$${import('.').TypedArrayName}`) => void} */ function (getter, name) { if (!found) { try { // @ts-expect-error a throw is fine here getter(value); found = /** @type {import('.').TypedArrayName} */ ($slice(name, 1)); } catch (e) { /**/ } } } ); return found; }; /** @type {import('.')} */ module.exports = function whichTypedArray(value) { if (!value || typeof value !== 'object') { return false; } if (!hasToStringTag) { /** @type {string} */ var tag = $slice($toString(value), 8, -1); if ($indexOf(typedArrays, tag) > -1) { return tag; } if (tag !== 'Object') { return false; } // node < 0.6 hits here on real Typed Arrays return trySlices(value); } if (!gOPD) { return null; } // unknown engine return tryTypedArrays(value); }; /***/ }), /***/ "?5042": /*!********************!*\ !*** fs (ignored) ***! \********************/ /***/ (() => { /* (ignored) */ /***/ }) /******/ }); /************************************************************************/ /******/ // The module cache /******/ var __webpack_module_cache__ = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache /******/ var cachedModule = __webpack_module_cache__[moduleId]; /******/ if (cachedModule !== undefined) { /******/ return cachedModule.exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = __webpack_module_cache__[moduleId] = { /******/ id: moduleId, /******/ loaded: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.loaded = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /************************************************************************/ /******/ /* webpack/runtime/define property getters */ /******/ (() => { /******/ // define getter functions for harmony exports /******/ __webpack_require__.d = (exports, definition) => { /******/ for(var key in definition) { /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); /******/ } /******/ } /******/ }; /******/ })(); /******/ /******/ /* webpack/runtime/global */ /******/ (() => { /******/ __webpack_require__.g = (function() { /******/ if (typeof globalThis === 'object') return globalThis; /******/ try { /******/ return this || new Function('return this')(); /******/ } catch (e) { /******/ if (typeof window === 'object') return window; /******/ } /******/ })(); /******/ })(); /******/ /******/ /* webpack/runtime/hasOwnProperty shorthand */ /******/ (() => { /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) /******/ })(); /******/ /******/ /* webpack/runtime/make namespace object */ /******/ (() => { /******/ // define __esModule on exports /******/ __webpack_require__.r = (exports) => { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ })(); /******/ /******/ /* webpack/runtime/node module decorator */ /******/ (() => { /******/ __webpack_require__.nmd = (module) => { /******/ module.paths = []; /******/ if (!module.children) module.children = []; /******/ return module; /******/ }; /******/ })(); /******/ /************************************************************************/ var __webpack_exports__ = {}; // This entry needs to be wrapped in an IIFE because it needs to be in strict mode. (() => { "use strict"; /*!***********************!*\ !*** ./src/lebab.mjs ***! \***********************/ __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ runTest: () => (/* binding */ runTest) /* harmony export */ }); /* harmony import */ var lebab__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lebab */ "./node_modules/lebab/index.js"); // Copyright 2017 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. const payloads = [ { name: "preact-8.2.5.js", options: [ "arg-rest", "arg-spread", "arrow", "class", "for-of", "let", "template", "includes", "obj-method", "obj-shorthand", ], }, ]; function runTest(fileData) { const testData = payloads.map(({ name, options }) => ({ payload: fileData[name], options, })); return testData.map(({ payload, options }) => lebab__WEBPACK_IMPORTED_MODULE_0__.transform(payload, options) ); } })(); self.WTBenchmark = __webpack_exports__; /******/ })() ;