0x104ED], [0x104C6, 0x104EE], [0x104C7, 0x104EF], [0x104C8, 0x104F0], [0x104C9, 0x104F1], [0x104CA, 0x104F2], [0x104CB, 0x104F3], [0x104CC, 0x104F4], [0x104CD, 0x104F5], [0x104CE, 0x104F6], [0x104CF, 0x104F7], [0x104D0, 0x104F8], [0x104D1, 0x104F9], [0x104D2, 0x104FA], [0x104D3, 0x104FB], [0x104D8, 0x104B0], [0x104D9, 0x104B1], [0x104DA, 0x104B2], [0x104DB, 0x104B3], [0x104DC, 0x104B4], [0x104DD, 0x104B5], [0x104DE, 0x104B6], [0x104DF, 0x104B7], [0x104E0, 0x104B8], [0x104E1, 0x104B9], [0x104E2, 0x104BA], [0x104E3, 0x104BB], [0x104E4, 0x104BC], [0x104E5, 0x104BD], [0x104E6, 0x104BE], [0x104E7, 0x104BF], [0x104E8, 0x104C0], [0x104E9, 0x104C1], [0x104EA, 0x104C2], [0x104EB, 0x104C3], [0x104EC, 0x104C4], [0x104ED, 0x104C5], [0x104EE, 0x104C6], [0x104EF, 0x104C7], [0x104F0, 0x104C8], [0x104F1, 0x104C9], [0x104F2, 0x104CA], [0x104F3, 0x104CB], [0x104F4, 0x104CC], [0x104F5, 0x104CD], [0x104F6, 0x104CE], [0x104F7, 0x104CF], [0x104F8, 0x104D0], [0x104F9, 0x104D1], [0x104FA, 0x104D2], [0x104FB, 0x104D3], [0x10C80, 0x10CC0], [0x10C81, 0x10CC1], [0x10C82, 0x10CC2], [0x10C83, 0x10CC3], [0x10C84, 0x10CC4], [0x10C85, 0x10CC5], [0x10C86, 0x10CC6], [0x10C87, 0x10CC7], [0x10C88, 0x10CC8], [0x10C89, 0x10CC9], [0x10C8A, 0x10CCA], [0x10C8B, 0x10CCB], [0x10C8C, 0x10CCC], [0x10C8D, 0x10CCD], [0x10C8E, 0x10CCE], [0x10C8F, 0x10CCF], [0x10C90, 0x10CD0], [0x10C91, 0x10CD1], [0x10C92, 0x10CD2], [0x10C93, 0x10CD3], [0x10C94, 0x10CD4], [0x10C95, 0x10CD5], [0x10C96, 0x10CD6], [0x10C97, 0x10CD7], [0x10C98, 0x10CD8], [0x10C99, 0x10CD9], [0x10C9A, 0x10CDA], [0x10C9B, 0x10CDB], [0x10C9C, 0x10CDC], [0x10C9D, 0x10CDD], [0x10C9E, 0x10CDE], [0x10C9F, 0x10CDF], [0x10CA0, 0x10CE0], [0x10CA1, 0x10CE1], [0x10CA2, 0x10CE2], [0x10CA3, 0x10CE3], [0x10CA4, 0x10CE4], [0x10CA5, 0x10CE5], [0x10CA6, 0x10CE6], [0x10CA7, 0x10CE7], [0x10CA8, 0x10CE8], [0x10CA9, 0x10CE9], [0x10CAA, 0x10CEA], [0x10CAB, 0x10CEB], [0x10CAC, 0x10CEC], [0x10CAD, 0x10CED], [0x10CAE, 0x10CEE], [0x10CAF, 0x10CEF], [0x10CB0, 0x10CF0], [0x10CB1, 0x10CF1], [0x10CB2, 0x10CF2], [0x10CC0, 0x10C80], [0x10CC1, 0x10C81], [0x10CC2, 0x10C82], [0x10CC3, 0x10C83], [0x10CC4, 0x10C84], [0x10CC5, 0x10C85], [0x10CC6, 0x10C86], [0x10CC7, 0x10C87], [0x10CC8, 0x10C88], [0x10CC9, 0x10C89], [0x10CCA, 0x10C8A], [0x10CCB, 0x10C8B], [0x10CCC, 0x10C8C], [0x10CCD, 0x10C8D], [0x10CCE, 0x10C8E], [0x10CCF, 0x10C8F], [0x10CD0, 0x10C90], [0x10CD1, 0x10C91], [0x10CD2, 0x10C92], [0x10CD3, 0x10C93], [0x10CD4, 0x10C94], [0x10CD5, 0x10C95], [0x10CD6, 0x10C96], [0x10CD7, 0x10C97], [0x10CD8, 0x10C98], [0x10CD9, 0x10C99], [0x10CDA, 0x10C9A], [0x10CDB, 0x10C9B], [0x10CDC, 0x10C9C], [0x10CDD, 0x10C9D], [0x10CDE, 0x10C9E], [0x10CDF, 0x10C9F], [0x10CE0, 0x10CA0], [0x10CE1, 0x10CA1], [0x10CE2, 0x10CA2], [0x10CE3, 0x10CA3], [0x10CE4, 0x10CA4], [0x10CE5, 0x10CA5], [0x10CE6, 0x10CA6], [0x10CE7, 0x10CA7], [0x10CE8, 0x10CA8], [0x10CE9, 0x10CA9], [0x10CEA, 0x10CAA], [0x10CEB, 0x10CAB], [0x10CEC, 0x10CAC], [0x10CED, 0x10CAD], [0x10CEE, 0x10CAE], [0x10CEF, 0x10CAF], [0x10CF0, 0x10CB0], [0x10CF1, 0x10CB1], [0x10CF2, 0x10CB2], [0x118A0, 0x118C0], [0x118A1, 0x118C1], [0x118A2, 0x118C2], [0x118A3, 0x118C3], [0x118A4, 0x118C4], [0x118A5, 0x118C5], [0x118A6, 0x118C6], [0x118A7, 0x118C7], [0x118A8, 0x118C8], [0x118A9, 0x118C9], [0x118AA, 0x118CA], [0x118AB, 0x118CB], [0x118AC, 0x118CC], [0x118AD, 0x118CD], [0x118AE, 0x118CE], [0x118AF, 0x118CF], [0x118B0, 0x118D0], [0x118B1, 0x118D1], [0x118B2, 0x118D2], [0x118B3, 0x118D3], [0x118B4, 0x118D4], [0x118B5, 0x118D5], [0x118B6, 0x118D6], [0x118B7, 0x118D7], [0x118B8, 0x118D8], [0x118B9, 0x118D9], [0x118BA, 0x118DA], [0x118BB, 0x118DB], [0x118BC, 0x118DC], [0x118BD, 0x118DD], [0x118BE, 0x118DE], [0x118BF, 0x118DF], [0x118C0, 0x118A0], [0x118C1, 0x118A1], [0x118C2, 0x118A2], [0x118C3, 0x118A3], [0x118C4, 0x118A4], [0x118C5, 0x118A5], [0x118C6, 0x118A6], [0x118C7, 0x118A7], [0x118C8, 0x118A8], [0x118C9, 0x118A9], [0x118CA, 0x118AA], [0x118CB, 0x118AB], [0x118CC, 0x118AC], [0x118CD, 0x118AD], [0x118CE, 0x118AE], [0x118CF, 0x118AF], [0x118D0, 0x118B0], [0x118D1, 0x118B1], [0x118D2, 0x118B2], [0x118D3, 0x118B3], [0x118D4, 0x118B4], [0x118D5, 0x118B5], [0x118D6, 0x118B6], [0x118D7, 0x118B7], [0x118D8, 0x118B8], [0x118D9, 0x118B9], [0x118DA, 0x118BA], [0x118DB, 0x118BB], [0x118DC, 0x118BC], [0x118DD, 0x118BD], [0x118DE, 0x118BE], [0x118DF, 0x118BF], [0x1E900, 0x1E922], [0x1E901, 0x1E923], [0x1E902, 0x1E924], [0x1E903, 0x1E925], [0x1E904, 0x1E926], [0x1E905, 0x1E927], [0x1E906, 0x1E928], [0x1E907, 0x1E929], [0x1E908, 0x1E92A], [0x1E909, 0x1E92B], [0x1E90A, 0x1E92C], [0x1E90B, 0x1E92D], [0x1E90C, 0x1E92E], [0x1E90D, 0x1E92F], [0x1E90E, 0x1E930], [0x1E90F, 0x1E931], [0x1E910, 0x1E932], [0x1E911, 0x1E933], [0x1E912, 0x1E934], [0x1E913, 0x1E935], [0x1E914, 0x1E936], [0x1E915, 0x1E937], [0x1E916, 0x1E938], [0x1E917, 0x1E939], [0x1E918, 0x1E93A], [0x1E919, 0x1E93B], [0x1E91A, 0x1E93C], [0x1E91B, 0x1E93D], [0x1E91C, 0x1E93E], [0x1E91D, 0x1E93F], [0x1E91E, 0x1E940], [0x1E91F, 0x1E941], [0x1E920, 0x1E942], [0x1E921, 0x1E943], [0x1E922, 0x1E900], [0x1E923, 0x1E901], [0x1E924, 0x1E902], [0x1E925, 0x1E903], [0x1E926, 0x1E904], [0x1E927, 0x1E905], [0x1E928, 0x1E906], [0x1E929, 0x1E907], [0x1E92A, 0x1E908], [0x1E92B, 0x1E909], [0x1E92C, 0x1E90A], [0x1E92D, 0x1E90B], [0x1E92E, 0x1E90C], [0x1E92F, 0x1E90D], [0x1E930, 0x1E90E], [0x1E931, 0x1E90F], [0x1E932, 0x1E910], [0x1E933, 0x1E911], [0x1E934, 0x1E912], [0x1E935, 0x1E913], [0x1E936, 0x1E914], [0x1E937, 0x1E915], [0x1E938, 0x1E916], [0x1E939, 0x1E917], [0x1E93A, 0x1E918], [0x1E93B, 0x1E919], [0x1E93C, 0x1E91A], [0x1E93D, 0x1E91B], [0x1E93E, 0x1E91C], [0x1E93F, 0x1E91D], [0x1E940, 0x1E91E], [0x1E941, 0x1E91F], [0x1E942, 0x1E920], [0x1E943, 0x1E921] ]); // Generated using `npm run build`. Do not edit. 'use strict'; var REGULAR = new Map([ ['d', regenerate() .addRange(0x30, 0x39)], ['D', regenerate() .addRange(0x0, 0x2F) .addRange(0x3A, 0xFFFF)], ['s', regenerate(0x20, 0xA0, 0x1680, 0x202F, 0x205F, 0x3000, 0xFEFF) .addRange(0x9, 0xD) .addRange(0x2000, 0x200A) .addRange(0x2028, 0x2029)], ['S', regenerate() .addRange(0x0, 0x8) .addRange(0xE, 0x1F) .addRange(0x21, 0x9F) .addRange(0xA1, 0x167F) .addRange(0x1681, 0x1FFF) .addRange(0x200B, 0x2027) .addRange(0x202A, 0x202E) .addRange(0x2030, 0x205E) .addRange(0x2060, 0x2FFF) .addRange(0x3001, 0xFEFE) .addRange(0xFF00, 0xFFFF)], ['w', regenerate(0x5F) .addRange(0x30, 0x39) .addRange(0x41, 0x5A) .addRange(0x61, 0x7A)], ['W', regenerate(0x60) .addRange(0x0, 0x2F) .addRange(0x3A, 0x40) .addRange(0x5B, 0x5E) .addRange(0x7B, 0xFFFF)] ]); var UNICODE = new Map([ ['d', regenerate() .addRange(0x30, 0x39)], ['D', regenerate() .addRange(0x0, 0x2F) .addRange(0x3A, 0x10FFFF)], ['s', regenerate(0x20, 0xA0, 0x1680, 0x202F, 0x205F, 0x3000, 0xFEFF) .addRange(0x9, 0xD) .addRange(0x2000, 0x200A) .addRange(0x2028, 0x2029)], ['S', regenerate() .addRange(0x0, 0x8) .addRange(0xE, 0x1F) .addRange(0x21, 0x9F) .addRange(0xA1, 0x167F) .addRange(0x1681, 0x1FFF) .addRange(0x200B, 0x2027) .addRange(0x202A, 0x202E) .addRange(0x2030, 0x205E) .addRange(0x2060, 0x2FFF) .addRange(0x3001, 0xFEFE) .addRange(0xFF00, 0x10FFFF)], ['w', regenerate(0x5F) .addRange(0x30, 0x39) .addRange(0x41, 0x5A) .addRange(0x61, 0x7A)], ['W', regenerate(0x60) .addRange(0x0, 0x2F) .addRange(0x3A, 0x40) .addRange(0x5B, 0x5E) .addRange(0x7B, 0x10FFFF)] ]); var UNICODE_IGNORE_CASE = new Map([ ['d', regenerate() .addRange(0x30, 0x39)], ['D', regenerate() .addRange(0x0, 0x2F) .addRange(0x3A, 0x10FFFF)], ['s', regenerate(0x20, 0xA0, 0x1680, 0x202F, 0x205F, 0x3000, 0xFEFF) .addRange(0x9, 0xD) .addRange(0x2000, 0x200A) .addRange(0x2028, 0x2029)], ['S', regenerate() .addRange(0x0, 0x8) .addRange(0xE, 0x1F) .addRange(0x21, 0x9F) .addRange(0xA1, 0x167F) .addRange(0x1681, 0x1FFF) .addRange(0x200B, 0x2027) .addRange(0x202A, 0x202E) .addRange(0x2030, 0x205E) .addRange(0x2060, 0x2FFF) .addRange(0x3001, 0xFEFE) .addRange(0xFF00, 0x10FFFF)], ['w', regenerate(0x5F, 0x17F, 0x212A) .addRange(0x30, 0x39) .addRange(0x41, 0x5A) .addRange(0x61, 0x7A)], ['W', regenerate(0x60) .addRange(0x0, 0x2F) .addRange(0x3A, 0x40) .addRange(0x5B, 0x5E) .addRange(0x7B, 0x17E) .addRange(0x180, 0x2129) .addRange(0x212B, 0x10FFFF)] ]); var characterClassEscapeSets = { REGULAR: REGULAR, UNICODE: UNICODE, UNICODE_IGNORE_CASE: UNICODE_IGNORE_CASE }; var rewritePattern_1 = createCommonjsModule(function (module) { 'use strict'; var generate = regjsgen.generate; var parse = parser.parse; // Prepare a Regenerate set containing all code points, used for negative // character classes (if any). var UNICODE_SET = regenerate().addRange(0x0, 0x10FFFF); // Without the `u` flag, the range stops at 0xFFFF. // https://mths.be/es6#sec-pattern-semantics var BMP_SET = regenerate().addRange(0x0, 0xFFFF); // Prepare a Regenerate set containing all code points that are supposed to be // matched by `/./u`. https://mths.be/es6#sec-atom var DOT_SET_UNICODE = UNICODE_SET.clone() // all Unicode code points .remove( // minus `LineTerminator`s (https://mths.be/es6#sec-line-terminators): 0x000A, // Line Feed <LF> 0x000D, // Carriage Return <CR> 0x2028, // Line Separator <LS> 0x2029 // Paragraph Separator <PS> ); // Prepare a Regenerate set containing all code points that are supposed to be // matched by `/./` (only BMP code points). var DOT_SET = DOT_SET_UNICODE.clone() .intersection(BMP_SET); var getCharacterClassEscapeSet = function (character, unicode, ignoreCase) { if (unicode) { if (ignoreCase) { return characterClassEscapeSets.UNICODE_IGNORE_CASE.get(character); } return characterClassEscapeSets.UNICODE.get(character); } return characterClassEscapeSets.REGULAR.get(character); }; var getDotSet = function (unicode, dotAll) { if (dotAll) { return unicode ? UNICODE_SET : BMP_SET; } return unicode ? DOT_SET_UNICODE : DOT_SET; }; var getUnicodePropertyValueSet = function (property, value) { var path = value ? (property + "/" + value) : ("Binary_Property/" + property); try { return commonjsRequire(("regenerate-unicode-properties/" + path + ".js")); } catch (exception) { throw new Error( "Failed to recognize value `" + value + "` for property " + "`" + property + "`." ); } }; var handleLoneUnicodePropertyNameOrValue = function (value) { // It could be a `General_Category` value or a binary property. // Note: `unicodeMatchPropertyValue` throws on invalid values. try { var property$1 = 'General_Category'; var category = unicodeMatchPropertyValueEcmascript(property$1, value); return getUnicodePropertyValueSet(property$1, category); } catch (exception) {} // It’s not a `General_Category` value, so check if it’s a binary // property. Note: `unicodeMatchProperty` throws on invalid properties. var property = unicodeMatchPropertyEcmascript(value); return getUnicodePropertyValueSet(property); }; var getUnicodePropertyEscapeSet = function (value, isNegative) { var parts = value.split('='); var firstPart = parts[0]; var set; if (parts.length == 1) { set = handleLoneUnicodePropertyNameOrValue(firstPart); } else { // The pattern consists of two parts, i.e. `Property=Value`. var property = unicodeMatchPropertyEcmascript(firstPart); var value$1 = unicodeMatchPropertyValueEcmascript(property, parts[1]); set = getUnicodePropertyValueSet(property, value$1); } if (isNegative) { return UNICODE_SET.clone().remove(set); } return set.clone(); }; // Given a range of code points, add any case-folded code points in that range // to a set. regenerate.prototype.iuAddRange = function(min, max) { var $this = this; do { var folded = caseFold(min); if (folded) { $this.add(folded); } } while (++min <= max); return $this; }; var update = function (item, pattern) { var tree = parse(pattern, config.useUnicodeFlag ? 'u' : ''); switch (tree.type) { case 'characterClass': case 'group': case 'value': // No wrapping needed. break; default: // Wrap the pattern in a non-capturing group. tree = wrap(tree, pattern); } Object.assign(item, tree); }; var wrap = function (tree, pattern) { // Wrap the pattern in a non-capturing group. return { 'type': 'group', 'behavior': 'ignore', 'body': [tree], 'raw': ("(?:" + pattern + ")") }; }; var caseFold = function (codePoint) { return iuMappings.get(codePoint) || false; }; var processCharacterClass = function (characterClassItem, regenerateOptions) { var set = regenerate(); for (var i = 0, list = characterClassItem.body; i < list.length; i += 1) { var item = list[i]; switch (item.type) { case 'value': set.add(item.codePoint); if (config.ignoreCase && config.unicode && !config.useUnicodeFlag) { var folded = caseFold(item.codePoint); if (folded) { set.add(folded); } } break; case 'characterClassRange': var min = item.min.codePoint; var max = item.max.codePoint; set.addRange(min, max); if (config.ignoreCase && config.unicode && !config.useUnicodeFlag) { set.iuAddRange(min, max); } break; case 'characterClassEscape': set.add(getCharacterClassEscapeSet( item.value, config.unicode, config.ignoreCase )); break; case 'unicodePropertyEscape': set.add(getUnicodePropertyEscapeSet(item.value, item.negative)); break; // The `default` clause is only here as a safeguard; it should never be // reached. Code coverage tools should ignore it. /* istanbul ignore next */ default: throw new Error(("Unknown term type: " + (item.type))); } } if (characterClassItem.negative) { set = (config.unicode ? UNICODE_SET : BMP_SET).clone().remove(set); } update(characterClassItem, set.toString(regenerateOptions)); return characterClassItem; }; var processTerm = function (item, regenerateOptions) { switch (item.type) { case 'dot': update( item, getDotSet(config.unicode, config.dotAll).toString(regenerateOptions) ); break; case 'characterClass': item = processCharacterClass(item, regenerateOptions); break; case 'unicodePropertyEscape': update( item, getUnicodePropertyEscapeSet(item.value, item.negative) .toString(regenerateOptions) ); break; case 'characterClassEscape': update( item, getCharacterClassEscapeSet( item.value, config.unicode, config.ignoreCase ).toString(regenerateOptions) ); break; case 'alternative': case 'disjunction': case 'group': case 'quantifier': item.body = item.body.map(function ( term ) { return processTerm(term, regenerateOptions); }); break; case 'value': var codePoint = item.codePoint; var set = regenerate(codePoint); if (config.ignoreCase && config.unicode && !config.useUnicodeFlag) { var folded = caseFold(codePoint); if (folded) { set.add(folded); } } update(item, set.toString(regenerateOptions)); break; case 'anchor': case 'empty': case 'group': case 'reference': // Nothing to do here. break; // The `default` clause is only here as a safeguard; it should never be // reached. Code coverage tools should ignore it. /* istanbul ignore next */ default: throw new Error(("Unknown term type: " + (item.type))); } return item; }; var config = { 'ignoreCase': false, 'unicode': false, 'dotAll': false, 'useUnicodeFlag': false }; var rewritePattern = function (pattern, flags, options) { var regjsparserFeatures = { 'unicodePropertyEscape': options && options.unicodePropertyEscape }; config.ignoreCase = flags && flags.includes('i'); config.unicode = flags && flags.includes('u'); var supportDotAllFlag = options && options.dotAllFlag; config.dotAll = supportDotAllFlag && flags && flags.includes('s'); config.useUnicodeFlag = options && options.useUnicodeFlag; var regenerateOptions = { 'hasUnicodeFlag': config.useUnicodeFlag, 'bmpOnly': !config.unicode }; var tree = parse(pattern, flags, regjsparserFeatures); // Note: `processTerm` mutates `tree`. processTerm(tree, regenerateOptions); return generate(tree); }; module.exports = rewritePattern; }); var Literal = (function (Node) { function Literal () { Node.apply(this, arguments); } if ( Node ) Literal.__proto__ = Node; Literal.prototype = Object.create( Node && Node.prototype ); Literal.prototype.constructor = Literal; Literal.prototype.initialise = function initialise () { if ( typeof this.value === 'string' ) { this.program.indentExclusionElements.push( this ); } }; Literal.prototype.transpile = function transpile ( code, transforms ) { if ( transforms.numericLiteral ) { var leading = this.raw.slice( 0, 2 ); if ( leading === '0b' || leading === '0o' ) { code.overwrite( this.start, this.end, String( this.value ), true ); } } if ( this.regex ) { var ref = this.regex; var pattern = ref.pattern; var flags = ref.flags; if ( transforms.stickyRegExp && /y/.test( flags ) ) throw new CompileError( this, 'Regular expression sticky flag is not supported' ); if ( transforms.unicodeRegExp && /u/.test( flags ) ) { code.overwrite( this.start, this.end, ("/" + (rewritePattern_1( pattern, flags )) + "/" + (flags.replace( 'u', '' ))) ); } } }; return Literal; }(Node$1)); var MemberExpression = (function (Node) { function MemberExpression () { Node.apply(this, arguments); } if ( Node ) MemberExpression.__proto__ = Node; MemberExpression.prototype = Object.create( Node && Node.prototype ); MemberExpression.prototype.constructor = MemberExpression; MemberExpression.prototype.transpile = function transpile ( code, transforms ) { if ( transforms.reservedProperties && reserved[ this.property.name ] ) { code.overwrite( this.object.end, this.property.start, "['" ); code.insertLeft( this.property.end, "']" ); } Node.prototype.transpile.call( this, code, transforms ); }; return MemberExpression; }(Node$1)); var NewExpression = (function (Node) { function NewExpression () { Node.apply(this, arguments); } if ( Node ) NewExpression.__proto__ = Node; NewExpression.prototype = Object.create( Node && Node.prototype ); NewExpression.prototype.constructor = NewExpression; NewExpression.prototype.initialise = function initialise ( transforms ) { var this$1 = this; if ( transforms.spreadRest && this.arguments.length ) { var lexicalBoundary = this.findLexicalBoundary(); var i = this.arguments.length; while ( i-- ) { var arg = this$1.arguments[i]; if ( arg.type === 'SpreadElement' && isArguments( arg.argument ) ) { this$1.argumentsArrayAlias = lexicalBoundary.getArgumentsArrayAlias(); break; } } } Node.prototype.initialise.call( this, transforms ); }; NewExpression.prototype.transpile = function transpile ( code, transforms ) { if ( transforms.spreadRest && this.arguments.length ) { var firstArgument = this.arguments[0]; var isNew = true; var hasSpreadElements = spread( code, this.arguments, firstArgument.start, this.argumentsArrayAlias, isNew ); if ( hasSpreadElements ) { code.insertRight( this.start + 'new'.length, ' (Function.prototype.bind.apply(' ); code.overwrite( this.callee.end, firstArgument.start, ', [ null ].concat( ' ); code.insertLeft( this.end, ' ))' ); } } Node.prototype.transpile.call( this, code, transforms ); }; return NewExpression; }(Node$1)); var ObjectExpression = (function (Node) { function ObjectExpression () { Node.apply(this, arguments); } if ( Node ) ObjectExpression.__proto__ = Node; ObjectExpression.prototype = Object.create( Node && Node.prototype ); ObjectExpression.prototype.constructor = ObjectExpression; ObjectExpression.prototype.transpile = function transpile ( code, transforms ) { var this$1 = this; Node.prototype.transpile.call( this, code, transforms ); var firstPropertyStart = this.start + 1; var regularPropertyCount = 0; var spreadPropertyCount = 0; var computedPropertyCount = 0; for ( var i$2 = 0, list = this.properties; i$2 < list.length; i$2 += 1 ) { var prop = list[i$2]; if ( prop.type === 'SpreadProperty' ) { spreadPropertyCount += 1; } else if ( prop.computed ) { computedPropertyCount += 1; } else if ( prop.type === 'Property' ) { regularPropertyCount += 1; } } if ( spreadPropertyCount ) { if ( !this.program.options.objectAssign ) { throw new CompileError( this, 'Object spread operator requires specified objectAssign option with \'Object.assign\' or polyfill helper.' ); } // enclose run of non-spread properties in curlies var i = this.properties.length; if ( regularPropertyCount ) { while ( i-- ) { var prop$1 = this$1.properties[i]; if ( prop$1.type === 'Property' && !prop$1.computed ) { var lastProp = this$1.properties[ i - 1 ]; var nextProp = this$1.properties[ i + 1 ]; if ( !lastProp || lastProp.type !== 'Property' || lastProp.computed ) { code.insertRight( prop$1.start, '{' ); } if ( !nextProp || nextProp.type !== 'Property' || nextProp.computed ) { code.insertLeft( prop$1.end, '}' ); } } } } // wrap the whole thing in Object.assign firstPropertyStart = this.properties[0].start; code.overwrite( this.start, firstPropertyStart, ((this.program.options.objectAssign) + "({}, ")); code.overwrite( this.properties[ this.properties.length - 1 ].end, this.end, ')' ); } if ( computedPropertyCount && transforms.computedProperty ) { var i0 = this.getIndentation(); var isSimpleAssignment; var name; if ( this.parent.type === 'VariableDeclarator' && this.parent.parent.declarations.length === 1 ) { isSimpleAssignment = true; name = this.parent.id.alias || this.parent.id.name; // TODO is this right? } else if ( this.parent.type === 'AssignmentExpression' && this.parent.parent.type === 'ExpressionStatement' && this.parent.left.type === 'Identifier' ) { isSimpleAssignment = true; name = this.parent.left.alias || this.parent.left.name; // TODO is this right? } else if ( this.parent.type === 'AssignmentPattern' && this.parent.left.type === 'Identifier' ) { isSimpleAssignment = true; name = this.parent.left.alias || this.parent.left.name; // TODO is this right? } // handle block scoping var declaration = this.findScope( false ).findDeclaration( name ); if ( declaration ) name = declaration.name; var start = firstPropertyStart; var end = this.end; if ( isSimpleAssignment ) { // ??? } else { name = this.findScope( true ).createIdentifier( '_obj' ); var statement = this.findNearest( /(?:Statement|Declaration)$/ ); code.insertLeft( statement.end, ("\n" + i0 + "var " + name + ";") ); code.insertRight( this.start, ("( " + name + " = ") ); } var len = this.properties.length; var lastComputedProp; var sawNonComputedProperty = false; for ( var i$1 = 0; i$1 < len; i$1 += 1 ) { var prop$2 = this$1.properties[i$1]; if ( prop$2.computed ) { lastComputedProp = prop$2; var moveStart = i$1 > 0 ? this$1.properties[ i$1 - 1 ].end : start; var propId = isSimpleAssignment ? (";\n" + i0 + name) : (", " + name); if (moveStart < prop$2.start) { code.overwrite( moveStart, prop$2.start, propId ); } else { code.insertRight( prop$2.start, propId ); } var c = prop$2.key.end; while ( code.original[c] !== ']' ) c += 1; c += 1; if ( prop$2.value.start > c ) code.remove( c, prop$2.value.start ); code.insertLeft( c, ' = ' ); code.move( moveStart, prop$2.end, end ); if ( i$1 < len - 1 && ! sawNonComputedProperty ) { // remove trailing comma c = prop$2.end; while ( code.original[c] !== ',' ) c += 1; code.remove( prop$2.end, c + 1 ); } if ( prop$2.method && transforms.conciseMethodProperty ) { code.insertRight( prop$2.value.start, 'function ' ); } } else { sawNonComputedProperty = true; } } // special case if ( computedPropertyCount === len ) { code.remove( this.properties[ len - 1 ].end, this.end - 1 ); } if ( !isSimpleAssignment ) { code.insertLeft( lastComputedProp.end, (", " + name + " )") ); } } }; return ObjectExpression; }(Node$1)); var Property = (function (Node) { function Property () { Node.apply(this, arguments); } if ( Node ) Property.__proto__ = Node; Property.prototype = Object.create( Node && Node.prototype ); Property.prototype.constructor = Property; Property.prototype.transpile = function transpile ( code, transforms ) { if ( transforms.conciseMethodProperty && !this.computed && this.parent.type !== 'ObjectPattern' ) { if ( this.shorthand ) { code.insertRight( this.start, ((this.key.name) + ": " + (this.shouldPrefix() ? '_vm.' : '')) ); } else if ( this.method ) { var name = ''; if ( this.program.options.namedFunctionExpressions !== false ) { if ( this.key.type === 'Literal' && typeof this.key.value === 'number' ) { name = ""; } else if ( this.key.type === 'Identifier' ) { if ( reserved[ this.key.name ] || ! /^[a-z_$][a-z0-9_$]*$/i.test( this.key.name ) || this.value.body.scope.references[this.key.name] ) { name = this.findScope( true ).createIdentifier( this.key.name ); } else { name = this.key.name; } } else { name = this.findScope( true ).createIdentifier( this.key.value ); } name = ' ' + name; } if ( this.value.generator ) code.remove( this.start, this.key.start ); code.insertLeft( this.key.end, (": function" + (this.value.generator ? '*' : '') + name) ); } } if ( transforms.reservedProperties && reserved[ this.key.name ] ) { code.insertRight( this.key.start, "'" ); code.insertLeft( this.key.end, "'" ); } Node.prototype.transpile.call( this, code, transforms ); }; Property.prototype.shouldPrefix = function shouldPrefix () { if ( this.program.inWith > 0 && !hash[this.key.name] && !this.findScope(false).contains(this.key.name) ) { return true } return false }; return Property; }(Node$1)); var ReturnStatement = (function (Node) { function ReturnStatement () { Node.apply(this, arguments); } if ( Node ) ReturnStatement.__proto__ = Node; ReturnStatement.prototype = Object.create( Node && Node.prototype ); ReturnStatement.prototype.constructor = ReturnStatement; ReturnStatement.prototype.initialise = function initialise ( transforms ) { this.loop = this.findNearest( loopStatement ); this.nearestFunction = this.findNearest( /Function/ ); if ( this.loop && ( !this.nearestFunction || this.loop.depth > this.nearestFunction.depth ) ) { this.loop.canReturn = true; this.shouldWrap = true; } if ( this.argument ) this.argument.initialise( transforms ); }; ReturnStatement.prototype.transpile = function transpile ( code, transforms ) { var shouldWrap = this.shouldWrap && this.loop && this.loop.shouldRewriteAsFunction; if ( this.argument ) { if ( shouldWrap ) code.insertRight( this.argument.start, "{ v: " ); this.argument.transpile( code, transforms ); if ( shouldWrap ) code.insertLeft( this.argument.end, " }" ); } else if ( shouldWrap ) { code.insertLeft( this.start + 6, ' {}' ); } }; return ReturnStatement; }(Node$1)); var SpreadProperty = (function (Node) { function SpreadProperty () { Node.apply(this, arguments); } if ( Node ) SpreadProperty.__proto__ = Node; SpreadProperty.prototype = Object.create( Node && Node.prototype ); SpreadProperty.prototype.constructor = SpreadProperty; SpreadProperty.prototype.transpile = function transpile ( code, transforms ) { code.remove( this.start, this.argument.start ); code.remove( this.argument.end, this.end ); Node.prototype.transpile.call( this, code, transforms ); }; return SpreadProperty; }(Node$1)); var Super = (function (Node) { function Super () { Node.apply(this, arguments); } if ( Node ) Super.__proto__ = Node; Super.prototype = Object.create( Node && Node.prototype ); Super.prototype.constructor = Super; Super.prototype.initialise = function initialise ( transforms ) { if ( transforms.classes ) { this.method = this.findNearest( 'MethodDefinition' ); if ( !this.method ) throw new CompileError( this, 'use of super outside class method' ); var parentClass = this.findNearest( 'ClassBody' ).parent; this.superClassName = parentClass.superClass && (parentClass.superClass.name || 'superclass'); if ( !this.superClassName ) throw new CompileError( this, 'super used in base class' ); this.isCalled = this.parent.type === 'CallExpression' && this === this.parent.callee; if ( this.method.kind !== 'constructor' && this.isCalled ) { throw new CompileError( this, 'super() not allowed outside class constructor' ); } this.isMember = this.parent.type === 'MemberExpression'; if ( !this.isCalled && !this.isMember ) { throw new CompileError( this, 'Unexpected use of `super` (expected `super(...)` or `super.*`)' ); } } if ( transforms.arrow ) { var lexicalBoundary = this.findLexicalBoundary(); var arrowFunction = this.findNearest( 'ArrowFunctionExpression' ); var loop = this.findNearest( loopStatement ); if ( arrowFunction && arrowFunction.depth > lexicalBoundary.depth ) { this.thisAlias = lexicalBoundary.getThisAlias(); } if ( loop && loop.body.contains( this ) && loop.depth > lexicalBoundary.depth ) { this.thisAlias = lexicalBoundary.getThisAlias(); } } }; Super.prototype.transpile = function transpile ( code, transforms ) { if ( transforms.classes ) { var expression = ( this.isCalled || this.method.static ) ? this.superClassName : ((this.superClassName) + ".prototype"); code.overwrite( this.start, this.end, expression, true ); var callExpression = this.isCalled ? this.parent : this.parent.parent; if ( callExpression && callExpression.type === 'CallExpression' ) { if ( !this.noCall ) { // special case – `super( ...args )` code.insertLeft( callExpression.callee.end, '.call' ); } var thisAlias = this.thisAlias || 'this'; if ( callExpression.arguments.length ) { code.insertLeft( callExpression.arguments[0].start, (thisAlias + ", ") ); } else { code.insertLeft( callExpression.end - 1, ("" + thisAlias) ); } } } }; return Super; }(Node$1)); var TaggedTemplateExpression = (function (Node) { function TaggedTemplateExpression () { Node.apply(this, arguments); } if ( Node ) TaggedTemplateExpression.__proto__ = Node; TaggedTemplateExpression.prototype = Object.create( Node && Node.prototype ); TaggedTemplateExpression.prototype.constructor = TaggedTemplateExpression; TaggedTemplateExpression.prototype.initialise = function initialise ( transforms ) { if ( transforms.templateString && !transforms.dangerousTaggedTemplateString ) { throw new CompileError( this, 'Tagged template strings are not supported. Use `transforms: { templateString: false }` to skip transformation and disable this error, or `transforms: { dangerousTaggedTemplateString: true }` if you know what you\'re doing' ); } Node.prototype.initialise.call( this, transforms ); }; TaggedTemplateExpression.prototype.transpile = function transpile ( code, transforms ) { if ( transforms.templateString && transforms.dangerousTaggedTemplateString ) { var ordered = this.quasi.expressions.concat( this.quasi.quasis ).sort( function ( a, b ) { return a.start - b.start; } ); // insert strings at start var templateStrings = this.quasi.quasis.map( function ( quasi ) { return JSON.stringify( quasi.value.cooked ); } ); code.overwrite( this.tag.end, ordered[0].start, ("([" + (templateStrings.join(', ')) + "]") ); var lastIndex = ordered[0].start; ordered.forEach( function ( node ) { if ( node.type === 'TemplateElement' ) { code.remove( lastIndex, node.end ); } else { code.overwrite( lastIndex, node.start, ', ' ); } lastIndex = node.end; }); code.overwrite( lastIndex, this.end, ')' ); } Node.prototype.transpile.call( this, code, transforms ); }; return TaggedTemplateExpression; }(Node$1)); var TemplateElement = (function (Node) { function TemplateElement () { Node.apply(this, arguments); } if ( Node ) TemplateElement.__proto__ = Node; TemplateElement.prototype = Object.create( Node && Node.prototype ); TemplateElement.prototype.constructor = TemplateElement; TemplateElement.prototype.initialise = function initialise () { this.program.indentExclusionElements.push( this ); }; return TemplateElement; }(Node$1)); var TemplateLiteral = (function (Node) { function TemplateLiteral () { Node.apply(this, arguments); } if ( Node ) TemplateLiteral.__proto__ = Node; TemplateLiteral.prototype = Object.create( Node && Node.prototype ); TemplateLiteral.prototype.constructor = TemplateLiteral; TemplateLiteral.prototype.transpile = function transpile ( code, transforms ) { if ( transforms.templateString && this.parent.type !== 'TaggedTemplateExpression' ) { var ordered = this.expressions.concat( this.quasis ) .sort( function ( a, b ) { return a.start - b.start || a.end - b.end; } ) .filter( function ( node, i ) { // include all expressions if ( node.type !== 'TemplateElement' ) return true; // include all non-empty strings if ( node.value.raw ) return true; // exclude all empty strings not at the head return !i; }); // special case – we may be able to skip the first element, // if it's the empty string, but only if the second and // third elements aren't both expressions (since they maybe // be numeric, and `1 + 2 + '3' === '33'`) if ( ordered.length >= 3 ) { var first = ordered[0]; var third = ordered[2]; if ( first.type === 'TemplateElement' && first.value.raw === '' && third.type === 'TemplateElement' ) { ordered.shift(); } } var parenthesise = ( this.quasis.length !== 1 || this.expressions.length !== 0 ) && this.parent.type !== 'AssignmentExpression' && this.parent.type !== 'AssignmentPattern' && this.parent.type !== 'VariableDeclarator' && ( this.parent.type !== 'BinaryExpression' || this.parent.operator !== '+' ); if ( parenthesise ) code.insertRight( this.start, '(' ); var lastIndex = this.start; ordered.forEach( function ( node, i ) { if ( node.type === 'TemplateElement' ) { var replacement = ''; if ( i ) replacement += ' + '; replacement += JSON.stringify( node.value.cooked ); code.overwrite( lastIndex, node.end, replacement ); } else { var parenthesise = node.type !== 'Identifier'; // TODO other cases where it's safe var replacement$1 = ''; if ( i ) replacement$1 += ' + '; if ( parenthesise ) replacement$1 += '('; code.overwrite( lastIndex, node.start, replacement$1 ); if ( parenthesise ) code.insertLeft( node.end, ')' ); } lastIndex = node.end; }); var close = ''; if ( parenthesise ) close += ')'; code.overwrite( lastIndex, this.end, close ); } Node.prototype.transpile.call( this, code, transforms ); }; return TemplateLiteral; }(Node$1)); var ThisExpression = (function (Node) { function ThisExpression () { Node.apply(this, arguments); } if ( Node ) ThisExpression.__proto__ = Node; ThisExpression.prototype = Object.create( Node && Node.prototype ); ThisExpression.prototype.constructor = ThisExpression; ThisExpression.prototype.initialise = function initialise ( transforms ) { if ( transforms.arrow ) { var lexicalBoundary = this.findLexicalBoundary(); var arrowFunction = this.findNearest( 'ArrowFunctionExpression' ); var loop = this.findNearest( loopStatement ); if ( ( arrowFunction && arrowFunction.depth > lexicalBoundary.depth ) || ( loop && loop.body.contains( this ) && loop.depth > lexicalBoundary.depth ) || ( loop && loop.right && loop.right.contains( this ) ) ) { this.alias = lexicalBoundary.getThisAlias(); } } }; ThisExpression.prototype.transpile = function transpile ( code ) { if ( this.alias ) { code.overwrite( this.start, this.end, this.alias, true ); } }; return ThisExpression; }(Node$1)); var UpdateExpression = (function (Node) { function UpdateExpression () { Node.apply(this, arguments); } if ( Node ) UpdateExpression.__proto__ = Node; UpdateExpression.prototype = Object.create( Node && Node.prototype ); UpdateExpression.prototype.constructor = UpdateExpression; UpdateExpression.prototype.initialise = function initialise ( transforms ) { if ( this.argument.type === 'Identifier' ) { var declaration = this.findScope( false ).findDeclaration( this.argument.name ); if ( declaration && declaration.kind === 'const' ) { throw new CompileError( this, ((this.argument.name) + " is read-only") ); } // special case – https://gitlab.com/Rich-Harris/buble/issues/150 var statement = declaration && declaration.node.ancestor( 3 ); if ( statement && statement.type === 'ForStatement' && statement.body.contains( this ) ) { statement.reassigned[ this.argument.name ] = true; } } Node.prototype.initialise.call( this, transforms ); }; return UpdateExpression; }(Node$1)); var VariableDeclaration = (function (Node) { function VariableDeclaration () { Node.apply(this, arguments); } if ( Node ) VariableDeclaration.__proto__ = Node; VariableDeclaration.prototype = Object.create( Node && Node.prototype ); VariableDeclaration.prototype.constructor = VariableDeclaration; VariableDeclaration.prototype.initialise = function initialise ( transforms ) { this.scope = this.findScope( this.kind === 'var' ); this.declarations.forEach( function ( declarator ) { return declarator.initialise( transforms ); } ); }; VariableDeclaration.prototype.transpile = function transpile ( code, transforms ) { var this$1 = this; var i0 = this.getIndentation(); var kind = this.kind; if ( transforms.letConst && kind !== 'var' ) { kind = 'var'; code.overwrite( this.start, this.start + this.kind.length, kind, true ); } if ( transforms.destructuring && this.parent.type !== 'ForOfStatement' ) { var c = this.start; var lastDeclaratorIsPattern; this.declarations.forEach( function ( declarator, i ) { if ( declarator.id.type === 'Identifier' ) { if ( i > 0 && this$1.declarations[ i - 1 ].id.type !== 'Identifier' ) { code.overwrite( c, declarator.id.start, "var " ); } } else { var inline = loopStatement.test( this$1.parent.type ); if ( i === 0 ) { code.remove( c, declarator.id.start ); } else { code.overwrite( c, declarator.id.start, (";\n" + i0) ); } var simple = declarator.init.type === 'Identifier' && !declarator.init.rewritten; var name = simple ? declarator.init.name : declarator.findScope( true ).createIdentifier( 'ref' ); var statementGenerators = []; if ( simple ) { code.remove( declarator.id.end, declarator.end ); } else { statementGenerators.push( function ( start, prefix, suffix ) { code.insertRight( declarator.id.end, ("var " + name) ); code.insertLeft( declarator.init.end, ("" + suffix) ); code.move( declarator.id.end, declarator.end, start ); }); } destructure( code, declarator.findScope( false ), declarator.id, name, inline, statementGenerators ); var prefix = inline ? 'var ' : ''; var suffix = inline ? ", " : (";\n" + i0); statementGenerators.forEach( function ( fn, j ) { if ( i === this$1.declarations.length - 1 && j === statementGenerators.length - 1 ) { suffix = inline ? '' : ';'; } fn( declarator.start, j === 0 ? prefix : '', suffix ); }); } declarator.transpile( code, transforms ); c = declarator.end; lastDeclaratorIsPattern = declarator.id.type !== 'Identifier'; }); if ( lastDeclaratorIsPattern ) { code.remove( c, this.end ); } } else { this.declarations.forEach( function ( declarator ) { declarator.transpile( code, transforms ); }); } }; return VariableDeclaration; }(Node$1)); var VariableDeclarator = (function (Node) { function VariableDeclarator () { Node.apply(this, arguments); } if ( Node ) VariableDeclarator.__proto__ = Node; VariableDeclarator.prototype = Object.create( Node && Node.prototype ); VariableDeclarator.prototype.constructor = VariableDeclarator; VariableDeclarator.prototype.initialise = function initialise ( transforms ) { var kind = this.parent.kind; if ( kind === 'let' && this.parent.parent.type === 'ForStatement' ) { kind = 'for.let'; // special case... } this.parent.scope.addDeclaration( this.id, kind ); Node.prototype.initialise.call( this, transforms ); }; VariableDeclarator.prototype.transpile = function transpile ( code, transforms ) { if ( !this.init && transforms.letConst && this.parent.kind !== 'var' ) { var inLoop = this.findNearest( /Function|^For(In|Of)?Statement|^(?:Do)?WhileStatement/ ); if ( inLoop && ! /Function/.test( inLoop.type ) && ! this.isLeftDeclaratorOfLoop() ) { code.insertLeft( this.id.end, ' = (void 0)' ); } } if ( this.id ) this.id.transpile( code, transforms ); if ( this.init ) this.init.transpile( code, transforms ); }; VariableDeclarator.prototype.isLeftDeclaratorOfLoop = function isLeftDeclaratorOfLoop () { return this.parent && this.parent.type === 'VariableDeclaration' && this.parent.parent && (this.parent.parent.type === 'ForInStatement' || this.parent.parent.type === 'ForOfStatement') && this.parent.parent.left && this.parent.parent.left.declarations[0] === this; }; return VariableDeclarator; }(Node$1)); var WithStatement = (function (Node) { function WithStatement () { Node.apply(this, arguments); } if ( Node ) WithStatement.__proto__ = Node; WithStatement.prototype = Object.create( Node && Node.prototype ); WithStatement.prototype.constructor = WithStatement; WithStatement.prototype.transpile = function transpile (code, transforms) { if (transforms.stripWith) { this.program.inWith = (this.program.inWith || 0) + 1; // remove surrounding with block code.remove(this.start, this.body.start + 1); code.remove(this.end - 1, this.end); if (transforms.stripWithFunctional) { code.insertRight(this.start, "var _c=_vm._c;"); } else { code.insertRight(this.start, "var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;"); } Node.prototype.transpile.call(this, code, transforms); this.program.inWith--; } else { Node.prototype.transpile.call(this, code, transforms); } }; return WithStatement; }(Node$1)); var types$1$1 = { ArrayExpression: ArrayExpression, ArrowFunctionExpression: ArrowFunctionExpression, AssignmentExpression: AssignmentExpression, BinaryExpression: BinaryExpression, BreakStatement: BreakStatement, CallExpression: CallExpression, ClassBody: ClassBody, ClassDeclaration: ClassDeclaration, ClassExpression: ClassExpression, ContinueStatement: ContinueStatement, DoWhileStatement: LoopStatement, ExportNamedDeclaration: ExportNamedDeclaration, ExportDefaultDeclaration: ExportDefaultDeclaration, ForStatement: ForStatement, ForInStatement: ForInStatement, ForOfStatement: ForOfStatement, FunctionDeclaration: FunctionDeclaration, FunctionExpression: FunctionExpression, Identifier: Identifier, IfStatement: IfStatement, ImportDeclaration: ImportDeclaration, ImportDefaultSpecifier: ImportDefaultSpecifier, ImportSpecifier: ImportSpecifier, JSXAttribute: JSXAttribute, JSXClosingElement: JSXClosingElement, JSXElement: JSXElement, JSXExpressionContainer: JSXExpressionContainer, JSXOpeningElement: JSXOpeningElement, JSXSpreadAttribute: JSXSpreadAttribute, Literal: Literal, MemberExpression: MemberExpression, NewExpression: NewExpression, ObjectExpression: ObjectExpression, Property: Property, ReturnStatement: ReturnStatement, SpreadProperty: SpreadProperty, Super: Super, TaggedTemplateExpression: TaggedTemplateExpression, TemplateElement: TemplateElement, TemplateLiteral: TemplateLiteral, ThisExpression: ThisExpression, UpdateExpression: UpdateExpression, VariableDeclaration: VariableDeclaration, VariableDeclarator: VariableDeclarator, WhileStatement: LoopStatement, WithStatement: WithStatement }; var statementsWithBlocks = { IfStatement: 'consequent', ForStatement: 'body', ForInStatement: 'body', ForOfStatement: 'body', WhileStatement: 'body', DoWhileStatement: 'body', ArrowFunctionExpression: 'body' }; function wrap ( raw, parent ) { if ( !raw ) return; if ( 'length' in raw ) { var i = raw.length; while ( i-- ) wrap( raw[i], parent ); return; } // with e.g. shorthand properties, key and value are // the same node. We don't want to wrap an object twice if ( raw.__wrapped ) return; raw.__wrapped = true; if ( !keys[ raw.type ] ) { keys[ raw.type ] = Object.keys( raw ).filter( function ( key ) { return typeof raw[ key ] === 'object'; } ); } // special case – body-less if/for/while statements. TODO others? var bodyType = statementsWithBlocks[ raw.type ]; if ( bodyType && raw[ bodyType ].type !== 'BlockStatement' ) { var expression = raw[ bodyType ]; // create a synthetic block statement, otherwise all hell // breaks loose when it comes to block scoping raw[ bodyType ] = { start: expression.start, end: expression.end, type: 'BlockStatement', body: [ expression ], synthetic: true }; } new Node$1( raw, parent ); var type = ( raw.type === 'BlockStatement' ? BlockStatement : types$1$1[ raw.type ] ) || Node$1; raw.__proto__ = type.prototype; } function Scope ( options ) { options = options || {}; this.parent = options.parent; this.isBlockScope = !!options.block; var scope = this; while ( scope.isBlockScope ) scope = scope.parent; this.functionScope = scope; this.identifiers = []; this.declarations = Object.create( null ); this.references = Object.create( null ); this.blockScopedDeclarations = this.isBlockScope ? null : Object.create( null ); this.aliases = this.isBlockScope ? null : Object.create( null ); } Scope.prototype = { addDeclaration: function addDeclaration ( node, kind ) { for ( var i = 0, list = extractNames( node ); i < list.length; i += 1 ) { var identifier = list[i]; var name = identifier.name; var declaration = { name: name, node: identifier, kind: kind, instances: [] }; this.declarations[ name ] = declaration; if ( this.isBlockScope ) { if ( !this.functionScope.blockScopedDeclarations[ name ] ) this.functionScope.blockScopedDeclarations[ name ] = []; this.functionScope.blockScopedDeclarations[ name ].push( declaration ); } } }, addReference: function addReference ( identifier ) { if ( this.consolidated ) { this.consolidateReference( identifier ); } else { this.identifiers.push( identifier ); } }, consolidate: function consolidate () { var this$1 = this; for ( var i = 0; i < this$1.identifiers.length; i += 1 ) { // we might push to the array during consolidation, so don't cache length var identifier = this$1.identifiers[i]; this$1.consolidateReference( identifier ); } this.consolidated = true; // TODO understand why this is necessary... seems bad }, consolidateReference: function consolidateReference ( identifier ) { var declaration = this.declarations[ identifier.name ]; if ( declaration ) { declaration.instances.push( identifier ); } else { this.references[ identifier.name ] = true; if ( this.parent ) this.parent.addReference( identifier ); } }, contains: function contains ( name ) { return this.declarations[ name ] || ( this.parent ? this.parent.contains( name ) : false ); }, createIdentifier: function createIdentifier ( base ) { var this$1 = this; if ( typeof base === 'number' ) base = base.toString(); base = base .replace( /\s/g, '' ) .replace( /\[([^\]]+)\]/g, '_$1' ) .replace( /[^a-zA-Z0-9_$]/g, '_' ) .replace( /_{2,}/, '_' ); var name = base; var counter = 1; while ( this$1.declarations[ name ] || this$1.references[ name ] || this$1.aliases[ name ] || name in reserved ) { name = base + "$" + (counter++); } this.aliases[ name ] = true; return name; }, findDeclaration: function findDeclaration ( name ) { return this.declarations[ name ] || ( this.parent && this.parent.findDeclaration( name ) ); } }; function isUseStrict ( node ) { if ( !node ) return false; if ( node.type !== 'ExpressionStatement' ) return false; if ( node.expression.type !== 'Literal' ) return false; return node.expression.value === 'use strict'; } var BlockStatement = (function (Node) { function BlockStatement () { Node.apply(this, arguments); } if ( Node ) BlockStatement.__proto__ = Node; BlockStatement.prototype = Object.create( Node && Node.prototype ); BlockStatement.prototype.constructor = BlockStatement; BlockStatement.prototype.createScope = function createScope () { var this$1 = this; this.parentIsFunction = /Function/.test( this.parent.type ); this.isFunctionBlock = this.parentIsFunction || this.parent.type === 'Root'; this.scope = new Scope({ block: !this.isFunctionBlock, parent: this.parent.findScope( false ) }); if ( this.parentIsFunction ) { this.parent.params.forEach( function ( node ) { this$1.scope.addDeclaration( node, 'param' ); }); } }; BlockStatement.prototype.initialise = function initialise ( transforms ) { this.thisAlias = null; this.argumentsAlias = null; this.defaultParameters = []; // normally the scope gets created here, during initialisation, // but in some cases (e.g. `for` statements), we need to create // the scope early, as it pertains to both the init block and // the body of the statement if ( !this.scope ) this.createScope(); this.body.forEach( function ( node ) { return node.initialise( transforms ); } ); this.scope.consolidate(); }; BlockStatement.prototype.findLexicalBoundary = function findLexicalBoundary () { if ( this.type === 'Program' ) return this; if ( /^Function/.test( this.parent.type ) ) return this; return this.parent.findLexicalBoundary(); }; BlockStatement.prototype.findScope = function findScope ( functionScope ) { if ( functionScope && !this.isFunctionBlock ) return this.parent.findScope( functionScope ); return this.scope; }; BlockStatement.prototype.getArgumentsAlias = function getArgumentsAlias () { if ( !this.argumentsAlias ) { this.argumentsAlias = this.scope.createIdentifier( 'arguments' ); } return this.argumentsAlias; }; BlockStatement.prototype.getArgumentsArrayAlias = function getArgumentsArrayAlias () { if ( !this.argumentsArrayAlias ) { this.argumentsArrayAlias = this.scope.createIdentifier( 'argsArray' ); } return this.argumentsArrayAlias; }; BlockStatement.prototype.getThisAlias = function getThisAlias () { if ( !this.thisAlias ) { this.thisAlias = this.scope.createIdentifier( 'this' ); } return this.thisAlias; }; BlockStatement.prototype.getIndentation = function getIndentation () { var this$1 = this; if ( this.indentation === undefined ) { var source = this.program.magicString.original; var useOuter = this.synthetic || !this.body.length; var c = useOuter ? this.start : this.body[0].start; while ( c && source[c] !== '\n' ) c -= 1; this.indentation = ''; while ( true ) { // eslint-disable-line no-constant-condition c += 1; var char = source[c]; if ( char !== ' ' && char !== '\t' ) break; this$1.indentation += char; } var indentString = this.program.magicString.getIndentString(); // account for dedented class constructors var parent = this.parent; while ( parent ) { if ( parent.kind === 'constructor' && !parent.parent.parent.superClass ) { this$1.indentation = this$1.indentation.replace( indentString, '' ); } parent = parent.parent; } if ( useOuter ) this.indentation += indentString; } return this.indentation; }; BlockStatement.prototype.transpile = function transpile ( code, transforms ) { var this$1 = this; var indentation = this.getIndentation(); var introStatementGenerators = []; if ( this.argumentsAlias ) { introStatementGenerators.push( function ( start, prefix, suffix ) { var assignment = prefix + "var " + (this$1.argumentsAlias) + " = arguments" + suffix; code.insertLeft( start, assignment ); }); } if ( this.thisAlias ) { introStatementGenerators.push( function ( start, prefix, suffix ) { var assignment = prefix + "var " + (this$1.thisAlias) + " = this" + suffix; code.insertLeft( start, assignment ); }); } if ( this.argumentsArrayAlias ) { introStatementGenerators.push( function ( start, prefix, suffix ) { var i = this$1.scope.createIdentifier( 'i' ); var assignment = prefix + "var " + i + " = arguments.length, " + (this$1.argumentsArrayAlias) + " = Array(" + i + ");\n" + indentation + "while ( " + i + "-- ) " + (this$1.argumentsArrayAlias) + "[" + i + "] = arguments[" + i + "]" + suffix; code.insertLeft( start, assignment ); }); } if ( /Function/.test( this.parent.type ) ) { this.transpileParameters( code, transforms, indentation, introStatementGenerators ); } if ( transforms.letConst && this.isFunctionBlock ) { this.transpileBlockScopedIdentifiers( code ); } Node.prototype.transpile.call( this, code, transforms ); if ( this.synthetic ) { if ( this.parent.type === 'ArrowFunctionExpression' ) { var expr = this.body[0]; if ( introStatementGenerators.length ) { code.insertLeft( this.start, "{" ).insertRight( this.end, ((this.parent.getIndentation()) + "}") ); code.insertRight( expr.start, ("\n" + indentation + "return ") ); code.insertLeft( expr.end, ";\n" ); } else if ( transforms.arrow ) { code.insertLeft( expr.start, "{ return " ); code.insertLeft( expr.end, "; }" ); } } else if ( introStatementGenerators.length ) { code.insertLeft( this.start, "{" ).insertRight( this.end, "}" ); } } var start; if ( isUseStrict( this.body[0] ) ) { start = this.body[0].end; } else if ( this.synthetic || this.parent.type === 'Root' ) { start = this.start; } else { start = this.start + 1; } var prefix = "\n" + indentation; var suffix = ';'; introStatementGenerators.forEach( function ( fn, i ) { if ( i === introStatementGenerators.length - 1 ) suffix = ";\n"; fn( start, prefix, suffix ); }); }; BlockStatement.prototype.transpileParameters = function transpileParameters ( code, transforms, indentation, introStatementGenerators ) { var this$1 = this; var params = this.parent.params; params.forEach( function ( param ) { if ( param.type === 'AssignmentPattern' && param.left.type === 'Identifier' ) { if ( transforms.defaultParameter ) { introStatementGenerators.push( function ( start, prefix, suffix ) { var lhs = prefix + "if ( " + (param.left.name) + " === void 0 ) " + (param.left.name); code .insertRight( param.left.end, lhs ) .move( param.left.end, param.right.end, start ) .insertLeft( param.right.end, suffix ); }); } } else if ( param.type === 'RestElement' ) { if ( transforms.spreadRest ) { introStatementGenerators.push( function ( start, prefix, suffix ) { var penultimateParam = params[ params.length - 2 ]; if ( penultimateParam ) { code.remove( penultimateParam ? penultimateParam.end : param.start, param.end ); } else { var start$1 = param.start, end = param.end; // TODO https://gitlab.com/Rich-Harris/buble/issues/8 while ( /\s/.test( code.original[ start$1 - 1 ] ) ) start$1 -= 1; while ( /\s/.test( code.original[ end ] ) ) end += 1; code.remove( start$1, end ); } var name = param.argument.name; var len = this$1.scope.createIdentifier( 'len' ); var count = params.length - 1; if ( count ) { code.insertLeft( start, (prefix + "var " + name + " = [], " + len + " = arguments.length - " + count + ";\n" + indentation + "while ( " + len + "-- > 0 ) " + name + "[ " + len + " ] = arguments[ " + len + " + " + count + " ]" + suffix) ); } else { code.insertLeft( start, (prefix + "var " + name + " = [], " + len + " = arguments.length;\n" + indentation + "while ( " + len + "-- ) " + name + "[ " + len + " ] = arguments[ " + len + " ]" + suffix) ); } }); } } else if ( param.type !== 'Identifier' ) { if ( transforms.parameterDestructuring ) { var ref = this$1.scope.createIdentifier( 'ref' ); destructure( code, this$1.scope, param, ref, false, introStatementGenerators ); code.insertLeft( param.start, ref ); } } }); }; BlockStatement.prototype.transpileBlockScopedIdentifiers = function transpileBlockScopedIdentifiers ( code ) { var this$1 = this; Object.keys( this.scope.blockScopedDeclarations ).forEach( function ( name ) { var declarations = this$1.scope.blockScopedDeclarations[ name ]; for ( var i = 0, list = declarations; i < list.length; i += 1 ) { var declaration = list[i]; var cont = false; // TODO implement proper continue... if ( declaration.kind === 'for.let' ) { // special case var forStatement = declaration.node.findNearest( 'ForStatement' ); if ( forStatement.shouldRewriteAsFunction ) { var outerAlias = this$1.scope.createIdentifier( name ); var innerAlias = forStatement.reassigned[ name ] ? this$1.scope.createIdentifier( name ) : name; declaration.name = outerAlias; code.overwrite( declaration.node.start, declaration.node.end, outerAlias, true ); forStatement.aliases[ name ] = { outer: outerAlias, inner: innerAlias }; for ( var i$1 = 0, list$1 = declaration.instances; i$1 < list$1.length; i$1 += 1 ) { var identifier = list$1[i$1]; var alias = forStatement.body.contains( identifier ) ? innerAlias : outerAlias; if ( name !== alias ) { code.overwrite( identifier.start, identifier.end, alias, true ); } } cont = true; } } if ( !cont ) { var alias$1 = this$1.scope.createIdentifier( name ); if ( name !== alias$1 ) { declaration.name = alias$1; code.overwrite( declaration.node.start, declaration.node.end, alias$1, true ); for ( var i$2 = 0, list$2 = declaration.instances; i$2 < list$2.length; i$2 += 1 ) { var identifier$1 = list$2[i$2]; identifier$1.rewritten = true; code.overwrite( identifier$1.start, identifier$1.end, alias$1, true ); } } } } }); }; return BlockStatement; }(Node$1)); function Program ( source, ast, transforms, options ) { var this$1 = this; this.type = 'Root'; // options this.jsx = options.jsx || 'React.createElement'; this.options = options; this.source = source; this.magicString = new magicString_cjs( source ); this.ast = ast; this.depth = 0; wrap( this.body = ast, this ); this.body.__proto__ = BlockStatement.prototype; this.indentExclusionElements = []; this.body.initialise( transforms ); this.indentExclusions = Object.create( null ); for ( var i$1 = 0, list = this.indentExclusionElements; i$1 < list.length; i$1 += 1 ) { var node = list[i$1]; for ( var i = node.start; i < node.end; i += 1 ) { this$1.indentExclusions[ i ] = true; } } this.body.transpile( this.magicString, transforms ); } Program.prototype = { export: function export$1 ( options ) { if ( options === void 0 ) options = {}; return { code: this.magicString.toString(), map: this.magicString.generateMap({ file: options.file, source: options.source, includeContent: options.includeContent !== false }) }; }, findNearest: function findNearest () { return null; }, findScope: function findScope () { return null; } }; var matrix = { chrome: { 48: 1333689725, 49: 1342078975, 50: 1610514431, 51: 1610514431, 52: 2147385343 }, firefox: { 43: 1207307741, 44: 1207307741, 45: 1207307741, 46: 1476267485, 47: 1476296671, 48: 1476296671 }, safari: { 8: 1073741824, 9: 1328940894 }, ie: { 8: 0, 9: 1073741824, 10: 1073741824, 11: 1073770592 }, edge: { 12: 1591620701, 13: 1608400479 }, node: { '0.10': 1075052608, '0.12': 1091830852, 4: 1327398527, 5: 1327398527, 6: 1610514431 } }; var features = [ 'arrow', 'classes', 'collections', 'computedProperty', 'conciseMethodProperty', 'constLoop', 'constRedef', 'defaultParameter', 'destructuring', 'extendNatives', 'forOf', 'generator', 'letConst', 'letLoop', 'letLoopScope', 'moduleExport', 'moduleImport', 'numericLiteral', 'objectProto', 'objectSuper', 'oldOctalLiteral', 'parameterDestructuring', 'spreadRest', 'stickyRegExp', 'symbol', 'templateString', 'unicodeEscape', 'unicodeIdentifier', 'unicodeRegExp', // ES2016 'exponentiation', // additional transforms, not from // https://featuretests.io 'reservedProperties' ]; var version$1 = "0.16.0"; var ref = [ inject$1, inject ].reduce( function ( final, plugin ) { return plugin( final ); }, acorn ); var parse = ref.parse; var dangerousTransforms = [ 'dangerousTaggedTemplateString', 'dangerousForOf' ]; function target ( target ) { var targets = Object.keys( target ); var bitmask = targets.length ? 2147483647 : 1073741824; Object.keys( target ).forEach( function ( environment ) { var versions = matrix[ environment ]; if ( !versions ) throw new Error( ("Unknown environment '" + environment + "'. Please raise an issue at https://gitlab.com/Rich-Harris/buble/issues") ); var targetVersion = target[ environment ]; if ( !( targetVersion in versions ) ) throw new Error( ("Support data exists for the following versions of " + environment + ": " + (Object.keys( versions ).join( ', ')) + ". Please raise an issue at https://gitlab.com/Rich-Harris/buble/issues") ); var support = versions[ targetVersion ]; bitmask &= support; }); var transforms = Object.create( null ); features.forEach( function ( name, i ) { transforms[ name ] = !( bitmask & 1 << i ); }); dangerousTransforms.forEach( function ( name ) { transforms[ name ] = false; }); transforms.stripWith = false; transforms.stripWithFunctional = false; return transforms; } function transform ( source, options ) { if ( options === void 0 ) options = {}; var transforms = target( options.target || {} ); Object.keys( options.transforms || {} ).forEach( function ( name ) { if ( name === 'modules' ) { if ( !( 'moduleImport' in options.transforms ) ) transforms.moduleImport = options.transforms.modules; if ( !( 'moduleExport' in options.transforms ) ) transforms.moduleExport = options.transforms.modules; return; } if ( !( name in transforms ) ) throw new Error( ("Unknown transform '" + name + "'") ); transforms[ name ] = options.transforms[ name ]; }); if (transforms.stripWith) { // necessary for { key } to be prefixed properly // in case the user uses a target environment that supports this transforms.conciseMethodProperty = true; } var ast; var jsx = null; try { ast = parse( source, { ecmaVersion: 8, preserveParens: true, sourceType: transforms.stripWith ? 'script' : 'module', onComment: function (block, text) { if ( !jsx ) { var match = /@jsx\s+([^\s]+)/.exec( text ); if ( match ) jsx = match[1]; } }, plugins: { jsx: true, objectSpread: true } }); options.jsx = jsx || options.jsx; } catch ( err ) { err.snippet = getSnippet( source, err.loc ); err.toString = function () { return ((err.name) + ": " + (err.message) + "\n" + (err.snippet)); }; throw err; } return new Program( source, ast, transforms, options ).export( options ); } exports.target = target; exports.transform = transform; exports.VERSION = version$1; Object.defineProperty(exports, '__esModule', { value: true }); }))); //# sourceMappingURL=buble.deps.js.map Kodo/kodo - Gogs: Go Git Service

2 コミット (8fd8731267a2c8b06d765a4437fd66a3ce4853eb)

作者 SHA1 メッセージ 日付
  Brightcells fabef63211 set line_length=200 for isort 10 年 前
  Brightcells df1df69fe3 add api upgrade/splash 10 年 前