Skip to content

Instantly share code, notes, and snippets.

@homam
Created January 23, 2018 20:55
Show Gist options
  • Save homam/1f17336d1b6323bda2728c5412d7775d to your computer and use it in GitHub Desktop.
Save homam/1f17336d1b6323bda2728c5412d7775d to your computer and use it in GitHub Desktop.
This file has been truncated, but you can view the full file.

(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.babel = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
},{}],2:[function(_dereq_,module,exports){
// http://wiki.commonjs.org/wiki/Unit_Testing/1.0
//
// THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
//
// Originally from narwhal.js (http://narwhaljs.org)
// Copyright (c) 2009 Thomas Robinson <280north.com>
//
// 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 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.
// when used in node, this will actually load the util module we depend on
// versus loading the builtin util module as happens otherwise
// this is a bug in node module loading as far as I am concerned
var util = _dereq_(13);
var pSlice = Array.prototype.slice;
var hasOwn = Object.prototype.hasOwnProperty;
// 1. The assert module provides functions that throw
// AssertionError's when particular conditions are not met. The
// assert module must conform to the following interface.
var assert = module.exports = ok;
// 2. The AssertionError is defined in assert.
// new assert.AssertionError({ message: message,
// actual: actual,
// expected: expected })
assert.AssertionError = function AssertionError(options) {
this.name = 'AssertionError';
this.actual = options.actual;
this.expected = options.expected;
this.operator = options.operator;
if (options.message) {
this.message = options.message;
this.generatedMessage = false;
} else {
this.message = getMessage(this);
this.generatedMessage = true;
}
var stackStartFunction = options.stackStartFunction || fail;
if (Error.captureStackTrace) {
Error.captureStackTrace(this, stackStartFunction);
}
else {
// non v8 browsers so we can have a stacktrace
var err = new Error();
if (err.stack) {
var out = err.stack;
// try to strip useless frames
var fn_name = stackStartFunction.name;
var idx = out.indexOf('\n' + fn_name);
if (idx >= 0) {
// once we have located the function frame
// we need to strip out everything before it (and its line)
var next_line = out.indexOf('\n', idx + 1);
out = out.substring(next_line + 1);
}
this.stack = out;
}
}
};
// assert.AssertionError instanceof Error
util.inherits(assert.AssertionError, Error);
function replacer(key, value) {
if (util.isUndefined(value)) {
return '' + value;
}
if (util.isNumber(value) && !isFinite(value)) {
return value.toString();
}
if (util.isFunction(value) || util.isRegExp(value)) {
return value.toString();
}
return value;
}
function truncate(s, n) {
if (util.isString(s)) {
return s.length < n ? s : s.slice(0, n);
} else {
return s;
}
}
function getMessage(self) {
return truncate(JSON.stringify(self.actual, replacer), 128) + ' ' +
self.operator + ' ' +
truncate(JSON.stringify(self.expected, replacer), 128);
}
// At present only the three keys mentioned above are used and
// understood by the spec. Implementations or sub modules can pass
// other keys to the AssertionError's constructor - they will be
// ignored.
// 3. All of the following functions must throw an AssertionError
// when a corresponding condition is not met, with a message that
// may be undefined if not provided. All assertion methods provide
// both the actual and expected values to the assertion error for
// display purposes.
function fail(actual, expected, message, operator, stackStartFunction) {
throw new assert.AssertionError({
message: message,
actual: actual,
expected: expected,
operator: operator,
stackStartFunction: stackStartFunction
});
}
// EXTENSION! allows for well behaved errors defined elsewhere.
assert.fail = fail;
// 4. Pure assertion tests whether a value is truthy, as determined
// by !!guard.
// assert.ok(guard, message_opt);
// This statement is equivalent to assert.equal(true, !!guard,
// message_opt);. To test strictly for the value true, use
// assert.strictEqual(true, guard, message_opt);.
function ok(value, message) {
if (!value) fail(value, true, message, '==', assert.ok);
}
assert.ok = ok;
// 5. The equality assertion tests shallow, coercive equality with
// ==.
// assert.equal(actual, expected, message_opt);
assert.equal = function equal(actual, expected, message) {
if (actual != expected) fail(actual, expected, message, '==', assert.equal);
};
// 6. The non-equality assertion tests for whether two objects are not equal
// with != assert.notEqual(actual, expected, message_opt);
assert.notEqual = function notEqual(actual, expected, message) {
if (actual == expected) {
fail(actual, expected, message, '!=', assert.notEqual);
}
};
// 7. The equivalence assertion tests a deep equality relation.
// assert.deepEqual(actual, expected, message_opt);
assert.deepEqual = function deepEqual(actual, expected, message) {
if (!_deepEqual(actual, expected)) {
fail(actual, expected, message, 'deepEqual', assert.deepEqual);
}
};
function _deepEqual(actual, expected) {
// 7.1. All identical values are equivalent, as determined by ===.
if (actual === expected) {
return true;
} else if (util.isBuffer(actual) && util.isBuffer(expected)) {
if (actual.length != expected.length) return false;
for (var i = 0; i < actual.length; i++) {
if (actual[i] !== expected[i]) return false;
}
return true;
// 7.2. If the expected value is a Date object, the actual value is
// equivalent if it is also a Date object that refers to the same time.
} else if (util.isDate(actual) && util.isDate(expected)) {
return actual.getTime() === expected.getTime();
// 7.3 If the expected value is a RegExp object, the actual value is
// equivalent if it is also a RegExp object with the same source and
// properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
} else if (util.isRegExp(actual) && util.isRegExp(expected)) {
return actual.source === expected.source &&
actual.global === expected.global &&
actual.multiline === expected.multiline &&
actual.lastIndex === expected.lastIndex &&
actual.ignoreCase === expected.ignoreCase;
// 7.4. Other pairs that do not both pass typeof value == 'object',
// equivalence is determined by ==.
} else if (!util.isObject(actual) && !util.isObject(expected)) {
return actual == expected;
// 7.5 For all other Object pairs, including Array objects, equivalence is
// determined by having the same number of owned properties (as verified
// with Object.prototype.hasOwnProperty.call), the same set of keys
// (although not necessarily the same order), equivalent values for every
// corresponding key, and an identical 'prototype' property. Note: this
// accounts for both named and indexed properties on Arrays.
} else {
return objEquiv(actual, expected);
}
}
function isArguments(object) {
return Object.prototype.toString.call(object) == '[object Arguments]';
}
function objEquiv(a, b) {
if (util.isNullOrUndefined(a) || util.isNullOrUndefined(b))
return false;
// an identical 'prototype' property.
if (a.prototype !== b.prototype) return false;
// if one is a primitive, the other must be same
if (util.isPrimitive(a) || util.isPrimitive(b)) {
return a === b;
}
var aIsArgs = isArguments(a),
bIsArgs = isArguments(b);
if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs))
return false;
if (aIsArgs) {
a = pSlice.call(a);
b = pSlice.call(b);
return _deepEqual(a, b);
}
var ka = objectKeys(a),
kb = objectKeys(b),
key, i;
// having the same number of owned properties (keys incorporates
// hasOwnProperty)
if (ka.length != kb.length)
return false;
//the same set of keys (although not necessarily the same order),
ka.sort();
kb.sort();
//~~~cheap key test
for (i = ka.length - 1; i >= 0; i--) {
if (ka[i] != kb[i])
return false;
}
//equivalent values for every corresponding key, and
//~~~possibly expensive deep test
for (i = ka.length - 1; i >= 0; i--) {
key = ka[i];
if (!_deepEqual(a[key], b[key])) return false;
}
return true;
}
// 8. The non-equivalence assertion tests for any deep inequality.
// assert.notDeepEqual(actual, expected, message_opt);
assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
if (_deepEqual(actual, expected)) {
fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
}
};
// 9. The strict equality assertion tests strict equality, as determined by ===.
// assert.strictEqual(actual, expected, message_opt);
assert.strictEqual = function strictEqual(actual, expected, message) {
if (actual !== expected) {
fail(actual, expected, message, '===', assert.strictEqual);
}
};
// 10. The strict non-equality assertion tests for strict inequality, as
// determined by !==. assert.notStrictEqual(actual, expected, message_opt);
assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
if (actual === expected) {
fail(actual, expected, message, '!==', assert.notStrictEqual);
}
};
function expectedException(actual, expected) {
if (!actual || !expected) {
return false;
}
if (Object.prototype.toString.call(expected) == '[object RegExp]') {
return expected.test(actual);
} else if (actual instanceof expected) {
return true;
} else if (expected.call({}, actual) === true) {
return true;
}
return false;
}
function _throws(shouldThrow, block, expected, message) {
var actual;
if (util.isString(expected)) {
message = expected;
expected = null;
}
try {
block();
} catch (e) {
actual = e;
}
message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
(message ? ' ' + message : '.');
if (shouldThrow && !actual) {
fail(actual, expected, 'Missing expected exception' + message);
}
if (!shouldThrow && expectedException(actual, expected)) {
fail(actual, expected, 'Got unwanted exception' + message);
}
if ((shouldThrow && actual && expected &&
!expectedException(actual, expected)) || (!shouldThrow && actual)) {
throw actual;
}
}
// 11. Expected to throw an error:
// assert.throws(block, Error_opt, message_opt);
assert.throws = function(block, /*optional*/error, /*optional*/message) {
_throws.apply(this, [true].concat(pSlice.call(arguments)));
};
// EXTENSION! This is annoying to write outside this module.
assert.doesNotThrow = function(block, /*optional*/message) {
_throws.apply(this, [false].concat(pSlice.call(arguments)));
};
assert.ifError = function(err) { if (err) {throw err;}};
var objectKeys = Object.keys || function (obj) {
var keys = [];
for (var key in obj) {
if (hasOwn.call(obj, key)) keys.push(key);
}
return keys;
};
},{"13":13}],3:[function(_dereq_,module,exports){
(function (global){
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
* @license MIT
*/
/* eslint-disable no-proto */
var base64 = _dereq_(4)
var ieee754 = _dereq_(5)
var isArray = _dereq_(6)
exports.Buffer = Buffer
exports.SlowBuffer = SlowBuffer
exports.INSPECT_MAX_BYTES = 50
Buffer.poolSize = 8192 // not used by this implementation
var rootParent = {}
/**
* If `Buffer.TYPED_ARRAY_SUPPORT`:
* === true Use Uint8Array implementation (fastest)
* === false Use Object implementation (most compatible, even IE6)
*
* Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
* Opera 11.6+, iOS 4.2+.
*
* Due to various browser bugs, sometimes the Object implementation will be used even
* when the browser supports typed arrays.
*
* Note:
*
* - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
* See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
*
* - Safari 5-7 lacks support for changing the `Object.prototype.constructor` property
* on objects.
*
* - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
*
* - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
* incorrect length in some situations.
* We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
* get the Object implementation, which is slower but behaves correctly.
*/
Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
? global.TYPED_ARRAY_SUPPORT
: typedArraySupport()
function typedArraySupport () {
function Bar () {}
try {
var arr = new Uint8Array(1)
arr.foo = function () { return 42 }
arr.constructor = Bar
return arr.foo() === 42 && // typed array instances can be augmented
arr.constructor === Bar && // constructor can be set
typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
} catch (e) {
return false
}
}
function kMaxLength () {
return Buffer.TYPED_ARRAY_SUPPORT
? 0x7fffffff
: 0x3fffffff
}
/**
* Class: Buffer
* =============
*
* The Buffer constructor returns instances of `Uint8Array` that are augmented
* with function properties for all the node `Buffer` API functions. We use
* `Uint8Array` so that square bracket notation works as expected -- it returns
* a single octet.
*
* By augmenting the instances, we can avoid modifying the `Uint8Array`
* prototype.
*/
function Buffer (arg) {
if (!(this instanceof Buffer)) {
// Avoid going through an ArgumentsAdaptorTrampoline in the common case.
if (arguments.length > 1) return new Buffer(arg, arguments[1])
return new Buffer(arg)
}
this.length = 0
this.parent = undefined
// Common case.
if (typeof arg === 'number') {
return fromNumber(this, arg)
}
// Slightly less common case.
if (typeof arg === 'string') {
return fromString(this, arg, arguments.length > 1 ? arguments[1] : 'utf8')
}
// Unusual.
return fromObject(this, arg)
}
function fromNumber (that, length) {
that = allocate(that, length < 0 ? 0 : checked(length) | 0)
if (!Buffer.TYPED_ARRAY_SUPPORT) {
for (var i = 0; i < length; i++) {
that[i] = 0
}
}
return that
}
function fromString (that, string, encoding) {
if (typeof encoding !== 'string' || encoding === '') encoding = 'utf8'
// Assumption: byteLength() return value is always < kMaxLength.
var length = byteLength(string, encoding) | 0
that = allocate(that, length)
that.write(string, encoding)
return that
}
function fromObject (that, object) {
if (Buffer.isBuffer(object)) return fromBuffer(that, object)
if (isArray(object)) return fromArray(that, object)
if (object == null) {
throw new TypeError('must start with number, buffer, array or string')
}
if (typeof ArrayBuffer !== 'undefined') {
if (object.buffer instanceof ArrayBuffer) {
return fromTypedArray(that, object)
}
if (object instanceof ArrayBuffer) {
return fromArrayBuffer(that, object)
}
}
if (object.length) return fromArrayLike(that, object)
return fromJsonObject(that, object)
}
function fromBuffer (that, buffer) {
var length = checked(buffer.length) | 0
that = allocate(that, length)
buffer.copy(that, 0, 0, length)
return that
}
function fromArray (that, array) {
var length = checked(array.length) | 0
that = allocate(that, length)
for (var i = 0; i < length; i += 1) {
that[i] = array[i] & 255
}
return that
}
// Duplicate of fromArray() to keep fromArray() monomorphic.
function fromTypedArray (that, array) {
var length = checked(array.length) | 0
that = allocate(that, length)
// Truncating the elements is probably not what people expect from typed
// arrays with BYTES_PER_ELEMENT > 1 but it's compatible with the behavior
// of the old Buffer constructor.
for (var i = 0; i < length; i += 1) {
that[i] = array[i] & 255
}
return that
}
function fromArrayBuffer (that, array) {
if (Buffer.TYPED_ARRAY_SUPPORT) {
// Return an augmented `Uint8Array` instance, for best performance
array.byteLength
that = Buffer._augment(new Uint8Array(array))
} else {
// Fallback: Return an object instance of the Buffer class
that = fromTypedArray(that, new Uint8Array(array))
}
return that
}
function fromArrayLike (that, array) {
var length = checked(array.length) | 0
that = allocate(that, length)
for (var i = 0; i < length; i += 1) {
that[i] = array[i] & 255
}
return that
}
// Deserialize { type: 'Buffer', data: [1,2,3,...] } into a Buffer object.
// Returns a zero-length buffer for inputs that don't conform to the spec.
function fromJsonObject (that, object) {
var array
var length = 0
if (object.type === 'Buffer' && isArray(object.data)) {
array = object.data
length = checked(array.length) | 0
}
that = allocate(that, length)
for (var i = 0; i < length; i += 1) {
that[i] = array[i] & 255
}
return that
}
if (Buffer.TYPED_ARRAY_SUPPORT) {
Buffer.prototype.__proto__ = Uint8Array.prototype
Buffer.__proto__ = Uint8Array
}
function allocate (that, length) {
if (Buffer.TYPED_ARRAY_SUPPORT) {
// Return an augmented `Uint8Array` instance, for best performance
that = Buffer._augment(new Uint8Array(length))
that.__proto__ = Buffer.prototype
} else {
// Fallback: Return an object instance of the Buffer class
that.length = length
that._isBuffer = true
}
var fromPool = length !== 0 && length <= Buffer.poolSize >>> 1
if (fromPool) that.parent = rootParent
return that
}
function checked (length) {
// Note: cannot use `length < kMaxLength` here because that fails when
// length is NaN (which is otherwise coerced to zero.)
if (length >= kMaxLength()) {
throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
'size: 0x' + kMaxLength().toString(16) + ' bytes')
}
return length | 0
}
function SlowBuffer (subject, encoding) {
if (!(this instanceof SlowBuffer)) return new SlowBuffer(subject, encoding)
var buf = new Buffer(subject, encoding)
delete buf.parent
return buf
}
Buffer.isBuffer = function isBuffer (b) {
return !!(b != null && b._isBuffer)
}
Buffer.compare = function compare (a, b) {
if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
throw new TypeError('Arguments must be Buffers')
}
if (a === b) return 0
var x = a.length
var y = b.length
var i = 0
var len = Math.min(x, y)
while (i < len) {
if (a[i] !== b[i]) break
++i
}
if (i !== len) {
x = a[i]
y = b[i]
}
if (x < y) return -1
if (y < x) return 1
return 0
}
Buffer.isEncoding = function isEncoding (encoding) {
switch (String(encoding).toLowerCase()) {
case 'hex':
case 'utf8':
case 'utf-8':
case 'ascii':
case 'binary':
case 'base64':
case 'raw':
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
return true
default:
return false
}
}
Buffer.concat = function concat (list, length) {
if (!isArray(list)) throw new TypeError('list argument must be an Array of Buffers.')
if (list.length === 0) {
return new Buffer(0)
}
var i
if (length === undefined) {
length = 0
for (i = 0; i < list.length; i++) {
length += list[i].length
}
}
var buf = new Buffer(length)
var pos = 0
for (i = 0; i < list.length; i++) {
var item = list[i]
item.copy(buf, pos)
pos += item.length
}
return buf
}
function byteLength (string, encoding) {
if (typeof string !== 'string') string = '' + string
var len = string.length
if (len === 0) return 0
// Use a for loop to avoid recursion
var loweredCase = false
for (;;) {
switch (encoding) {
case 'ascii':
case 'binary':
// Deprecated
case 'raw':
case 'raws':
return len
case 'utf8':
case 'utf-8':
return utf8ToBytes(string).length
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
return len * 2
case 'hex':
return len >>> 1
case 'base64':
return base64ToBytes(string).length
default:
if (loweredCase) return utf8ToBytes(string).length // assume utf8
encoding = ('' + encoding).toLowerCase()
loweredCase = true
}
}
}
Buffer.byteLength = byteLength
// pre-set for values that may exist in the future
Buffer.prototype.length = undefined
Buffer.prototype.parent = undefined
function slowToString (encoding, start, end) {
var loweredCase = false
start = start | 0
end = end === undefined || end === Infinity ? this.length : end | 0
if (!encoding) encoding = 'utf8'
if (start < 0) start = 0
if (end > this.length) end = this.length
if (end <= start) return ''
while (true) {
switch (encoding) {
case 'hex':
return hexSlice(this, start, end)
case 'utf8':
case 'utf-8':
return utf8Slice(this, start, end)
case 'ascii':
return asciiSlice(this, start, end)
case 'binary':
return binarySlice(this, start, end)
case 'base64':
return base64Slice(this, start, end)
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
return utf16leSlice(this, start, end)
default:
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
encoding = (encoding + '').toLowerCase()
loweredCase = true
}
}
}
Buffer.prototype.toString = function toString () {
var length = this.length | 0
if (length === 0) return ''
if (arguments.length === 0) return utf8Slice(this, 0, length)
return slowToString.apply(this, arguments)
}
Buffer.prototype.equals = function equals (b) {
if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
if (this === b) return true
return Buffer.compare(this, b) === 0
}
Buffer.prototype.inspect = function inspect () {
var str = ''
var max = exports.INSPECT_MAX_BYTES
if (this.length > 0) {
str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
if (this.length > max) str += ' ... '
}
return '<Buffer ' + str + '>'
}
Buffer.prototype.compare = function compare (b) {
if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
if (this === b) return 0
return Buffer.compare(this, b)
}
Buffer.prototype.indexOf = function indexOf (val, byteOffset) {
if (byteOffset > 0x7fffffff) byteOffset = 0x7fffffff
else if (byteOffset < -0x80000000) byteOffset = -0x80000000
byteOffset >>= 0
if (this.length === 0) return -1
if (byteOffset >= this.length) return -1
// Negative offsets start from the end of the buffer
if (byteOffset < 0) byteOffset = Math.max(this.length + byteOffset, 0)
if (typeof val === 'string') {
if (val.length === 0) return -1 // special case: looking for empty string always fails
return String.prototype.indexOf.call(this, val, byteOffset)
}
if (Buffer.isBuffer(val)) {
return arrayIndexOf(this, val, byteOffset)
}
if (typeof val === 'number') {
if (Buffer.TYPED_ARRAY_SUPPORT && Uint8Array.prototype.indexOf === 'function') {
return Uint8Array.prototype.indexOf.call(this, val, byteOffset)
}
return arrayIndexOf(this, [ val ], byteOffset)
}
function arrayIndexOf (arr, val, byteOffset) {
var foundIndex = -1
for (var i = 0; byteOffset + i < arr.length; i++) {
if (arr[byteOffset + i] === val[foundIndex === -1 ? 0 : i - foundIndex]) {
if (foundIndex === -1) foundIndex = i
if (i - foundIndex + 1 === val.length) return byteOffset + foundIndex
} else {
foundIndex = -1
}
}
return -1
}
throw new TypeError('val must be string, number or Buffer')
}
// `get` is deprecated
Buffer.prototype.get = function get (offset) {
console.log('.get() is deprecated. Access using array indexes instead.')
return this.readUInt8(offset)
}
// `set` is deprecated
Buffer.prototype.set = function set (v, offset) {
console.log('.set() is deprecated. Access using array indexes instead.')
return this.writeUInt8(v, offset)
}
function hexWrite (buf, string, offset, length) {
offset = Number(offset) || 0
var remaining = buf.length - offset
if (!length) {
length = remaining
} else {
length = Number(length)
if (length > remaining) {
length = remaining
}
}
// must be an even number of digits
var strLen = string.length
if (strLen % 2 !== 0) throw new Error('Invalid hex string')
if (length > strLen / 2) {
length = strLen / 2
}
for (var i = 0; i < length; i++) {
var parsed = parseInt(string.substr(i * 2, 2), 16)
if (isNaN(parsed)) throw new Error('Invalid hex string')
buf[offset + i] = parsed
}
return i
}
function utf8Write (buf, string, offset, length) {
return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
}
function asciiWrite (buf, string, offset, length) {
return blitBuffer(asciiToBytes(string), buf, offset, length)
}
function binaryWrite (buf, string, offset, length) {
return asciiWrite(buf, string, offset, length)
}
function base64Write (buf, string, offset, length) {
return blitBuffer(base64ToBytes(string), buf, offset, length)
}
function ucs2Write (buf, string, offset, length) {
return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
}
Buffer.prototype.write = function write (string, offset, length, encoding) {
// Buffer#write(string)
if (offset === undefined) {
encoding = 'utf8'
length = this.length
offset = 0
// Buffer#write(string, encoding)
} else if (length === undefined && typeof offset === 'string') {
encoding = offset
length = this.length
offset = 0
// Buffer#write(string, offset[, length][, encoding])
} else if (isFinite(offset)) {
offset = offset | 0
if (isFinite(length)) {
length = length | 0
if (encoding === undefined) encoding = 'utf8'
} else {
encoding = length
length = undefined
}
// legacy write(string, encoding, offset, length) - remove in v0.13
} else {
var swap = encoding
encoding = offset
offset = length | 0
length = swap
}
var remaining = this.length - offset
if (length === undefined || length > remaining) length = remaining
if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
throw new RangeError('attempt to write outside buffer bounds')
}
if (!encoding) encoding = 'utf8'
var loweredCase = false
for (;;) {
switch (encoding) {
case 'hex':
return hexWrite(this, string, offset, length)
case 'utf8':
case 'utf-8':
return utf8Write(this, string, offset, length)
case 'ascii':
return asciiWrite(this, string, offset, length)
case 'binary':
return binaryWrite(this, string, offset, length)
case 'base64':
// Warning: maxLength not taken into account in base64Write
return base64Write(this, string, offset, length)
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
return ucs2Write(this, string, offset, length)
default:
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
encoding = ('' + encoding).toLowerCase()
loweredCase = true
}
}
}
Buffer.prototype.toJSON = function toJSON () {
return {
type: 'Buffer',
data: Array.prototype.slice.call(this._arr || this, 0)
}
}
function base64Slice (buf, start, end) {
if (start === 0 && end === buf.length) {
return base64.fromByteArray(buf)
} else {
return base64.fromByteArray(buf.slice(start, end))
}
}
function utf8Slice (buf, start, end) {
end = Math.min(buf.length, end)
var res = []
var i = start
while (i < end) {
var firstByte = buf[i]
var codePoint = null
var bytesPerSequence = (firstByte > 0xEF) ? 4
: (firstByte > 0xDF) ? 3
: (firstByte > 0xBF) ? 2
: 1
if (i + bytesPerSequence <= end) {
var secondByte, thirdByte, fourthByte, tempCodePoint
switch (bytesPerSequence) {
case 1:
if (firstByte < 0x80) {
codePoint = firstByte
}
break
case 2:
secondByte = buf[i + 1]
if ((secondByte & 0xC0) === 0x80) {
tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
if (tempCodePoint > 0x7F) {
codePoint = tempCodePoint
}
}
break
case 3:
secondByte = buf[i + 1]
thirdByte = buf[i + 2]
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
codePoint = tempCodePoint
}
}
break
case 4:
secondByte = buf[i + 1]
thirdByte = buf[i + 2]
fourthByte = buf[i + 3]
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
codePoint = tempCodePoint
}
}
}
}
if (codePoint === null) {
// we did not generate a valid codePoint so insert a
// replacement char (U+FFFD) and advance only 1 byte
codePoint = 0xFFFD
bytesPerSequence = 1
} else if (codePoint > 0xFFFF) {
// encode to utf16 (surrogate pair dance)
codePoint -= 0x10000
res.push(codePoint >>> 10 & 0x3FF | 0xD800)
codePoint = 0xDC00 | codePoint & 0x3FF
}
res.push(codePoint)
i += bytesPerSequence
}
return decodeCodePointsArray(res)
}
// Based on http://stackoverflow.com/a/22747272/680742, the browser with
// the lowest limit is Chrome, with 0x10000 args.
// We go 1 magnitude less, for safety
var MAX_ARGUMENTS_LENGTH = 0x1000
function decodeCodePointsArray (codePoints) {
var len = codePoints.length
if (len <= MAX_ARGUMENTS_LENGTH) {
return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
}
// Decode in chunks to avoid "call stack size exceeded".
var res = ''
var i = 0
while (i < len) {
res += String.fromCharCode.apply(
String,
codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
)
}
return res
}
function asciiSlice (buf, start, end) {
var ret = ''
end = Math.min(buf.length, end)
for (var i = start; i < end; i++) {
ret += String.fromCharCode(buf[i] & 0x7F)
}
return ret
}
function binarySlice (buf, start, end) {
var ret = ''
end = Math.min(buf.length, end)
for (var i = start; i < end; i++) {
ret += String.fromCharCode(buf[i])
}
return ret
}
function hexSlice (buf, start, end) {
var len = buf.length
if (!start || start < 0) start = 0
if (!end || end < 0 || end > len) end = len
var out = ''
for (var i = start; i < end; i++) {
out += toHex(buf[i])
}
return out
}
function utf16leSlice (buf, start, end) {
var bytes = buf.slice(start, end)
var res = ''
for (var i = 0; i < bytes.length; i += 2) {
res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
}
return res
}
Buffer.prototype.slice = function slice (start, end) {
var len = this.length
start = ~~start
end = end === undefined ? len : ~~end
if (start < 0) {
start += len
if (start < 0) start = 0
} else if (start > len) {
start = len
}
if (end < 0) {
end += len
if (end < 0) end = 0
} else if (end > len) {
end = len
}
if (end < start) end = start
var newBuf
if (Buffer.TYPED_ARRAY_SUPPORT) {
newBuf = Buffer._augment(this.subarray(start, end))
} else {
var sliceLen = end - start
newBuf = new Buffer(sliceLen, undefined)
for (var i = 0; i < sliceLen; i++) {
newBuf[i] = this[i + start]
}
}
if (newBuf.length) newBuf.parent = this.parent || this
return newBuf
}
/*
* Need to make sure that buffer isn't trying to write out of bounds.
*/
function checkOffset (offset, ext, length) {
if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
}
Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
offset = offset | 0
byteLength = byteLength | 0
if (!noAssert) checkOffset(offset, byteLength, this.length)
var val = this[offset]
var mul = 1
var i = 0
while (++i < byteLength && (mul *= 0x100)) {
val += this[offset + i] * mul
}
return val
}
Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
offset = offset | 0
byteLength = byteLength | 0
if (!noAssert) {
checkOffset(offset, byteLength, this.length)
}
var val = this[offset + --byteLength]
var mul = 1
while (byteLength > 0 && (mul *= 0x100)) {
val += this[offset + --byteLength] * mul
}
return val
}
Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
if (!noAssert) checkOffset(offset, 1, this.length)
return this[offset]
}
Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
if (!noAssert) checkOffset(offset, 2, this.length)
return this[offset] | (this[offset + 1] << 8)
}
Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
if (!noAssert) checkOffset(offset, 2, this.length)
return (this[offset] << 8) | this[offset + 1]
}
Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
if (!noAssert) checkOffset(offset, 4, this.length)
return ((this[offset]) |
(this[offset + 1] << 8) |
(this[offset + 2] << 16)) +
(this[offset + 3] * 0x1000000)
}
Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
if (!noAssert) checkOffset(offset, 4, this.length)
return (this[offset] * 0x1000000) +
((this[offset + 1] << 16) |
(this[offset + 2] << 8) |
this[offset + 3])
}
Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
offset = offset | 0
byteLength = byteLength | 0
if (!noAssert) checkOffset(offset, byteLength, this.length)
var val = this[offset]
var mul = 1
var i = 0
while (++i < byteLength && (mul *= 0x100)) {
val += this[offset + i] * mul
}
mul *= 0x80
if (val >= mul) val -= Math.pow(2, 8 * byteLength)
return val
}
Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
offset = offset | 0
byteLength = byteLength | 0
if (!noAssert) checkOffset(offset, byteLength, this.length)
var i = byteLength
var mul = 1
var val = this[offset + --i]
while (i > 0 && (mul *= 0x100)) {
val += this[offset + --i] * mul
}
mul *= 0x80
if (val >= mul) val -= Math.pow(2, 8 * byteLength)
return val
}
Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
if (!noAssert) checkOffset(offset, 1, this.length)
if (!(this[offset] & 0x80)) return (this[offset])
return ((0xff - this[offset] + 1) * -1)
}
Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
if (!noAssert) checkOffset(offset, 2, this.length)
var val = this[offset] | (this[offset + 1] << 8)
return (val & 0x8000) ? val | 0xFFFF0000 : val
}
Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
if (!noAssert) checkOffset(offset, 2, this.length)
var val = this[offset + 1] | (this[offset] << 8)
return (val & 0x8000) ? val | 0xFFFF0000 : val
}
Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
if (!noAssert) checkOffset(offset, 4, this.length)
return (this[offset]) |
(this[offset + 1] << 8) |
(this[offset + 2] << 16) |
(this[offset + 3] << 24)
}
Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
if (!noAssert) checkOffset(offset, 4, this.length)
return (this[offset] << 24) |
(this[offset + 1] << 16) |
(this[offset + 2] << 8) |
(this[offset + 3])
}
Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
if (!noAssert) checkOffset(offset, 4, this.length)
return ieee754.read(this, offset, true, 23, 4)
}
Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
if (!noAssert) checkOffset(offset, 4, this.length)
return ieee754.read(this, offset, false, 23, 4)
}
Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
if (!noAssert) checkOffset(offset, 8, this.length)
return ieee754.read(this, offset, true, 52, 8)
}
Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
if (!noAssert) checkOffset(offset, 8, this.length)
return ieee754.read(this, offset, false, 52, 8)
}
function checkInt (buf, value, offset, ext, max, min) {
if (!Buffer.isBuffer(buf)) throw new TypeError('buffer must be a Buffer instance')
if (value > max || value < min) throw new RangeError('value is out of bounds')
if (offset + ext > buf.length) throw new RangeError('index out of range')
}
Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
value = +value
offset = offset | 0
byteLength = byteLength | 0
if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
var mul = 1
var i = 0
this[offset] = value & 0xFF
while (++i < byteLength && (mul *= 0x100)) {
this[offset + i] = (value / mul) & 0xFF
}
return offset + byteLength
}
Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
value = +value
offset = offset | 0
byteLength = byteLength | 0
if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
var i = byteLength - 1
var mul = 1
this[offset + i] = value & 0xFF
while (--i >= 0 && (mul *= 0x100)) {
this[offset + i] = (value / mul) & 0xFF
}
return offset + byteLength
}
Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
value = +value
offset = offset | 0
if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
this[offset] = (value & 0xff)
return offset + 1
}
function objectWriteUInt16 (buf, value, offset, littleEndian) {
if (value < 0) value = 0xffff + value + 1
for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) {
buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
(littleEndian ? i : 1 - i) * 8
}
}
Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
value = +value
offset = offset | 0
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
if (Buffer.TYPED_ARRAY_SUPPORT) {
this[offset] = (value & 0xff)
this[offset + 1] = (value >>> 8)
} else {
objectWriteUInt16(this, value, offset, true)
}
return offset + 2
}
Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
value = +value
offset = offset | 0
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
if (Buffer.TYPED_ARRAY_SUPPORT) {
this[offset] = (value >>> 8)
this[offset + 1] = (value & 0xff)
} else {
objectWriteUInt16(this, value, offset, false)
}
return offset + 2
}
function objectWriteUInt32 (buf, value, offset, littleEndian) {
if (value < 0) value = 0xffffffff + value + 1
for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) {
buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
}
}
Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
value = +value
offset = offset | 0
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
if (Buffer.TYPED_ARRAY_SUPPORT) {
this[offset + 3] = (value >>> 24)
this[offset + 2] = (value >>> 16)
this[offset + 1] = (value >>> 8)
this[offset] = (value & 0xff)
} else {
objectWriteUInt32(this, value, offset, true)
}
return offset + 4
}
Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
value = +value
offset = offset | 0
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
if (Buffer.TYPED_ARRAY_SUPPORT) {
this[offset] = (value >>> 24)
this[offset + 1] = (value >>> 16)
this[offset + 2] = (value >>> 8)
this[offset + 3] = (value & 0xff)
} else {
objectWriteUInt32(this, value, offset, false)
}
return offset + 4
}
Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
value = +value
offset = offset | 0
if (!noAssert) {
var limit = Math.pow(2, 8 * byteLength - 1)
checkInt(this, value, offset, byteLength, limit - 1, -limit)
}
var i = 0
var mul = 1
var sub = value < 0 ? 1 : 0
this[offset] = value & 0xFF
while (++i < byteLength && (mul *= 0x100)) {
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
}
return offset + byteLength
}
Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
value = +value
offset = offset | 0
if (!noAssert) {
var limit = Math.pow(2, 8 * byteLength - 1)
checkInt(this, value, offset, byteLength, limit - 1, -limit)
}
var i = byteLength - 1
var mul = 1
var sub = value < 0 ? 1 : 0
this[offset + i] = value & 0xFF
while (--i >= 0 && (mul *= 0x100)) {
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
}
return offset + byteLength
}
Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
value = +value
offset = offset | 0
if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
if (value < 0) value = 0xff + value + 1
this[offset] = (value & 0xff)
return offset + 1
}
Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
value = +value
offset = offset | 0
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
if (Buffer.TYPED_ARRAY_SUPPORT) {
this[offset] = (value & 0xff)
this[offset + 1] = (value >>> 8)
} else {
objectWriteUInt16(this, value, offset, true)
}
return offset + 2
}
Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
value = +value
offset = offset | 0
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
if (Buffer.TYPED_ARRAY_SUPPORT) {
this[offset] = (value >>> 8)
this[offset + 1] = (value & 0xff)
} else {
objectWriteUInt16(this, value, offset, false)
}
return offset + 2
}
Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
value = +value
offset = offset | 0
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
if (Buffer.TYPED_ARRAY_SUPPORT) {
this[offset] = (value & 0xff)
this[offset + 1] = (value >>> 8)
this[offset + 2] = (value >>> 16)
this[offset + 3] = (value >>> 24)
} else {
objectWriteUInt32(this, value, offset, true)
}
return offset + 4
}
Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
value = +value
offset = offset | 0
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
if (value < 0) value = 0xffffffff + value + 1
if (Buffer.TYPED_ARRAY_SUPPORT) {
this[offset] = (value >>> 24)
this[offset + 1] = (value >>> 16)
this[offset + 2] = (value >>> 8)
this[offset + 3] = (value & 0xff)
} else {
objectWriteUInt32(this, value, offset, false)
}
return offset + 4
}
function checkIEEE754 (buf, value, offset, ext, max, min) {
if (value > max || value < min) throw new RangeError('value is out of bounds')
if (offset + ext > buf.length) throw new RangeError('index out of range')
if (offset < 0) throw new RangeError('index out of range')
}
function writeFloat (buf, value, offset, littleEndian, noAssert) {
if (!noAssert) {
checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
}
ieee754.write(buf, value, offset, littleEndian, 23, 4)
return offset + 4
}
Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
return writeFloat(this, value, offset, true, noAssert)
}
Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
return writeFloat(this, value, offset, false, noAssert)
}
function writeDouble (buf, value, offset, littleEndian, noAssert) {
if (!noAssert) {
checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
}
ieee754.write(buf, value, offset, littleEndian, 52, 8)
return offset + 8
}
Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
return writeDouble(this, value, offset, true, noAssert)
}
Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
return writeDouble(this, value, offset, false, noAssert)
}
// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
Buffer.prototype.copy = function copy (target, targetStart, start, end) {
if (!start) start = 0
if (!end && end !== 0) end = this.length
if (targetStart >= target.length) targetStart = target.length
if (!targetStart) targetStart = 0
if (end > 0 && end < start) end = start
// Copy 0 bytes; we're done
if (end === start) return 0
if (target.length === 0 || this.length === 0) return 0
// Fatal error conditions
if (targetStart < 0) {
throw new RangeError('targetStart out of bounds')
}
if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
if (end < 0) throw new RangeError('sourceEnd out of bounds')
// Are we oob?
if (end > this.length) end = this.length
if (target.length - targetStart < end - start) {
end = target.length - targetStart + start
}
var len = end - start
var i
if (this === target && start < targetStart && targetStart < end) {
// descending copy from end
for (i = len - 1; i >= 0; i--) {
target[i + targetStart] = this[i + start]
}
} else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
// ascending copy from start
for (i = 0; i < len; i++) {
target[i + targetStart] = this[i + start]
}
} else {
target._set(this.subarray(start, start + len), targetStart)
}
return len
}
// fill(value, start=0, end=buffer.length)
Buffer.prototype.fill = function fill (value, start, end) {
if (!value) value = 0
if (!start) start = 0
if (!end) end = this.length
if (end < start) throw new RangeError('end < start')
// Fill 0 bytes; we're done
if (end === start) return
if (this.length === 0) return
if (start < 0 || start >= this.length) throw new RangeError('start out of bounds')
if (end < 0 || end > this.length) throw new RangeError('end out of bounds')
var i
if (typeof value === 'number') {
for (i = start; i < end; i++) {
this[i] = value
}
} else {
var bytes = utf8ToBytes(value.toString())
var len = bytes.length
for (i = start; i < end; i++) {
this[i] = bytes[i % len]
}
}
return this
}
/**
* Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance.
* Added in Node 0.12. Only available in browsers that support ArrayBuffer.
*/
Buffer.prototype.toArrayBuffer = function toArrayBuffer () {
if (typeof Uint8Array !== 'undefined') {
if (Buffer.TYPED_ARRAY_SUPPORT) {
return (new Buffer(this)).buffer
} else {
var buf = new Uint8Array(this.length)
for (var i = 0, len = buf.length; i < len; i += 1) {
buf[i] = this[i]
}
return buf.buffer
}
} else {
throw new TypeError('Buffer.toArrayBuffer not supported in this browser')
}
}
// HELPER FUNCTIONS
// ================
var BP = Buffer.prototype
/**
* Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods
*/
Buffer._augment = function _augment (arr) {
arr.constructor = Buffer
arr._isBuffer = true
// save reference to original Uint8Array set method before overwriting
arr._set = arr.set
// deprecated
arr.get = BP.get
arr.set = BP.set
arr.write = BP.write
arr.toString = BP.toString
arr.toLocaleString = BP.toString
arr.toJSON = BP.toJSON
arr.equals = BP.equals
arr.compare = BP.compare
arr.indexOf = BP.indexOf
arr.copy = BP.copy
arr.slice = BP.slice
arr.readUIntLE = BP.readUIntLE
arr.readUIntBE = BP.readUIntBE
arr.readUInt8 = BP.readUInt8
arr.readUInt16LE = BP.readUInt16LE
arr.readUInt16BE = BP.readUInt16BE
arr.readUInt32LE = BP.readUInt32LE
arr.readUInt32BE = BP.readUInt32BE
arr.readIntLE = BP.readIntLE
arr.readIntBE = BP.readIntBE
arr.readInt8 = BP.readInt8
arr.readInt16LE = BP.readInt16LE
arr.readInt16BE = BP.readInt16BE
arr.readInt32LE = BP.readInt32LE
arr.readInt32BE = BP.readInt32BE
arr.readFloatLE = BP.readFloatLE
arr.readFloatBE = BP.readFloatBE
arr.readDoubleLE = BP.readDoubleLE
arr.readDoubleBE = BP.readDoubleBE
arr.writeUInt8 = BP.writeUInt8
arr.writeUIntLE = BP.writeUIntLE
arr.writeUIntBE = BP.writeUIntBE
arr.writeUInt16LE = BP.writeUInt16LE
arr.writeUInt16BE = BP.writeUInt16BE
arr.writeUInt32LE = BP.writeUInt32LE
arr.writeUInt32BE = BP.writeUInt32BE
arr.writeIntLE = BP.writeIntLE
arr.writeIntBE = BP.writeIntBE
arr.writeInt8 = BP.writeInt8
arr.writeInt16LE = BP.writeInt16LE
arr.writeInt16BE = BP.writeInt16BE
arr.writeInt32LE = BP.writeInt32LE
arr.writeInt32BE = BP.writeInt32BE
arr.writeFloatLE = BP.writeFloatLE
arr.writeFloatBE = BP.writeFloatBE
arr.writeDoubleLE = BP.writeDoubleLE
arr.writeDoubleBE = BP.writeDoubleBE
arr.fill = BP.fill
arr.inspect = BP.inspect
arr.toArrayBuffer = BP.toArrayBuffer
return arr
}
var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
function base64clean (str) {
// Node strips out invalid characters like \n and \t from the string, base64-js does not
str = stringtrim(str).replace(INVALID_BASE64_RE, '')
// Node converts strings with length < 2 to ''
if (str.length < 2) return ''
// Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
while (str.length % 4 !== 0) {
str = str + '='
}
return str
}
function stringtrim (str) {
if (str.trim) return str.trim()
return str.replace(/^\s+|\s+$/g, '')
}
function toHex (n) {
if (n < 16) return '0' + n.toString(16)
return n.toString(16)
}
function utf8ToBytes (string, units) {
units = units || Infinity
var codePoint
var length = string.length
var leadSurrogate = null
var bytes = []
for (var i = 0; i < length; i++) {
codePoint = string.charCodeAt(i)
// is surrogate component
if (codePoint > 0xD7FF && codePoint < 0xE000) {
// last char was a lead
if (!leadSurrogate) {
// no lead yet
if (codePoint > 0xDBFF) {
// unexpected trail
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
continue
} else if (i + 1 === length) {
// unpaired lead
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
continue
}
// valid lead
leadSurrogate = codePoint
continue
}
// 2 leads in a row
if (codePoint < 0xDC00) {
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
leadSurrogate = codePoint
continue
}
// valid surrogate pair
codePoint = leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00 | 0x10000
} else if (leadSurrogate) {
// valid bmp char, but last char was a lead
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
}
leadSurrogate = null
// encode utf8
if (codePoint < 0x80) {
if ((units -= 1) < 0) break
bytes.push(codePoint)
} else if (codePoint < 0x800) {
if ((units -= 2) < 0) break
bytes.push(
codePoint >> 0x6 | 0xC0,
codePoint & 0x3F | 0x80
)
} else if (codePoint < 0x10000) {
if ((units -= 3) < 0) break
bytes.push(
codePoint >> 0xC | 0xE0,
codePoint >> 0x6 & 0x3F | 0x80,
codePoint & 0x3F | 0x80
)
} else if (codePoint < 0x110000) {
if ((units -= 4) < 0) break
bytes.push(
codePoint >> 0x12 | 0xF0,
codePoint >> 0xC & 0x3F | 0x80,
codePoint >> 0x6 & 0x3F | 0x80,
codePoint & 0x3F | 0x80
)
} else {
throw new Error('Invalid code point')
}
}
return bytes
}
function asciiToBytes (str) {
var byteArray = []
for (var i = 0; i < str.length; i++) {
// Node's code seems to be doing this and not & 0x7F..
byteArray.push(str.charCodeAt(i) & 0xFF)
}
return byteArray
}
function utf16leToBytes (str, units) {
var c, hi, lo
var byteArray = []
for (var i = 0; i < str.length; i++) {
if ((units -= 2) < 0) break
c = str.charCodeAt(i)
hi = c >> 8
lo = c % 256
byteArray.push(lo)
byteArray.push(hi)
}
return byteArray
}
function base64ToBytes (str) {
return base64.toByteArray(base64clean(str))
}
function blitBuffer (src, dst, offset, length) {
for (var i = 0; i < length; i++) {
if ((i + offset >= dst.length) || (i >= src.length)) break
dst[i + offset] = src[i]
}
return i
}
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"4":4,"5":5,"6":6}],4:[function(_dereq_,module,exports){
var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
;(function (exports) {
'use strict';
var Arr = (typeof Uint8Array !== 'undefined')
? Uint8Array
: Array
var PLUS = '+'.charCodeAt(0)
var SLASH = '/'.charCodeAt(0)
var NUMBER = '0'.charCodeAt(0)
var LOWER = 'a'.charCodeAt(0)
var UPPER = 'A'.charCodeAt(0)
var PLUS_URL_SAFE = '-'.charCodeAt(0)
var SLASH_URL_SAFE = '_'.charCodeAt(0)
function decode (elt) {
var code = elt.charCodeAt(0)
if (code === PLUS ||
code === PLUS_URL_SAFE)
return 62 // '+'
if (code === SLASH ||
code === SLASH_URL_SAFE)
return 63 // '/'
if (code < NUMBER)
return -1 //no match
if (code < NUMBER + 10)
return code - NUMBER + 26 + 26
if (code < UPPER + 26)
return code - UPPER
if (code < LOWER + 26)
return code - LOWER + 26
}
function b64ToByteArray (b64) {
var i, j, l, tmp, placeHolders, arr
if (b64.length % 4 > 0) {
throw new Error('Invalid string. Length must be a multiple of 4')
}
// the number of equal signs (place holders)
// if there are two placeholders, than the two characters before it
// represent one byte
// if there is only one, then the three characters before it represent 2 bytes
// this is just a cheap hack to not do indexOf twice
var len = b64.length
placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0
// base64 is 4/3 + up to two characters of the original data
arr = new Arr(b64.length * 3 / 4 - placeHolders)
// if there are placeholders, only get up to the last complete 4 chars
l = placeHolders > 0 ? b64.length - 4 : b64.length
var L = 0
function push (v) {
arr[L++] = v
}
for (i = 0, j = 0; i < l; i += 4, j += 3) {
tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3))
push((tmp & 0xFF0000) >> 16)
push((tmp & 0xFF00) >> 8)
push(tmp & 0xFF)
}
if (placeHolders === 2) {
tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4)
push(tmp & 0xFF)
} else if (placeHolders === 1) {
tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2)
push((tmp >> 8) & 0xFF)
push(tmp & 0xFF)
}
return arr
}
function uint8ToBase64 (uint8) {
var i,
extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes
output = "",
temp, length
function encode (num) {
return lookup.charAt(num)
}
function tripletToBase64 (num) {
return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F)
}
// go through the array every three bytes, we'll deal with trailing stuff later
for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
output += tripletToBase64(temp)
}
// pad the end with zeros, but make sure to not forget the extra bytes
switch (extraBytes) {
case 1:
temp = uint8[uint8.length - 1]
output += encode(temp >> 2)
output += encode((temp << 4) & 0x3F)
output += '=='
break
case 2:
temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1])
output += encode(temp >> 10)
output += encode((temp >> 4) & 0x3F)
output += encode((temp << 2) & 0x3F)
output += '='
break
}
return output
}
exports.toByteArray = b64ToByteArray
exports.fromByteArray = uint8ToBase64
}(typeof exports === 'undefined' ? (this.base64js = {}) : exports))
},{}],5:[function(_dereq_,module,exports){
exports.read = function (buffer, offset, isLE, mLen, nBytes) {
var e, m
var eLen = nBytes * 8 - mLen - 1
var eMax = (1 << eLen) - 1
var eBias = eMax >> 1
var nBits = -7
var i = isLE ? (nBytes - 1) : 0
var d = isLE ? -1 : 1
var s = buffer[offset + i]
i += d
e = s & ((1 << (-nBits)) - 1)
s >>= (-nBits)
nBits += eLen
for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
m = e & ((1 << (-nBits)) - 1)
e >>= (-nBits)
nBits += mLen
for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
if (e === 0) {
e = 1 - eBias
} else if (e === eMax) {
return m ? NaN : ((s ? -1 : 1) * Infinity)
} else {
m = m + Math.pow(2, mLen)
e = e - eBias
}
return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
}
exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
var e, m, c
var eLen = nBytes * 8 - mLen - 1
var eMax = (1 << eLen) - 1
var eBias = eMax >> 1
var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
var i = isLE ? 0 : (nBytes - 1)
var d = isLE ? 1 : -1
var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
value = Math.abs(value)
if (isNaN(value) || value === Infinity) {
m = isNaN(value) ? 1 : 0
e = eMax
} else {
e = Math.floor(Math.log(value) / Math.LN2)
if (value * (c = Math.pow(2, -e)) < 1) {
e--
c *= 2
}
if (e + eBias >= 1) {
value += rt / c
} else {
value += rt * Math.pow(2, 1 - eBias)
}
if (value * c >= 2) {
e++
c /= 2
}
if (e + eBias >= eMax) {
m = 0
e = eMax
} else if (e + eBias >= 1) {
m = (value * c - 1) * Math.pow(2, mLen)
e = e + eBias
} else {
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
e = 0
}
}
for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
e = (e << mLen) | m
eLen += mLen
for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
buffer[offset + i - d] |= s * 128
}
},{}],6:[function(_dereq_,module,exports){
/**
* isArray
*/
var isArray = Array.isArray;
/**
* toString
*/
var str = Object.prototype.toString;
/**
* Whether or not the given `val`
* is an array.
*
* example:
*
* isArray([]);
* // > true
* isArray(arguments);
* // > false
* isArray('');
* // > false
*
* @param {mixed} val
* @return {bool}
*/
module.exports = isArray || function (val) {
return !! val && '[object Array]' == str.call(val);
};
},{}],7:[function(_dereq_,module,exports){
if (typeof Object.create === 'function') {
// implementation from standard node.js 'util' module
module.exports = function inherits(ctor, superCtor) {
ctor.super_ = superCtor
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false,
writable: true,
configurable: true
}
});
};
} else {
// old school shim for old browsers
module.exports = function inherits(ctor, superCtor) {
ctor.super_ = superCtor
var TempCtor = function () {}
TempCtor.prototype = superCtor.prototype
ctor.prototype = new TempCtor()
ctor.prototype.constructor = ctor
}
}
},{}],8:[function(_dereq_,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';
},{}],9:[function(_dereq_,module,exports){
(function (process){
// 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.
// resolves . and .. elements in a path array with directory names there
// must be no slashes, empty elements, or device names (c:\) in the array
// (so also no leading and trailing slashes - it does not distinguish
// relative and absolute paths)
function normalizeArray(parts, allowAboveRoot) {
// if the path tries to go above the root, `up` ends up > 0
var up = 0;
for (var i = parts.length - 1; i >= 0; i--) {
var last = parts[i];
if (last === '.') {
parts.splice(i, 1);
} else if (last === '..') {
parts.splice(i, 1);
up++;
} else if (up) {
parts.splice(i, 1);
up--;
}
}
// if the path is allowed to go above the root, restore leading ..s
if (allowAboveRoot) {
for (; up--; up) {
parts.unshift('..');
}
}
return parts;
}
// Split a filename into [root, dir, basename, ext], unix version
// 'root' is just a slash, or nothing.
var splitPathRe =
/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
var splitPath = function(filename) {
return splitPathRe.exec(filename).slice(1);
};
// path.resolve([from ...], to)
// posix version
exports.resolve = function() {
var resolvedPath = '',
resolvedAbsolute = false;
for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
var path = (i >= 0) ? arguments[i] : process.cwd();
// Skip empty and invalid entries
if (typeof path !== 'string') {
throw new TypeError('Arguments to path.resolve must be strings');
} else if (!path) {
continue;
}
resolvedPath = path + '/' + resolvedPath;
resolvedAbsolute = path.charAt(0) === '/';
}
// At this point the path should be resolved to a full absolute path, but
// handle relative paths to be safe (might happen when process.cwd() fails)
// Normalize the path
resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
return !!p;
}), !resolvedAbsolute).join('/');
return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
};
// path.normalize(path)
// posix version
exports.normalize = function(path) {
var isAbsolute = exports.isAbsolute(path),
trailingSlash = substr(path, -1) === '/';
// Normalize the path
path = normalizeArray(filter(path.split('/'), function(p) {
return !!p;
}), !isAbsolute).join('/');
if (!path && !isAbsolute) {
path = '.';
}
if (path && trailingSlash) {
path += '/';
}
return (isAbsolute ? '/' : '') + path;
};
// posix version
exports.isAbsolute = function(path) {
return path.charAt(0) === '/';
};
// posix version
exports.join = function() {
var paths = Array.prototype.slice.call(arguments, 0);
return exports.normalize(filter(paths, function(p, index) {
if (typeof p !== 'string') {
throw new TypeError('Arguments to path.join must be strings');
}
return p;
}).join('/'));
};
// path.relative(from, to)
// posix version
exports.relative = function(from, to) {
from = exports.resolve(from).substr(1);
to = exports.resolve(to).substr(1);
function trim(arr) {
var start = 0;
for (; start < arr.length; start++) {
if (arr[start] !== '') break;
}
var end = arr.length - 1;
for (; end >= 0; end--) {
if (arr[end] !== '') break;
}
if (start > end) return [];
return arr.slice(start, end - start + 1);
}
var fromParts = trim(from.split('/'));
var toParts = trim(to.split('/'));
var length = Math.min(fromParts.length, toParts.length);
var samePartsLength = length;
for (var i = 0; i < length; i++) {
if (fromParts[i] !== toParts[i]) {
samePartsLength = i;
break;
}
}
var outputParts = [];
for (var i = samePartsLength; i < fromParts.length; i++) {
outputParts.push('..');
}
outputParts = outputParts.concat(toParts.slice(samePartsLength));
return outputParts.join('/');
};
exports.sep = '/';
exports.delimiter = ':';
exports.dirname = function(path) {
var result = splitPath(path),
root = result[0],
dir = result[1];
if (!root && !dir) {
// No dirname whatsoever
return '.';
}
if (dir) {
// It has a dirname, strip trailing slash
dir = dir.substr(0, dir.length - 1);
}
return root + dir;
};
exports.basename = function(path, ext) {
var f = splitPath(path)[2];
// TODO: make this comparison case-insensitive on windows?
if (ext && f.substr(-1 * ext.length) === ext) {
f = f.substr(0, f.length - ext.length);
}
return f;
};
exports.extname = function(path) {
return splitPath(path)[3];
};
function filter (xs, f) {
if (xs.filter) return xs.filter(f);
var res = [];
for (var i = 0; i < xs.length; i++) {
if (f(xs[i], i, xs)) res.push(xs[i]);
}
return res;
}
// String.prototype.substr - negative index don't work in IE8
var substr = 'ab'.substr(-1) === 'b'
? function (str, start, len) { return str.substr(start, len) }
: function (str, start, len) {
if (start < 0) start = str.length + start;
return str.substr(start, len);
}
;
}).call(this,_dereq_(10))
},{"10":10}],10:[function(_dereq_,module,exports){
// shim for using process in browser
var process = module.exports = {};
var queue = [];
var draining = false;
var currentQueue;
var queueIndex = -1;
function cleanUpNextTick() {
draining = false;
if (currentQueue.length) {
queue = currentQueue.concat(queue);
} else {
queueIndex = -1;
}
if (queue.length) {
drainQueue();
}
}
function drainQueue() {
if (draining) {
return;
}
var timeout = setTimeout(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;
clearTimeout(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) {
setTimeout(drainQueue, 0);
}
};
// 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.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; };
},{}],11:[function(_dereq_,module,exports){
exports.isatty = function () { return false; };
function ReadStream() {
throw new Error('tty.ReadStream is not implemented');
}
exports.ReadStream = ReadStream;
function WriteStream() {
throw new Error('tty.ReadStream is not implemented');
}
exports.WriteStream = WriteStream;
},{}],12:[function(_dereq_,module,exports){
module.exports = function isBuffer(arg) {
return arg && typeof arg === 'object'
&& typeof arg.copy === 'function'
&& typeof arg.fill === 'function'
&& typeof arg.readUInt8 === 'function';
}
},{}],13:[function(_dereq_,module,exports){
(function (process,global){
// 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 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) {
// Allow for deprecating things in the process of starting up.
if (isUndefined(global.process)) {
return function() {
return exports.deprecate(fn, msg).apply(this, arguments);
};
}
if (process.noDeprecation === true) {
return fn;
}
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 debugEnviron;
exports.debuglog = function(set) {
if (isUndefined(debugEnviron))
debugEnviron = process.env.NODE_DEBUG || '';
set = set.toUpperCase();
if (!debugs[set]) {
if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
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').substr(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.substr(1, name.length - 2);
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()`.
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;
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;
function isError(e) {
return isObject(e) &&
(objectToString(e) === '[object Error]' || e instanceof Error);
}
exports.isError = 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 = _dereq_(12);
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 = _dereq_(7);
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);
}
}).call(this,_dereq_(10),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"10":10,"12":12,"7":7}],14:[function(_dereq_,module,exports){
(function (global){
/* eslint no-new-func: 0 */
"use strict";
_dereq_(15);
var transform = module.exports = _dereq_(66);
/**
* Add `options` and `version` to `babel` global.
*/
transform.options = _dereq_(49);
transform.version = _dereq_(603).version;
/**
* Add `transform` api to `babel` global.
*/
transform.transform = transform;
/**
* Tranform and execute script, adding in inline sourcemaps.
*/
transform.run = function (code) {
var opts = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
opts.sourceMaps = "inline";
return new Function(transform(code, opts).code)();
};
/**
* Load scripts via xhr, and `transform` when complete (optional).
*/
transform.load = function (url, callback, opts, hold) {
if (opts === undefined) opts = {};
opts.filename = opts.filename || url;
var xhr = global.ActiveXObject ? new global.ActiveXObject("Microsoft.XMLHTTP") : new global.XMLHttpRequest();
xhr.open("GET", url, true);
if ("overrideMimeType" in xhr) xhr.overrideMimeType("text/plain");
/**
* When successfully loaded, transform (optional), and call `callback`.
*/
xhr.onreadystatechange = function () {
if (xhr.readyState !== 4) return;
var status = xhr.status;
if (status === 0 || status === 200) {
var param = [xhr.responseText, opts];
if (!hold) transform.run.apply(transform, param);
if (callback) callback(param);
} else {
throw new Error("Could not load " + url);
}
};
xhr.send(null);
};
/**
* Load and transform all scripts of `types`.
*
* @example
* <script type="module"></script>
*/
var runScripts = function runScripts() {
var scripts = [];
var types = ["text/ecmascript-6", "text/6to5", "text/babel", "module"];
var index = 0;
/**
* Transform and execute script. Ensures correct load order.
*/
var exec = function exec() {
var param = scripts[index];
if (param instanceof Array) {
transform.run.apply(transform, param);
index++;
exec();
}
};
/**
* Load, transform, and execute all scripts.
*/
var run = function run(script, i) {
var opts = {};
if (script.src) {
transform.load(script.src, function (param) {
scripts[i] = param;
exec();
}, opts, true);
} else {
opts.filename = "embedded";
scripts[i] = [script.innerHTML, opts];
}
};
// Collect scripts with Babel `types`.
var _scripts = global.document.getElementsByTagName("script");
for (var i = 0; i < _scripts.length; ++i) {
var _script = _scripts[i];
if (types.indexOf(_script.type) >= 0) scripts.push(_script);
}
for (i in scripts) {
run(scripts[i], i);
}
exec();
};
/**
* Register load event to transform and execute scripts.
*/
if (global.addEventListener) {
global.addEventListener("DOMContentLoaded", runScripts, false);
} else if (global.attachEvent) {
global.attachEvent("onload", runScripts);
}
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"15":15,"49":49,"603":603,"66":66}],15:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports.register = register;
exports.polyfill = polyfill;
exports.transformFile = transformFile;
exports.transformFileSync = transformFileSync;
exports.parse = parse;
// istanbul ignore next
function _interopRequire(obj) { return obj && obj.__esModule ? obj["default"] : obj; }
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _lodashLangIsFunction = _dereq_(500);
var _lodashLangIsFunction2 = _interopRequireDefault(_lodashLangIsFunction);
var _transformation = _dereq_(66);
var _transformation2 = _interopRequireDefault(_transformation);
var _babylon = _dereq_(605);
var babylon = _interopRequireWildcard(_babylon);
var _util = _dereq_(182);
var util = _interopRequireWildcard(_util);
var _fs = _dereq_(1);
var _fs2 = _interopRequireDefault(_fs);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
exports.util = util;
exports.acorn = babylon;
exports.transform = _transformation2["default"];
exports.pipeline = _transformation.pipeline;
exports.canCompile = _util.canCompile;
var _transformationFile = _dereq_(46);
exports.File = _interopRequire(_transformationFile);
var _transformationFileOptionsConfig = _dereq_(48);
exports.options = _interopRequire(_transformationFileOptionsConfig);
var _transformationPlugin = _dereq_(82);
exports.Plugin = _interopRequire(_transformationPlugin);
var _transformationTransformer = _dereq_(83);
exports.Transformer = _interopRequire(_transformationTransformer);
var _transformationPipeline = _dereq_(80);
exports.Pipeline = _interopRequire(_transformationPipeline);
var _traversal = _dereq_(148);
exports.traverse = _interopRequire(_traversal);
var _toolsBuildExternalHelpers = _dereq_(45);
exports.buildExternalHelpers = _interopRequire(_toolsBuildExternalHelpers);
var _package = _dereq_(603);
exports.version = _package.version;
exports.types = t;
/**
* Register Babel and polyfill globally.
*/
function register(opts) {
var callback = _dereq_(17);
if (opts != null) callback(opts);
return callback;
}
/**
* Register polyfill globally.
*/
function polyfill() {
_dereq_(44);
}
/**
* Asynchronously transform `filename` with optional `opts`, calls `callback` when complete.
*/
function transformFile(filename, opts, callback) {
if (_lodashLangIsFunction2["default"](opts)) {
callback = opts;
opts = {};
}
opts.filename = filename;
_fs2["default"].readFile(filename, function (err, code) {
if (err) return callback(err);
var result;
try {
result = _transformation2["default"](code, opts);
} catch (err) {
return callback(err);
}
callback(null, result);
});
}
/**
* Synchronous form of `transformFile`.
*/
function transformFileSync(filename) {
var opts = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
opts.filename = filename;
return _transformation2["default"](_fs2["default"].readFileSync(filename, "utf8"), opts);
}
/**
* Parse script with Babel's parser.
*/
function parse(code) {
var opts = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
opts.allowHashBang = true;
opts.sourceType = "module";
opts.ecmaVersion = Infinity;
opts.plugins = {
jsx: true,
flow: true
};
opts.features = {};
for (var key in _transformation2["default"].pipeline.transformers) {
opts.features[key] = true;
}
var ast = babylon.parse(code, opts);
if (opts.onToken) {
// istanbul ignore next
var _opts$onToken;
(_opts$onToken = opts.onToken).push.apply(_opts$onToken, ast.tokens);
}
if (opts.onComment) {
// istanbul ignore next
var _opts$onComment;
(_opts$onComment = opts.onComment).push.apply(_opts$onComment, ast.comments);
}
return ast.program;
}
},{"1":1,"148":148,"17":17,"179":179,"182":182,"44":44,"45":45,"46":46,"48":48,"500":500,"603":603,"605":605,"66":66,"80":80,"82":82,"83":83}],16:[function(_dereq_,module,exports){
// required to safely use babel/register within a browserify codebase
"use strict";
exports.__esModule = true;
_dereq_(44);
exports["default"] = function () {};
module.exports = exports["default"];
},{"44":44}],17:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequire(obj) { return obj && obj.__esModule ? obj["default"] : obj; }
_dereq_(44);
var _node = _dereq_(16);
exports["default"] = _interopRequire(_node);
module.exports = exports["default"];
},{"16":16,"44":44}],18:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// istanbul ignore next
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _repeating = _dereq_(584);
var _repeating2 = _interopRequireDefault(_repeating);
var _trimRight = _dereq_(601);
var _trimRight2 = _interopRequireDefault(_trimRight);
var _lodashLangIsBoolean = _dereq_(498);
var _lodashLangIsBoolean2 = _interopRequireDefault(_lodashLangIsBoolean);
var _lodashCollectionIncludes = _dereq_(413);
var _lodashCollectionIncludes2 = _interopRequireDefault(_lodashCollectionIncludes);
var _lodashLangIsNumber = _dereq_(502);
var _lodashLangIsNumber2 = _interopRequireDefault(_lodashLangIsNumber);
/**
* Buffer for collecting generated output.
*/
var Buffer = (function () {
function Buffer(position, format) {
_classCallCheck(this, Buffer);
this.parenPushNewlineState = null;
this.position = position;
this._indent = format.indent.base;
this.format = format;
this.buf = "";
}
/**
* Get the current trimmed buffer.
*/
Buffer.prototype.get = function get() {
return _trimRight2["default"](this.buf);
};
/**
* Get the current indent.
*/
Buffer.prototype.getIndent = function getIndent() {
if (this.format.compact || this.format.concise) {
return "";
} else {
return _repeating2["default"](this.format.indent.style, this._indent);
}
};
/**
* Get the current indent size.
*/
Buffer.prototype.indentSize = function indentSize() {
return this.getIndent().length;
};
/**
* Increment indent size.
*/
Buffer.prototype.indent = function indent() {
this._indent++;
};
/**
* Decrement indent size.
*/
Buffer.prototype.dedent = function dedent() {
this._indent--;
};
/**
* Add a semicolon to the buffer.
*/
Buffer.prototype.semicolon = function semicolon() {
this.push(";");
};
/**
* Ensure last character is a semicolon.
*/
Buffer.prototype.ensureSemicolon = function ensureSemicolon() {
if (!this.isLast(";")) this.semicolon();
};
/**
* Add a right brace to the buffer.
*/
Buffer.prototype.rightBrace = function rightBrace() {
this.newline(true);
this.push("}");
};
/**
* Add a keyword to the buffer.
*/
Buffer.prototype.keyword = function keyword(name) {
this.push(name);
this.space();
};
/**
* Add a space to the buffer unless it is compact (override with force).
*/
Buffer.prototype.space = function space(force) {
if (!force && this.format.compact) return;
if (force || this.buf && !this.isLast(" ") && !this.isLast("\n")) {
this.push(" ");
}
};
/**
* Remove the last character.
*/
Buffer.prototype.removeLast = function removeLast(cha) {
if (this.format.compact) return;
if (!this.isLast(cha)) return;
this.buf = this.buf.substr(0, this.buf.length - 1);
this.position.unshift(cha);
};
/**
* Set some state that will be modified if a newline has been inserted before any
* non-space characters.
*
* This is to prevent breaking semantics for terminatorless separator nodes. eg:
*
* return foo;
*
* returns `foo`. But if we do:
*
* return
* foo;
*
* `undefined` will be returned and not `foo` due to the terminator.
*/
Buffer.prototype.startTerminatorless = function startTerminatorless() {
return this.parenPushNewlineState = {
printed: false
};
};
/**
* Print an ending parentheses if a starting one has been printed.
*/
Buffer.prototype.endTerminatorless = function endTerminatorless(state) {
if (state.printed) {
this.dedent();
this.newline();
this.push(")");
}
};
/**
* Add a newline (or many newlines), maintaining formatting.
* Strips multiple newlines if removeLast is true.
*/
Buffer.prototype.newline = function newline(i, removeLast) {
if (this.format.compact || this.format.retainLines) return;
if (this.format.concise) {
this.space();
return;
}
removeLast = removeLast || false;
if (_lodashLangIsNumber2["default"](i)) {
i = Math.min(2, i);
if (this.endsWith("{\n") || this.endsWith(":\n")) i--;
if (i <= 0) return;
while (i > 0) {
this._newline(removeLast);
i--;
}
return;
}
if (_lodashLangIsBoolean2["default"](i)) {
removeLast = i;
}
this._newline(removeLast);
};
/**
* Adds a newline unless there is already two previous newlines.
*/
Buffer.prototype._newline = function _newline(removeLast) {
// never allow more than two lines
if (this.endsWith("\n\n")) return;
// remove the last newline
if (removeLast && this.isLast("\n")) this.removeLast("\n");
this.removeLast(" ");
this._removeSpacesAfterLastNewline();
this._push("\n");
};
/**
* If buffer ends with a newline and some spaces after it, trim those spaces.
*/
Buffer.prototype._removeSpacesAfterLastNewline = function _removeSpacesAfterLastNewline() {
var lastNewlineIndex = this.buf.lastIndexOf("\n");
if (lastNewlineIndex === -1) {
return;
}
var index = this.buf.length - 1;
while (index > lastNewlineIndex) {
if (this.buf[index] !== " ") {
break;
}
index--;
}
if (index === lastNewlineIndex) {
this.buf = this.buf.substring(0, index + 1);
}
};
/**
* Push a string to the buffer, maintaining indentation and newlines.
*/
Buffer.prototype.push = function push(str, noIndent) {
if (!this.format.compact && this._indent && !noIndent && str !== "\n") {
// we have an indent level and we aren't pushing a newline
var indent = this.getIndent();
// replace all newlines with newlines with the indentation
str = str.replace(/\n/g, "\n" + indent);
// we've got a newline before us so prepend on the indentation
if (this.isLast("\n")) this._push(indent);
}
this._push(str);
};
/**
* Push a string to the buffer.
*/
Buffer.prototype._push = function _push(str) {
// see startTerminatorless() instance method
var parenPushNewlineState = this.parenPushNewlineState;
if (parenPushNewlineState) {
for (var i = 0; i < str.length; i++) {
var cha = str[i];
// we can ignore spaces since they wont interupt a terminatorless separator
if (cha === " ") continue;
this.parenPushNewlineState = null;
if (cha === "\n" || cha === "/") {
// we're going to break this terminator expression so we need to add a parentheses
this._push("(");
this.indent();
parenPushNewlineState.printed = true;
}
break;
}
}
//
this.position.push(str);
this.buf += str;
};
/**
* Test if the buffer ends with a string.
*/
Buffer.prototype.endsWith = function endsWith(str) {
var buf = arguments.length <= 1 || arguments[1] === undefined ? this.buf : arguments[1];
if (str.length === 1) {
return buf[buf.length - 1] === str;
} else {
return buf.slice(-str.length) === str;
}
};
/**
* Test if a character is last in the buffer.
*/
Buffer.prototype.isLast = function isLast(cha) {
if (this.format.compact) return false;
var buf = this.buf;
var last = buf[buf.length - 1];
if (Array.isArray(cha)) {
return _lodashCollectionIncludes2["default"](cha, last);
} else {
return cha === last;
}
};
return Buffer;
})();
exports["default"] = Buffer;
module.exports = exports["default"];
},{"413":413,"498":498,"502":502,"584":584,"601":601}],19:[function(_dereq_,module,exports){
/**
* Print File.program
*/
"use strict";
exports.__esModule = true;
exports.File = File;
exports.Program = Program;
exports.BlockStatement = BlockStatement;
exports.Noop = Noop;
function File(node, print) {
print.plain(node.program);
}
/**
* Print all nodes in a Program.body.
*/
function Program(node, print) {
print.sequence(node.body);
}
/**
* Print BlockStatement, collapses empty blocks, prints body.
*/
function BlockStatement(node, print) {
this.push("{");
if (node.body.length) {
this.newline();
print.sequence(node.body, { indent: true });
if (!this.format.retainLines) this.removeLast("\n");
this.rightBrace();
} else {
print.printInnerComments();
this.push("}");
}
}
/**
* What is my purpose?
* Why am I here?
* Why are any of us here?
* Does any of this really matter?
*/
function Noop() {}
},{}],20:[function(_dereq_,module,exports){
/**
* Print ClassDeclaration, prints decorators, typeParameters, extends, implements, and body.
*/
"use strict";
exports.__esModule = true;
exports.ClassDeclaration = ClassDeclaration;
exports.ClassBody = ClassBody;
exports.ClassProperty = ClassProperty;
exports.MethodDefinition = MethodDefinition;
function ClassDeclaration(node, print) {
print.list(node.decorators, { separator: "" });
this.push("class");
if (node.id) {
this.push(" ");
print.plain(node.id);
}
print.plain(node.typeParameters);
if (node.superClass) {
this.push(" extends ");
print.plain(node.superClass);
print.plain(node.superTypeParameters);
}
if (node["implements"]) {
this.push(" implements ");
print.join(node["implements"], { separator: ", " });
}
this.space();
print.plain(node.body);
}
/**
* Alias ClassDeclaration printer as ClassExpression.
*/
exports.ClassExpression = ClassDeclaration;
/**
* Print ClassBody, collapses empty blocks, prints body.
*/
function ClassBody(node, print) {
this.push("{");
if (node.body.length === 0) {
print.printInnerComments();
this.push("}");
} else {
this.newline();
this.indent();
print.sequence(node.body);
this.dedent();
this.rightBrace();
}
}
/**
* Print ClassProperty, prints decorators, static, key, typeAnnotation, and value.
* Also: semicolons, deal with it.
*/
function ClassProperty(node, print) {
print.list(node.decorators, { separator: "" });
if (node["static"]) this.push("static ");
print.plain(node.key);
print.plain(node.typeAnnotation);
if (node.value) {
this.space();
this.push("=");
this.space();
print.plain(node.value);
}
this.semicolon();
}
/**
* Print MethodDefinition, prints decorations, static, and method.
*/
function MethodDefinition(node, print) {
print.list(node.decorators, { separator: "" });
if (node["static"]) {
this.push("static ");
}
this._method(node, print);
}
},{}],21:[function(_dereq_,module,exports){
/**
* Prints ComprehensionBlock, prints left and right.
*/
"use strict";
exports.__esModule = true;
exports.ComprehensionBlock = ComprehensionBlock;
exports.ComprehensionExpression = ComprehensionExpression;
function ComprehensionBlock(node, print) {
this.keyword("for");
this.push("(");
print.plain(node.left);
this.push(" of ");
print.plain(node.right);
this.push(")");
}
/**
* Prints ComprehensionExpression, prints blocks, filter, and body. Handles generators.
*/
function ComprehensionExpression(node, print) {
this.push(node.generator ? "(" : "[");
print.join(node.blocks, { separator: " " });
this.space();
if (node.filter) {
this.keyword("if");
this.push("(");
print.plain(node.filter);
this.push(")");
this.space();
}
print.plain(node.body);
this.push(node.generator ? ")" : "]");
}
},{}],22:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports.UnaryExpression = UnaryExpression;
exports.DoExpression = DoExpression;
exports.ParenthesizedExpression = ParenthesizedExpression;
exports.UpdateExpression = UpdateExpression;
exports.ConditionalExpression = ConditionalExpression;
exports.NewExpression = NewExpression;
exports.SequenceExpression = SequenceExpression;
exports.ThisExpression = ThisExpression;
exports.Super = Super;
exports.Decorator = Decorator;
exports.CallExpression = CallExpression;
exports.EmptyStatement = EmptyStatement;
exports.ExpressionStatement = ExpressionStatement;
exports.AssignmentPattern = AssignmentPattern;
exports.AssignmentExpression = AssignmentExpression;
exports.BindExpression = BindExpression;
exports.MemberExpression = MemberExpression;
exports.MetaProperty = MetaProperty;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _isInteger = _dereq_(398);
var _isInteger2 = _interopRequireDefault(_isInteger);
var _lodashLangIsNumber = _dereq_(502);
var _lodashLangIsNumber2 = _interopRequireDefault(_lodashLangIsNumber);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* RegExp for testing scientific notation in literals.
*/
var SCIENTIFIC_NOTATION = /e/i;
/**
* RegExp for testing if a numeric literal is
* a BinaryIntegerLiteral, OctalIntegerLiteral or HexIntegerLiteral.
*/
var NON_DECIMAL_NUMERIC_LITERAL = /^0(b|o|x)/i;
/**
* Prints UnaryExpression, prints operator and argument.
*/
function UnaryExpression(node, print) {
var needsSpace = /[a-z]$/.test(node.operator);
var arg = node.argument;
if (t.isUpdateExpression(arg) || t.isUnaryExpression(arg)) {
needsSpace = true;
}
if (t.isUnaryExpression(arg) && arg.operator === "!") {
needsSpace = false;
}
this.push(node.operator);
if (needsSpace) this.push(" ");
print.plain(node.argument);
}
/**
* Prints DoExpression, prints body.
*/
function DoExpression(node, print) {
this.push("do");
this.space();
print.plain(node.body);
}
/**
* Prints ParenthesizedExpression, prints expression.
*/
function ParenthesizedExpression(node, print) {
this.push("(");
print.plain(node.expression);
this.push(")");
}
/**
* Prints UpdateExpression, prints operator and argument.
*/
function UpdateExpression(node, print) {
if (node.prefix) {
this.push(node.operator);
print.plain(node.argument);
} else {
print.plain(node.argument);
this.push(node.operator);
}
}
/**
* Prints ConditionalExpression, prints test, consequent, and alternate.
*/
function ConditionalExpression(node, print) {
print.plain(node.test);
this.space();
this.push("?");
this.space();
print.plain(node.consequent);
this.space();
this.push(":");
this.space();
print.plain(node.alternate);
}
/**
* Prints NewExpression, prints callee and arguments.
*/
function NewExpression(node, print) {
this.push("new ");
print.plain(node.callee);
this.push("(");
print.list(node.arguments);
this.push(")");
}
/**
* Prints SequenceExpression.expressions.
*/
function SequenceExpression(node, print) {
print.list(node.expressions);
}
/**
* Prints ThisExpression.
*/
function ThisExpression() {
this.push("this");
}
/**
* Prints Super.
*/
function Super() {
this.push("super");
}
/**
* Prints Decorator, prints expression.
*/
function Decorator(node, print) {
this.push("@");
print.plain(node.expression);
this.newline();
}
/**
* Prints CallExpression, prints callee and arguments.
*/
function CallExpression(node, print) {
print.plain(node.callee);
this.push("(");
var isPrettyCall = node._prettyCall && !this.format.retainLines && !this.format.compact;
var separator;
if (isPrettyCall) {
separator = ",\n";
this.newline();
this.indent();
}
print.list(node.arguments, { separator: separator });
if (isPrettyCall) {
this.newline();
this.dedent();
}
this.push(")");
}
/**
* Builds yield or await expression printer.
* Prints delegate, all, and argument.
*/
var buildYieldAwait = function buildYieldAwait(keyword) {
return function (node, print) {
this.push(keyword);
if (node.delegate || node.all) {
this.push("*");
}
if (node.argument) {
this.push(" ");
var terminatorState = this.startTerminatorless();
print.plain(node.argument);
this.endTerminatorless(terminatorState);
}
};
};
/**
* Create YieldExpression and AwaitExpression printers.
*/
var YieldExpression = buildYieldAwait("yield");
exports.YieldExpression = YieldExpression;
var AwaitExpression = buildYieldAwait("await");
exports.AwaitExpression = AwaitExpression;
/**
* Prints EmptyStatement.
*/
function EmptyStatement() {
this.semicolon();
}
/**
* Prints ExpressionStatement, prints expression.
*/
function ExpressionStatement(node, print) {
print.plain(node.expression);
this.semicolon();
}
/**
* Prints AssignmentPattern, prints left and right.
*/
function AssignmentPattern(node, print) {
print.plain(node.left);
this.push(" = ");
print.plain(node.right);
}
/**
* Prints AssignmentExpression, prints left, operator, and right.
*/
function AssignmentExpression(node, print) {
// todo: add cases where the spaces can be dropped when in compact mode
print.plain(node.left);
var spaces = node.operator === "in" || node.operator === "instanceof";
spaces = true; // todo: https://github.com/babel/babel/issues/1835
this.space(spaces);
this.push(node.operator);
if (!spaces) {
// space is mandatory to avoid outputting <!--
// http://javascript.spec.whatwg.org/#comment-syntax
spaces = node.operator === "<" && t.isUnaryExpression(node.right, { prefix: true, operator: "!" }) && t.isUnaryExpression(node.right.argument, { prefix: true, operator: "--" });
}
this.space(spaces);
print.plain(node.right);
}
/**
* Prints BindExpression, prints object and callee.
*/
function BindExpression(node, print) {
print.plain(node.object);
this.push("::");
print.plain(node.callee);
}
/**
* Alias ClassDeclaration printer as ClassExpression,
* and AssignmentExpression printer as LogicalExpression.
*/
exports.BinaryExpression = AssignmentExpression;
exports.LogicalExpression = AssignmentExpression;
/**
* Print MemberExpression, prints object, property, and value. Handles computed.
*/
function MemberExpression(node, print) {
var obj = node.object;
print.plain(obj);
if (!node.computed && t.isMemberExpression(node.property)) {
throw new TypeError("Got a MemberExpression for MemberExpression property");
}
var computed = node.computed;
if (t.isLiteral(node.property) && _lodashLangIsNumber2["default"](node.property.value)) {
computed = true;
}
if (computed) {
this.push("[");
print.plain(node.property);
this.push("]");
} else {
if (t.isLiteral(node.object)) {
var val = this._Literal(node.object);
if (_isInteger2["default"](+val) && !SCIENTIFIC_NOTATION.test(val) && !this.endsWith(".") && !NON_DECIMAL_NUMERIC_LITERAL.test(val)) {
this.push(".");
}
}
this.push(".");
print.plain(node.property);
}
}
/**
* Print MetaProperty, prints meta and property.
*/
function MetaProperty(node, print) {
print.plain(node.meta);
this.push(".");
print.plain(node.property);
}
},{"179":179,"398":398,"502":502}],23:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports.AnyTypeAnnotation = AnyTypeAnnotation;
exports.ArrayTypeAnnotation = ArrayTypeAnnotation;
exports.BooleanTypeAnnotation = BooleanTypeAnnotation;
exports.BooleanLiteralTypeAnnotation = BooleanLiteralTypeAnnotation;
exports.DeclareClass = DeclareClass;
exports.DeclareFunction = DeclareFunction;
exports.DeclareModule = DeclareModule;
exports.DeclareVariable = DeclareVariable;
exports.FunctionTypeAnnotation = FunctionTypeAnnotation;
exports.FunctionTypeParam = FunctionTypeParam;
exports.InterfaceExtends = InterfaceExtends;
exports._interfaceish = _interfaceish;
exports.InterfaceDeclaration = InterfaceDeclaration;
exports.IntersectionTypeAnnotation = IntersectionTypeAnnotation;
exports.MixedTypeAnnotation = MixedTypeAnnotation;
exports.NullableTypeAnnotation = NullableTypeAnnotation;
exports.NumberTypeAnnotation = NumberTypeAnnotation;
exports.StringLiteralTypeAnnotation = StringLiteralTypeAnnotation;
exports.StringTypeAnnotation = StringTypeAnnotation;
exports.TupleTypeAnnotation = TupleTypeAnnotation;
exports.TypeofTypeAnnotation = TypeofTypeAnnotation;
exports.TypeAlias = TypeAlias;
exports.TypeAnnotation = TypeAnnotation;
exports.TypeParameterInstantiation = TypeParameterInstantiation;
exports.ObjectTypeAnnotation = ObjectTypeAnnotation;
exports.ObjectTypeCallProperty = ObjectTypeCallProperty;
exports.ObjectTypeIndexer = ObjectTypeIndexer;
exports.ObjectTypeProperty = ObjectTypeProperty;
exports.QualifiedTypeIdentifier = QualifiedTypeIdentifier;
exports.UnionTypeAnnotation = UnionTypeAnnotation;
exports.TypeCastExpression = TypeCastExpression;
exports.VoidTypeAnnotation = VoidTypeAnnotation;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* Prints AnyTypeAnnotation.
*/
function AnyTypeAnnotation() {
this.push("any");
}
/**
* Prints ArrayTypeAnnotation, prints elementType.
*/
function ArrayTypeAnnotation(node, print) {
print.plain(node.elementType);
this.push("[");
this.push("]");
}
/**
* Prints BooleanTypeAnnotation.
*/
function BooleanTypeAnnotation() {
this.push("bool");
}
/**
* Prints BooleanLiteralTypeAnnotation.
*/
function BooleanLiteralTypeAnnotation(node) {
this.push(node.value ? "true" : "false");
}
/**
* Prints DeclareClass, prints node.
*/
function DeclareClass(node, print) {
this.push("declare class ");
this._interfaceish(node, print);
}
/**
* Prints DeclareFunction, prints id and id.typeAnnotation.
*/
function DeclareFunction(node, print) {
this.push("declare function ");
print.plain(node.id);
print.plain(node.id.typeAnnotation.typeAnnotation);
this.semicolon();
}
/**
* Prints DeclareModule, prints id and body.
*/
function DeclareModule(node, print) {
this.push("declare module ");
print.plain(node.id);
this.space();
print.plain(node.body);
}
/**
* Prints DeclareVariable, prints id and id.typeAnnotation.
*/
function DeclareVariable(node, print) {
this.push("declare var ");
print.plain(node.id);
print.plain(node.id.typeAnnotation);
this.semicolon();
}
/**
* Prints FunctionTypeAnnotation, prints typeParameters, params, and rest.
*/
function FunctionTypeAnnotation(node, print, parent) {
print.plain(node.typeParameters);
this.push("(");
print.list(node.params);
if (node.rest) {
if (node.params.length) {
this.push(",");
this.space();
}
this.push("...");
print.plain(node.rest);
}
this.push(")");
// this node type is overloaded, not sure why but it makes it EXTREMELY annoying
if (parent.type === "ObjectTypeProperty" || parent.type === "ObjectTypeCallProperty" || parent.type === "DeclareFunction") {
this.push(":");
} else {
this.space();
this.push("=>");
}
this.space();
print.plain(node.returnType);
}
/**
* Prints FunctionTypeParam, prints name and typeAnnotation, handles optional.
*/
function FunctionTypeParam(node, print) {
print.plain(node.name);
if (node.optional) this.push("?");
this.push(":");
this.space();
print.plain(node.typeAnnotation);
}
/**
* Prints InterfaceExtends, prints id and typeParameters.
*/
function InterfaceExtends(node, print) {
print.plain(node.id);
print.plain(node.typeParameters);
}
/**
* Alias InterfaceExtends printer as ClassImplements,
* and InterfaceExtends printer as GenericTypeAnnotation.
*/
exports.ClassImplements = InterfaceExtends;
exports.GenericTypeAnnotation = InterfaceExtends;
/**
* Prints interface-like node, prints id, typeParameters, extends, and body.
*/
function _interfaceish(node, print) {
print.plain(node.id);
print.plain(node.typeParameters);
if (node["extends"].length) {
this.push(" extends ");
print.join(node["extends"], { separator: ", " });
}
this.space();
print.plain(node.body);
}
/**
* Prints InterfaceDeclaration, prints node.
*/
function InterfaceDeclaration(node, print) {
this.push("interface ");
this._interfaceish(node, print);
}
/**
* Prints IntersectionTypeAnnotation, prints types.
*/
function IntersectionTypeAnnotation(node, print) {
print.join(node.types, { separator: " & " });
}
/**
* Prints MixedTypeAnnotation.
*/
function MixedTypeAnnotation() {
this.push("mixed");
}
/**
* Prints NullableTypeAnnotation, prints typeAnnotation.
*/
function NullableTypeAnnotation(node, print) {
this.push("?");
print.plain(node.typeAnnotation);
}
/**
* Prints NumberLiteralTypeAnnotation, prints value.
*/
var _types2 = _dereq_(29);
exports.NumberLiteralTypeAnnotation = _types2.Literal;
/**
* Prints NumberTypeAnnotation.
*/
function NumberTypeAnnotation() {
this.push("number");
}
/**
* Prints StringLiteralTypeAnnotation, prints value.
*/
function StringLiteralTypeAnnotation(node) {
this.push(this._stringLiteral(node.value));
}
/**
* Prints StringTypeAnnotation.
*/
function StringTypeAnnotation() {
this.push("string");
}
/**
* Prints TupleTypeAnnotation, prints types.
*/
function TupleTypeAnnotation(node, print) {
this.push("[");
print.join(node.types, { separator: ", " });
this.push("]");
}
/**
* Prints TypeofTypeAnnotation, prints argument.
*/
function TypeofTypeAnnotation(node, print) {
this.push("typeof ");
print.plain(node.argument);
}
/**
* Prints TypeAlias, prints id, typeParameters, and right.
*/
function TypeAlias(node, print) {
this.push("type ");
print.plain(node.id);
print.plain(node.typeParameters);
this.space();
this.push("=");
this.space();
print.plain(node.right);
this.semicolon();
}
/**
* Prints TypeAnnotation, prints typeAnnotation, handles optional.
*/
function TypeAnnotation(node, print) {
this.push(":");
this.space();
if (node.optional) this.push("?");
print.plain(node.typeAnnotation);
}
/**
* Prints TypeParameterInstantiation, prints params.
*/
function TypeParameterInstantiation(node, print) {
this.push("<");
print.join(node.params, {
separator: ", ",
iterator: function iterator(node) {
print.plain(node.typeAnnotation);
}
});
this.push(">");
}
/**
* Alias TypeParameterInstantiation printer as TypeParameterDeclaration
*/
exports.TypeParameterDeclaration = TypeParameterInstantiation;
/**
* Prints ObjectTypeAnnotation, prints properties, callProperties, and indexers.
*/
function ObjectTypeAnnotation(node, print) {
// istanbul ignore next
var _this = this;
this.push("{");
var props = node.properties.concat(node.callProperties, node.indexers);
if (props.length) {
this.space();
print.list(props, {
separator: false,
indent: true,
iterator: function iterator() {
if (props.length !== 1) {
_this.semicolon();
_this.space();
}
}
});
this.space();
}
this.push("}");
}
/**
* Prints ObjectTypeCallProperty, prints value, handles static.
*/
function ObjectTypeCallProperty(node, print) {
if (node["static"]) this.push("static ");
print.plain(node.value);
}
/**
* Prints ObjectTypeIndexer, prints id, key, and value, handles static.
*/
function ObjectTypeIndexer(node, print) {
if (node["static"]) this.push("static ");
this.push("[");
print.plain(node.id);
this.push(":");
this.space();
print.plain(node.key);
this.push("]");
this.push(":");
this.space();
print.plain(node.value);
}
/**
* Prints ObjectTypeProperty, prints static, key, and value.
*/
function ObjectTypeProperty(node, print) {
if (node["static"]) this.push("static ");
print.plain(node.key);
if (node.optional) this.push("?");
if (!t.isFunctionTypeAnnotation(node.value)) {
this.push(":");
this.space();
}
print.plain(node.value);
}
/**
* Prints QualifiedTypeIdentifier, prints qualification and id.
*/
function QualifiedTypeIdentifier(node, print) {
print.plain(node.qualification);
this.push(".");
print.plain(node.id);
}
/**
* Prints UnionTypeAnnotation, prints types.
*/
function UnionTypeAnnotation(node, print) {
print.join(node.types, { separator: " | " });
}
/**
* Prints TypeCastExpression, prints expression and typeAnnotation.
*/
function TypeCastExpression(node, print) {
this.push("(");
print.plain(node.expression);
print.plain(node.typeAnnotation);
this.push(")");
}
/**
* Prints VoidTypeAnnotation.
*/
function VoidTypeAnnotation() {
this.push("void");
}
},{"179":179,"29":29}],24:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports.JSXAttribute = JSXAttribute;
exports.JSXIdentifier = JSXIdentifier;
exports.JSXNamespacedName = JSXNamespacedName;
exports.JSXMemberExpression = JSXMemberExpression;
exports.JSXSpreadAttribute = JSXSpreadAttribute;
exports.JSXExpressionContainer = JSXExpressionContainer;
exports.JSXElement = JSXElement;
exports.JSXOpeningElement = JSXOpeningElement;
exports.JSXClosingElement = JSXClosingElement;
exports.JSXEmptyExpression = JSXEmptyExpression;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* Prints JSXAttribute, prints name and value.
*/
function JSXAttribute(node, print) {
print.plain(node.name);
if (node.value) {
this.push("=");
print.plain(node.value);
}
}
/**
* Prints JSXIdentifier, prints name.
*/
function JSXIdentifier(node) {
this.push(node.name);
}
/**
* Prints JSXNamespacedName, prints namespace and name.
*/
function JSXNamespacedName(node, print) {
print.plain(node.namespace);
this.push(":");
print.plain(node.name);
}
/**
* Prints JSXMemberExpression, prints object and property.
*/
function JSXMemberExpression(node, print) {
print.plain(node.object);
this.push(".");
print.plain(node.property);
}
/**
* Prints JSXSpreadAttribute, prints argument.
*/
function JSXSpreadAttribute(node, print) {
this.push("{...");
print.plain(node.argument);
this.push("}");
}
/**
* Prints JSXExpressionContainer, prints expression.
*/
function JSXExpressionContainer(node, print) {
this.push("{");
print.plain(node.expression);
this.push("}");
}
/**
* Prints JSXElement, prints openingElement, children, and closingElement.
*/
function JSXElement(node, print) {
var open = node.openingElement;
print.plain(open);
if (open.selfClosing) return;
this.indent();
var _arr = node.children;
for (var _i = 0; _i < _arr.length; _i++) {
var child = _arr[_i];
if (t.isLiteral(child)) {
this.push(child.value, true);
} else {
print.plain(child);
}
}
this.dedent();
print.plain(node.closingElement);
}
/**
* Prints JSXOpeningElement, prints name and attributes, handles selfClosing.
*/
function JSXOpeningElement(node, print) {
this.push("<");
print.plain(node.name);
if (node.attributes.length > 0) {
this.push(" ");
print.join(node.attributes, { separator: " " });
}
this.push(node.selfClosing ? " />" : ">");
}
/**
* Prints JSXClosingElement, prints name.
*/
function JSXClosingElement(node, print) {
this.push("</");
print.plain(node.name);
this.push(">");
}
/**
* Prints JSXEmptyExpression.
*/
function JSXEmptyExpression() {}
},{"179":179}],25:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports._params = _params;
exports._method = _method;
exports.FunctionExpression = FunctionExpression;
exports.ArrowFunctionExpression = ArrowFunctionExpression;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* Prints nodes with params, prints typeParameters, params, and returnType, handles optional params.
*/
function _params(node, print) {
// istanbul ignore next
var _this = this;
print.plain(node.typeParameters);
this.push("(");
print.list(node.params, {
iterator: function iterator(node) {
if (node.optional) _this.push("?");
print.plain(node.typeAnnotation);
}
});
this.push(")");
if (node.returnType) {
print.plain(node.returnType);
}
}
/**
* Prints method-like nodes, prints key, value, and body, handles async, generator, computed, and get or set.
*/
function _method(node, print) {
var value = node.value;
var kind = node.kind;
var key = node.key;
if (kind === "method" || kind === "init") {
if (value.generator) {
this.push("*");
}
}
if (kind === "get" || kind === "set") {
this.push(kind + " ");
}
if (value.async) this.push("async ");
if (node.computed) {
this.push("[");
print.plain(key);
this.push("]");
} else {
print.plain(key);
}
this._params(value, print);
this.space();
print.plain(value.body);
}
/**
* Prints FunctionExpression, prints id and body, handles async and generator.
*/
function FunctionExpression(node, print) {
if (node.async) this.push("async ");
this.push("function");
if (node.generator) this.push("*");
if (node.id) {
this.push(" ");
print.plain(node.id);
} else {
this.space();
}
this._params(node, print);
this.space();
print.plain(node.body);
}
/**
* Alias FunctionExpression printer as FunctionDeclaration.
*/
exports.FunctionDeclaration = FunctionExpression;
/**
* Prints ArrowFunctionExpression, prints params and body, handles async.
* Leaves out parentheses when single param.
*/
function ArrowFunctionExpression(node, print) {
if (node.async) this.push("async ");
if (node.params.length === 1 && t.isIdentifier(node.params[0])) {
print.plain(node.params[0]);
} else {
this._params(node, print);
}
this.push(" => ");
var bodyNeedsParens = t.isObjectExpression(node.body);
if (bodyNeedsParens) {
this.push("(");
}
print.plain(node.body);
if (bodyNeedsParens) {
this.push(")");
}
}
},{"179":179}],26:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports.ImportSpecifier = ImportSpecifier;
exports.ImportDefaultSpecifier = ImportDefaultSpecifier;
exports.ExportDefaultSpecifier = ExportDefaultSpecifier;
exports.ExportSpecifier = ExportSpecifier;
exports.ExportNamespaceSpecifier = ExportNamespaceSpecifier;
exports.ExportAllDeclaration = ExportAllDeclaration;
exports.ExportNamedDeclaration = ExportNamedDeclaration;
exports.ExportDefaultDeclaration = ExportDefaultDeclaration;
exports.ImportDeclaration = ImportDeclaration;
exports.ImportNamespaceSpecifier = ImportNamespaceSpecifier;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* Prints ImportSpecifier, prints imported and local.
*/
function ImportSpecifier(node, print) {
print.plain(node.imported);
if (node.local && node.local.name !== node.imported.name) {
this.push(" as ");
print.plain(node.local);
}
}
/**
* Prints ImportDefaultSpecifier, prints local.
*/
function ImportDefaultSpecifier(node, print) {
print.plain(node.local);
}
/**
* Prints ExportDefaultSpecifier, prints exported.
*/
function ExportDefaultSpecifier(node, print) {
print.plain(node.exported);
}
/**
* Prints ExportSpecifier, prints local and exported.
*/
function ExportSpecifier(node, print) {
print.plain(node.local);
if (node.exported && node.local.name !== node.exported.name) {
this.push(" as ");
print.plain(node.exported);
}
}
/**
* Prints ExportNamespaceSpecifier, prints exported.
*/
function ExportNamespaceSpecifier(node, print) {
this.push("* as ");
print.plain(node.exported);
}
/**
* Prints ExportAllDeclaration, prints exported and source.
*/
function ExportAllDeclaration(node, print) {
this.push("export *");
if (node.exported) {
this.push(" as ");
print.plain(node.exported);
}
this.push(" from ");
print.plain(node.source);
this.semicolon();
}
/**
* Prints ExportNamedDeclaration, delegates to ExportDeclaration.
*/
function ExportNamedDeclaration(node, print) {
this.push("export ");
ExportDeclaration.call(this, node, print);
}
/**
* Prints ExportDefaultDeclaration, delegates to ExportDeclaration.
*/
function ExportDefaultDeclaration(node, print) {
this.push("export default ");
ExportDeclaration.call(this, node, print);
}
/**
* Prints ExportDeclaration, prints specifiers, declration, and source.
*/
function ExportDeclaration(node, print) {
var specifiers = node.specifiers;
if (node.declaration) {
var declar = node.declaration;
print.plain(declar);
if (t.isStatement(declar) || t.isFunction(declar) || t.isClass(declar)) return;
} else {
if (node.exportKind === "type") {
this.push("type ");
}
var first = specifiers[0];
var hasSpecial = false;
if (t.isExportDefaultSpecifier(first) || t.isExportNamespaceSpecifier(first)) {
hasSpecial = true;
print.plain(specifiers.shift());
if (specifiers.length) {
this.push(", ");
}
}
if (specifiers.length || !specifiers.length && !hasSpecial) {
this.push("{");
if (specifiers.length) {
this.space();
print.join(specifiers, { separator: ", " });
this.space();
}
this.push("}");
}
if (node.source) {
this.push(" from ");
print.plain(node.source);
}
}
this.ensureSemicolon();
}
/**
* Prints ImportDeclaration, prints specifiers and source, handles isType.
*/
function ImportDeclaration(node, print) {
this.push("import ");
if (node.importKind === "type" || node.importKind === "typeof") {
this.push(node.importKind + " ");
}
var specfiers = node.specifiers;
if (specfiers && specfiers.length) {
var first = node.specifiers[0];
if (t.isImportDefaultSpecifier(first) || t.isImportNamespaceSpecifier(first)) {
print.plain(node.specifiers.shift());
if (node.specifiers.length) {
this.push(", ");
}
}
if (node.specifiers.length) {
this.push("{");
this.space();
print.join(node.specifiers, { separator: ", " });
this.space();
this.push("}");
}
this.push(" from ");
}
print.plain(node.source);
this.semicolon();
}
/**
* Prints ImportNamespaceSpecifier, prints local.
*/
function ImportNamespaceSpecifier(node, print) {
this.push("* as ");
print.plain(node.local);
}
},{"179":179}],27:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports.WithStatement = WithStatement;
exports.IfStatement = IfStatement;
exports.ForStatement = ForStatement;
exports.WhileStatement = WhileStatement;
exports.DoWhileStatement = DoWhileStatement;
exports.LabeledStatement = LabeledStatement;
exports.TryStatement = TryStatement;
exports.CatchClause = CatchClause;
exports.SwitchStatement = SwitchStatement;
exports.SwitchCase = SwitchCase;
exports.DebuggerStatement = DebuggerStatement;
exports.VariableDeclaration = VariableDeclaration;
exports.VariableDeclarator = VariableDeclarator;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _repeating = _dereq_(584);
var _repeating2 = _interopRequireDefault(_repeating);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* Prints WithStatement, prints object and body.
*/
function WithStatement(node, print) {
this.keyword("with");
this.push("(");
print.plain(node.object);
this.push(")");
print.block(node.body);
}
/**
* Prints IfStatement, prints test, consequent, and alternate.
*/
function IfStatement(node, print) {
this.keyword("if");
this.push("(");
print.plain(node.test);
this.push(")");
this.space();
print.indentOnComments(node.consequent);
if (node.alternate) {
if (this.isLast("}")) this.space();
this.push("else ");
print.indentOnComments(node.alternate);
}
}
/**
* Prints ForStatement, prints init, test, update, and body.
*/
function ForStatement(node, print) {
this.keyword("for");
this.push("(");
print.plain(node.init);
this.push(";");
if (node.test) {
this.space();
print.plain(node.test);
}
this.push(";");
if (node.update) {
this.space();
print.plain(node.update);
}
this.push(")");
print.block(node.body);
}
/**
* Prints WhileStatement, prints test and body.
*/
function WhileStatement(node, print) {
this.keyword("while");
this.push("(");
print.plain(node.test);
this.push(")");
print.block(node.body);
}
/**
* Builds ForIn or ForOf statement printers.
* Prints left, right, and body.
*/
var buildForXStatement = function buildForXStatement(op) {
return function (node, print) {
this.keyword("for");
this.push("(");
print.plain(node.left);
this.push(" " + op + " ");
print.plain(node.right);
this.push(")");
print.block(node.body);
};
};
/**
* Create ForInStatement and ForOfStatement printers.
*/
var ForInStatement = buildForXStatement("in");
exports.ForInStatement = ForInStatement;
var ForOfStatement = buildForXStatement("of");
exports.ForOfStatement = ForOfStatement;
/**
* Prints DoWhileStatement, prints body and test.
*/
function DoWhileStatement(node, print) {
this.push("do ");
print.plain(node.body);
this.space();
this.keyword("while");
this.push("(");
print.plain(node.test);
this.push(");");
}
/**
* Builds continue, return, or break statement printers.
* Prints label (or key).
*/
var buildLabelStatement = function buildLabelStatement(prefix) {
var key = arguments.length <= 1 || arguments[1] === undefined ? "label" : arguments[1];
return function (node, print) {
this.push(prefix);
var label = node[key];
if (label) {
this.push(" ");
var terminatorState = this.startTerminatorless();
print.plain(label);
this.endTerminatorless(terminatorState);
}
this.semicolon();
};
};
/**
* Create ContinueStatement, ReturnStatement, and BreakStatement printers.
*/
var ContinueStatement = buildLabelStatement("continue");
exports.ContinueStatement = ContinueStatement;
var ReturnStatement = buildLabelStatement("return", "argument");
exports.ReturnStatement = ReturnStatement;
var BreakStatement = buildLabelStatement("break");
exports.BreakStatement = BreakStatement;
var ThrowStatement = buildLabelStatement("throw", "argument");
exports.ThrowStatement = ThrowStatement;
/**
* Prints LabeledStatement, prints label and body.
*/
function LabeledStatement(node, print) {
print.plain(node.label);
this.push(": ");
print.plain(node.body);
}
/**
* Prints TryStatement, prints block, handlers, and finalizer.
*/
function TryStatement(node, print) {
this.keyword("try");
print.plain(node.block);
this.space();
// Esprima bug puts the catch clause in a `handlers` array.
// see https://code.google.com/p/esprima/issues/detail?id=433
// We run into this from regenerator generated ast.
if (node.handlers) {
print.plain(node.handlers[0]);
} else {
print.plain(node.handler);
}
if (node.finalizer) {
this.space();
this.push("finally ");
print.plain(node.finalizer);
}
}
/**
* Prints CatchClause, prints param and body.
*/
function CatchClause(node, print) {
this.keyword("catch");
this.push("(");
print.plain(node.param);
this.push(") ");
print.plain(node.body);
}
/**
* Prints SwitchStatement, prints discriminant and cases.
*/
function SwitchStatement(node, print) {
this.keyword("switch");
this.push("(");
print.plain(node.discriminant);
this.push(")");
this.space();
this.push("{");
print.sequence(node.cases, {
indent: true,
addNewlines: function addNewlines(leading, cas) {
if (!leading && node.cases[node.cases.length - 1] === cas) return -1;
}
});
this.push("}");
}
/**
* Prints SwitchCase, prints test and consequent.
*/
function SwitchCase(node, print) {
if (node.test) {
this.push("case ");
print.plain(node.test);
this.push(":");
} else {
this.push("default:");
}
if (node.consequent.length) {
this.newline();
print.sequence(node.consequent, { indent: true });
}
}
/**
* Prints DebuggerStatement.
*/
function DebuggerStatement() {
this.push("debugger;");
}
/**
* Prints VariableDeclaration, prints declarations, handles kind and format.
*/
function VariableDeclaration(node, print, parent) {
this.push(node.kind + " ");
var hasInits = false;
// don't add whitespace to loop heads
if (!t.isFor(parent)) {
var _arr = node.declarations;
for (var _i = 0; _i < _arr.length; _i++) {
var declar = _arr[_i];
if (declar.init) {
// has an init so let's split it up over multiple lines
hasInits = true;
}
}
}
//
// use a pretty separator when we aren't in compact mode, have initializers and don't have retainLines on
// this will format declarations like:
//
// var foo = "bar", bar = "foo";
//
// into
//
// var foo = "bar",
// bar = "foo";
//
var sep;
if (!this.format.compact && !this.format.concise && hasInits && !this.format.retainLines) {
sep = ",\n" + _repeating2["default"](" ", node.kind.length + 1);
}
//
print.list(node.declarations, { separator: sep });
if (t.isFor(parent)) {
// don't give semicolons to these nodes since they'll be inserted in the parent generator
if (parent.left === node || parent.init === node) return;
}
this.semicolon();
}
/**
* Prints VariableDeclarator, handles id, id.typeAnnotation, and init.
*/
function VariableDeclarator(node, print) {
print.plain(node.id);
print.plain(node.id.typeAnnotation);
if (node.init) {
this.space();
this.push("=");
this.space();
print.plain(node.init);
}
}
},{"179":179,"584":584}],28:[function(_dereq_,module,exports){
/**
* Prints TaggedTemplateExpression, prints tag and quasi.
*/
"use strict";
exports.__esModule = true;
exports.TaggedTemplateExpression = TaggedTemplateExpression;
exports.TemplateElement = TemplateElement;
exports.TemplateLiteral = TemplateLiteral;
function TaggedTemplateExpression(node, print) {
print.plain(node.tag);
print.plain(node.quasi);
}
/**
* Prints TemplateElement, prints value.
*/
function TemplateElement(node) {
this._push(node.value.raw);
}
/**
* Prints TemplateLiteral, prints quasis, and expressions.
*/
function TemplateLiteral(node, print) {
this.push("`");
var quasis = node.quasis;
var len = quasis.length;
for (var i = 0; i < len; i++) {
print.plain(quasis[i]);
if (i + 1 < len) {
this.push("${ ");
print.plain(node.expressions[i]);
this.push(" }");
}
}
this._push("`");
}
},{}],29:[function(_dereq_,module,exports){
/* eslint quotes: 0 */
"use strict";
exports.__esModule = true;
exports.Identifier = Identifier;
exports.RestElement = RestElement;
exports.ObjectExpression = ObjectExpression;
exports.Property = Property;
exports.ArrayExpression = ArrayExpression;
exports.Literal = Literal;
exports._Literal = _Literal;
exports._stringLiteral = _stringLiteral;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* Prints Identifier, prints name.
*/
function Identifier(node) {
this.push(node.name);
}
/**
* Prints RestElement, prints argument.
*/
function RestElement(node, print) {
this.push("...");
print.plain(node.argument);
}
/**
* Alias RestElement printer as SpreadElement,
* and RestElement printer as SpreadProperty.
*/
exports.SpreadElement = RestElement;
exports.SpreadProperty = RestElement;
/**
* Prints ObjectExpression, prints properties.
*/
function ObjectExpression(node, print) {
var props = node.properties;
this.push("{");
print.printInnerComments();
if (props.length) {
this.space();
print.list(props, { indent: true });
this.space();
}
this.push("}");
}
/**
* Alias ObjectExpression printer as ObjectPattern.
*/
exports.ObjectPattern = ObjectExpression;
/**
* Prints Property, prints decorators, key, and value, handles kind, computed, and shorthand.
*/
function Property(node, print) {
print.list(node.decorators, { separator: "" });
if (node.method || node.kind === "get" || node.kind === "set") {
this._method(node, print);
} else {
if (node.computed) {
this.push("[");
print.plain(node.key);
this.push("]");
} else {
// print `({ foo: foo = 5 } = {})` as `({ foo = 5 } = {});`
if (t.isAssignmentPattern(node.value) && t.isIdentifier(node.key) && node.key.name === node.value.left.name) {
print.plain(node.value);
return;
}
print.plain(node.key);
// shorthand!
if (node.shorthand && (t.isIdentifier(node.key) && t.isIdentifier(node.value) && node.key.name === node.value.name)) {
return;
}
}
this.push(":");
this.space();
print.plain(node.value);
}
}
/**
* Prints ArrayExpression, prints elements.
*/
function ArrayExpression(node, print) {
var elems = node.elements;
var len = elems.length;
this.push("[");
print.printInnerComments();
for (var i = 0; i < elems.length; i++) {
var elem = elems[i];
if (elem) {
if (i > 0) this.space();
print.plain(elem);
if (i < len - 1) this.push(",");
} else {
// 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.
this.push(",");
}
}
this.push("]");
}
/**
* Alias ArrayExpression printer as ArrayPattern.
*/
exports.ArrayPattern = ArrayExpression;
/**
* Prints Literal, prints value, regex, raw, handles val type.
*/
function Literal(node) {
this.push(""); // hack: catch up indentation
this._push(this._Literal(node));
}
function _Literal(node) {
var val = node.value;
if (node.regex) {
return "/" + node.regex.pattern + "/" + node.regex.flags;
}
// just use the raw property if our current value is equivalent to the one we got
// when we populated raw
if (node.raw != null && node.rawValue != null && val === node.rawValue) {
return node.raw;
}
switch (typeof val) {
case "string":
return this._stringLiteral(val);
case "number":
return val + "";
case "boolean":
return val ? "true" : "false";
default:
if (val === null) {
return "null";
} else {
throw new Error("Invalid Literal type");
}
}
}
/**
* Prints string literals, handles format.
*/
function _stringLiteral(val) {
val = JSON.stringify(val);
// escape illegal js but valid json unicode characters
val = val.replace(/[\u000A\u000D\u2028\u2029]/g, function (c) {
return "\\u" + ("0000" + c.charCodeAt(0).toString(16)).slice(-4);
});
if (this.format.quotes === "single") {
// remove double quotes
val = val.slice(1, -1);
// unescape double quotes
val = val.replace(/\\"/g, '"');
// escape single quotes
val = val.replace(/'/g, "\\'");
// add single quotes
val = "'" + val + "'";
}
return val;
}
},{"179":179}],30:[function(_dereq_,module,exports){
"use strict";
// istanbul ignore next
var _createClass = (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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// istanbul ignore next
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _detectIndent = _dereq_(391);
var _detectIndent2 = _interopRequireDefault(_detectIndent);
var _whitespace = _dereq_(37);
var _whitespace2 = _interopRequireDefault(_whitespace);
var _nodePrinter = _dereq_(33);
var _nodePrinter2 = _interopRequireDefault(_nodePrinter);
var _repeating = _dereq_(584);
var _repeating2 = _interopRequireDefault(_repeating);
var _sourceMap = _dereq_(36);
var _sourceMap2 = _interopRequireDefault(_sourceMap);
var _position = _dereq_(35);
var _position2 = _interopRequireDefault(_position);
var _messages = _dereq_(43);
var messages = _interopRequireWildcard(_messages);
var _buffer = _dereq_(18);
var _buffer2 = _interopRequireDefault(_buffer);
var _lodashObjectExtend = _dereq_(511);
var _lodashObjectExtend2 = _interopRequireDefault(_lodashObjectExtend);
var _lodashCollectionEach = _dereq_(411);
var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
var _node2 = _dereq_(31);
var _node3 = _interopRequireDefault(_node2);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* Babel's code generator, turns an ast into code, maintaining sourcemaps,
* user preferences, and valid output.
*/
var CodeGenerator = (function () {
function CodeGenerator(ast, opts, code) {
_classCallCheck(this, CodeGenerator);
opts = opts || {};
this.comments = ast.comments || [];
this.tokens = ast.tokens || [];
this.format = CodeGenerator.normalizeOptions(code, opts, this.tokens);
this.opts = opts;
this.ast = ast;
this.whitespace = new _whitespace2["default"](this.tokens);
this.position = new _position2["default"]();
this.map = new _sourceMap2["default"](this.position, opts, code);
this.buffer = new _buffer2["default"](this.position, this.format);
}
/**
* [Please add a description.]
*/
/**
* Normalize generator options, setting defaults.
*
* - Detects code indentation.
* - If `opts.compact = "auto"` and the code is over 100KB, `compact` will be set to `true`.
*/
CodeGenerator.normalizeOptions = function normalizeOptions(code, opts, tokens) {
var style = " ";
if (code) {
var indent = _detectIndent2["default"](code).indent;
if (indent && indent !== " ") style = indent;
}
var format = {
shouldPrintComment: opts.shouldPrintComment,
retainLines: opts.retainLines,
comments: opts.comments == null || opts.comments,
compact: opts.compact,
quotes: CodeGenerator.findCommonStringDelimiter(code, tokens),
indent: {
adjustMultilineComment: true,
style: style,
base: 0
}
};
if (format.compact === "auto") {
format.compact = code.length > 100000; // 100KB
if (format.compact) {
console.error("[BABEL] " + messages.get("codeGeneratorDeopt", opts.filename, "100KB"));
}
}
if (format.compact) {
format.indent.adjustMultilineComment = false;
}
return format;
};
/**
* Determine if input code uses more single or double quotes.
*/
CodeGenerator.findCommonStringDelimiter = function findCommonStringDelimiter(code, tokens) {
var occurences = {
single: 0,
double: 0
};
var checked = 0;
for (var i = 0; i < tokens.length; i++) {
var token = tokens[i];
if (token.type.label !== "string") continue;
var raw = code.slice(token.start, token.end);
if (raw[0] === "'") {
occurences.single++;
} else {
occurences.double++;
}
checked++;
if (checked >= 3) break;
}
if (occurences.single > occurences.double) {
return "single";
} else {
return "double";
}
};
/**
* All node generators.
*/
/**
* Generate code and sourcemap from ast.
*
* Appends comments that weren't attached to any node to the end of the generated output.
*/
CodeGenerator.prototype.generate = function generate() {
var ast = this.ast;
this.print(ast);
if (ast.comments) {
var comments = [];
var _arr = ast.comments;
for (var _i = 0; _i < _arr.length; _i++) {
var comment = _arr[_i];
if (!comment._displayed) comments.push(comment);
}
this._printComments(comments);
}
return {
map: this.map.get(),
code: this.buffer.get()
};
};
/**
* Build NodePrinter.
*/
CodeGenerator.prototype.buildPrint = function buildPrint(parent) {
return new _nodePrinter2["default"](this, parent);
};
/**
* [Please add a description.]
*/
CodeGenerator.prototype.catchUp = function catchUp(node) {
// catch up to this nodes newline if we're behind
if (node.loc && this.format.retainLines && this.buffer.buf) {
while (this.position.line < node.loc.start.line) {
this._push("\n");
}
}
};
/**
* [Please add a description.]
*/
CodeGenerator.prototype._printNewline = function _printNewline(leading, node, parent, opts) {
if (!opts.statement && !_node3["default"].isUserWhitespacable(node, parent)) {
return;
}
var lines = 0;
if (node.start != null && !node._ignoreUserWhitespace) {
// user node
if (leading) {
lines = this.whitespace.getNewlinesBefore(node);
} else {
lines = this.whitespace.getNewlinesAfter(node);
}
} else {
// generated node
if (!leading) lines++; // always include at least a single line after
if (opts.addNewlines) lines += opts.addNewlines(leading, node) || 0;
var needs = _node3["default"].needsWhitespaceAfter;
if (leading) needs = _node3["default"].needsWhitespaceBefore;
if (needs(node, parent)) lines++;
// generated nodes can't add starting file whitespace
if (!this.buffer.buf) lines = 0;
}
this.newline(lines);
};
/**
* [Please add a description.]
*/
CodeGenerator.prototype.print = function print(node, parent) {
var opts = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
if (!node) return;
if (parent && parent._compact) {
node._compact = true;
}
var oldConcise = this.format.concise;
if (node._compact) {
this.format.concise = true;
}
if (!this[node.type]) {
throw new ReferenceError("unknown node of type " + JSON.stringify(node.type) + " with constructor " + JSON.stringify(node && node.constructor.name));
}
var needsParens = _node3["default"].needsParens(node, parent);
if (needsParens) this.push("(");
this.printLeadingComments(node, parent);
this.catchUp(node);
this._printNewline(true, node, parent, opts);
if (opts.before) opts.before();
this.map.mark(node, "start");
this[node.type](node, this.buildPrint(node), parent);
if (needsParens) this.push(")");
this.map.mark(node, "end");
if (opts.after) opts.after();
this.format.concise = oldConcise;
this._printNewline(false, node, parent, opts);
this.printTrailingComments(node, parent);
};
/**
* [Please add a description.]
*/
CodeGenerator.prototype.printJoin = function printJoin(print, nodes) {
// istanbul ignore next
var _this = this;
var opts = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
if (!nodes || !nodes.length) return;
var len = nodes.length;
if (opts.indent) this.indent();
var printOpts = {
statement: opts.statement,
addNewlines: opts.addNewlines,
after: function after() {
if (opts.iterator) {
opts.iterator(node, i);
}
if (opts.separator && i < len - 1) {
_this.push(opts.separator);
}
}
};
for (var i = 0; i < nodes.length; i++) {
var node = nodes[i];
print.plain(node, printOpts);
}
if (opts.indent) this.dedent();
};
/**
* [Please add a description.]
*/
CodeGenerator.prototype.printAndIndentOnComments = function printAndIndentOnComments(print, node) {
var indent = !!node.leadingComments;
if (indent) this.indent();
print.plain(node);
if (indent) this.dedent();
};
/**
* [Please add a description.]
*/
CodeGenerator.prototype.printBlock = function printBlock(print, node) {
if (t.isEmptyStatement(node)) {
this.semicolon();
} else {
this.push(" ");
print.plain(node);
}
};
/**
* [Please add a description.]
*/
CodeGenerator.prototype.generateComment = function generateComment(comment) {
var val = comment.value;
if (comment.type === "CommentLine") {
val = "//" + val;
} else {
val = "/*" + val + "*/";
}
return val;
};
/**
* [Please add a description.]
*/
CodeGenerator.prototype.printTrailingComments = function printTrailingComments(node, parent) {
this._printComments(this.getComments("trailingComments", node, parent));
};
/**
* [Please add a description.]
*/
CodeGenerator.prototype.printLeadingComments = function printLeadingComments(node, parent) {
this._printComments(this.getComments("leadingComments", node, parent));
};
/**
* [Please add a description.]
*/
CodeGenerator.prototype.getComments = function getComments(key, node, parent) {
if (t.isExpressionStatement(parent)) {
return [];
}
var comments = [];
var nodes = [node];
if (t.isExpressionStatement(node)) {
nodes.push(node.argument);
}
var _arr2 = nodes;
for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
var _node = _arr2[_i2];
comments = comments.concat(this._getComments(key, _node));
}
return comments;
};
/**
* [Please add a description.]
*/
CodeGenerator.prototype._getComments = function _getComments(key, node) {
return node && node[key] || [];
};
/**
* [Please add a description.]
*/
CodeGenerator.prototype.shouldPrintComment = function shouldPrintComment(comment) {
if (this.format.shouldPrintComment) {
return this.format.shouldPrintComment(comment.value);
} else {
if (comment.value.indexOf("@license") >= 0 || comment.value.indexOf("@preserve") >= 0) {
return true;
} else {
return this.format.comments;
}
}
};
/**
* [Please add a description.]
*/
CodeGenerator.prototype._printComments = function _printComments(comments) {
if (!comments || !comments.length) return;
var _arr3 = comments;
for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
var comment = _arr3[_i3];
if (!this.shouldPrintComment(comment)) continue;
if (comment._displayed) continue;
comment._displayed = true;
this.catchUp(comment);
// whitespace before
this.newline(this.whitespace.getNewlinesBefore(comment));
var column = this.position.column;
var val = this.generateComment(comment);
if (column && !this.isLast(["\n", " ", "[", "{"])) {
this._push(" ");
column++;
}
//
if (comment.type === "CommentBlock" && this.format.indent.adjustMultilineComment) {
var offset = comment.loc && comment.loc.start.column;
if (offset) {
var newlineRegex = new RegExp("\\n\\s{1," + offset + "}", "g");
val = val.replace(newlineRegex, "\n");
}
var indent = Math.max(this.indentSize(), column);
val = val.replace(/\n/g, "\n" + _repeating2["default"](" ", indent));
}
if (column === 0) {
val = this.getIndent() + val;
}
// force a newline for line comments when retainLines is set in case the next printed node
// doesn't catch up
if ((this.format.compact || this.format.retainLines) && comment.type === "CommentLine") {
val += "\n";
}
//
this._push(val);
// whitespace after
this.newline(this.whitespace.getNewlinesAfter(comment));
}
};
_createClass(CodeGenerator, null, [{
key: "generators",
value: {
templateLiterals: _dereq_(28),
comprehensions: _dereq_(21),
expressions: _dereq_(22),
statements: _dereq_(27),
classes: _dereq_(20),
methods: _dereq_(25),
modules: _dereq_(26),
types: _dereq_(29),
flow: _dereq_(23),
base: _dereq_(19),
jsx: _dereq_(24)
},
enumerable: true
}]);
return CodeGenerator;
})();
_lodashCollectionEach2["default"](_buffer2["default"].prototype, function (fn, key) {
CodeGenerator.prototype[key] = function () {
return fn.apply(this.buffer, arguments);
};
});
/**
* [Please add a description.]
*/
_lodashCollectionEach2["default"](CodeGenerator.generators, function (generator) {
_lodashObjectExtend2["default"](CodeGenerator.prototype, generator);
});
/**
* [Please add a description.]
*/
module.exports = function (ast, opts, code) {
var gen = new CodeGenerator(ast, opts, code);
return gen.generate();
};
module.exports.CodeGenerator = CodeGenerator;
},{"179":179,"18":18,"19":19,"20":20,"21":21,"22":22,"23":23,"24":24,"25":25,"26":26,"27":27,"28":28,"29":29,"31":31,"33":33,"35":35,"36":36,"37":37,"391":391,"411":411,"43":43,"511":511,"584":584}],31:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// istanbul ignore next
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _whitespace = _dereq_(34);
var _whitespace2 = _interopRequireDefault(_whitespace);
var _parentheses = _dereq_(32);
var parens = _interopRequireWildcard(_parentheses);
var _lodashCollectionEach = _dereq_(411);
var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
var _lodashCollectionSome = _dereq_(416);
var _lodashCollectionSome2 = _interopRequireDefault(_lodashCollectionSome);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* Test if node matches a set of type-matcher pairs.
* @example
* find({
* VariableDeclaration(node, parent) {
* return true;
* }
* }, node, parent);
*/
var find = function find(obj, node, parent) {
if (!obj) return;
var result;
var types = Object.keys(obj);
for (var i = 0; i < types.length; i++) {
var type = types[i];
if (t.is(type, node)) {
var fn = obj[type];
result = fn(node, parent);
if (result != null) break;
}
}
return result;
};
/**
* Whitespace and Parenthesis related methods for nodes.
*/
var Node = (function () {
function Node(node, parent) {
_classCallCheck(this, Node);
this.parent = parent;
this.node = node;
}
/**
* Add all static methods from `Node` to `Node.prototype`.
*/
/**
* Test if `node` can have whitespace set by the user.
*/
Node.isUserWhitespacable = function isUserWhitespacable(node) {
return t.isUserWhitespacable(node);
};
/**
* Test if a `node` requires whitespace.
*/
Node.needsWhitespace = function needsWhitespace(node, parent, type) {
if (!node) return 0;
if (t.isExpressionStatement(node)) {
node = node.expression;
}
var linesInfo = find(_whitespace2["default"].nodes, node, parent);
if (!linesInfo) {
var items = find(_whitespace2["default"].list, node, parent);
if (items) {
for (var i = 0; i < items.length; i++) {
linesInfo = Node.needsWhitespace(items[i], node, type);
if (linesInfo) break;
}
}
}
return linesInfo && linesInfo[type] || 0;
};
/**
* Test if a `node` requires whitespace before it.
*/
Node.needsWhitespaceBefore = function needsWhitespaceBefore(node, parent) {
return Node.needsWhitespace(node, parent, "before");
};
/**
* Test if a `note` requires whitespace after it.
*/
Node.needsWhitespaceAfter = function needsWhitespaceAfter(node, parent) {
return Node.needsWhitespace(node, parent, "after");
};
/**
* Test if a `node` needs parentheses around it.
*/
Node.needsParens = function needsParens(node, parent) {
if (!parent) return false;
if (t.isNewExpression(parent) && parent.callee === node) {
if (t.isCallExpression(node)) return true;
var hasCall = _lodashCollectionSome2["default"](node, function (val) {
return t.isCallExpression(val);
});
if (hasCall) return true;
}
return find(parens, node, parent);
};
return Node;
})();
exports["default"] = Node;
_lodashCollectionEach2["default"](Node, function (fn, key) {
Node.prototype[key] = function () {
// Avoid leaking arguments to prevent deoptimization
var args = new Array(arguments.length + 2);
args[0] = this.node;
args[1] = this.parent;
for (var i = 0; i < args.length; i++) {
args[i + 2] = arguments[i];
}
return Node[key].apply(null, args);
};
});
module.exports = exports["default"];
},{"179":179,"32":32,"34":34,"411":411,"416":416}],32:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports.NullableTypeAnnotation = NullableTypeAnnotation;
exports.UpdateExpression = UpdateExpression;
exports.ObjectExpression = ObjectExpression;
exports.Binary = Binary;
exports.BinaryExpression = BinaryExpression;
exports.SequenceExpression = SequenceExpression;
exports.YieldExpression = YieldExpression;
exports.ClassExpression = ClassExpression;
exports.UnaryLike = UnaryLike;
exports.FunctionExpression = FunctionExpression;
exports.ConditionalExpression = ConditionalExpression;
exports.AssignmentExpression = AssignmentExpression;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _lodashCollectionEach = _dereq_(411);
var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* Create a mapping of operators to precendence.
*
* @example
* { "==": 6, "+": 9 }
*/
var PRECEDENCE = {};
_lodashCollectionEach2["default"]([["||"], ["&&"], ["|"], ["^"], ["&"], ["==", "===", "!=", "!=="], ["<", ">", "<=", ">=", "in", "instanceof"], [">>", "<<", ">>>"], ["+", "-"], ["*", "/", "%"], ["**"]], function (tier, i) {
_lodashCollectionEach2["default"](tier, function (op) {
PRECEDENCE[op] = i;
});
});
/**
* Test if NullableTypeAnnotation needs parentheses.
*/
function NullableTypeAnnotation(node, parent) {
return t.isArrayTypeAnnotation(parent);
}
/**
* Alias NullableTypeAnnotation test as FunctionTypeAnnotation.
*/
exports.FunctionTypeAnnotation = NullableTypeAnnotation;
/**
* Test if UpdateExpression needs parentheses.
*/
function UpdateExpression(node, parent) {
if (t.isMemberExpression(parent) && parent.object === node) {
// (foo++).test()
return true;
}
}
/**
* Test if ObjectExpression needs parentheses.
*/
function ObjectExpression(node, parent) {
if (t.isExpressionStatement(parent)) {
// ({ foo: "bar" });
return true;
}
if (t.isMemberExpression(parent) && parent.object === node) {
// ({ foo: "bar" }).foo
return true;
}
return false;
}
/**
* Test if Binary needs parentheses.
*/
function Binary(node, parent) {
if ((t.isCallExpression(parent) || t.isNewExpression(parent)) && parent.callee === node) {
return true;
}
if (t.isUnaryLike(parent)) {
return true;
}
if (t.isMemberExpression(parent) && parent.object === node) {
return true;
}
if (t.isBinary(parent)) {
var parentOp = parent.operator;
var parentPos = PRECEDENCE[parentOp];
var nodeOp = node.operator;
var nodePos = PRECEDENCE[nodeOp];
if (parentPos > nodePos) {
return true;
}
if (parentPos === nodePos && parent.right === node) {
return true;
}
}
}
/**
* Test if BinaryExpression needs parentheses.
*/
function BinaryExpression(node, parent) {
if (node.operator === "in") {
// var i = (1 in []);
if (t.isVariableDeclarator(parent)) {
return true;
}
// for ((1 in []);;);
if (t.isFor(parent)) {
return true;
}
}
}
/**
* Test if SequenceExpression needs parentheses.
*/
function SequenceExpression(node, parent) {
if (t.isForStatement(parent)) {
// 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;
}
if (t.isExpressionStatement(parent) && parent.expression === node) {
return false;
}
// Otherwise err on the side of overparenthesization, adding
// explicit exceptions above if this proves overzealous.
return true;
}
/**
* Test if YieldExpression needs parentheses.
*/
function YieldExpression(node, parent) {
return t.isBinary(parent) || t.isUnaryLike(parent) || t.isCallExpression(parent) || t.isMemberExpression(parent) || t.isNewExpression(parent) || t.isConditionalExpression(parent) || t.isYieldExpression(parent);
}
/**
* Test if ClassExpression needs parentheses.
*/
function ClassExpression(node, parent) {
return t.isExpressionStatement(parent);
}
/**
* Test if UnaryLike needs parentheses.
*/
function UnaryLike(node, parent) {
return t.isMemberExpression(parent) && parent.object === node;
}
/**
* Test if FunctionExpression needs parentheses.
*/
function FunctionExpression(node, parent) {
// function () {};
if (t.isExpressionStatement(parent)) {
return true;
}
// (function test() {}).name;
if (t.isMemberExpression(parent) && parent.object === node) {
return true;
}
// (function () {})();
if (t.isCallExpression(parent) && parent.callee === node) {
return true;
}
}
/**
* Test if ConditionalExpression needs parentheses.
*/
function ConditionalExpression(node, parent) {
if (t.isUnaryLike(parent)) {
return true;
}
if (t.isBinary(parent)) {
return true;
}
if (t.isCallExpression(parent) || t.isNewExpression(parent)) {
if (parent.callee === node) {
return true;
}
}
if (t.isConditionalExpression(parent) && parent.test === node) {
return true;
}
if (t.isMemberExpression(parent) && parent.object === node) {
return true;
}
return false;
}
/**
* Test if AssignmentExpression needs parentheses.
*/
function AssignmentExpression(node) {
if (t.isObjectPattern(node.left)) {
return true;
} else {
return ConditionalExpression.apply(undefined, arguments);
}
}
},{"179":179,"411":411}],33:[function(_dereq_,module,exports){
/**
* Printer for nodes, needs a `generator` and a `parent`.
*/
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var NodePrinter = (function () {
function NodePrinter(generator, parent) {
_classCallCheck(this, NodePrinter);
this.generator = generator;
this.parent = parent;
}
/**
* Description
*/
NodePrinter.prototype.printInnerComments = function printInnerComments() {
if (!this.parent.innerComments) return;
var gen = this.generator;
gen.indent();
gen._printComments(this.parent.innerComments);
gen.dedent();
};
/**
* Print a plain node.
*/
NodePrinter.prototype.plain = function plain(node, opts) {
return this.generator.print(node, this.parent, opts);
};
/**
* Print a sequence of nodes as statements.
*/
NodePrinter.prototype.sequence = function sequence(nodes) {
var opts = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
opts.statement = true;
return this.generator.printJoin(this, nodes, opts);
};
/**
* Print a sequence of nodes as expressions.
*/
NodePrinter.prototype.join = function join(nodes, opts) {
return this.generator.printJoin(this, nodes, opts);
};
/**
* Print a list of nodes, with a customizable separator (defaults to ",").
*/
NodePrinter.prototype.list = function list(items) {
var opts = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
if (opts.separator == null) {
opts.separator = ",";
if (!this.generator.format.compact) opts.separator += " ";
}
return this.join(items, opts);
};
/**
* Print a block-like node.
*/
NodePrinter.prototype.block = function block(node) {
return this.generator.printBlock(this, node);
};
/**
* Print node and indent comments.
*/
NodePrinter.prototype.indentOnComments = function indentOnComments(node) {
return this.generator.printAndIndentOnComments(this, node);
};
return NodePrinter;
})();
exports["default"] = NodePrinter;
module.exports = exports["default"];
},{}],34:[function(_dereq_,module,exports){
"use strict";
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _lodashLangIsBoolean = _dereq_(498);
var _lodashLangIsBoolean2 = _interopRequireDefault(_lodashLangIsBoolean);
var _lodashCollectionEach = _dereq_(411);
var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
var _lodashCollectionMap = _dereq_(414);
var _lodashCollectionMap2 = _interopRequireDefault(_lodashCollectionMap);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* Crawl a node to test if it contains a CallExpression, a Function, or a Helper.
*
* @example
* crawl(node)
* // { hasCall: false, hasFunction: true, hasHelper: false }
*/
function crawl(node) {
var state = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
if (t.isMemberExpression(node)) {
crawl(node.object, state);
if (node.computed) crawl(node.property, state);
} else if (t.isBinary(node) || t.isAssignmentExpression(node)) {
crawl(node.left, state);
crawl(node.right, state);
} else if (t.isCallExpression(node)) {
state.hasCall = true;
crawl(node.callee, state);
} else if (t.isFunction(node)) {
state.hasFunction = true;
} else if (t.isIdentifier(node)) {
state.hasHelper = state.hasHelper || isHelper(node.callee);
}
return state;
}
/**
* Test if a node is or has a helper.
*/
function isHelper(node) {
if (t.isMemberExpression(node)) {
return isHelper(node.object) || isHelper(node.property);
} else if (t.isIdentifier(node)) {
return node.name === "require" || node.name[0] === "_";
} else if (t.isCallExpression(node)) {
return isHelper(node.callee);
} else if (t.isBinary(node) || t.isAssignmentExpression(node)) {
return t.isIdentifier(node.left) && isHelper(node.left) || isHelper(node.right);
} else {
return false;
}
}
/**
* [Please add a description.]
*/
function isType(node) {
return t.isLiteral(node) || t.isObjectExpression(node) || t.isArrayExpression(node) || t.isIdentifier(node) || t.isMemberExpression(node);
}
/**
* Tests for node types that need whitespace.
*/
exports.nodes = {
/**
* Test if AssignmentExpression needs whitespace.
*/
AssignmentExpression: function AssignmentExpression(node) {
var state = crawl(node.right);
if (state.hasCall && state.hasHelper || state.hasFunction) {
return {
before: state.hasFunction,
after: true
};
}
},
/**
* Test if SwitchCase needs whitespace.
*/
SwitchCase: function SwitchCase(node, parent) {
return {
before: node.consequent.length || parent.cases[0] === node
};
},
/**
* Test if LogicalExpression needs whitespace.
*/
LogicalExpression: function LogicalExpression(node) {
if (t.isFunction(node.left) || t.isFunction(node.right)) {
return {
after: true
};
}
},
/**
* Test if Literal needs whitespace.
*/
Literal: function Literal(node) {
if (node.value === "use strict") {
return {
after: true
};
}
},
/**
* Test if CallExpression needs whitespace.
*/
CallExpression: function CallExpression(node) {
if (t.isFunction(node.callee) || isHelper(node)) {
return {
before: true,
after: true
};
}
},
/**
* Test if VariableDeclaration needs whitespace.
*/
VariableDeclaration: function VariableDeclaration(node) {
for (var i = 0; i < node.declarations.length; i++) {
var declar = node.declarations[i];
var enabled = isHelper(declar.id) && !isType(declar.init);
if (!enabled) {
var state = crawl(declar.init);
enabled = isHelper(declar.init) && state.hasCall || state.hasFunction;
}
if (enabled) {
return {
before: true,
after: true
};
}
}
},
/**
* Test if IfStatement needs whitespace.
*/
IfStatement: function IfStatement(node) {
if (t.isBlockStatement(node.consequent)) {
return {
before: true,
after: true
};
}
}
};
/**
* Test if Property or SpreadProperty needs whitespace.
*/
exports.nodes.Property = exports.nodes.SpreadProperty = function (node, parent) {
if (parent.properties[0] === node) {
return {
before: true
};
}
};
/**
* Returns lists from node types that need whitespace.
*/
exports.list = {
/**
* Return VariableDeclaration declarations init properties.
*/
VariableDeclaration: function VariableDeclaration(node) {
return _lodashCollectionMap2["default"](node.declarations, "init");
},
/**
* Return VariableDeclaration elements.
*/
ArrayExpression: function ArrayExpression(node) {
return node.elements;
},
/**
* Return VariableDeclaration properties.
*/
ObjectExpression: function ObjectExpression(node) {
return node.properties;
}
};
/**
* Add whitespace tests for nodes and their aliases.
*/
_lodashCollectionEach2["default"]({
Function: true,
Class: true,
Loop: true,
LabeledStatement: true,
SwitchStatement: true,
TryStatement: true
}, function (amounts, type) {
if (_lodashLangIsBoolean2["default"](amounts)) {
amounts = { after: amounts, before: amounts };
}
_lodashCollectionEach2["default"]([type].concat(t.FLIPPED_ALIAS_KEYS[type] || []), function (type) {
exports.nodes[type] = function () {
return amounts;
};
});
});
},{"179":179,"411":411,"414":414,"498":498}],35:[function(_dereq_,module,exports){
/**
* Track current position in code generation.
*/
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Position = (function () {
function Position() {
_classCallCheck(this, Position);
this.line = 1;
this.column = 0;
}
/**
* Push a string to the current position, mantaining the current line and column.
*/
Position.prototype.push = function push(str) {
for (var i = 0; i < str.length; i++) {
if (str[i] === "\n") {
this.line++;
this.column = 0;
} else {
this.column++;
}
}
};
/**
* Unshift a string from the current position, mantaining the current line and column.
*/
Position.prototype.unshift = function unshift(str) {
for (var i = 0; i < str.length; i++) {
if (str[i] === "\n") {
this.line--;
} else {
this.column--;
}
}
};
return Position;
})();
exports["default"] = Position;
module.exports = exports["default"];
},{}],36:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// istanbul ignore next
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _sourceMap = _dereq_(599);
var _sourceMap2 = _interopRequireDefault(_sourceMap);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* Build a sourcemap.
*/
var SourceMap = (function () {
function SourceMap(position, opts, code) {
_classCallCheck(this, SourceMap);
this.position = position;
this.opts = opts;
if (opts.sourceMaps) {
this.map = new _sourceMap2["default"].SourceMapGenerator({
file: opts.sourceMapTarget,
sourceRoot: opts.sourceRoot
});
this.map.setSourceContent(opts.sourceFileName, code);
} else {
this.map = null;
}
}
/**
* Get the sourcemap.
*/
SourceMap.prototype.get = function get() {
var map = this.map;
if (map) {
return map.toJSON();
} else {
return map;
}
};
/**
* Mark a node's generated position, and add it to the sourcemap.
*/
SourceMap.prototype.mark = function mark(node, type) {
var loc = node.loc;
if (!loc) return; // no location info
var map = this.map;
if (!map) return; // no source map
if (t.isProgram(node) || t.isFile(node)) return; // illegal mapping nodes
var position = this.position;
var generated = {
line: position.line,
column: position.column
};
var original = loc[type];
map.addMapping({
source: this.opts.sourceFileName,
generated: generated,
original: original
});
};
return SourceMap;
})();
exports["default"] = SourceMap;
module.exports = exports["default"];
},{"179":179,"599":599}],37:[function(_dereq_,module,exports){
/**
* Returns `i`th number from `base`, continuing from 0 when `max` is reached.
* Useful for shifting `for` loop by a fixed number but going over all items.
*
* @param {Number} i Current index in the loop
* @param {Number} base Start index for which to return 0
* @param {Number} max Array length
* @returns {Number} shiftedIndex
*/
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function getLookupIndex(i, base, max) {
i += base;
if (i >= max) {
i -= max;
}
return i;
}
/**
* Get whitespace around tokens.
*/
var Whitespace = (function () {
function Whitespace(tokens) {
_classCallCheck(this, Whitespace);
this.tokens = tokens;
this.used = {};
// Profiling this code shows that while generator passes over it, indexes
// returned by `getNewlinesBefore` and `getNewlinesAfter` are always increasing.
// We use this implementation detail for an optimization: instead of always
// starting to look from `this.tokens[0]`, we will start `for` loops from the
// previous successful match. We will enumerate all tokens—but the common
// case will be much faster.
this._lastFoundIndex = 0;
}
/**
* Count all the newlines before a node.
*/
Whitespace.prototype.getNewlinesBefore = function getNewlinesBefore(node) {
var startToken;
var endToken;
var tokens = this.tokens;
for (var j = 0; j < tokens.length; j++) {
// optimize for forward traversal by shifting for loop index
var i = getLookupIndex(j, this._lastFoundIndex, this.tokens.length);
var token = tokens[i];
// this is the token this node starts with
if (node.start === token.start) {
startToken = tokens[i - 1];
endToken = token;
this._lastFoundIndex = i;
break;
}
}
return this.getNewlinesBetween(startToken, endToken);
};
/**
* Count all the newlines after a node.
*/
Whitespace.prototype.getNewlinesAfter = function getNewlinesAfter(node) {
var startToken;
var endToken;
var tokens = this.tokens;
for (var j = 0; j < tokens.length; j++) {
// optimize for forward traversal by shifting for loop index
var i = getLookupIndex(j, this._lastFoundIndex, this.tokens.length);
var token = tokens[i];
// this is the token this node ends with
if (node.end === token.end) {
startToken = token;
endToken = tokens[i + 1];
if (endToken.type.label === ",") endToken = tokens[i + 2];
this._lastFoundIndex = i;
break;
}
}
if (endToken && endToken.type.label === "eof") {
return 1;
} else {
var lines = this.getNewlinesBetween(startToken, endToken);
if (node.type === "CommentLine" && !lines) {
// line comment
return 1;
} else {
return lines;
}
}
};
/**
* Count all the newlines between two tokens.
*/
Whitespace.prototype.getNewlinesBetween = function getNewlinesBetween(startToken, endToken) {
if (!endToken || !endToken.loc) return 0;
var start = startToken ? startToken.loc.end.line : 1;
var end = endToken.loc.start.line;
var lines = 0;
for (var line = start; line < end; line++) {
if (typeof this.used[line] === "undefined") {
this.used[line] = true;
lines++;
}
}
return lines;
};
return Whitespace;
})();
exports["default"] = Whitespace;
module.exports = exports["default"];
},{}],38:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _lineNumbers = _dereq_(403);
var _lineNumbers2 = _interopRequireDefault(_lineNumbers);
var _repeating = _dereq_(584);
var _repeating2 = _interopRequireDefault(_repeating);
var _jsTokens = _dereq_(401);
var _jsTokens2 = _interopRequireDefault(_jsTokens);
var _esutils = _dereq_(395);
var _esutils2 = _interopRequireDefault(_esutils);
var _chalk = _dereq_(200);
var _chalk2 = _interopRequireDefault(_chalk);
/**
* Chalk styles for token types.
*/
var defs = {
string: _chalk2["default"].red,
punctuator: _chalk2["default"].bold,
curly: _chalk2["default"].green,
parens: _chalk2["default"].blue.bold,
square: _chalk2["default"].yellow,
keyword: _chalk2["default"].cyan,
number: _chalk2["default"].magenta,
regex: _chalk2["default"].magenta,
comment: _chalk2["default"].grey,
invalid: _chalk2["default"].inverse
};
/**
* RegExp to test for newlines in terminal.
*/
var NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
/**
* Get the type of token, specifying punctuator type.
*/
function getTokenType(match) {
var token = _jsTokens2["default"].matchToToken(match);
if (token.type === "name" && _esutils2["default"].keyword.isReservedWordES6(token.value)) {
return "keyword";
}
if (token.type === "punctuator") {
switch (token.value) {
case "{":
case "}":
return "curly";
case "(":
case ")":
return "parens";
case "[":
case "]":
return "square";
}
}
return token.type;
}
/**
* Highlight `text`.
*/
function highlight(text) {
return text.replace(_jsTokens2["default"], function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var type = getTokenType(args);
var colorize = defs[type];
if (colorize) {
return args[0].split(NEWLINE).map(function (str) {
return colorize(str);
}).join("\n");
} else {
return args[0];
}
});
}
/**
* Create a code frame, adding line numbers, code highlighting, and pointing to a given position.
*/
exports["default"] = function (lines, lineNumber, colNumber) {
var opts = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3];
colNumber = Math.max(colNumber, 0);
var highlighted = opts.highlightCode && _chalk2["default"].supportsColor;
if (highlighted) lines = highlight(lines);
lines = lines.split(NEWLINE);
var start = Math.max(lineNumber - 3, 0);
var end = Math.min(lines.length, lineNumber + 3);
if (!lineNumber && !colNumber) {
start = 0;
end = lines.length;
}
var frame = _lineNumbers2["default"](lines.slice(start, end), {
start: start + 1,
before: " ",
after: " | ",
transform: function transform(params) {
if (params.number !== lineNumber) {
return;
}
if (colNumber) {
params.line += "\n" + params.before + _repeating2["default"](" ", params.width) + params.after + _repeating2["default"](" ", colNumber - 1) + "^";
}
params.before = params.before.replace(/^./, ">");
}
}).join("\n");
if (highlighted) {
return _chalk2["default"].reset(frame);
} else {
return frame;
}
};
module.exports = exports["default"];
},{"200":200,"395":395,"401":401,"403":403,"584":584}],39:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _lodashObjectMerge = _dereq_(515);
var _lodashObjectMerge2 = _interopRequireDefault(_lodashObjectMerge);
/**
* Merge options.
*/
exports["default"] = function (dest, src) {
if (!dest || !src) return;
return _lodashObjectMerge2["default"](dest, src, function (a, b) {
if (b && Array.isArray(a)) {
var c = a.slice(0);
for (var _iterator = b, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
}
var v = _ref;
if (a.indexOf(v) < 0) {
c.push(v);
}
}
return c;
}
});
};
module.exports = exports["default"];
},{"515":515}],40:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* Normalize an AST.
*
* - Wrap `Program` node with a `File` node.
*/
exports["default"] = function (ast, comments, tokens) {
if (ast && ast.type === "Program") {
return t.file(ast, comments || [], tokens || []);
} else {
throw new Error("Not a valid ast?");
}
};
module.exports = exports["default"];
},{"179":179}],41:[function(_dereq_,module,exports){
/**
* Create an object with a `null` prototype.
*/
"use strict";
exports.__esModule = true;
exports["default"] = function () {
return Object.create(null);
};
module.exports = exports["default"];
},{}],42:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _babylon = _dereq_(605);
var babylon = _interopRequireWildcard(_babylon);
/**
* Parse `code` with normalized options, collecting tokens and comments.
*/
exports["default"] = function (code) {
var opts = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var parseOpts = {
allowImportExportEverywhere: opts.looseModules,
allowReturnOutsideFunction: opts.looseModules,
allowHashBang: true,
ecmaVersion: 6,
strictMode: opts.strictMode,
sourceType: opts.sourceType,
locations: true,
features: opts.features || {},
plugins: opts.plugins || {}
};
if (opts.nonStandard) {
parseOpts.plugins.jsx = true;
parseOpts.plugins.flow = true;
}
return babylon.parse(code, parseOpts);
};
module.exports = exports["default"];
},{"605":605}],43:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports.get = get;
exports.parseArgs = parseArgs;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _util = _dereq_(13);
var util = _interopRequireWildcard(_util);
/**
* Mapping of messages to be used in Babel.
* Messages can include $0-style placeholders.
*/
var MESSAGES = {
tailCallReassignmentDeopt: "Function reference has been reassigned, so it will probably be dereferenced, therefore we can't optimise this with confidence",
JSXNamespacedTags: "Namespace tags are not supported. ReactJSX is not XML.",
classesIllegalBareSuper: "Illegal use of bare super",
classesIllegalSuperCall: "Direct super call is illegal in non-constructor, use super.$1() instead",
scopeDuplicateDeclaration: "Duplicate declaration $1",
settersNoRest: "Setters aren't allowed to have a rest",
noAssignmentsInForHead: "No assignments allowed in for-in/of head",
expectedMemberExpressionOrIdentifier: "Expected type MemberExpression or Identifier",
invalidParentForThisNode: "We don't know how to handle this node within the current parent - please open an issue",
readOnly: "$1 is read-only",
unknownForHead: "Unknown node type $1 in ForStatement",
didYouMean: "Did you mean $1?",
codeGeneratorDeopt: "Note: The code generator has deoptimised the styling of $1 as it exceeds the max of $2.",
missingTemplatesDirectory: "no templates directory - this is most likely the result of a broken `npm publish`. Please report to https://github.com/babel/babel/issues",
unsupportedOutputType: "Unsupported output type $1",
illegalMethodName: "Illegal method name $1",
lostTrackNodePath: "We lost track of this node's position, likely because the AST was directly manipulated",
modulesIllegalExportName: "Illegal export $1",
modulesDuplicateDeclarations: "Duplicate module declarations with the same source but in different scopes",
undeclaredVariable: "Reference to undeclared variable $1",
undeclaredVariableType: "Referencing a type alias outside of a type annotation",
undeclaredVariableSuggestion: "Reference to undeclared variable $1 - did you mean $2?",
traverseNeedsParent: "You must pass a scope and parentPath unless traversing a Program/File got a $1 node",
traverseVerifyRootFunction: "You passed `traverse()` a function when it expected a visitor object, are you sure you didn't mean `{ enter: Function }`?",
traverseVerifyVisitorProperty: "You passed `traverse()` a visitor object with the property $1 that has the invalid property $2",
traverseVerifyNodeType: "You gave us a visitor for the node type $1 but it's not a valid type",
pluginIllegalKind: "Illegal kind $1 for plugin $2",
pluginIllegalPosition: "Illegal position $1 for plugin $2",
pluginKeyCollision: "The plugin $1 collides with another of the same name",
pluginNotTransformer: "The plugin $1 didn't export a Plugin instance",
pluginUnknown: "Unknown plugin $1",
pluginNotFile: "Plugin $1 is resolving to a different Babel version than what is performing the transformation.",
pluginInvalidProperty: "Plugin $1 provided an invalid property of $2.",
pluginInvalidPropertyVisitor: "Define your visitor methods inside a `visitor` property like so:\n\n new Plugin(\"foobar\", {\n visitor: {\n // define your visitor methods here!\n }\n });\n"
};
exports.MESSAGES = MESSAGES;
/**
* Get a message with $0 placeholders replaced by arguments.
*/
function get(key) {
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
var msg = MESSAGES[key];
if (!msg) throw new ReferenceError("Unknown message " + JSON.stringify(key));
// stringify args
args = parseArgs(args);
// replace $0 placeholders with args
return msg.replace(/\$(\d+)/g, function (str, i) {
return args[--i];
});
}
/**
* Stingify arguments to be used inside messages.
*/
function parseArgs(args) {
return args.map(function (val) {
if (val != null && val.inspect) {
return val.inspect();
} else {
try {
return JSON.stringify(val) || val + "";
} catch (e) {
return util.inspect(val);
}
}
});
}
},{"13":13}],44:[function(_dereq_,module,exports){
(function (global){
"use strict";
_dereq_(387);
_dereq_(577);
if (global._babelPolyfill) {
throw new Error("only one instance of babel/polyfill is allowed");
}
global._babelPolyfill = true;
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"387":387,"577":577}],45:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _generation = _dereq_(30);
var _generation2 = _interopRequireDefault(_generation);
var _messages = _dereq_(43);
var messages = _interopRequireWildcard(_messages);
var _util = _dereq_(182);
var util = _interopRequireWildcard(_util);
var _transformationFile = _dereq_(46);
var _transformationFile2 = _interopRequireDefault(_transformationFile);
var _lodashCollectionEach = _dereq_(411);
var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
function buildGlobal(namespace, builder) {
var body = [];
var container = t.functionExpression(null, [t.identifier("global")], t.blockStatement(body));
var tree = t.program([t.expressionStatement(t.callExpression(container, [util.template("helper-self-global")]))]);
body.push(t.variableDeclaration("var", [t.variableDeclarator(namespace, t.assignmentExpression("=", t.memberExpression(t.identifier("global"), namespace), t.objectExpression([])))]));
builder(body);
return tree;
}
/**
* [Please add a description.]
*/
function buildUmd(namespace, builder) {
var body = [];
body.push(t.variableDeclaration("var", [t.variableDeclarator(namespace, t.identifier("global"))]));
builder(body);
var container = util.template("umd-commonjs-strict", {
FACTORY_PARAMETERS: t.identifier("global"),
BROWSER_ARGUMENTS: t.assignmentExpression("=", t.memberExpression(t.identifier("root"), namespace), t.objectExpression({})),
COMMON_ARGUMENTS: t.identifier("exports"),
AMD_ARGUMENTS: t.arrayExpression([t.literal("exports")]),
FACTORY_BODY: body,
UMD_ROOT: t.identifier("this")
});
return t.program([container]);
}
/**
* [Please add a description.]
*/
function buildVar(namespace, builder) {
var body = [];
body.push(t.variableDeclaration("var", [t.variableDeclarator(namespace, t.objectExpression({}))]));
builder(body);
return t.program(body);
}
/**
* [Please add a description.]
*/
function buildHelpers(body, namespace, whitelist) {
_lodashCollectionEach2["default"](_transformationFile2["default"].helpers, function (name) {
if (whitelist && whitelist.indexOf(name) === -1) return;
var key = t.identifier(t.toIdentifier(name));
body.push(t.expressionStatement(t.assignmentExpression("=", t.memberExpression(namespace, key), util.template("helper-" + name))));
});
}
/**
* [Please add a description.]
*/
exports["default"] = function (whitelist) {
var outputType = arguments.length <= 1 || arguments[1] === undefined ? "global" : arguments[1];
var namespace = t.identifier("babelHelpers");
var builder = function builder(body) {
return buildHelpers(body, namespace, whitelist);
};
var tree;
var build = ({
global: buildGlobal,
umd: buildUmd,
"var": buildVar
})[outputType];
if (build) {
tree = build(namespace, builder);
} else {
throw new Error(messages.get("unsupportedOutputType", outputType));
}
return _generation2["default"](tree).code;
};
module.exports = exports["default"];
},{"179":179,"182":182,"30":30,"411":411,"43":43,"46":46}],46:[function(_dereq_,module,exports){
(function (process){
"use strict";
exports.__esModule = true;
// istanbul ignore next
var _createClass = (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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// istanbul ignore next
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _convertSourceMap = _dereq_(208);
var _convertSourceMap2 = _interopRequireDefault(_convertSourceMap);
var _modules = _dereq_(74);
var _modules2 = _interopRequireDefault(_modules);
var _optionsOptionManager = _dereq_(50);
var _optionsOptionManager2 = _interopRequireDefault(_optionsOptionManager);
var _pluginManager = _dereq_(52);
var _pluginManager2 = _interopRequireDefault(_pluginManager);
var _shebangRegex = _dereq_(587);
var _shebangRegex2 = _interopRequireDefault(_shebangRegex);
var _traversalPath = _dereq_(155);
var _traversalPath2 = _interopRequireDefault(_traversalPath);
var _lodashLangIsFunction = _dereq_(500);
var _lodashLangIsFunction2 = _interopRequireDefault(_lodashLangIsFunction);
var _sourceMap = _dereq_(599);
var _sourceMap2 = _interopRequireDefault(_sourceMap);
var _generation = _dereq_(30);
var _generation2 = _interopRequireDefault(_generation);
var _helpersCodeFrame = _dereq_(38);
var _helpersCodeFrame2 = _interopRequireDefault(_helpersCodeFrame);
var _lodashObjectDefaults = _dereq_(510);
var _lodashObjectDefaults2 = _interopRequireDefault(_lodashObjectDefaults);
var _lodashCollectionIncludes = _dereq_(413);
var _lodashCollectionIncludes2 = _interopRequireDefault(_lodashCollectionIncludes);
var _traversal = _dereq_(148);
var _traversal2 = _interopRequireDefault(_traversal);
var _tryResolve = _dereq_(602);
var _tryResolve2 = _interopRequireDefault(_tryResolve);
var _logger = _dereq_(47);
var _logger2 = _interopRequireDefault(_logger);
var _plugin = _dereq_(82);
var _plugin2 = _interopRequireDefault(_plugin);
var _helpersParse = _dereq_(42);
var _helpersParse2 = _interopRequireDefault(_helpersParse);
var _traversalHub = _dereq_(147);
var _traversalHub2 = _interopRequireDefault(_traversalHub);
var _util = _dereq_(182);
var util = _interopRequireWildcard(_util);
var _path = _dereq_(9);
var _path2 = _interopRequireDefault(_path);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
var File = (function () {
function File(opts, pipeline) {
if (opts === undefined) opts = {};
_classCallCheck(this, File);
this.transformerDependencies = {};
this.dynamicImportTypes = {};
this.dynamicImportIds = {};
this.dynamicImports = [];
this.declarations = {};
this.usedHelpers = {};
this.dynamicData = {};
this.data = {};
this.ast = {};
this.metadata = {
modules: {
imports: [],
exports: {
exported: [],
specifiers: []
}
}
};
this.hub = new _traversalHub2["default"](this);
this.pipeline = pipeline;
this.log = new _logger2["default"](this, opts.filename || "unknown");
this.opts = this.initOptions(opts);
this.buildTransformers();
}
/**
* [Please add a description.]
*/
File.prototype.initOptions = function initOptions(opts) {
opts = new _optionsOptionManager2["default"](this.log, this.pipeline).init(opts);
if (opts.inputSourceMap) {
opts.sourceMaps = true;
}
if (opts.moduleId) {
opts.moduleIds = true;
}
opts.basename = _path2["default"].basename(opts.filename, _path2["default"].extname(opts.filename));
opts.ignore = util.arrayify(opts.ignore, util.regexify);
if (opts.only) opts.only = util.arrayify(opts.only, util.regexify);
_lodashObjectDefaults2["default"](opts, {
moduleRoot: opts.sourceRoot
});
_lodashObjectDefaults2["default"](opts, {
sourceRoot: opts.moduleRoot
});
_lodashObjectDefaults2["default"](opts, {
filenameRelative: opts.filename
});
_lodashObjectDefaults2["default"](opts, {
sourceFileName: opts.filenameRelative,
sourceMapTarget: opts.filenameRelative
});
//
if (opts.externalHelpers) {
this.set("helpersNamespace", t.identifier("babelHelpers"));
}
return opts;
};
/**
* [Please add a description.]
*/
File.prototype.isLoose = function isLoose(key) {
return _lodashCollectionIncludes2["default"](this.opts.loose, key);
};
/**
* [Please add a description.]
*/
File.prototype.buildTransformers = function buildTransformers() {
var file = this;
var transformers = this.transformers = {};
var secondaryStack = [];
var stack = [];
// build internal transformers
for (var key in this.pipeline.transformers) {
var transformer = this.pipeline.transformers[key];
var pass = transformers[key] = transformer.buildPass(file);
if (pass.canTransform()) {
stack.push(pass);
if (transformer.metadata.secondPass) {
secondaryStack.push(pass);
}
if (transformer.manipulateOptions) {
transformer.manipulateOptions(file.opts, file);
}
}
}
// init plugins!
var beforePlugins = [];
var afterPlugins = [];
var pluginManager = new _pluginManager2["default"]({
file: this,
transformers: this.transformers,
before: beforePlugins,
after: afterPlugins
});
for (var i = 0; i < file.opts.plugins.length; i++) {
pluginManager.add(file.opts.plugins[i]);
}
stack = beforePlugins.concat(stack, afterPlugins);
// build transformer stack
this.uncollapsedTransformerStack = stack = stack.concat(secondaryStack);
// build dependency graph
var _arr = stack;
for (var _i = 0; _i < _arr.length; _i++) {
var pass = _arr[_i];var _arr2 = pass.plugin.dependencies;
for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
var dep = _arr2[_i2];
this.transformerDependencies[dep] = pass.key;
}
}
// collapse stack categories
this.transformerStack = this.collapseStack(stack);
};
/**
* [Please add a description.]
*/
File.prototype.collapseStack = function collapseStack(_stack) {
var stack = [];
var ignore = [];
var _arr3 = _stack;
for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
var pass = _arr3[_i3];
// been merged
if (ignore.indexOf(pass) >= 0) continue;
var group = pass.plugin.metadata.group;
// can't merge
if (!pass.canTransform() || !group) {
stack.push(pass);
continue;
}
var mergeStack = [];
var _arr4 = _stack;
for (var _i4 = 0; _i4 < _arr4.length; _i4++) {
var _pass = _arr4[_i4];
if (_pass.plugin.metadata.group === group) {
mergeStack.push(_pass);
ignore.push(_pass);
}
}
var visitors = [];
var _arr5 = mergeStack;
for (var _i5 = 0; _i5 < _arr5.length; _i5++) {
var _pass2 = _arr5[_i5];
visitors.push(_pass2.plugin.visitor);
}
var visitor = _traversal2["default"].visitors.merge(visitors);
var mergePlugin = new _plugin2["default"](group, { visitor: visitor });
stack.push(mergePlugin.buildPass(this));
}
return stack;
};
/**
* [Please add a description.]
*/
File.prototype.set = function set(key, val) {
return this.data[key] = val;
};
/**
* [Please add a description.]
*/
File.prototype.setDynamic = function setDynamic(key, fn) {
this.dynamicData[key] = fn;
};
/**
* [Please add a description.]
*/
File.prototype.get = function get(key) {
var data = this.data[key];
if (data) {
return data;
} else {
var dynamic = this.dynamicData[key];
if (dynamic) {
return this.set(key, dynamic());
}
}
};
/**
* [Please add a description.]
*/
File.prototype.resolveModuleSource = function resolveModuleSource(source) {
var resolveModuleSource = this.opts.resolveModuleSource;
if (resolveModuleSource) source = resolveModuleSource(source, this.opts.filename);
return source;
};
/**
* [Please add a description.]
*/
File.prototype.addImport = function addImport(source, name, type) {
name = name || source;
var id = this.dynamicImportIds[name];
if (!id) {
source = this.resolveModuleSource(source);
id = this.dynamicImportIds[name] = this.scope.generateUidIdentifier(name);
var specifiers = [t.importDefaultSpecifier(id)];
var declar = t.importDeclaration(specifiers, t.literal(source));
declar._blockHoist = 3;
if (type) {
var modules = this.dynamicImportTypes[type] = this.dynamicImportTypes[type] || [];
modules.push(declar);
}
if (this.transformers["es6.modules"].canTransform()) {
this.moduleFormatter.importSpecifier(specifiers[0], declar, this.dynamicImports, this.scope);
this.moduleFormatter.hasLocalImports = true;
} else {
this.dynamicImports.push(declar);
}
}
return id;
};
/**
* [Please add a description.]
*/
File.prototype.attachAuxiliaryComment = function attachAuxiliaryComment(node) {
var beforeComment = this.opts.auxiliaryCommentBefore;
if (beforeComment) {
node.leadingComments = node.leadingComments || [];
node.leadingComments.push({
type: "CommentLine",
value: " " + beforeComment
});
}
var afterComment = this.opts.auxiliaryCommentAfter;
if (afterComment) {
node.trailingComments = node.trailingComments || [];
node.trailingComments.push({
type: "CommentLine",
value: " " + afterComment
});
}
return node;
};
/**
* [Please add a description.]
*/
File.prototype.addHelper = function addHelper(name) {
var isSolo = _lodashCollectionIncludes2["default"](File.soloHelpers, name);
if (!isSolo && !_lodashCollectionIncludes2["default"](File.helpers, name)) {
throw new ReferenceError("Unknown helper " + name);
}
var declar = this.declarations[name];
if (declar) return declar;
this.usedHelpers[name] = true;
if (!isSolo) {
var generator = this.get("helperGenerator");
var runtime = this.get("helpersNamespace");
if (generator) {
return generator(name);
} else if (runtime) {
var id = t.identifier(t.toIdentifier(name));
return t.memberExpression(runtime, id);
}
}
var ref = util.template("helper-" + name);
var uid = this.declarations[name] = this.scope.generateUidIdentifier(name);
if (t.isFunctionExpression(ref) && !ref.id) {
ref.body._compact = true;
ref._generated = true;
ref.id = uid;
ref.type = "FunctionDeclaration";
this.attachAuxiliaryComment(ref);
this.path.unshiftContainer("body", ref);
} else {
ref._compact = true;
this.scope.push({
id: uid,
init: ref,
unique: true
});
}
return uid;
};
File.prototype.addTemplateObject = function addTemplateObject(helperName, strings, raw) {
// Generate a unique name based on the string literals so we dedupe
// identical strings used in the program.
var stringIds = raw.elements.map(function (string) {
return string.value;
});
var name = helperName + "_" + raw.elements.length + "_" + stringIds.join(",");
var declar = this.declarations[name];
if (declar) return declar;
var uid = this.declarations[name] = this.scope.generateUidIdentifier("templateObject");
var helperId = this.addHelper(helperName);
var init = t.callExpression(helperId, [strings, raw]);
init._compact = true;
this.scope.push({
id: uid,
init: init,
_blockHoist: 1.9 // This ensures that we don't fail if not using function expression helpers
});
return uid;
};
/**
* [Please add a description.]
*/
File.prototype.errorWithNode = function errorWithNode(node, msg) {
var Error = arguments.length <= 2 || arguments[2] === undefined ? SyntaxError : arguments[2];
var err;
var loc = node && (node.loc || node._loc);
if (loc) {
err = new Error("Line " + loc.start.line + ": " + msg);
err.loc = loc.start;
} else {
// todo: find errors with nodes inside to at least point to something
err = new Error("There's been an error on a dynamic node. This is almost certainly an internal error. Please report it.");
}
return err;
};
/**
* [Please add a description.]
*/
File.prototype.mergeSourceMap = function mergeSourceMap(map) {
var opts = this.opts;
var inputMap = opts.inputSourceMap;
if (inputMap) {
map.sources[0] = inputMap.file;
var inputMapConsumer = new _sourceMap2["default"].SourceMapConsumer(inputMap);
var outputMapConsumer = new _sourceMap2["default"].SourceMapConsumer(map);
var outputMapGenerator = _sourceMap2["default"].SourceMapGenerator.fromSourceMap(outputMapConsumer);
outputMapGenerator.applySourceMap(inputMapConsumer);
var mergedMap = outputMapGenerator.toJSON();
mergedMap.sources = inputMap.sources;
mergedMap.file = inputMap.file;
return mergedMap;
}
return map;
};
/**
* [Please add a description.]
*/
File.prototype.getModuleFormatter = function getModuleFormatter(type) {
if (_lodashLangIsFunction2["default"](type) || !_modules2["default"][type]) {
this.log.deprecate("Custom module formatters are deprecated and will be removed in the next major. Please use Babel plugins instead.");
}
var ModuleFormatter = _lodashLangIsFunction2["default"](type) ? type : _modules2["default"][type];
if (!ModuleFormatter) {
var loc = _tryResolve2["default"].relative(type);
if (loc) ModuleFormatter = _dereq_(loc);
}
if (!ModuleFormatter) {
throw new ReferenceError("Unknown module formatter type " + JSON.stringify(type));
}
return new ModuleFormatter(this);
};
/**
* [Please add a description.]
*/
File.prototype.parse = function parse(code) {
var opts = this.opts;
//
var parseOpts = {
highlightCode: opts.highlightCode,
nonStandard: opts.nonStandard,
sourceType: opts.sourceType,
filename: opts.filename,
plugins: {}
};
var features = parseOpts.features = {};
for (var key in this.transformers) {
var transformer = this.transformers[key];
features[key] = transformer.canTransform();
}
parseOpts.looseModules = this.isLoose("es6.modules");
parseOpts.strictMode = features.strict;
this.log.debug("Parse start");
var ast = _helpersParse2["default"](code, parseOpts);
this.log.debug("Parse stop");
return ast;
};
/**
* [Please add a description.]
*/
File.prototype._addAst = function _addAst(ast) {
this.path = _traversalPath2["default"].get({
hub: this.hub,
parentPath: null,
parent: ast,
container: ast,
key: "program"
}).setContext();
this.scope = this.path.scope;
this.ast = ast;
};
/**
* [Please add a description.]
*/
File.prototype.addAst = function addAst(ast) {
this.log.debug("Start set AST");
this._addAst(ast);
this.log.debug("End set AST");
this.log.debug("Start module formatter init");
var modFormatter = this.moduleFormatter = this.getModuleFormatter(this.opts.modules);
if (modFormatter.init && this.transformers["es6.modules"].canTransform()) {
modFormatter.init();
}
this.log.debug("End module formatter init");
};
/**
* [Please add a description.]
*/
File.prototype.transform = function transform() {
this.call("pre");
var _arr6 = this.transformerStack;
for (var _i6 = 0; _i6 < _arr6.length; _i6++) {
var pass = _arr6[_i6];
pass.transform();
}
this.call("post");
return this.generate();
};
/**
* [Please add a description.]
*/
File.prototype.wrap = function wrap(code, callback) {
code = code + "";
try {
if (this.shouldIgnore()) {
return this.makeResult({ code: code, ignored: true });
} else {
return callback();
}
} catch (err) {
if (err._babel) {
throw err;
} else {
err._babel = true;
}
var message = err.message = this.opts.filename + ": " + err.message;
var loc = err.loc;
if (loc) {
err.codeFrame = _helpersCodeFrame2["default"](code, loc.line, loc.column + 1, this.opts);
message += "\n" + err.codeFrame;
}
if (process.browser) {
// chrome has it's own pretty stringifier which doesn't use the stack property
// https://github.com/babel/babel/issues/2175
err.message = message;
}
if (err.stack) {
var newStack = err.stack.replace(err.message, message);
try {
err.stack = newStack;
} catch (e) {
// `err.stack` may be a readonly property in some environments
}
}
throw err;
}
};
/**
* [Please add a description.]
*/
File.prototype.addCode = function addCode(code) {
code = (code || "") + "";
code = this.parseInputSourceMap(code);
this.code = code;
};
/**
* [Please add a description.]
*/
File.prototype.parseCode = function parseCode() {
this.parseShebang();
var ast = this.parse(this.code);
this.addAst(ast);
};
/**
* [Please add a description.]
*/
File.prototype.shouldIgnore = function shouldIgnore() {
var opts = this.opts;
return util.shouldIgnore(opts.filename, opts.ignore, opts.only);
};
/**
* [Please add a description.]
*/
File.prototype.call = function call(key) {
var _arr7 = this.uncollapsedTransformerStack;
for (var _i7 = 0; _i7 < _arr7.length; _i7++) {
var pass = _arr7[_i7];
var fn = pass.plugin[key];
if (fn) fn(this);
}
};
/**
* [Please add a description.]
*/
File.prototype.parseInputSourceMap = function parseInputSourceMap(code) {
var opts = this.opts;
if (opts.inputSourceMap !== false) {
var inputMap = _convertSourceMap2["default"].fromSource(code);
if (inputMap) {
opts.inputSourceMap = inputMap.toObject();
code = _convertSourceMap2["default"].removeComments(code);
}
}
return code;
};
/**
* [Please add a description.]
*/
File.prototype.parseShebang = function parseShebang() {
var shebangMatch = _shebangRegex2["default"].exec(this.code);
if (shebangMatch) {
this.shebang = shebangMatch[0];
this.code = this.code.replace(_shebangRegex2["default"], "");
}
};
/**
* [Please add a description.]
*/
File.prototype.makeResult = function makeResult(_ref) {
var code = _ref.code;
var _ref$map = _ref.map;
var map = _ref$map === undefined ? null : _ref$map;
var ast = _ref.ast;
var ignored = _ref.ignored;
var result = {
metadata: null,
ignored: !!ignored,
code: null,
ast: null,
map: map
};
if (this.opts.code) {
result.code = code;
}
if (this.opts.ast) {
result.ast = ast;
}
if (this.opts.metadata) {
result.metadata = this.metadata;
result.metadata.usedHelpers = Object.keys(this.usedHelpers);
}
return result;
};
/**
* [Please add a description.]
*/
File.prototype.generate = function generate() {
var opts = this.opts;
var ast = this.ast;
var result = { ast: ast };
if (!opts.code) return this.makeResult(result);
this.log.debug("Generation start");
var _result = _generation2["default"](ast, opts, this.code);
result.code = _result.code;
result.map = _result.map;
this.log.debug("Generation end");
if (this.shebang) {
// add back shebang
result.code = this.shebang + "\n" + result.code;
}
if (result.map) {
result.map = this.mergeSourceMap(result.map);
}
if (opts.sourceMaps === "inline" || opts.sourceMaps === "both") {
result.code += "\n" + _convertSourceMap2["default"].fromObject(result.map).toComment();
}
if (opts.sourceMaps === "inline") {
result.map = null;
}
return this.makeResult(result);
};
_createClass(File, null, [{
key: "helpers",
/**
* [Please add a description.]
*/
value: ["inherits", "defaults", "create-class", "create-decorated-class", "create-decorated-object", "define-decorated-property-descriptor", "tagged-template-literal", "tagged-template-literal-loose", "to-array", "to-consumable-array", "sliced-to-array", "sliced-to-array-loose", "object-without-properties", "has-own", "slice", "bind", "define-property", "async-to-generator", "interop-export-wildcard", "interop-require-wildcard", "interop-require-default", "typeof", "extends", "get", "set", "new-arrow-check", "class-call-check", "object-destructuring-empty", "temporal-undefined", "temporal-assert-defined", "self-global", "typeof-react-element", "default-props", "instanceof",
// legacy
"interop-require"],
/**
* [Please add a description.]
*/
enumerable: true
}, {
key: "soloHelpers",
value: [],
enumerable: true
}]);
return File;
})();
exports["default"] = File;
module.exports = exports["default"];
}).call(this,_dereq_(10))
},{"10":10,"147":147,"148":148,"155":155,"179":179,"182":182,"208":208,"30":30,"38":38,"413":413,"42":42,"47":47,"50":50,"500":500,"510":510,"52":52,"587":587,"599":599,"602":602,"74":74,"82":82,"9":9}],47:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// istanbul ignore next
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _debugNode = _dereq_(389);
var _debugNode2 = _interopRequireDefault(_debugNode);
var verboseDebug = _debugNode2["default"]("babel:verbose");
var generalDebug = _debugNode2["default"]("babel");
var seenDeprecatedMessages = [];
/**
* [Please add a description.]
*/
var Logger = (function () {
function Logger(file, filename) {
_classCallCheck(this, Logger);
this.filename = filename;
this.file = file;
}
/**
* [Please add a description.]
*/
Logger.prototype._buildMessage = function _buildMessage(msg) {
var parts = "[BABEL] " + this.filename;
if (msg) parts += ": " + msg;
return parts;
};
/**
* [Please add a description.]
*/
Logger.prototype.warn = function warn(msg) {
console.warn(this._buildMessage(msg));
};
/**
* [Please add a description.]
*/
Logger.prototype.error = function error(msg) {
var Constructor = arguments.length <= 1 || arguments[1] === undefined ? Error : arguments[1];
throw new Constructor(this._buildMessage(msg));
};
/**
* [Please add a description.]
*/
Logger.prototype.deprecate = function deprecate(msg) {
if (this.file.opts && this.file.opts.suppressDeprecationMessages) return;
msg = this._buildMessage(msg);
// already seen this message
if (seenDeprecatedMessages.indexOf(msg) >= 0) return;
// make sure we don't see it again
seenDeprecatedMessages.push(msg);
console.error(msg);
};
/**
* [Please add a description.]
*/
Logger.prototype.verbose = function verbose(msg) {
if (verboseDebug.enabled) verboseDebug(this._buildMessage(msg));
};
/**
* [Please add a description.]
*/
Logger.prototype.debug = function debug(msg) {
if (generalDebug.enabled) generalDebug(this._buildMessage(msg));
};
/**
* [Please add a description.]
*/
Logger.prototype.deopt = function deopt(node, msg) {
this.debug(msg);
};
return Logger;
})();
exports["default"] = Logger;
module.exports = exports["default"];
},{"389":389}],48:[function(_dereq_,module,exports){
module.exports={
"filename": {
"type": "filename",
"description": "filename to use when reading from stdin - this will be used in source-maps, errors etc",
"default": "unknown",
"shorthand": "f"
},
"filenameRelative": {
"hidden": true,
"type": "string"
},
"inputSourceMap": {
"hidden": true
},
"extra": {
"hidden": true,
"default": {}
},
"env": {
"hidden": true,
"default": {}
},
"moduleId": {
"description": "specify a custom name for module ids",
"type": "string"
},
"getModuleId": {
"hidden": true
},
"retainLines": {
"type": "boolean",
"default": false,
"description": "retain line numbers - will result in really ugly code"
},
"nonStandard": {
"type": "boolean",
"default": true,
"description": "enable/disable support for JSX and Flow (on by default)"
},
"experimental": {
"type": "boolean",
"description": "allow use of experimental transformers",
"default": false
},
"highlightCode": {
"description": "enable/disable ANSI syntax highlighting of code frames (on by default)",
"type": "boolean",
"default": true
},
"suppressDeprecationMessages": {
"type": "boolean",
"default": false,
"hidden": true
},
"resolveModuleSource": {
"hidden": true
},
"stage": {
"description": "ECMAScript proposal stage version to allow [0-4]",
"shorthand": "e",
"type": "number",
"default": 2
},
"blacklist": {
"type": "transformerList",
"description": "blacklist of transformers to NOT use",
"shorthand": "b",
"default": []
},
"whitelist": {
"type": "transformerList",
"optional": true,
"description": "whitelist of transformers to ONLY use",
"shorthand": "l"
},
"optional": {
"type": "transformerList",
"description": "list of optional transformers to enable",
"default": []
},
"modules": {
"type": "string",
"description": "module formatter type to use [common]",
"default": "common",
"shorthand": "m"
},
"moduleIds": {
"type": "boolean",
"default": false,
"shorthand": "M",
"description": "insert an explicit id for modules"
},
"loose": {
"type": "transformerList",
"description": "list of transformers to enable loose mode ON",
"shorthand": "L"
},
"jsxPragma": {
"type": "string",
"description": "custom pragma to use with JSX (same functionality as @jsx comments)",
"default": "React.createElement",
"shorthand": "P"
},
"plugins": {
"type": "list",
"description": "",
"default": []
},
"ignore": {
"type": "list",
"description": "list of glob paths to **not** compile",
"default": []
},
"only": {
"type": "list",
"description": "list of glob paths to **only** compile"
},
"code": {
"hidden": true,
"default": true,
"type": "boolean"
},
"metadata": {
"hidden": true,
"default": true,
"type": "boolean"
},
"ast": {
"hidden": true,
"default": true,
"type": "boolean"
},
"comments": {
"type": "boolean",
"default": true,
"description": "strip/output comments in generated output (on by default)"
},
"shouldPrintComment": {
"hidden": true,
"description": "optional callback to control whether a comment should be inserted, when this is used the comments option is ignored"
},
"compact": {
"type": "booleanString",
"default": "auto",
"description": "do not include superfluous whitespace characters and line terminators [true|false|auto]"
},
"keepModuleIdExtensions": {
"type": "boolean",
"description": "keep extensions when generating module ids",
"default": false,
"shorthand": "k"
},
"auxiliaryComment": {
"deprecated": "renamed to auxiliaryCommentBefore",
"shorthand": "a",
"alias": "auxiliaryCommentBefore"
},
"auxiliaryCommentBefore": {
"type": "string",
"default": "",
"description": "attach a comment before all helper declarations and auxiliary code"
},
"auxiliaryCommentAfter": {
"type": "string",
"default": "",
"description": "attach a comment after all helper declarations and auxiliary code"
},
"externalHelpers": {
"type": "boolean",
"default": false,
"shorthand": "r",
"description": "uses a reference to `babelHelpers` instead of placing helpers at the top of your code."
},
"metadataUsedHelpers": {
"deprecated": "Not required anymore as this is enabled by default",
"type": "boolean",
"default": false,
"hidden": true
},
"sourceMap": {
"alias": "sourceMaps",
"hidden": true
},
"sourceMaps": {
"type": "booleanString",
"description": "[true|false|inline]",
"default": false,
"shorthand": "s"
},
"sourceMapName": {
"alias": "sourceMapTarget",
"description": "DEPRECATED - Please use sourceMapTarget"
},
"sourceMapTarget": {
"type": "string",
"description": "set `file` on returned source map"
},
"sourceFileName": {
"type": "string",
"description": "set `sources[0]` on returned source map"
},
"sourceRoot": {
"type": "filename",
"description": "the root from which all sources are relative"
},
"moduleRoot": {
"type": "filename",
"description": "optional prefix for the AMD module formatter that will be prepend to the filename on module definitions"
},
"breakConfig": {
"type": "boolean",
"default": false,
"hidden": true,
"description": "stop trying to load .babelrc files"
},
"babelrc": {
"description": "Specify a custom list of babelrc files to use",
"type": "list"
},
"sourceType": {
"description": "",
"default": "module"
}
}
},{}],49:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports.validateOption = validateOption;
exports.normaliseOptions = normaliseOptions;
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _parsers = _dereq_(51);
var parsers = _interopRequireWildcard(_parsers);
var _config = _dereq_(48);
var _config2 = _interopRequireDefault(_config);
exports.config = _config2["default"];
/**
* Validate an option.
*/
function validateOption(key, val, pipeline) {
var opt = _config2["default"][key];
var parser = opt && parsers[opt.type];
if (parser && parser.validate) {
return parser.validate(key, val, pipeline);
} else {
return val;
}
}
/**
* Normalize all options.
*/
function normaliseOptions() {
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
for (var key in options) {
var val = options[key];
if (val == null) continue;
var opt = _config2["default"][key];
if (!opt) continue;
var parser = parsers[opt.type];
if (parser) val = parser(val);
options[key] = val;
}
return options;
}
},{"48":48,"51":51}],50:[function(_dereq_,module,exports){
(function (process){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// istanbul ignore next
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _index = _dereq_(49);
var _json5 = _dereq_(402);
var _json52 = _interopRequireDefault(_json5);
var _pathIsAbsolute = _dereq_(527);
var _pathIsAbsolute2 = _interopRequireDefault(_pathIsAbsolute);
var _pathExists = _dereq_(526);
var _pathExists2 = _interopRequireDefault(_pathExists);
var _lodashLangClone = _dereq_(494);
var _lodashLangClone2 = _interopRequireDefault(_lodashLangClone);
var _helpersMerge = _dereq_(39);
var _helpersMerge2 = _interopRequireDefault(_helpersMerge);
var _config = _dereq_(48);
var _config2 = _interopRequireDefault(_config);
var _path = _dereq_(9);
var _path2 = _interopRequireDefault(_path);
var _fs = _dereq_(1);
var _fs2 = _interopRequireDefault(_fs);
var existsCache = {};
var jsonCache = {};
var BABELIGNORE_FILENAME = ".babelignore";
var BABELRC_FILENAME = ".babelrc";
var PACKAGE_FILENAME = "package.json";
function exists(filename) {
var cached = existsCache[filename];
if (cached != null) {
return cached;
} else {
return existsCache[filename] = _pathExists2["default"].sync(filename);
}
}
var OptionManager = (function () {
function OptionManager(log, pipeline) {
_classCallCheck(this, OptionManager);
this.resolvedConfigs = [];
this.options = OptionManager.createBareOptions();
this.pipeline = pipeline;
this.log = log;
}
/**
* [Please add a description.]
*/
OptionManager.createBareOptions = function createBareOptions() {
var opts = {};
for (var key in _config2["default"]) {
var opt = _config2["default"][key];
opts[key] = _lodashLangClone2["default"](opt["default"]);
}
return opts;
};
/**
* [Please add a description.]
*/
OptionManager.prototype.addConfig = function addConfig(loc, key) {
var json = arguments.length <= 2 || arguments[2] === undefined ? _json52["default"] : arguments[2];
if (this.resolvedConfigs.indexOf(loc) >= 0) return;
var content = _fs2["default"].readFileSync(loc, "utf8");
var opts;
try {
opts = jsonCache[content] = jsonCache[content] || json.parse(content);
if (key) opts = opts[key];
} catch (err) {
err.message = loc + ": Error while parsing JSON - " + err.message;
throw err;
}
this.mergeOptions(opts, loc);
this.resolvedConfigs.push(loc);
};
/**
* [Please add a description.]
*/
OptionManager.prototype.mergeOptions = function mergeOptions(opts) {
var alias = arguments.length <= 1 || arguments[1] === undefined ? "foreign" : arguments[1];
if (!opts) return;
for (var key in opts) {
if (key[0] === "_") continue;
var option = _config2["default"][key];
// check for an unknown option
if (!option) this.log.error("Unknown option: " + alias + "." + key, ReferenceError);
}
// normalise options
_index.normaliseOptions(opts);
// merge them into this current files options
_helpersMerge2["default"](this.options, opts);
};
/**
* [Please add a description.]
*/
OptionManager.prototype.addIgnoreConfig = function addIgnoreConfig(loc) {
var file = _fs2["default"].readFileSync(loc, "utf8");
var lines = file.split("\n");
lines = lines.map(function (line) {
return line.replace(/#(.*?)$/, "").trim();
}).filter(function (line) {
return !!line;
});
this.mergeOptions({ ignore: lines }, loc);
};
/**
* Description
*/
OptionManager.prototype.findConfigs = function findConfigs(loc) {
if (!loc) return;
if (!_pathIsAbsolute2["default"](loc)) {
loc = _path2["default"].join(process.cwd(), loc);
}
while (loc !== (loc = _path2["default"].dirname(loc))) {
if (this.options.breakConfig) return;
var configLoc = _path2["default"].join(loc, BABELRC_FILENAME);
if (exists(configLoc)) this.addConfig(configLoc);
var pkgLoc = _path2["default"].join(loc, PACKAGE_FILENAME);
if (exists(pkgLoc)) this.addConfig(pkgLoc, "babel", JSON);
var ignoreLoc = _path2["default"].join(loc, BABELIGNORE_FILENAME);
if (exists(ignoreLoc)) this.addIgnoreConfig(ignoreLoc);
}
};
/**
* [Please add a description.]
*/
OptionManager.prototype.normaliseOptions = function normaliseOptions() {
var opts = this.options;
for (var key in _config2["default"]) {
var option = _config2["default"][key];
var val = opts[key];
// optional
if (!val && option.optional) continue;
// deprecated
if (this.log && val && option.deprecated) {
this.log.deprecate("Deprecated option " + key + ": " + option.deprecated);
}
// validate
if (this.pipeline && val) {
val = _index.validateOption(key, val, this.pipeline);
}
// aaliases
if (option.alias) {
opts[option.alias] = opts[option.alias] || val;
} else {
opts[key] = val;
}
}
};
/**
* [Please add a description.]
*/
OptionManager.prototype.init = function init(opts) {
this.mergeOptions(opts, "direct");
// babelrc option
if (opts.babelrc) {
var _arr = opts.babelrc;
for (var _i = 0; _i < _arr.length; _i++) {
var loc = _arr[_i];this.addConfig(loc);
}
}
// resolve all .babelrc files
if (opts.babelrc !== false) {
this.findConfigs(opts.filename);
}
// merge in env
var envKey = process.env.BABEL_ENV || process.env.NODE_ENV || "development";
if (this.options.env) {
this.mergeOptions(this.options.env[envKey], "direct.env." + envKey);
}
// normalise
this.normaliseOptions(opts);
return this.options;
};
return OptionManager;
})();
exports["default"] = OptionManager;
module.exports = exports["default"];
}).call(this,_dereq_(10))
},{"1":1,"10":10,"39":39,"402":402,"48":48,"49":49,"494":494,"526":526,"527":527,"9":9}],51:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports.transformerList = transformerList;
exports.number = number;
exports.boolean = boolean;
exports.booleanString = booleanString;
exports.list = list;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _slash = _dereq_(588);
var _slash2 = _interopRequireDefault(_slash);
var _util = _dereq_(182);
var util = _interopRequireWildcard(_util);
/**
* Get a transformer list from a value.
*/
function transformerList(val) {
return util.arrayify(val);
}
/**
* Validate transformer list. Maps "all" to all transformer names.
*/
transformerList.validate = function (key, val, pipeline) {
if (val.indexOf("all") >= 0 || val.indexOf(true) >= 0) {
val = Object.keys(pipeline.transformers);
}
return pipeline._ensureTransformerNames(key, val);
};
/**
* Cast a value to a number.
*/
function number(val) {
return +val;
}
/**
* Cast a value to a boolean.
*/
var filename = _slash2["default"];
exports.filename = filename;
/**
* [Please add a description.]
*/
function boolean(val) {
return !!val;
}
/**
* Cast a boolean-like string to a boolean.
*/
function booleanString(val) {
return util.booleanify(val);
}
/**
* Cast a value to an array, splitting strings by ",".
*/
function list(val) {
return util.list(val);
}
},{"182":182,"588":588}],52:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
var _createClass = (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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// istanbul ignore next
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _transformer = _dereq_(83);
var _transformer2 = _interopRequireDefault(_transformer);
var _plugin = _dereq_(82);
var _plugin2 = _interopRequireDefault(_plugin);
var _types = _dereq_(179);
var types = _interopRequireWildcard(_types);
var _messages = _dereq_(43);
var messages = _interopRequireWildcard(_messages);
var _tryResolve = _dereq_(602);
var _tryResolve2 = _interopRequireDefault(_tryResolve);
var _traversal = _dereq_(148);
var _traversal2 = _interopRequireDefault(_traversal);
var _helpersParse = _dereq_(42);
var _helpersParse2 = _interopRequireDefault(_helpersParse);
/**
* [Please add a description.]
*/
var context = {
messages: messages,
Transformer: _transformer2["default"],
Plugin: _plugin2["default"],
types: types,
parse: _helpersParse2["default"],
traverse: _traversal2["default"]
};
/**
* [Please add a description.]
*/
var PluginManager = (function () {
/**
* [Please add a description.]
*/
PluginManager.memoisePluginContainer = function memoisePluginContainer(fn) {
for (var i = 0; i < PluginManager.memoisedPlugins.length; i++) {
var plugin = PluginManager.memoisedPlugins[i];
if (plugin.container === fn) return plugin.transformer;
}
var transformer = fn(context);
PluginManager.memoisedPlugins.push({
container: fn,
transformer: transformer
});
return transformer;
};
/**
* [Please add a description.]
*/
_createClass(PluginManager, null, [{
key: "memoisedPlugins",
/**
* [Please add a description.]
*/
value: [],
enumerable: true
}, {
key: "positions",
value: ["before", "after"],
/**
* [Please add a description.]
*/
enumerable: true
}]);
function PluginManager() {
var _ref = arguments.length <= 0 || arguments[0] === undefined ? { transformers: {}, before: [], after: [] } : arguments[0];
var file = _ref.file;
var transformers = _ref.transformers;
var before = _ref.before;
var after = _ref.after;
_classCallCheck(this, PluginManager);
this.transformers = transformers;
this.file = file;
this.before = before;
this.after = after;
}
/**
* [Please add a description.]
*/
PluginManager.prototype.subnormaliseString = function subnormaliseString(name, position) {
// this is a plugin in the form of "foobar" or "foobar:after"
// where the optional colon is the delimiter for plugin position in the transformer stack
var match = name.match(/^(.*?):(after|before)$/);
if (match) {
;
name = match[1];
position = match[2];
}var loc = _tryResolve2["default"].relative("babel-plugin-" + name) || _tryResolve2["default"].relative(name);
if (loc) {
var plugin = _dereq_(loc);
return {
position: position,
plugin: plugin["default"] || plugin
};
} else {
throw new ReferenceError(messages.get("pluginUnknown", name));
}
};
/**
* [Please add a description.]
*/
PluginManager.prototype.validate = function validate(name, plugin) {
// validate transformer key
var key = plugin.key;
if (this.transformers[key]) {
throw new ReferenceError(messages.get("pluginKeyCollision", key));
}
// validate Transformer instance
if (!plugin.buildPass || plugin.constructor.name !== "Plugin") {
throw new TypeError(messages.get("pluginNotTransformer", name));
}
// register as a plugin
plugin.metadata.plugin = true;
};
/**
* [Please add a description.]
*/
PluginManager.prototype.add = function add(name) {
var position;
var plugin;
if (name) {
if (typeof name === "object" && name.transformer) {
plugin = name.transformer;
position = name.position;
} else if (typeof name !== "string") {
// not a string so we'll just assume that it's a direct Transformer instance, if not then
// the checks later on will complain
plugin = name;
}
if (typeof name === "string") {
var _subnormaliseString = this.subnormaliseString(name, position);
plugin = _subnormaliseString.plugin;
position = _subnormaliseString.position;
}
} else {
throw new TypeError(messages.get("pluginIllegalKind", typeof name, name));
}
// default position
position = position || "before";
// validate position
if (PluginManager.positions.indexOf(position) < 0) {
throw new TypeError(messages.get("pluginIllegalPosition", position, name));
}
// allow plugin containers to be specified so they don't have to manually require
if (typeof plugin === "function") {
plugin = PluginManager.memoisePluginContainer(plugin);
}
//
this.validate(name, plugin);
// build!
var pass = this.transformers[plugin.key] = plugin.buildPass(this.file);
if (pass.canTransform()) {
var stack = position === "before" ? this.before : this.after;
stack.push(pass);
}
};
return PluginManager;
})();
exports["default"] = PluginManager;
module.exports = exports["default"];
},{"148":148,"179":179,"42":42,"43":43,"602":602,"82":82,"83":83}],53:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _explodeAssignableExpression = _dereq_(58);
var _explodeAssignableExpression2 = _interopRequireDefault(_explodeAssignableExpression);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
exports["default"] = function (opts) {
var exports = {};
/**
* [Please add a description.]
*/
var isAssignment = function isAssignment(node) {
return node.operator === opts.operator + "=";
};
/**
* [Please add a description.]
*/
var buildAssignment = function buildAssignment(left, right) {
return t.assignmentExpression("=", left, right);
};
/**
* [Please add a description.]
*/
exports.ExpressionStatement = function (node, parent, scope, file) {
// hit the `AssignmentExpression` one below
if (this.isCompletionRecord()) return;
var expr = node.expression;
if (!isAssignment(expr)) return;
var nodes = [];
var exploded = _explodeAssignableExpression2["default"](expr.left, nodes, file, scope, true);
nodes.push(t.expressionStatement(buildAssignment(exploded.ref, opts.build(exploded.uid, expr.right))));
return nodes;
};
/**
* [Please add a description.]
*/
exports.AssignmentExpression = function (node, parent, scope, file) {
if (!isAssignment(node)) return;
var nodes = [];
var exploded = _explodeAssignableExpression2["default"](node.left, nodes, file, scope);
nodes.push(buildAssignment(exploded.ref, opts.build(exploded.uid, node.right)));
return nodes;
};
/**
* [Please add a description.]
*/
exports.BinaryExpression = function (node) {
if (node.operator !== opts.operator) return;
return opts.build(node.left, node.right);
};
return exports;
};
module.exports = exports["default"];
},{"179":179,"58":58}],54:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports["default"] = build;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
function build(node, buildBody) {
var self = node.blocks.shift();
if (!self) return;
var child = build(node, buildBody);
if (!child) {
// last item
child = buildBody();
// add a filter as this is our final stop
if (node.filter) {
child = t.ifStatement(node.filter, t.blockStatement([child]));
}
}
return t.forOfStatement(t.variableDeclaration("let", [t.variableDeclarator(self.left)]), self.right, t.blockStatement([child]));
}
module.exports = exports["default"];
},{"179":179}],55:[function(_dereq_,module,exports){
// Based upon the excellent jsx-transpiler by Ingvar Stepanyan (RReverser)
// https://github.com/RReverser/jsx-transpiler
// jsx
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _lodashLangIsString = _dereq_(506);
var _lodashLangIsString2 = _interopRequireDefault(_lodashLangIsString);
var _messages = _dereq_(43);
var messages = _interopRequireWildcard(_messages);
var _esutils = _dereq_(395);
var _esutils2 = _interopRequireDefault(_esutils);
var _react = _dereq_(62);
var react = _interopRequireWildcard(_react);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
exports["default"] = function (opts) {
var visitor = {};
/**
* [Please add a description.]
*/
visitor.JSXIdentifier = function (node) {
if (node.name === "this" && this.isReferenced()) {
return t.thisExpression();
} else if (_esutils2["default"].keyword.isIdentifierNameES6(node.name)) {
node.type = "Identifier";
} else {
return t.literal(node.name);
}
};
/**
* [Please add a description.]
*/
visitor.JSXNamespacedName = function () {
throw this.errorWithNode(messages.get("JSXNamespacedTags"));
};
/**
* [Please add a description.]
*/
visitor.JSXMemberExpression = {
exit: function exit(node) {
node.computed = t.isLiteral(node.property);
node.type = "MemberExpression";
}
};
/**
* [Please add a description.]
*/
visitor.JSXExpressionContainer = function (node) {
return node.expression;
};
/**
* [Please add a description.]
*/
visitor.JSXAttribute = {
enter: function enter(node) {
var value = node.value;
if (t.isLiteral(value) && _lodashLangIsString2["default"](value.value)) {
value.value = value.value.replace(/\n\s+/g, " ");
}
},
exit: function exit(node) {
var value = node.value || t.literal(true);
return t.inherits(t.property("init", node.name, value), node);
}
};
/**
* [Please add a description.]
*/
visitor.JSXOpeningElement = {
exit: function exit(node, parent, scope, file) {
parent.children = react.buildChildren(parent);
var tagExpr = node.name;
var args = [];
var tagName;
if (t.isIdentifier(tagExpr)) {
tagName = tagExpr.name;
} else if (t.isLiteral(tagExpr)) {
tagName = tagExpr.value;
}
var state = {
tagExpr: tagExpr,
tagName: tagName,
args: args
};
if (opts.pre) {
opts.pre(state, file);
}
var attribs = node.attributes;
if (attribs.length) {
attribs = buildJSXOpeningElementAttributes(attribs, file);
} else {
attribs = t.literal(null);
}
args.push(attribs);
if (opts.post) {
opts.post(state, file);
}
return state.call || t.callExpression(state.callee, args);
}
};
/**
* The logic for this is quite terse. It's because we need to
* support spread elements. We loop over all attributes,
* breaking on spreads, we then push a new object containg
* all prior attributes to an array for later processing.
*/
var buildJSXOpeningElementAttributes = function buildJSXOpeningElementAttributes(attribs, file) {
var _props = [];
var objs = [];
var pushProps = function pushProps() {
if (!_props.length) return;
objs.push(t.objectExpression(_props));
_props = [];
};
while (attribs.length) {
var prop = attribs.shift();
if (t.isJSXSpreadAttribute(prop)) {
pushProps();
objs.push(prop.argument);
} else {
_props.push(prop);
}
}
pushProps();
if (objs.length === 1) {
// only one object
attribs = objs[0];
} else {
// looks like we have multiple objects
if (!t.isObjectExpression(objs[0])) {
objs.unshift(t.objectExpression([]));
}
// spread it
attribs = t.callExpression(file.addHelper("extends"), objs);
}
return attribs;
};
/**
* [Please add a description.]
*/
visitor.JSXElement = {
exit: function exit(node) {
var callExpr = node.openingElement;
callExpr.arguments = callExpr.arguments.concat(node.children);
if (callExpr.arguments.length >= 3) {
callExpr._prettyCall = true;
}
return t.inherits(callExpr, node);
}
};
return visitor;
};
module.exports = exports["default"];
},{"179":179,"395":395,"43":43,"506":506,"62":62}],56:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
enter: function enter(node, parent, scope, state) {
if (this.isThisExpression() || this.isReferencedIdentifier({ name: "arguments" })) {
state.found = true;
this.stop();
}
},
/**
* [Please add a description.]
*/
Function: function Function() {
this.skip();
}
};
/**
* [Please add a description.]
*/
exports["default"] = function (node, scope) {
var container = t.functionExpression(null, [], node.body, node.generator, node.async);
var callee = container;
var args = [];
var state = { found: false };
scope.traverse(node, visitor, state);
if (state.found) {
callee = t.memberExpression(container, t.identifier("apply"));
args = [t.thisExpression(), t.identifier("arguments")];
}
var call = t.callExpression(callee, args);
if (node.generator) call = t.yieldExpression(call, true);
return t.returnStatement(call);
};
module.exports = exports["default"];
},{"179":179}],57:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports.push = push;
exports.hasComputed = hasComputed;
exports.toComputedObjectFromClass = toComputedObjectFromClass;
exports.toClassObject = toClassObject;
exports.toDefineObject = toDefineObject;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _lodashCollectionEach = _dereq_(411);
var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
var _lodashObjectHas = _dereq_(512);
var _lodashObjectHas2 = _interopRequireDefault(_lodashObjectHas);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
function push(mutatorMap, node, kind, file) {
var alias = t.toKeyAlias(node);
//
var map = {};
if (_lodashObjectHas2["default"](mutatorMap, alias)) map = mutatorMap[alias];
mutatorMap[alias] = map;
//
map._inherits = map._inherits || [];
map._inherits.push(node);
map._key = node.key;
if (node.computed) {
map._computed = true;
}
if (node.decorators) {
var decorators = map.decorators = map.decorators || t.arrayExpression([]);
decorators.elements = decorators.elements.concat(node.decorators.map(function (dec) {
return dec.expression;
}).reverse());
}
if (map.value || map.initializer) {
throw file.errorWithNode(node, "Key conflict with sibling node");
}
if (node.value) {
if (node.kind === "init") kind = "value";
if (node.kind === "get") kind = "get";
if (node.kind === "set") kind = "set";
t.inheritsComments(node.value, node);
map[kind] = node.value;
}
return map;
}
/**
* [Please add a description.]
*/
function hasComputed(mutatorMap) {
for (var key in mutatorMap) {
if (mutatorMap[key]._computed) {
return true;
}
}
return false;
}
/**
* [Please add a description.]
*/
function toComputedObjectFromClass(obj) {
var objExpr = t.arrayExpression([]);
for (var i = 0; i < obj.properties.length; i++) {
var prop = obj.properties[i];
var val = prop.value;
val.properties.unshift(t.property("init", t.identifier("key"), t.toComputedKey(prop)));
objExpr.elements.push(val);
}
return objExpr;
}
/**
* [Please add a description.]
*/
function toClassObject(mutatorMap) {
var objExpr = t.objectExpression([]);
_lodashCollectionEach2["default"](mutatorMap, function (map) {
var mapNode = t.objectExpression([]);
var propNode = t.property("init", map._key, mapNode, map._computed);
_lodashCollectionEach2["default"](map, function (node, key) {
if (key[0] === "_") return;
var inheritNode = node;
if (t.isMethodDefinition(node) || t.isClassProperty(node)) node = node.value;
var prop = t.property("init", t.identifier(key), node);
t.inheritsComments(prop, inheritNode);
t.removeComments(inheritNode);
mapNode.properties.push(prop);
});
objExpr.properties.push(propNode);
});
return objExpr;
}
/**
* [Please add a description.]
*/
function toDefineObject(mutatorMap) {
_lodashCollectionEach2["default"](mutatorMap, function (map) {
if (map.value) map.writable = t.literal(true);
map.configurable = t.literal(true);
map.enumerable = t.literal(true);
});
return toClassObject(mutatorMap);
}
},{"179":179,"411":411,"512":512}],58:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
var getObjRef = function getObjRef(node, nodes, file, scope) {
var ref;
if (t.isIdentifier(node)) {
if (scope.hasBinding(node.name)) {
// this variable is declared in scope so we can be 100% sure
// that evaluating it multiple times wont trigger a getter
// or something else
return node;
} else {
// could possibly trigger a getter so we need to only evaluate
// it once
ref = node;
}
} else if (t.isMemberExpression(node)) {
ref = node.object;
if (t.isIdentifier(ref) && scope.hasGlobal(ref.name)) {
// the object reference that we need to save is locally declared
// so as per the previous comment we can be 100% sure evaluating
// it multiple times will be safe
return ref;
}
} else {
throw new Error("We can't explode this node type " + node.type);
}
var temp = scope.generateUidIdentifierBasedOnNode(ref);
nodes.push(t.variableDeclaration("var", [t.variableDeclarator(temp, ref)]));
return temp;
};
/**
* [Please add a description.]
*/
var getPropRef = function getPropRef(node, nodes, file, scope) {
var prop = node.property;
var key = t.toComputedKey(node, prop);
if (t.isLiteral(key)) return key;
var temp = scope.generateUidIdentifierBasedOnNode(prop);
nodes.push(t.variableDeclaration("var", [t.variableDeclarator(temp, prop)]));
return temp;
};
/**
* [Please add a description.]
*/
exports["default"] = function (node, nodes, file, scope, allowedSingleIdent) {
var obj;
if (t.isIdentifier(node) && allowedSingleIdent) {
obj = node;
} else {
obj = getObjRef(node, nodes, file, scope);
}
var ref, uid;
if (t.isIdentifier(node)) {
ref = node;
uid = obj;
} else {
var prop = getPropRef(node, nodes, file, scope);
var computed = node.computed || t.isLiteral(prop);
uid = ref = t.memberExpression(obj, prop, computed);
}
return {
uid: uid,
ref: ref
};
};
module.exports = exports["default"];
},{"179":179}],59:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
exports["default"] = function (node) {
var lastNonDefault = 0;
for (var i = 0; i < node.params.length; i++) {
var param = node.params[i];
if (!t.isAssignmentPattern(param) && !t.isRestElement(param)) {
lastNonDefault = i + 1;
}
}
return lastNonDefault;
};
module.exports = exports["default"];
},{"179":179}],60:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
exports["default"] = function (decorators, scope) {
for (var i = 0; i < decorators.length; i++) {
var decorator = decorators[i];
var expression = decorator.expression;
if (!t.isMemberExpression(expression)) continue;
var temp = scope.maybeGenerateMemoised(expression.object);
var ref;
var nodes = [];
if (temp) {
ref = temp;
nodes.push(t.assignmentExpression("=", temp, expression.object));
} else {
ref = expression.object;
}
nodes.push(t.callExpression(t.memberExpression(t.memberExpression(ref, expression.property, expression.computed), t.identifier("bind")), [ref]));
if (nodes.length === 1) {
decorator.expression = nodes[0];
} else {
decorator.expression = t.sequenceExpression(nodes);
}
}
return decorators;
};
module.exports = exports["default"];
},{"179":179}],61:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports.custom = custom;
exports.property = property;
exports.bare = bare;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _getFunctionArity = _dereq_(59);
var _getFunctionArity2 = _interopRequireDefault(_getFunctionArity);
var _util = _dereq_(182);
var util = _interopRequireWildcard(_util);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
function visitIdentifier(context, node, scope, state) {
// check if this node matches our function id
if (node.name !== state.name) return;
// check that we don't have a local variable declared as that removes the need
// for the wrapper
var localDeclar = scope.getBindingIdentifier(state.name);
if (localDeclar !== state.outerDeclar) return;
state.selfReference = true;
context.stop();
}
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
ReferencedIdentifier: function ReferencedIdentifier(node, parent, scope, state) {
visitIdentifier(this, node, scope, state);
},
/**
* [Please add a description.]
*/
BindingIdentifier: function BindingIdentifier(node, parent, scope, state) {
visitIdentifier(this, node, scope, state);
}
};
/**
* [Please add a description.]
*/
var wrap = function wrap(state, method, id, scope) {
if (state.selfReference) {
if (scope.hasBinding(id.name) && !scope.hasGlobal(id.name)) {
// we can just munge the local binding
scope.rename(id.name);
} else {
// need to add a wrapper since we can't change the references
var templateName = "property-method-assignment-wrapper";
if (method.generator) templateName += "-generator";
var template = util.template(templateName, {
FUNCTION: method,
FUNCTION_ID: id,
FUNCTION_KEY: scope.generateUidIdentifier(id.name)
});
template.callee._skipModulesRemap = true;
// shim in dummy params to retain function arity, if you try to read the
// source then you'll get the original since it's proxied so it's all good
var params = template.callee.body.body[0].params;
for (var i = 0, len = _getFunctionArity2["default"](method); i < len; i++) {
params.push(scope.generateUidIdentifier("x"));
}
return template;
}
}
method.id = id;
scope.getProgramParent().references[id.name] = true;
};
/**
* [Please add a description.]
*/
var visit = function visit(node, name, scope) {
var state = {
selfAssignment: false,
selfReference: false,
outerDeclar: scope.getBindingIdentifier(name),
references: [],
name: name
};
// check to see if we have a local binding of the id we're setting inside of
// the function, this is important as there are caveats associated
var binding = scope.getOwnBinding(name);
if (binding) {
if (binding.kind === "param") {
// safari will blow up in strict mode with code like:
//
// var t = function t(t) {};
//
// with the error:
//
// Cannot declare a parameter named 't' as it shadows the name of a
// strict mode function.
//
// this isn't to the spec and they've invented this behaviour which is
// **extremely** annoying so we avoid setting the name if it has a param
// with the same id
state.selfReference = true;
} else {
// otherwise it's defined somewhere in scope like:
//
// var t = function () {
// var t = 2;
// };
//
// so we can safely just set the id and move along as it shadows the
// bound function id
}
} else if (state.outerDeclar || scope.hasGlobal(name)) {
scope.traverse(node, visitor, state);
}
return state;
};
/**
* [Please add a description.]
*/
function custom(node, id, scope) {
var state = visit(node, id.name, scope);
return wrap(state, node, id, scope);
}
/**
* [Please add a description.]
*/
function property(node, file, scope) {
var key = t.toComputedKey(node, node.key);
if (!t.isLiteral(key)) return; // we can't set a function id with this
var name = t.toBindingIdentifierName(key.value);
var id = t.identifier(name);
var method = node.value;
var state = visit(method, name, scope);
node.value = wrap(state, method, id, scope) || method;
}
/**
* [Please add a description.]
*/
function bare(node, parent, scope) {
// has an `id` so we don't need to infer one
if (node.id) return;
var id;
if (t.isProperty(parent) && parent.kind === "init" && (!parent.computed || t.isLiteral(parent.key))) {
// { foo() {} };
id = parent.key;
} else if (t.isVariableDeclarator(parent)) {
// var foo = function () {};
id = parent.id;
if (t.isIdentifier(id)) {
var binding = scope.parent.getBinding(id.name);
if (binding && binding.constant && scope.getBinding(id.name) === binding) {
// always going to reference this method
node.id = id;
return;
}
}
} else {
return;
}
var name;
if (t.isLiteral(id)) {
name = id.value;
} else if (t.isIdentifier(id)) {
name = id.name;
} else {
return;
}
name = t.toBindingIdentifierName(name);
id = t.identifier(name);
var state = visit(node, name, scope);
return wrap(state, node, id, scope);
}
},{"179":179,"182":182,"59":59}],62:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports.isCompatTag = isCompatTag;
exports.buildChildren = buildChildren;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
var isReactComponent = t.buildMatchMemberExpression("React.Component");
exports.isReactComponent = isReactComponent;
/**
* [Please add a description.]
*/
function isCompatTag(tagName) {
return tagName && /^[a-z]|\-/.test(tagName);
}
/**
* [Please add a description.]
*/
function cleanJSXElementLiteralChild(child, args) {
var lines = child.value.split(/\r\n|\n|\r/);
var lastNonEmptyLine = 0;
for (var i = 0; i < lines.length; i++) {
if (lines[i].match(/[^ \t]/)) {
lastNonEmptyLine = i;
}
}
var str = "";
for (var i = 0; i < lines.length; i++) {
var line = lines[i];
var isFirstLine = i === 0;
var isLastLine = i === lines.length - 1;
var isLastNonEmptyLine = i === lastNonEmptyLine;
// replace rendered whitespace tabs with spaces
var trimmedLine = line.replace(/\t/g, " ");
// trim whitespace touching a newline
if (!isFirstLine) {
trimmedLine = trimmedLine.replace(/^[ ]+/, "");
}
// trim whitespace touching an endline
if (!isLastLine) {
trimmedLine = trimmedLine.replace(/[ ]+$/, "");
}
if (trimmedLine) {
if (!isLastNonEmptyLine) {
trimmedLine += " ";
}
str += trimmedLine;
}
}
if (str) args.push(t.literal(str));
}
/**
* [Please add a description.]
*/
function buildChildren(node) {
var elems = [];
for (var i = 0; i < node.children.length; i++) {
var child = node.children[i];
if (t.isLiteral(child) && typeof child.value === "string") {
cleanJSXElementLiteralChild(child, elems);
continue;
}
if (t.isJSXExpressionContainer(child)) child = child.expression;
if (t.isJSXEmptyExpression(child)) continue;
elems.push(child);
}
return elems;
}
},{"179":179}],63:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports.is = is;
exports.pullFlag = pullFlag;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _lodashArrayPull = _dereq_(408);
var _lodashArrayPull2 = _interopRequireDefault(_lodashArrayPull);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
function is(node, flag) {
return t.isLiteral(node) && node.regex && node.regex.flags.indexOf(flag) >= 0;
}
/**
* [Please add a description.]
*/
function pullFlag(node, flag) {
var flags = node.regex.flags.split("");
if (node.regex.flags.indexOf(flag) < 0) return;
_lodashArrayPull2["default"](flags, flag);
node.regex.flags = flags.join("");
}
},{"179":179,"408":408}],64:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
var awaitVisitor = {
/**
* [Please add a description.]
*/
Function: function Function() {
this.skip();
},
/**
* [Please add a description.]
*/
AwaitExpression: function AwaitExpression(node) {
node.type = "YieldExpression";
if (node.all) {
// await* foo; -> yield Promise.all(foo);
node.all = false;
node.argument = t.callExpression(t.memberExpression(t.identifier("Promise"), t.identifier("all")), [node.argument]);
}
}
};
/**
* [Please add a description.]
*/
var referenceVisitor = {
/**
* [Please add a description.]
*/
ReferencedIdentifier: function ReferencedIdentifier(node, parent, scope, state) {
var name = state.id.name;
if (node.name === name && scope.bindingIdentifierEquals(name, state.id)) {
return state.ref = state.ref || scope.generateUidIdentifier(name);
}
}
};
/**
* [Please add a description.]
*/
exports["default"] = function (path, callId) {
var node = path.node;
node.async = false;
node.generator = true;
path.traverse(awaitVisitor, state);
var call = t.callExpression(callId, [node]);
var id = node.id;
node.id = null;
if (t.isFunctionDeclaration(node)) {
var declar = t.variableDeclaration("let", [t.variableDeclarator(id, call)]);
declar._blockHoist = true;
return declar;
} else {
if (id) {
var state = { id: id };
path.traverse(referenceVisitor, state);
if (state.ref) {
path.scope.parent.push({ id: state.ref });
return t.assignmentExpression("=", state.ref, call);
}
}
return call;
}
};
module.exports = exports["default"];
},{"179":179}],65:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _messages = _dereq_(43);
var messages = _interopRequireWildcard(_messages);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
function isIllegalBareSuper(node, parent) {
if (!t.isSuper(node)) return false;
if (t.isMemberExpression(parent, { computed: false })) return false;
if (t.isCallExpression(parent, { callee: node })) return false;
return true;
}
/**
* [Please add a description.]
*/
function isMemberExpressionSuper(node) {
return t.isMemberExpression(node) && t.isSuper(node.object);
}
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
enter: function enter(node, parent, scope, state) {
var topLevel = state.topLevel;
var self = state.self;
if (t.isFunction(node) && !t.isArrowFunctionExpression(node)) {
// we need to call traverseLevel again so we're context aware
self.traverseLevel(this, false);
return this.skip();
}
if (t.isProperty(node, { method: true }) || t.isMethodDefinition(node)) {
// break on object methods
return this.skip();
}
var getThisReference = topLevel ?
// top level so `this` is the instance
t.thisExpression :
// not in the top level so we need to create a reference
self.getThisReference.bind(self);
var callback = self.specHandle;
if (self.isLoose) callback = self.looseHandle;
var result = callback.call(self, this, getThisReference);
if (result) this.hasSuper = true;
if (result === true) return;
return result;
}
};
/**
* [Please add a description.]
*/
var ReplaceSupers = (function () {
function ReplaceSupers(opts) {
var inClass = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1];
_classCallCheck(this, ReplaceSupers);
this.topLevelThisReference = opts.topLevelThisReference;
this.methodPath = opts.methodPath;
this.methodNode = opts.methodNode;
this.superRef = opts.superRef;
this.isStatic = opts.isStatic;
this.hasSuper = false;
this.inClass = inClass;
this.isLoose = opts.isLoose;
this.scope = opts.scope;
this.file = opts.file;
this.opts = opts;
}
/**
* [Please add a description.]
*/
ReplaceSupers.prototype.getObjectRef = function getObjectRef() {
return this.opts.objectRef || this.opts.getObjectRef();
};
/**
* Sets a super class value of the named property.
*
* @example
*
* _set(Object.getPrototypeOf(CLASS.prototype), "METHOD", "VALUE", this)
*
*/
ReplaceSupers.prototype.setSuperProperty = function setSuperProperty(property, value, isComputed, thisExpression) {
return t.callExpression(this.file.addHelper("set"), [t.callExpression(t.memberExpression(t.identifier("Object"), t.identifier("getPrototypeOf")), [this.isStatic ? this.getObjectRef() : t.memberExpression(this.getObjectRef(), t.identifier("prototype"))]), isComputed ? property : t.literal(property.name), value, thisExpression]);
};
/**
* Gets a node representing the super class value of the named property.
*
* @example
*
* _get(Object.getPrototypeOf(CLASS.prototype), "METHOD", this)
*
*/
ReplaceSupers.prototype.getSuperProperty = function getSuperProperty(property, isComputed, thisExpression) {
return t.callExpression(this.file.addHelper("get"), [t.callExpression(t.memberExpression(t.identifier("Object"), t.identifier("getPrototypeOf")), [this.isStatic ? this.getObjectRef() : t.memberExpression(this.getObjectRef(), t.identifier("prototype"))]), isComputed ? property : t.literal(property.name), thisExpression]);
};
/**
* [Please add a description.]
*/
ReplaceSupers.prototype.replace = function replace() {
this.traverseLevel(this.methodPath.get("value"), true);
};
/**
* [Please add a description.]
*/
ReplaceSupers.prototype.traverseLevel = function traverseLevel(path, topLevel) {
var state = { self: this, topLevel: topLevel };
path.traverse(visitor, state);
};
/**
* [Please add a description.]
*/
ReplaceSupers.prototype.getThisReference = function getThisReference() {
if (this.topLevelThisReference) {
return this.topLevelThisReference;
} else {
var ref = this.topLevelThisReference = this.scope.generateUidIdentifier("this");
this.methodNode.value.body.body.unshift(t.variableDeclaration("var", [t.variableDeclarator(this.topLevelThisReference, t.thisExpression())]));
return ref;
}
};
/**
* [Please add a description.]
*/
ReplaceSupers.prototype.getLooseSuperProperty = function getLooseSuperProperty(id, parent) {
var methodNode = this.methodNode;
var methodName = methodNode.key;
var superRef = this.superRef || t.identifier("Function");
if (parent.property === id) {
return;
} else if (t.isCallExpression(parent, { callee: id })) {
// super(); -> objectRef.prototype.MethodName.call(this);
parent.arguments.unshift(t.thisExpression());
if (methodName.name === "constructor") {
// constructor() { super(); }
if (parent.arguments.length === 2 && t.isSpreadElement(parent.arguments[1]) && t.isIdentifier(parent.arguments[1].argument, { name: "arguments" })) {
// special case single arguments spread
parent.arguments[1] = parent.arguments[1].argument;
return t.memberExpression(superRef, t.identifier("apply"));
} else {
return t.memberExpression(superRef, t.identifier("call"));
}
} else {
id = superRef;
// foo() { super(); }
if (!methodNode["static"]) {
id = t.memberExpression(id, t.identifier("prototype"));
}
id = t.memberExpression(id, methodName, methodNode.computed);
return t.memberExpression(id, t.identifier("call"));
}
} else if (t.isMemberExpression(parent) && !methodNode["static"]) {
// super.test -> objectRef.prototype.test
return t.memberExpression(superRef, t.identifier("prototype"));
} else {
return superRef;
}
};
/**
* [Please add a description.]
*/
ReplaceSupers.prototype.looseHandle = function looseHandle(path, getThisReference) {
var node = path.node;
if (path.isSuper()) {
return this.getLooseSuperProperty(node, path.parent);
} else if (path.isCallExpression()) {
var callee = node.callee;
if (!t.isMemberExpression(callee)) return;
if (!t.isSuper(callee.object)) return;
// super.test(); -> objectRef.prototype.MethodName.call(this);
t.appendToMemberExpression(callee, t.identifier("call"));
node.arguments.unshift(getThisReference());
return true;
}
};
/**
* [Please add a description.]
*/
ReplaceSupers.prototype.specHandleAssignmentExpression = function specHandleAssignmentExpression(ref, path, node, getThisReference) {
if (node.operator === "=") {
// super.name = "val"; -> _set(Object.getPrototypeOf(objectRef.prototype), "name", this);
return this.setSuperProperty(node.left.property, node.right, node.left.computed, getThisReference());
} else {
// super.age += 2; -> var _ref = super.age; super.age = _ref + 2;
ref = ref || path.scope.generateUidIdentifier("ref");
return [t.variableDeclaration("var", [t.variableDeclarator(ref, node.left)]), t.expressionStatement(t.assignmentExpression("=", node.left, t.binaryExpression(node.operator[0], ref, node.right)))];
}
};
/**
* [Please add a description.]
*/
ReplaceSupers.prototype.specHandle = function specHandle(path, getThisReference) {
var methodNode = this.methodNode;
var property;
var computed;
var args;
var thisReference;
var parent = path.parent;
var node = path.node;
if (isIllegalBareSuper(node, parent)) {
throw path.errorWithNode(messages.get("classesIllegalBareSuper"));
}
if (t.isCallExpression(node)) {
var callee = node.callee;
if (t.isSuper(callee)) {
// super(); -> _get(Object.getPrototypeOf(objectRef), "MethodName", this).call(this);
property = methodNode.key;
computed = methodNode.computed;
args = node.arguments;
// bare `super` call is illegal inside non-constructors
// - https://esdiscuss.org/topic/super-call-in-methods
// - https://twitter.com/wycats/status/544553184396836864
if (methodNode.key.name !== "constructor" || !this.inClass) {
var methodName = methodNode.key.name || "METHOD_NAME";
throw this.file.errorWithNode(node, messages.get("classesIllegalSuperCall", methodName));
}
} else if (isMemberExpressionSuper(callee)) {
// super.test(); -> _get(Object.getPrototypeOf(objectRef.prototype), "test", this).call(this);
property = callee.property;
computed = callee.computed;
args = node.arguments;
}
} else if (t.isMemberExpression(node) && t.isSuper(node.object)) {
// super.name; -> _get(Object.getPrototypeOf(objectRef.prototype), "name", this);
property = node.property;
computed = node.computed;
} else if (t.isUpdateExpression(node) && isMemberExpressionSuper(node.argument)) {
var binary = t.binaryExpression(node.operator[0], node.argument, t.literal(1));
if (node.prefix) {
// ++super.foo; -> super.foo += 1;
return this.specHandleAssignmentExpression(null, path, binary, getThisReference);
} else {
// super.foo++; -> var _ref = super.foo; super.foo = _ref + 1;
var ref = path.scope.generateUidIdentifier("ref");
return this.specHandleAssignmentExpression(ref, path, binary, getThisReference).concat(t.expressionStatement(ref));
}
} else if (t.isAssignmentExpression(node) && isMemberExpressionSuper(node.left)) {
return this.specHandleAssignmentExpression(null, path, node, getThisReference);
}
if (!property) return;
thisReference = getThisReference();
var superProperty = this.getSuperProperty(property, computed, thisReference);
if (args) {
if (args.length === 1 && t.isSpreadElement(args[0])) {
// super(...arguments);
return t.callExpression(t.memberExpression(superProperty, t.identifier("apply")), [thisReference, args[0].argument]);
} else {
return t.callExpression(t.memberExpression(superProperty, t.identifier("call")), [thisReference].concat(args));
}
} else {
return superProperty;
}
};
return ReplaceSupers;
})();
exports["default"] = ReplaceSupers;
module.exports = exports["default"];
},{"179":179,"43":43}],66:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _pipeline = _dereq_(80);
var _pipeline2 = _interopRequireDefault(_pipeline);
/**
* [Please add a description.]
*/
/**
* [Please add a description.]
*/
var _transformers = _dereq_(126);
var _transformers2 = _interopRequireDefault(_transformers);
/**
* [Please add a description.]
*/
var _transformersDeprecated = _dereq_(85);
var _transformersDeprecated2 = _interopRequireDefault(_transformersDeprecated);
/**
* [Please add a description.]
*/
var _transformersAliases = _dereq_(84);
var _transformersAliases2 = _interopRequireDefault(_transformersAliases);
/**
* [Please add a description.]
*/
var _transformersFilters = _dereq_(125);
var filters = _interopRequireWildcard(_transformersFilters);
var pipeline = new _pipeline2["default"]();
for (var key in _transformers2["default"]) {
var transformer = _transformers2["default"][key];
if (typeof transformer === "object") {
var metadata = transformer.metadata = transformer.metadata || {};
metadata.group = metadata.group || "builtin-basic";
}
}
pipeline.addTransformers(_transformers2["default"]);
pipeline.addDeprecated(_transformersDeprecated2["default"]);
pipeline.addAliases(_transformersAliases2["default"]);
pipeline.addFilter(filters.internal);
pipeline.addFilter(filters.blacklist);
pipeline.addFilter(filters.whitelist);
pipeline.addFilter(filters.stage);
pipeline.addFilter(filters.optional);
/**
* [Please add a description.]
*/
var transform = pipeline.transform.bind(pipeline);
transform.fromAst = pipeline.transformFromAst.bind(pipeline);
transform.pipeline = pipeline;
exports["default"] = transform;
module.exports = exports["default"];
},{"125":125,"126":126,"80":80,"84":84,"85":85}],67:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _libMetadata = _dereq_(75);
var metadataVisitor = _interopRequireWildcard(_libMetadata);
var _messages = _dereq_(43);
var messages = _interopRequireWildcard(_messages);
var _libRemaps = _dereq_(76);
var _libRemaps2 = _interopRequireDefault(_libRemaps);
var _helpersObject = _dereq_(41);
var _helpersObject2 = _interopRequireDefault(_helpersObject);
var _util = _dereq_(182);
var util = _interopRequireWildcard(_util);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
var DefaultFormatter = (function () {
function DefaultFormatter(file) {
_classCallCheck(this, DefaultFormatter);
// object containg all module sources with the scope that they're contained in
this.sourceScopes = _helpersObject2["default"]();
// ids for use in module ids
this.defaultIds = _helpersObject2["default"]();
this.ids = _helpersObject2["default"]();
// contains reference aliases for live bindings
this.remaps = new _libRemaps2["default"](file, this);
this.scope = file.scope;
this.file = file;
this.hasNonDefaultExports = false;
this.hasLocalExports = false;
this.hasLocalImports = false;
this.localExports = _helpersObject2["default"]();
this.localImports = _helpersObject2["default"]();
this.metadata = file.metadata.modules;
this.getMetadata();
}
/**
* [Please add a description.]
*/
DefaultFormatter.prototype.addScope = function addScope(path) {
var source = path.node.source && path.node.source.value;
if (!source) return;
var existingScope = this.sourceScopes[source];
if (existingScope && existingScope !== path.scope) {
throw path.errorWithNode(messages.get("modulesDuplicateDeclarations"));
}
this.sourceScopes[source] = path.scope;
};
/**
* [Please add a description.]
*/
DefaultFormatter.prototype.isModuleType = function isModuleType(node, type) {
var modules = this.file.dynamicImportTypes[type];
return modules && modules.indexOf(node) >= 0;
};
/**
* [Please add a description.]
*/
DefaultFormatter.prototype.transform = function transform() {
this.remapAssignments();
};
/**
* [Please add a description.]
*/
DefaultFormatter.prototype.doDefaultExportInterop = function doDefaultExportInterop(node) {
return (t.isExportDefaultDeclaration(node) || t.isSpecifierDefault(node)) && !this.noInteropRequireExport && !this.hasNonDefaultExports;
};
/**
* [Please add a description.]
*/
DefaultFormatter.prototype.getMetadata = function getMetadata() {
var has = false;
var _arr = this.file.ast.program.body;
for (var _i = 0; _i < _arr.length; _i++) {
var node = _arr[_i];
if (t.isModuleDeclaration(node)) {
has = true;
break;
}
}
if (has || this.isLoose()) {
this.file.path.traverse(metadataVisitor, this);
}
};
/**
* [Please add a description.]
*/
DefaultFormatter.prototype.remapAssignments = function remapAssignments() {
if (this.hasLocalExports || this.hasLocalImports) {
this.remaps.run();
}
};
/**
* [Please add a description.]
*/
DefaultFormatter.prototype.remapExportAssignment = function remapExportAssignment(node, exported) {
var assign = node;
for (var i = 0; i < exported.length; i++) {
assign = t.assignmentExpression("=", t.memberExpression(t.identifier("exports"), exported[i]), assign);
}
return assign;
};
/**
* [Please add a description.]
*/
DefaultFormatter.prototype._addExport = function _addExport(name, exported) {
var info = this.localExports[name] = this.localExports[name] || {
binding: this.scope.getBindingIdentifier(name),
exported: []
};
info.exported.push(exported);
};
/**
* [Please add a description.]
*/
DefaultFormatter.prototype.getExport = function getExport(node, scope) {
if (!t.isIdentifier(node)) return;
var local = this.localExports[node.name];
if (local && local.binding === scope.getBindingIdentifier(node.name)) {
return local.exported;
}
};
/**
* [Please add a description.]
*/
DefaultFormatter.prototype.getModuleName = function getModuleName() {
var opts = this.file.opts;
// moduleId is n/a if a `getModuleId()` is provided
if (opts.moduleId != null && !opts.getModuleId) {
return opts.moduleId;
}
var filenameRelative = opts.filenameRelative;
var moduleName = "";
if (opts.moduleRoot != null) {
moduleName = opts.moduleRoot + "/";
}
if (!opts.filenameRelative) {
return moduleName + opts.filename.replace(/^\//, "");
}
if (opts.sourceRoot != null) {
// remove sourceRoot from filename
var sourceRootRegEx = new RegExp("^" + opts.sourceRoot + "\/?");
filenameRelative = filenameRelative.replace(sourceRootRegEx, "");
}
if (!opts.keepModuleIdExtensions) {
// remove extension
filenameRelative = filenameRelative.replace(/\.(\w*?)$/, "");
}
moduleName += filenameRelative;
// normalize path separators
moduleName = moduleName.replace(/\\/g, "/");
if (opts.getModuleId) {
// If return is falsy, assume they want us to use our generated default name
return opts.getModuleId(moduleName) || moduleName;
} else {
return moduleName;
}
};
/**
* [Please add a description.]
*/
DefaultFormatter.prototype._pushStatement = function _pushStatement(ref, nodes) {
if (t.isClass(ref) || t.isFunction(ref)) {
if (ref.id) {
nodes.push(t.toStatement(ref));
ref = ref.id;
}
}
return ref;
};
/**
* [Please add a description.]
*/
DefaultFormatter.prototype._hoistExport = function _hoistExport(declar, assign, priority) {
if (t.isFunctionDeclaration(declar)) {
assign._blockHoist = priority || 2;
}
return assign;
};
/**
* [Please add a description.]
*/
DefaultFormatter.prototype.getExternalReference = function getExternalReference(node, nodes) {
var ids = this.ids;
var id = node.source.value;
if (ids[id]) {
return ids[id];
} else {
return this.ids[id] = this._getExternalReference(node, nodes);
}
};
/**
* [Please add a description.]
*/
DefaultFormatter.prototype.checkExportIdentifier = function checkExportIdentifier(node) {
if (t.isIdentifier(node, { name: "__esModule" })) {
throw this.file.errorWithNode(node, messages.get("modulesIllegalExportName", node.name));
}
};
/**
* [Please add a description.]
*/
DefaultFormatter.prototype.exportAllDeclaration = function exportAllDeclaration(node, nodes) {
var ref = this.getExternalReference(node, nodes);
nodes.push(this.buildExportsWildcard(ref, node));
};
/**
* [Please add a description.]
*/
DefaultFormatter.prototype.isLoose = function isLoose() {
return this.file.isLoose("es6.modules");
};
/**
* [Please add a description.]
*/
DefaultFormatter.prototype.exportSpecifier = function exportSpecifier(specifier, node, nodes) {
if (node.source) {
var ref = this.getExternalReference(node, nodes);
if (specifier.local.name === "default" && !this.noInteropRequireExport) {
// importing a default so we need to normalize it
ref = t.callExpression(this.file.addHelper("interop-require"), [ref]);
} else {
ref = t.memberExpression(ref, specifier.local);
if (!this.isLoose()) {
nodes.push(this.buildExportsFromAssignment(specifier.exported, ref, node));
return;
}
}
// export { foo } from "test";
nodes.push(this.buildExportsAssignment(specifier.exported, ref, node));
} else {
// export { foo };
nodes.push(this.buildExportsAssignment(specifier.exported, specifier.local, node));
}
};
/**
* [Please add a description.]
*/
DefaultFormatter.prototype.buildExportsWildcard = function buildExportsWildcard(objectIdentifier) {
return t.expressionStatement(t.callExpression(this.file.addHelper("defaults"), [t.identifier("exports"), t.callExpression(this.file.addHelper("interop-export-wildcard"), [objectIdentifier, this.file.addHelper("defaults")])]));
};
/**
* [Please add a description.]
*/
DefaultFormatter.prototype.buildExportsFromAssignment = function buildExportsFromAssignment(id, init) {
this.checkExportIdentifier(id);
return util.template("exports-from-assign", {
INIT: init,
ID: t.literal(id.name)
}, true);
};
/**
* [Please add a description.]
*/
DefaultFormatter.prototype.buildExportsAssignment = function buildExportsAssignment(id, init) {
this.checkExportIdentifier(id);
return util.template("exports-assign", {
VALUE: init,
KEY: id
}, true);
};
/**
* [Please add a description.]
*/
DefaultFormatter.prototype.exportDeclaration = function exportDeclaration(node, nodes) {
var declar = node.declaration;
var id = declar.id;
if (t.isExportDefaultDeclaration(node)) {
id = t.identifier("default");
}
var assign;
if (t.isVariableDeclaration(declar)) {
for (var i = 0; i < declar.declarations.length; i++) {
var decl = declar.declarations[i];
decl.init = this.buildExportsAssignment(decl.id, decl.init, node).expression;
var newDeclar = t.variableDeclaration(declar.kind, [decl]);
if (i === 0) t.inherits(newDeclar, declar);
nodes.push(newDeclar);
}
} else {
var ref = declar;
if (t.isFunctionDeclaration(declar) || t.isClassDeclaration(declar)) {
ref = declar.id;
nodes.push(declar);
}
assign = this.buildExportsAssignment(id, ref, node);
nodes.push(assign);
this._hoistExport(declar, assign);
}
};
return DefaultFormatter;
})();
exports["default"] = DefaultFormatter;
module.exports = exports["default"];
},{"179":179,"182":182,"41":41,"43":43,"75":75,"76":76}],68:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _util = _dereq_(182);
var util = _interopRequireWildcard(_util);
/**
* [Please add a description.]
*/
exports["default"] = function (Parent) {
var Constructor = function Constructor() {
this.noInteropRequireImport = true;
this.noInteropRequireExport = true;
Parent.apply(this, arguments);
};
util.inherits(Constructor, Parent);
return Constructor;
};
module.exports = exports["default"];
},{"182":182}],69:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _amd = _dereq_(70);
var _amd2 = _interopRequireDefault(_amd);
var _strict = _dereq_(68);
var _strict2 = _interopRequireDefault(_strict);
/**
* [Please add a description.]
*/
exports["default"] = _strict2["default"](_amd2["default"]);
module.exports = exports["default"];
},{"68":68,"70":70}],70:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// istanbul ignore next
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
// istanbul ignore next
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var _default = _dereq_(67);
var _default2 = _interopRequireDefault(_default);
var _common = _dereq_(72);
var _common2 = _interopRequireDefault(_common);
var _lodashCollectionIncludes = _dereq_(413);
var _lodashCollectionIncludes2 = _interopRequireDefault(_lodashCollectionIncludes);
var _lodashObjectValues = _dereq_(517);
var _lodashObjectValues2 = _interopRequireDefault(_lodashObjectValues);
var _util = _dereq_(182);
var util = _interopRequireWildcard(_util);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
var AMDFormatter = (function (_DefaultFormatter) {
_inherits(AMDFormatter, _DefaultFormatter);
function AMDFormatter() {
_classCallCheck(this, AMDFormatter);
_DefaultFormatter.apply(this, arguments);
}
/**
* [Please add a description.]
*/
AMDFormatter.prototype.setup = function setup() {
_common2["default"].prototype._setup.call(this, this.hasNonDefaultExports);
};
/**
* [Please add a description.]
*/
AMDFormatter.prototype.buildDependencyLiterals = function buildDependencyLiterals() {
var names = [];
for (var name in this.ids) {
names.push(t.literal(name));
}
return names;
};
/**
* Wrap the entire body in a `define` wrapper.
*/
AMDFormatter.prototype.transform = function transform(program) {
_common2["default"].prototype.transform.apply(this, arguments);
var body = program.body;
// build an array of module names
var names = [t.literal("exports")];
if (this.passModuleArg) names.push(t.literal("module"));
names = names.concat(this.buildDependencyLiterals());
names = t.arrayExpression(names);
// build up define container
var params = _lodashObjectValues2["default"](this.ids);
if (this.passModuleArg) params.unshift(t.identifier("module"));
params.unshift(t.identifier("exports"));
var container = t.functionExpression(null, params, t.blockStatement(body));
var defineArgs = [names, container];
var moduleName = this.getModuleName();
if (moduleName) defineArgs.unshift(t.literal(moduleName));
var call = t.callExpression(t.identifier("define"), defineArgs);
program.body = [t.expressionStatement(call)];
};
/**
* Get the AMD module name that we'll prepend to the wrapper
* to define this module
*/
AMDFormatter.prototype.getModuleName = function getModuleName() {
if (this.file.opts.moduleIds) {
return _default2["default"].prototype.getModuleName.apply(this, arguments);
} else {
return null;
}
};
/**
* [Please add a description.]
*/
AMDFormatter.prototype._getExternalReference = function _getExternalReference(node) {
return this.scope.generateUidIdentifier(node.source.value);
};
/**
* [Please add a description.]
*/
AMDFormatter.prototype.importDeclaration = function importDeclaration(node) {
this.getExternalReference(node);
};
/**
* [Please add a description.]
*/
AMDFormatter.prototype.importSpecifier = function importSpecifier(specifier, node, nodes, scope) {
var key = node.source.value;
var ref = this.getExternalReference(node);
if (t.isImportNamespaceSpecifier(specifier) || t.isImportDefaultSpecifier(specifier)) {
this.defaultIds[key] = specifier.local;
}
if (this.isModuleType(node, "absolute")) {
// absolute module reference
} else if (this.isModuleType(node, "absoluteDefault")) {
// prevent unnecessary renaming of dynamic imports
this.ids[node.source.value] = ref;
ref = t.memberExpression(ref, t.identifier("default"));
} else if (t.isImportNamespaceSpecifier(specifier)) {
// import * as bar from "foo";
} else if (!_lodashCollectionIncludes2["default"](this.file.dynamicImported, node) && t.isSpecifierDefault(specifier) && !this.noInteropRequireImport) {
// import foo from "foo";
var uid = scope.generateUidIdentifier(specifier.local.name);
nodes.push(t.variableDeclaration("var", [t.variableDeclarator(uid, t.callExpression(this.file.addHelper("interop-require-default"), [ref]))]));
ref = t.memberExpression(uid, t.identifier("default"));
} else {
// import { foo } from "foo";
var imported = specifier.imported;
if (t.isSpecifierDefault(specifier)) imported = t.identifier("default");
ref = t.memberExpression(ref, imported);
}
this.remaps.add(scope, specifier.local.name, ref);
};
/**
* [Please add a description.]
*/
AMDFormatter.prototype.exportSpecifier = function exportSpecifier(specifier, node, nodes) {
if (this.doDefaultExportInterop(specifier)) {
this.passModuleArg = true;
if (specifier.exported !== specifier.local && !node.source) {
nodes.push(util.template("exports-default-assign", {
VALUE: specifier.local
}, true));
return;
}
}
_common2["default"].prototype.exportSpecifier.apply(this, arguments);
};
/**
* [Please add a description.]
*/
AMDFormatter.prototype.exportDeclaration = function exportDeclaration(node, nodes) {
if (this.doDefaultExportInterop(node)) {
this.passModuleArg = true;
var declar = node.declaration;
var assign = util.template("exports-default-assign", {
VALUE: this._pushStatement(declar, nodes)
}, true);
if (t.isFunctionDeclaration(declar)) {
// we can hoist this assignment to the top of the file
assign._blockHoist = 3;
}
nodes.push(assign);
return;
}
_default2["default"].prototype.exportDeclaration.apply(this, arguments);
};
return AMDFormatter;
})(_default2["default"]);
exports["default"] = AMDFormatter;
module.exports = exports["default"];
},{"179":179,"182":182,"413":413,"517":517,"67":67,"72":72}],71:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _common = _dereq_(72);
var _common2 = _interopRequireDefault(_common);
var _strict = _dereq_(68);
var _strict2 = _interopRequireDefault(_strict);
/**
* [Please add a description.]
*/
exports["default"] = _strict2["default"](_common2["default"]);
module.exports = exports["default"];
},{"68":68,"72":72}],72:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// istanbul ignore next
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
// istanbul ignore next
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var _default = _dereq_(67);
var _default2 = _interopRequireDefault(_default);
var _util = _dereq_(182);
var util = _interopRequireWildcard(_util);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
var CommonJSFormatter = (function (_DefaultFormatter) {
_inherits(CommonJSFormatter, _DefaultFormatter);
function CommonJSFormatter() {
_classCallCheck(this, CommonJSFormatter);
_DefaultFormatter.apply(this, arguments);
}
/**
* [Please add a description.]
*/
CommonJSFormatter.prototype.setup = function setup() {
this._setup(this.hasLocalExports);
};
/**
* [Please add a description.]
*/
CommonJSFormatter.prototype._setup = function _setup(conditional) {
var file = this.file;
var scope = file.scope;
scope.rename("module");
scope.rename("exports");
if (!this.noInteropRequireImport && conditional) {
var templateName = "exports-module-declaration";
if (this.file.isLoose("es6.modules")) templateName += "-loose";
var declar = util.template(templateName, true);
declar._blockHoist = 3;
file.path.unshiftContainer("body", [declar]);
}
};
/**
* [Please add a description.]
*/
CommonJSFormatter.prototype.transform = function transform(program) {
_default2["default"].prototype.transform.apply(this, arguments);
if (this.hasDefaultOnlyExport) {
program.body.push(t.expressionStatement(t.assignmentExpression("=", t.memberExpression(t.identifier("module"), t.identifier("exports")), t.memberExpression(t.identifier("exports"), t.identifier("default")))));
}
};
/**
* [Please add a description.]
*/
CommonJSFormatter.prototype.importSpecifier = function importSpecifier(specifier, node, nodes, scope) {
var variableName = specifier.local;
var ref = this.getExternalReference(node, nodes);
// import foo from "foo";
if (t.isSpecifierDefault(specifier)) {
if (this.isModuleType(node, "absolute")) {
// absolute module reference
} else if (this.isModuleType(node, "absoluteDefault")) {
this.remaps.add(scope, variableName.name, ref);
} else if (this.noInteropRequireImport) {
this.remaps.add(scope, variableName.name, t.memberExpression(ref, t.identifier("default")));
} else {
var uid = this.scope.generateUidIdentifierBasedOnNode(node, "import");
nodes.push(t.variableDeclaration("var", [t.variableDeclarator(uid, t.callExpression(this.file.addHelper("interop-require-default"), [ref]))]));
this.remaps.add(scope, variableName.name, t.memberExpression(uid, t.identifier("default")));
}
} else {
if (t.isImportNamespaceSpecifier(specifier)) {
if (!this.noInteropRequireImport) {
ref = t.callExpression(this.file.addHelper("interop-require-wildcard"), [ref]);
}
// import * as bar from "foo";
nodes.push(t.variableDeclaration("var", [t.variableDeclarator(variableName, ref)]));
} else {
// import { foo } from "foo";
this.remaps.add(scope, variableName.name, t.memberExpression(ref, t.identifier(specifier.imported.name)));
}
}
};
/**
* [Please add a description.]
*/
CommonJSFormatter.prototype.importDeclaration = function importDeclaration(node, nodes) {
// import "foo";
nodes.push(util.template("require", {
MODULE_NAME: node.source
}, true));
};
/**
* [Please add a description.]
*/
CommonJSFormatter.prototype.exportSpecifier = function exportSpecifier(specifier) {
if (this.doDefaultExportInterop(specifier)) {
this.hasDefaultOnlyExport = true;
}
_default2["default"].prototype.exportSpecifier.apply(this, arguments);
};
/**
* [Please add a description.]
*/
CommonJSFormatter.prototype.exportDeclaration = function exportDeclaration(node) {
if (this.doDefaultExportInterop(node)) {
this.hasDefaultOnlyExport = true;
}
_default2["default"].prototype.exportDeclaration.apply(this, arguments);
};
/**
* [Please add a description.]
*/
CommonJSFormatter.prototype._getExternalReference = function _getExternalReference(node, nodes) {
var call = t.callExpression(t.identifier("require"), [node.source]);
var uid;
if (this.isModuleType(node, "absolute")) {
// absolute module reference
} else if (this.isModuleType(node, "absoluteDefault")) {
call = t.memberExpression(call, t.identifier("default"));
} else {
uid = this.scope.generateUidIdentifierBasedOnNode(node, "import");
}
uid = uid || node.specifiers[0].local;
var declar = t.variableDeclaration("var", [t.variableDeclarator(uid, call)]);
nodes.push(declar);
return uid;
};
return CommonJSFormatter;
})(_default2["default"]);
exports["default"] = CommonJSFormatter;
module.exports = exports["default"];
},{"179":179,"182":182,"67":67}],73:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// istanbul ignore next
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
// istanbul ignore next
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var _default = _dereq_(67);
var _default2 = _interopRequireDefault(_default);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
var IgnoreFormatter = (function (_DefaultFormatter) {
_inherits(IgnoreFormatter, _DefaultFormatter);
function IgnoreFormatter() {
_classCallCheck(this, IgnoreFormatter);
_DefaultFormatter.apply(this, arguments);
}
/**
* [Please add a description.]
*/
IgnoreFormatter.prototype.exportDeclaration = function exportDeclaration(node, nodes) {
var declar = t.toStatement(node.declaration, true);
if (declar) nodes.push(t.inherits(declar, node));
};
/**
* [Please add a description.]
*/
IgnoreFormatter.prototype.exportAllDeclaration = function exportAllDeclaration() {};
IgnoreFormatter.prototype.importDeclaration = function importDeclaration() {};
IgnoreFormatter.prototype.importSpecifier = function importSpecifier() {};
IgnoreFormatter.prototype.exportSpecifier = function exportSpecifier() {};
IgnoreFormatter.prototype.transform = function transform() {};
return IgnoreFormatter;
})(_default2["default"]);
exports["default"] = IgnoreFormatter;
module.exports = exports["default"];
},{"179":179,"67":67}],74:[function(_dereq_,module,exports){
/**
* [Please add a description.]
*/
"use strict";
exports.__esModule = true;
exports["default"] = {
commonStrict: _dereq_(71),
amdStrict: _dereq_(69),
umdStrict: _dereq_(78),
common: _dereq_(72),
system: _dereq_(77),
ignore: _dereq_(73),
amd: _dereq_(70),
umd: _dereq_(79)
};
module.exports = exports["default"];
},{"69":69,"70":70,"71":71,"72":72,"73":73,"77":77,"78":78,"79":79}],75:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports.ExportDeclaration = ExportDeclaration;
exports.Scope = Scope;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _lodashObjectExtend = _dereq_(511);
var _lodashObjectExtend2 = _interopRequireDefault(_lodashObjectExtend);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
var ModuleDeclaration = {
enter: function enter(node, parent, scope, formatter) {
if (node.source) {
node.source.value = formatter.file.resolveModuleSource(node.source.value);
formatter.addScope(this);
}
}
};
exports.ModuleDeclaration = ModuleDeclaration;
/**
* [Please add a description.]
*/
var ImportDeclaration = {
exit: function exit(node, parent, scope, formatter) {
formatter.hasLocalImports = true;
var specifiers = [];
var imported = [];
formatter.metadata.imports.push({
source: node.source.value,
imported: imported,
specifiers: specifiers
});
var _arr = this.get("specifiers");
for (var _i = 0; _i < _arr.length; _i++) {
var specifier = _arr[_i];
var ids = specifier.getBindingIdentifiers();
_lodashObjectExtend2["default"](formatter.localImports, ids);
var local = specifier.node.local.name;
if (specifier.isImportDefaultSpecifier()) {
imported.push("default");
specifiers.push({
kind: "named",
imported: "default",
local: local
});
}
if (specifier.isImportSpecifier()) {
var importedName = specifier.node.imported.name;
imported.push(importedName);
specifiers.push({
kind: "named",
imported: importedName,
local: local
});
}
if (specifier.isImportNamespaceSpecifier()) {
imported.push("*");
specifiers.push({
kind: "namespace",
local: local
});
}
}
}
};
exports.ImportDeclaration = ImportDeclaration;
/**
* [Please add a description.]
*/
function ExportDeclaration(node, parent, scope, formatter) {
formatter.hasLocalExports = true;
var source = node.source ? node.source.value : null;
var exports = formatter.metadata.exports;
// export function foo() {}
// export var foo = "bar";
var declar = this.get("declaration");
if (declar.isStatement()) {
var bindings = declar.getBindingIdentifiers();
for (var name in bindings) {
var binding = bindings[name];
formatter._addExport(name, binding);
exports.exported.push(name);
exports.specifiers.push({
kind: "local",
local: name,
exported: this.isExportDefaultDeclaration() ? "default" : name
});
}
}
if (this.isExportNamedDeclaration() && node.specifiers) {
var _arr2 = node.specifiers;
for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
var specifier = _arr2[_i2];
var exported = specifier.exported.name;
exports.exported.push(exported);
// export foo from "bar";
if (t.isExportDefaultSpecifier(specifier)) {
exports.specifiers.push({
kind: "external",
local: exported,
exported: exported,
source: source
});
}
// export * as foo from "bar";
if (t.isExportNamespaceSpecifier(specifier)) {
exports.specifiers.push({
kind: "external-namespace",
exported: exported,
source: source
});
}
var local = specifier.local;
if (!local) continue;
formatter._addExport(local.name, specifier.exported);
// export { foo } from "bar";
// export { foo as bar } from "bar";
if (source) {
exports.specifiers.push({
kind: "external",
local: local.name,
exported: exported,
source: source
});
}
// export { foo };
// export { foo as bar };
if (!source) {
exports.specifiers.push({
kind: "local",
local: local.name,
exported: exported
});
}
}
}
// export * from "bar";
if (this.isExportAllDeclaration()) {
exports.specifiers.push({
kind: "external-all",
source: source
});
}
if (!t.isExportDefaultDeclaration(node) && !declar.isTypeAlias()) {
var onlyDefault = node.specifiers && node.specifiers.length === 1 && t.isSpecifierDefault(node.specifiers[0]);
if (!onlyDefault) {
formatter.hasNonDefaultExports = true;
}
}
}
/**
* [Please add a description.]
*/
function Scope(node, parent, scope, formatter) {
if (!formatter.isLoose()) {
this.skip();
}
}
},{"179":179,"511":511}],76:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
var remapVisitor = {
/**
* [Please add a description.]
*/
enter: function enter(node) {
if (node._skipModulesRemap) {
return this.skip();
}
},
/**
* [Please add a description.]
*/
ReferencedIdentifier: function ReferencedIdentifier(node, parent, scope, remaps) {
var formatter = remaps.formatter;
var remap = remaps.get(scope, node.name);
if (!remap || node === remap) return;
if (!scope.hasBinding(node.name) || scope.bindingIdentifierEquals(node.name, formatter.localImports[node.name])) {
if (!formatter.isLoose() && this.key === "callee" && this.parentPath.isCallExpression()) {
return t.sequenceExpression([t.literal(0), remap]);
} else {
return remap;
}
}
},
/**
* [Please add a description.]
*/
AssignmentExpression: {
exit: function exit(node, parent, scope, _ref) {
var formatter = _ref.formatter;
if (!node._ignoreModulesRemap) {
var exported = formatter.getExport(node.left, scope);
if (exported) {
return formatter.remapExportAssignment(node, exported);
}
}
}
},
/**
* [Please add a description.]
*/
UpdateExpression: function UpdateExpression(node, parent, scope, _ref2) {
var formatter = _ref2.formatter;
var exported = formatter.getExport(node.argument, scope);
if (!exported) return;
this.skip();
// expand to long file assignment expression
var assign = t.assignmentExpression(node.operator[0] + "=", node.argument, t.literal(1));
// remap this assignment expression
var remapped = formatter.remapExportAssignment(assign, exported);
// we don't need to change the result
if (t.isExpressionStatement(parent) || node.prefix) {
return remapped;
}
var nodes = [];
nodes.push(remapped);
var operator;
if (node.operator === "--") {
operator = "+";
} else {
// "++"
operator = "-";
}
nodes.push(t.binaryExpression(operator, node.argument, t.literal(1)));
return t.sequenceExpression(nodes);
}
};
/**
* [Please add a description.]
*/
var Remaps = (function () {
function Remaps(file, formatter) {
_classCallCheck(this, Remaps);
this.formatter = formatter;
this.file = file;
}
/**
* [Please add a description.]
*/
Remaps.prototype.run = function run() {
this.file.path.traverse(remapVisitor, this);
};
/**
* [Please add a description.]
*/
Remaps.prototype._getKey = function _getKey(name) {
return name + ":moduleRemap";
};
/**
* [Please add a description.]
*/
Remaps.prototype.get = function get(scope, name) {
return scope.getData(this._getKey(name));
};
/**
* [Please add a description.]
*/
Remaps.prototype.add = function add(scope, name, val) {
if (this.all) {
this.all.push({
name: name,
scope: scope,
node: val
});
}
return scope.setData(this._getKey(name), val);
};
/**
* [Please add a description.]
*/
Remaps.prototype.remove = function remove(scope, name) {
return scope.removeData(this._getKey(name));
};
/**
* These methods are used by the system module formatter who needs access to all the remaps
* so it can process them into it's specific setter method. We don't do this by default since
* no other module formatters need access to this.
*/
Remaps.prototype.getAll = function getAll() {
return this.all;
};
/**
* [Please add a description.]
*/
Remaps.prototype.clearAll = function clearAll() {
if (this.all) {
var _arr = this.all;
for (var _i = 0; _i < _arr.length; _i++) {
var remap = _arr[_i];
remap.scope.removeData(this._getKey(remap.name));
}
}
this.all = [];
};
return Remaps;
})();
exports["default"] = Remaps;
module.exports = exports["default"];
},{"179":179}],77:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// istanbul ignore next
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
// istanbul ignore next
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var _default = _dereq_(67);
var _default2 = _interopRequireDefault(_default);
var _amd = _dereq_(70);
var _amd2 = _interopRequireDefault(_amd);
var _util = _dereq_(182);
var util = _interopRequireWildcard(_util);
var _lodashArrayLast = _dereq_(407);
var _lodashArrayLast2 = _interopRequireDefault(_lodashArrayLast);
var _lodashCollectionMap = _dereq_(414);
var _lodashCollectionMap2 = _interopRequireDefault(_lodashCollectionMap);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
var hoistVariablesVisitor = {
/**
* [Please add a description.]
*/
Function: function Function() {
// nothing inside is accessible
this.skip();
},
/**
* [Please add a description.]
*/
VariableDeclaration: function VariableDeclaration(node, parent, scope, state) {
if (node.kind !== "var" && !t.isProgram(parent)) {
// let, const
// can't be accessed
return;
}
// ignore block hoisted nodes as these can be left in
if (state.formatter._canHoist(node)) return;
var nodes = [];
for (var i = 0; i < node.declarations.length; i++) {
var declar = node.declarations[i];
state.hoistDeclarators.push(t.variableDeclarator(declar.id));
if (declar.init) {
// no initializer so we can just hoist it as-is
var assign = t.expressionStatement(t.assignmentExpression("=", declar.id, declar.init));
nodes.push(assign);
}
}
// for (var i in test)
if (t.isFor(parent) && parent.left === node) {
return node.declarations[0].id;
}
return nodes;
}
};
/**
* [Please add a description.]
*/
var hoistFunctionsVisitor = {
/**
* [Please add a description.]
*/
Function: function Function() {
this.skip();
},
/**
* [Please add a description.]
*/
enter: function enter(node, parent, scope, state) {
if (t.isFunctionDeclaration(node) || state.formatter._canHoist(node)) {
state.handlerBody.push(node);
this.dangerouslyRemove();
}
}
};
/**
* [Please add a description.]
*/
var runnerSettersVisitor = {
/**
* [Please add a description.]
*/
enter: function enter(node, parent, scope, state) {
if (node._importSource === state.source) {
if (t.isVariableDeclaration(node)) {
var _arr = node.declarations;
for (var _i = 0; _i < _arr.length; _i++) {
var declar = _arr[_i];
state.hoistDeclarators.push(t.variableDeclarator(declar.id));
state.nodes.push(t.expressionStatement(t.assignmentExpression("=", declar.id, declar.init)));
}
} else {
state.nodes.push(node);
}
this.dangerouslyRemove();
}
}
};
/**
* [Please add a description.]
*/
var SystemFormatter = (function (_AMDFormatter) {
_inherits(SystemFormatter, _AMDFormatter);
function SystemFormatter(file) {
_classCallCheck(this, SystemFormatter);
_AMDFormatter.call(this, file);
this._setters = null;
this.exportIdentifier = file.scope.generateUidIdentifier("export");
this.noInteropRequireExport = true;
this.noInteropRequireImport = true;
this.remaps.clearAll();
}
/**
* [Please add a description.]
*/
SystemFormatter.prototype._addImportSource = function _addImportSource(node, exportNode) {
if (node) node._importSource = exportNode.source && exportNode.source.value;
return node;
};
/**
* [Please add a description.]
*/
SystemFormatter.prototype.buildExportsWildcard = function buildExportsWildcard(objectIdentifier, node) {
var leftIdentifier = this.scope.generateUidIdentifier("key");
var valIdentifier = t.memberExpression(objectIdentifier, leftIdentifier, true);
var left = t.variableDeclaration("var", [t.variableDeclarator(leftIdentifier)]);
var right = objectIdentifier;
var block = t.blockStatement([t.ifStatement(t.binaryExpression("!==", leftIdentifier, t.literal("default")), t.expressionStatement(this._buildExportCall(leftIdentifier, valIdentifier)))]);
return this._addImportSource(t.forInStatement(left, right, block), node);
};
/**
* [Please add a description.]
*/
SystemFormatter.prototype.buildExportsAssignment = function buildExportsAssignment(id, init, node) {
var call = this._buildExportCall(t.literal(id.name), init, true);
return this._addImportSource(call, node);
};
/**
* [Please add a description.]
*/
SystemFormatter.prototype.buildExportsFromAssignment = function buildExportsFromAssignment() {
return this.buildExportsAssignment.apply(this, arguments);
};
/**
* [Please add a description.]
*/
SystemFormatter.prototype.remapExportAssignment = function remapExportAssignment(node, exported) {
var assign = node;
for (var i = 0; i < exported.length; i++) {
assign = this._buildExportCall(t.literal(exported[i].name), assign);
}
return assign;
};
/**
* [Please add a description.]
*/
SystemFormatter.prototype._buildExportCall = function _buildExportCall(id, init, isStatement) {
var call = t.callExpression(this.exportIdentifier, [id, init]);
if (isStatement) {
return t.expressionStatement(call);
} else {
return call;
}
};
/**
* [Please add a description.]
*/
SystemFormatter.prototype.importSpecifier = function importSpecifier(specifier, node, nodes) {
_amd2["default"].prototype.importSpecifier.apply(this, arguments);
var _arr2 = this.remaps.getAll();
for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
var remap = _arr2[_i2];
nodes.push(t.variableDeclaration("var", [t.variableDeclarator(t.identifier(remap.name), remap.node)]));
}
this.remaps.clearAll();
this._addImportSource(_lodashArrayLast2["default"](nodes), node);
};
/**
* [Please add a description.]
*/
SystemFormatter.prototype._buildRunnerSetters = function _buildRunnerSetters(block, hoistDeclarators) {
var scope = this.file.scope;
return t.arrayExpression(_lodashCollectionMap2["default"](this.ids, function (uid, source) {
var state = {
hoistDeclarators: hoistDeclarators,
source: source,
nodes: []
};
scope.traverse(block, runnerSettersVisitor, state);
return t.functionExpression(null, [uid], t.blockStatement(state.nodes));
}));
};
/**
* [Please add a description.]
*/
SystemFormatter.prototype._canHoist = function _canHoist(node) {
return node._blockHoist && !this.file.dynamicImports.length;
};
/**
* [Please add a description.]
*/
SystemFormatter.prototype.transform = function transform(program) {
_default2["default"].prototype.transform.apply(this, arguments);
var hoistDeclarators = [];
var moduleName = this.getModuleName();
var moduleNameLiteral = t.literal(moduleName);
var block = t.blockStatement(program.body);
var setterListNode = this._buildRunnerSetters(block, hoistDeclarators);
this._setters = setterListNode;
var runner = util.template("system", {
MODULE_DEPENDENCIES: t.arrayExpression(this.buildDependencyLiterals()),
EXPORT_IDENTIFIER: this.exportIdentifier,
MODULE_NAME: moduleNameLiteral,
SETTERS: setterListNode,
EXECUTE: t.functionExpression(null, [], block)
}, true);
var handlerBody = runner.expression.arguments[2].body.body;
if (!moduleName) runner.expression.arguments.shift();
var returnStatement = handlerBody.pop();
// hoist up all variable declarations
this.file.scope.traverse(block, hoistVariablesVisitor, {
formatter: this,
hoistDeclarators: hoistDeclarators
});
if (hoistDeclarators.length) {
var hoistDeclar = t.variableDeclaration("var", hoistDeclarators);
hoistDeclar._blockHoist = true;
handlerBody.unshift(hoistDeclar);
}
// hoist up function declarations for circular references
this.file.scope.traverse(block, hoistFunctionsVisitor, {
formatter: this,
handlerBody: handlerBody
});
handlerBody.push(returnStatement);
program.body = [runner];
};
return SystemFormatter;
})(_amd2["default"]);
exports["default"] = SystemFormatter;
module.exports = exports["default"];
},{"179":179,"182":182,"407":407,"414":414,"67":67,"70":70}],78:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _umd = _dereq_(79);
var _umd2 = _interopRequireDefault(_umd);
var _strict = _dereq_(68);
var _strict2 = _interopRequireDefault(_strict);
/**
* [Please add a description.]
*/
exports["default"] = _strict2["default"](_umd2["default"]);
module.exports = exports["default"];
},{"68":68,"79":79}],79:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// istanbul ignore next
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
// istanbul ignore next
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var _default = _dereq_(67);
var _default2 = _interopRequireDefault(_default);
var _amd = _dereq_(70);
var _amd2 = _interopRequireDefault(_amd);
var _lodashObjectValues = _dereq_(517);
var _lodashObjectValues2 = _interopRequireDefault(_lodashObjectValues);
var _path = _dereq_(9);
var _path2 = _interopRequireDefault(_path);
var _util = _dereq_(182);
var util = _interopRequireWildcard(_util);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
var UMDFormatter = (function (_AMDFormatter) {
_inherits(UMDFormatter, _AMDFormatter);
function UMDFormatter() {
_classCallCheck(this, UMDFormatter);
_AMDFormatter.apply(this, arguments);
}
/**
* [Please add a description.]
*/
UMDFormatter.prototype.transform = function transform(program) {
_default2["default"].prototype.transform.apply(this, arguments);
var body = program.body;
// build an array of module names
var names = [];
for (var _name in this.ids) {
names.push(t.literal(_name));
}
// factory
var ids = _lodashObjectValues2["default"](this.ids);
var args = [t.identifier("exports")];
if (this.passModuleArg) args.push(t.identifier("module"));
args = args.concat(ids);
var factory = t.functionExpression(null, args, t.blockStatement(body));
// amd
var defineArgs = [t.literal("exports")];
if (this.passModuleArg) defineArgs.push(t.literal("module"));
defineArgs = defineArgs.concat(names);
defineArgs = [t.arrayExpression(defineArgs)];
// common
var testExports = util.template("test-exports");
var testModule = util.template("test-module");
var commonTests = this.passModuleArg ? t.logicalExpression("&&", testExports, testModule) : testExports;
var commonArgs = [t.identifier("exports")];
if (this.passModuleArg) commonArgs.push(t.identifier("module"));
commonArgs = commonArgs.concat(names.map(function (name) {
return t.callExpression(t.identifier("require"), [name]);
}));
// globals
var browserArgs = [];
if (this.passModuleArg) browserArgs.push(t.identifier("mod"));
for (var _name2 in this.ids) {
var id = this.defaultIds[_name2] || t.identifier(t.toIdentifier(_path2["default"].basename(_name2, _path2["default"].extname(_name2))));
browserArgs.push(t.memberExpression(t.identifier("global"), id));
}
//
var moduleName = this.getModuleName();
if (moduleName) defineArgs.unshift(t.literal(moduleName));
//
var globalArg = this.file.opts.basename;
if (moduleName) globalArg = moduleName;
globalArg = t.identifier(t.toIdentifier(globalArg));
var runner = util.template("umd-runner-body", {
AMD_ARGUMENTS: defineArgs,
COMMON_TEST: commonTests,
COMMON_ARGUMENTS: commonArgs,
BROWSER_ARGUMENTS: browserArgs,
GLOBAL_ARG: globalArg
});
//
program.body = [t.expressionStatement(t.callExpression(runner, [t.thisExpression(), factory]))];
};
return UMDFormatter;
})(_amd2["default"]);
exports["default"] = UMDFormatter;
module.exports = exports["default"];
},{"179":179,"182":182,"517":517,"67":67,"70":70,"9":9}],80:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// istanbul ignore next
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _filePluginManager = _dereq_(52);
var _filePluginManager2 = _interopRequireDefault(_filePluginManager);
var _helpersNormalizeAst = _dereq_(40);
var _helpersNormalizeAst2 = _interopRequireDefault(_helpersNormalizeAst);
var _plugin = _dereq_(82);
var _plugin2 = _interopRequireDefault(_plugin);
var _lodashObjectAssign = _dereq_(509);
var _lodashObjectAssign2 = _interopRequireDefault(_lodashObjectAssign);
var _helpersObject = _dereq_(41);
var _helpersObject2 = _interopRequireDefault(_helpersObject);
var _file = _dereq_(46);
var _file2 = _interopRequireDefault(_file);
/**
* [Please add a description.]
*/
var Pipeline = (function () {
function Pipeline() {
_classCallCheck(this, Pipeline);
this.transformers = _helpersObject2["default"]();
this.namespaces = _helpersObject2["default"]();
this.deprecated = _helpersObject2["default"]();
this.aliases = _helpersObject2["default"]();
this.filters = [];
}
/**
* [Please add a description.]
*/
Pipeline.prototype.addTransformers = function addTransformers(transformers) {
for (var key in transformers) {
this.addTransformer(key, transformers[key]);
}
return this;
};
/**
* [Please add a description.]
*/
Pipeline.prototype.addTransformer = function addTransformer(key, plugin) {
if (this.transformers[key]) throw new Error(); // todo: error
var namespace = key.split(".")[0];
this.namespaces[namespace] = this.namespaces[namespace] || [];
this.namespaces[namespace].push(key);
this.namespaces[key] = namespace;
if (typeof plugin === "function") {
plugin = _filePluginManager2["default"].memoisePluginContainer(plugin);
plugin.key = key;
plugin.metadata.optional = true;
if (key === "react.displayName") {
plugin.metadata.optional = false;
}
} else {
plugin = new _plugin2["default"](key, plugin);
}
this.transformers[key] = plugin;
};
/**
* [Please add a description.]
*/
Pipeline.prototype.addAliases = function addAliases(names) {
_lodashObjectAssign2["default"](this.aliases, names);
return this;
};
/**
* [Please add a description.]
*/
Pipeline.prototype.addDeprecated = function addDeprecated(names) {
_lodashObjectAssign2["default"](this.deprecated, names);
return this;
};
/**
* [Please add a description.]
*/
Pipeline.prototype.addFilter = function addFilter(filter) {
this.filters.push(filter);
return this;
};
/**
* [Please add a description.]
*/
Pipeline.prototype.canTransform = function canTransform(plugin, fileOpts) {
if (plugin.metadata.plugin) {
return true;
}
var _arr = this.filters;
for (var _i = 0; _i < _arr.length; _i++) {
var filter = _arr[_i];
var result = filter(plugin, fileOpts);
if (result != null) return result;
}
return true;
};
/**
* [Please add a description.]
*/
Pipeline.prototype.analyze = function analyze(code) {
var opts = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
opts.code = false;
return this.transform(code, opts);
};
/**
* Build dependency graph by recursing `metadata.modules`. WIP.
*/
Pipeline.prototype.pretransform = function pretransform(code, opts) {
var file = new _file2["default"](opts, this);
return file.wrap(code, function () {
file.addCode(code);
file.parseCode(code);
return file;
});
};
/**
* [Please add a description.]
*/
Pipeline.prototype.transform = function transform(code, opts) {
var file = new _file2["default"](opts, this);
return file.wrap(code, function () {
file.addCode(code);
file.parseCode(code);
return file.transform();
});
};
/**
* [Please add a description.]
*/
Pipeline.prototype.transformFromAst = function transformFromAst(ast, code, opts) {
ast = _helpersNormalizeAst2["default"](ast);
var file = new _file2["default"](opts, this);
return file.wrap(code, function () {
file.addCode(code);
file.addAst(ast);
return file.transform();
});
};
/**
* [Please add a description.]
*/
Pipeline.prototype._ensureTransformerNames = function _ensureTransformerNames(type, rawKeys) {
var keys = [];
for (var i = 0; i < rawKeys.length; i++) {
var key = rawKeys[i];
var deprecatedKey = this.deprecated[key];
var aliasKey = this.aliases[key];
if (aliasKey) {
keys.push(aliasKey);
} else if (deprecatedKey) {
// deprecated key, remap it to the new one
console.error("[BABEL] The transformer " + key + " has been renamed to " + deprecatedKey);
rawKeys.push(deprecatedKey);
} else if (this.transformers[key]) {
// valid key
keys.push(key);
} else if (this.namespaces[key]) {
// namespace, append all transformers within this namespace
keys = keys.concat(this.namespaces[key]);
} else {
// invalid key
throw new ReferenceError("Unknown transformer " + key + " specified in " + type);
}
}
return keys;
};
return Pipeline;
})();
exports["default"] = Pipeline;
module.exports = exports["default"];
},{"40":40,"41":41,"46":46,"509":509,"52":52,"82":82}],81:[function(_dereq_,module,exports){
/**
* This class is responsible for traversing over the provided `File`s
* AST and running it's parent transformers handlers over it.
*/
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// istanbul ignore next
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _traversal = _dereq_(148);
var _traversal2 = _interopRequireDefault(_traversal);
var PluginPass = (function () {
function PluginPass(file, plugin) {
_classCallCheck(this, PluginPass);
this.plugin = plugin;
this.file = file;
this.key = plugin.key;
if (this.canTransform() && plugin.metadata.experimental && !file.opts.experimental) {
file.log.warn("THE TRANSFORMER " + this.key + " HAS BEEN MARKED AS EXPERIMENTAL AND IS WIP. USE AT YOUR OWN RISK. " + "THIS WILL HIGHLY LIKELY BREAK YOUR CODE SO USE WITH **EXTREME** CAUTION. ENABLE THE " + "`experimental` OPTION TO IGNORE THIS WARNING.");
}
}
/**
* [Please add a description.]
*/
PluginPass.prototype.canTransform = function canTransform() {
return this.file.transformerDependencies[this.key] || this.file.pipeline.canTransform(this.plugin, this.file.opts);
};
/**
* [Please add a description.]
*/
PluginPass.prototype.transform = function transform() {
var file = this.file;
file.log.debug("Start transformer " + this.key);
_traversal2["default"](file.ast, this.plugin.visitor, file.scope, file);
file.log.debug("Finish transformer " + this.key);
};
return PluginPass;
})();
exports["default"] = PluginPass;
module.exports = exports["default"];
},{"148":148}],82:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// istanbul ignore next
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _pluginPass = _dereq_(81);
var _pluginPass2 = _interopRequireDefault(_pluginPass);
var _messages = _dereq_(43);
var messages = _interopRequireWildcard(_messages);
var _traversal = _dereq_(148);
var _traversal2 = _interopRequireDefault(_traversal);
var _lodashObjectAssign = _dereq_(509);
var _lodashObjectAssign2 = _interopRequireDefault(_lodashObjectAssign);
var _lodashLangClone = _dereq_(494);
var _lodashLangClone2 = _interopRequireDefault(_lodashLangClone);
var _file = _dereq_(46);
var _file2 = _interopRequireDefault(_file);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
var VALID_PLUGIN_PROPERTIES = ["visitor", "metadata", "manipulateOptions", "post", "pre"];
var VALID_METADATA_PROPERTIES = ["dependencies", "optional", "stage", "group", "experimental", "secondPass"];
/**
* [Please add a description.]
*/
var Plugin = (function () {
function Plugin(key, plugin) {
_classCallCheck(this, Plugin);
Plugin.validate(key, plugin);
plugin = _lodashObjectAssign2["default"]({}, plugin);
var take = function take(key) {
var val = plugin[key];
delete plugin[key];
return val;
};
this.manipulateOptions = take("manipulateOptions");
this.metadata = take("metadata") || {};
this.dependencies = this.metadata.dependencies || [];
this.post = take("post");
this.pre = take("pre");
//
if (this.metadata.stage != null) {
this.metadata.optional = true;
}
//
this.visitor = this.normalize(_lodashLangClone2["default"](take("visitor")) || {});
this.key = key;
}
/**
* [Please add a description.]
*/
Plugin.validate = function validate(name, plugin) {
for (var key in plugin) {
if (key[0] === "_") continue;
if (VALID_PLUGIN_PROPERTIES.indexOf(key) >= 0) continue;
var msgType = "pluginInvalidProperty";
if (t.TYPES.indexOf(key) >= 0) msgType = "pluginInvalidPropertyVisitor";
throw new Error(messages.get(msgType, name, key));
}
for (var key in plugin.metadata) {
if (VALID_METADATA_PROPERTIES.indexOf(key) >= 0) continue;
throw new Error(messages.get("pluginInvalidProperty", name, "metadata." + key));
}
};
/**
* [Please add a description.]
*/
Plugin.prototype.normalize = function normalize(visitor) {
_traversal2["default"].explode(visitor);
return visitor;
};
/**
* [Please add a description.]
*/
Plugin.prototype.buildPass = function buildPass(file) {
// validate Transformer instance
if (!(file instanceof _file2["default"])) {
throw new TypeError(messages.get("pluginNotFile", this.key));
}
return new _pluginPass2["default"](file, this);
};
return Plugin;
})();
exports["default"] = Plugin;
module.exports = exports["default"];
},{"148":148,"179":179,"43":43,"46":46,"494":494,"509":509,"81":81}],83:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// istanbul ignore next
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _plugin = _dereq_(82);
var _plugin2 = _interopRequireDefault(_plugin);
/**
* [Please add a description.]
*/
var Transformer = function Transformer(key, obj) {
_classCallCheck(this, Transformer);
var plugin = {};
plugin.metadata = obj.metadata;
delete obj.metadata;
plugin.visitor = obj;
return new _plugin2["default"](key, plugin);
};
exports["default"] = Transformer;
module.exports = exports["default"];
},{"82":82}],84:[function(_dereq_,module,exports){
module.exports={
"useStrict": "strict",
"es5.runtime": "runtime",
"es6.runtime": "runtime",
"minification.inlineExpressions": "minification.constantFolding"
}
},{}],85:[function(_dereq_,module,exports){
module.exports={
"selfContained": "runtime",
"unicode-regex": "regex.unicode",
"spec.typeofSymbol": "es6.spec.symbols",
"es6.symbols": "es6.spec.symbols",
"es6.blockScopingTDZ": "es6.spec.blockScoping",
"utility.inlineExpressions": "minification.constantFolding",
"utility.deadCodeElimination": "minification.deadCodeElimination",
"utility.removeConsoleCalls": "minification.removeConsole",
"utility.removeDebugger": "minification.removeDebugger",
"es6.parameters.rest": "es6.parameters",
"es6.parameters.default": "es6.parameters"
}
},{}],86:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
var metadata = {
group: "builtin-trailing"
};
exports.metadata = metadata;
/**
* Turn member expression reserved word properties into literals.
*
* @example
*
* **In**
*
* ```javascript
* foo.catch;
* ```
*
* **Out**
*
* ```javascript
* foo["catch"];
* ```
*/
var visitor = {
/**
* Look for non-computed properties with names that are not valid identifiers.
* Turn them into computed properties with literal names.
*/
MemberExpression: {
exit: function exit(node) {
var prop = node.property;
if (!node.computed && t.isIdentifier(prop) && !t.isValidIdentifier(prop.name)) {
// foo.default -> foo["default"]
node.property = t.literal(prop.name);
node.computed = true;
}
}
}
};
exports.visitor = visitor;
},{"179":179}],87:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
var metadata = {
group: "builtin-trailing"
};
exports.metadata = metadata;
/**
* Turn reserved word properties into literals.
*
* **In**
*
* ```javascript
* var foo = {
* catch: function () {}
* };
* ```
*
* **Out**
*
* ```javascript
* var foo = {
* "catch": function () {}
* };
* ```
*/
var visitor = {
/**
* Look for non-computed keys with names that are not valid identifiers.
* Turn them into literals.
*/
Property: {
exit: function exit(node) {
var key = node.key;
if (!node.computed && t.isIdentifier(key) && !t.isValidIdentifier(key.name)) {
// default: "bar" -> "default": "bar"
node.key = t.literal(key.name);
}
}
}
};
exports.visitor = visitor;
},{"179":179}],88:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _helpersDefineMap = _dereq_(57);
var defineMap = _interopRequireWildcard(_helpersDefineMap);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* Turn [object initializer mutators](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer#Method_definitions)
* into `Object.defineProperties`.
*
* **In**
*
* ```javascript
* var foo = {
* get bar() {
* return "bar";
* }
* };
* ```
*
* **Out**
*
* ```javascript
* var foo = Object.defineProperties({}, {
* bar: {
* get: function () {
* return "bar";
* },
* enumerable: true,
* configurable: true
* }
* });
* ```
*/
var visitor = {
/**
* Look for getters and setters on an object.
* Filter them out and wrap the object with an `Object.defineProperties` that
* defines the getters and setters.
*/
ObjectExpression: function ObjectExpression(node, parent, scope, file) {
var hasAny = false;
var _arr = node.properties;
for (var _i = 0; _i < _arr.length; _i++) {
var prop = _arr[_i];
if (prop.kind === "get" || prop.kind === "set") {
hasAny = true;
break;
}
}
if (!hasAny) return;
var mutatorMap = {};
node.properties = node.properties.filter(function (prop) {
if (prop.kind === "get" || prop.kind === "set") {
defineMap.push(mutatorMap, prop, prop.kind, file);
return false;
} else {
return true;
}
});
return t.callExpression(t.memberExpression(t.identifier("Object"), t.identifier("defineProperties")), [node, defineMap.toDefineObject(mutatorMap)]);
}
};
exports.visitor = visitor;
},{"179":179,"57":57}],89:[function(_dereq_,module,exports){
/**
* Turn arrow functions into normal functions.
*
* @example
*
* **In**
*
* ```javascript
* arr.map(x => x * x);
* ```
*
* **Out**
*
* ```javascript
* arr.map(function (x) {
* return x * x;
* });
*/
"use strict";
exports.__esModule = true;
var visitor = {
/**
* Look for arrow functions and mark them as "shadow functions".
* @see /transformation/transformers/internal/shadow-functions.js
*/
ArrowFunctionExpression: function ArrowFunctionExpression(node) {
this.ensureBlock();
node.expression = false;
node.type = "FunctionExpression";
node.shadow = node.shadow || true;
}
};
exports.visitor = visitor;
},{}],90:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// istanbul ignore next
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _traversal = _dereq_(148);
var _traversal2 = _interopRequireDefault(_traversal);
var _helpersObject = _dereq_(41);
var _helpersObject2 = _interopRequireDefault(_helpersObject);
var _util = _dereq_(182);
var util = _interopRequireWildcard(_util);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
var _lodashObjectValues = _dereq_(517);
var _lodashObjectValues2 = _interopRequireDefault(_lodashObjectValues);
var _lodashObjectExtend = _dereq_(511);
var _lodashObjectExtend2 = _interopRequireDefault(_lodashObjectExtend);
/**
* [Please add a description.]
*/
function isLet(node, parent) {
if (!t.isVariableDeclaration(node)) return false;
if (node._let) return true;
if (node.kind !== "let") return false;
// https://github.com/babel/babel/issues/255
if (isLetInitable(node, parent)) {
for (var i = 0; i < node.declarations.length; i++) {
var declar = node.declarations[i];
declar.init = declar.init || t.identifier("undefined");
}
}
node._let = true;
node.kind = "var";
return true;
}
/**
* [Please add a description.]
*/
function isLetInitable(node, parent) {
return !t.isFor(parent) || !t.isFor(parent, { left: node });
}
/**
* [Please add a description.]
*/
function isVar(node, parent) {
return t.isVariableDeclaration(node, { kind: "var" }) && !isLet(node, parent);
}
/**
* [Please add a description.]
*/
function standardizeLets(declars) {
var _arr = declars;
for (var _i = 0; _i < _arr.length; _i++) {
var declar = _arr[_i];
delete declar._let;
}
}
var metadata = {
group: "builtin-advanced"
};
exports.metadata = metadata;
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
VariableDeclaration: function VariableDeclaration(node, parent, scope, file) {
if (!isLet(node, parent)) return;
if (isLetInitable(node) && file.transformers["es6.spec.blockScoping"].canTransform()) {
var nodes = [node];
for (var i = 0; i < node.declarations.length; i++) {
var decl = node.declarations[i];
if (decl.init) {
var assign = t.assignmentExpression("=", decl.id, decl.init);
assign._ignoreBlockScopingTDZ = true;
nodes.push(t.expressionStatement(assign));
}
decl.init = file.addHelper("temporal-undefined");
}
node._blockHoist = 2;
return nodes;
}
},
/**
* [Please add a description.]
*/
Loop: function Loop(node, parent, scope, file) {
var init = node.left || node.init;
if (isLet(init, node)) {
t.ensureBlock(node);
node.body._letDeclarators = [init];
}
var blockScoping = new BlockScoping(this, this.get("body"), parent, scope, file);
return blockScoping.run();
},
/**
* [Please add a description.]
*/
"BlockStatement|Program": function BlockStatementProgram(block, parent, scope, file) {
if (!t.isLoop(parent)) {
var blockScoping = new BlockScoping(null, this, parent, scope, file);
blockScoping.run();
}
}
};
exports.visitor = visitor;
/**
* [Please add a description.]
*/
function replace(node, parent, scope, remaps) {
var remap = remaps[node.name];
if (!remap) return;
var ownBinding = scope.getBindingIdentifier(node.name);
if (ownBinding === remap.binding) {
node.name = remap.uid;
} else {
// scope already has it's own binding that doesn't
// match the one we have a stored replacement for
if (this) this.skip();
}
}
/**
* [Please add a description.]
*/
var replaceVisitor = {
ReferencedIdentifier: replace,
/**
* [Please add a description.]
*/
AssignmentExpression: function AssignmentExpression(node, parent, scope, remaps) {
var ids = this.getBindingIdentifiers();
for (var name in ids) {
replace(ids[name], node, scope, remaps);
}
}
};
/**
* [Please add a description.]
*/
function traverseReplace(node, parent, scope, remaps) {
if (t.isIdentifier(node)) {
replace(node, parent, scope, remaps);
}
if (t.isAssignmentExpression(node)) {
var ids = t.getBindingIdentifiers(node);
for (var name in ids) {
replace(ids[name], parent, scope, remaps);
}
}
scope.traverse(node, replaceVisitor, remaps);
}
/**
* [Please add a description.]
*/
var letReferenceBlockVisitor = {
/**
* [Please add a description.]
*/
Function: function Function(node, parent, scope, state) {
this.traverse(letReferenceFunctionVisitor, state);
return this.skip();
}
};
/**
* [Please add a description.]
*/
var letReferenceFunctionVisitor = {
/**
* [Please add a description.]
*/
ReferencedIdentifier: function ReferencedIdentifier(node, parent, scope, state) {
var ref = state.letReferences[node.name];
// not a part of our scope
if (!ref) return;
// this scope has a variable with the same name so it couldn't belong
// to our let scope
var localBinding = scope.getBindingIdentifier(node.name);
if (localBinding && localBinding !== ref) return;
state.closurify = true;
}
};
/**
* [Please add a description.]
*/
var hoistVarDeclarationsVisitor = {
enter: function enter(node, parent, scope, self) {
if (this.isForStatement()) {
if (isVar(node.init, node)) {
var nodes = self.pushDeclar(node.init);
if (nodes.length === 1) {
node.init = nodes[0];
} else {
node.init = t.sequenceExpression(nodes);
}
}
} else if (this.isFor()) {
if (isVar(node.left, node)) {
self.pushDeclar(node.left);
node.left = node.left.declarations[0].id;
}
} else if (isVar(node, parent)) {
return self.pushDeclar(node).map(t.expressionStatement);
} else if (this.isFunction()) {
return this.skip();
}
}
};
/**
* [Please add a description.]
*/
var loopLabelVisitor = {
LabeledStatement: function LabeledStatement(node, parent, scope, state) {
state.innerLabels.push(node.label.name);
}
};
/**
* [Please add a description.]
*/
var continuationVisitor = {
enter: function enter(node, parent, scope, state) {
if (this.isAssignmentExpression() || this.isUpdateExpression()) {
var bindings = this.getBindingIdentifiers();
for (var name in bindings) {
if (state.outsideReferences[name] !== scope.getBindingIdentifier(name)) continue;
state.reassignments[name] = true;
}
}
}
};
/**
* [Please add a description.]
*/
var loopNodeTo = function loopNodeTo(node) {
if (t.isBreakStatement(node)) {
return "break";
} else if (t.isContinueStatement(node)) {
return "continue";
}
};
/**
* [Please add a description.]
*/
var loopVisitor = {
/**
* [Please add a description.]
*/
Loop: function Loop(node, parent, scope, state) {
var oldIgnoreLabeless = state.ignoreLabeless;
state.ignoreLabeless = true;
this.traverse(loopVisitor, state);
state.ignoreLabeless = oldIgnoreLabeless;
this.skip();
},
/**
* [Please add a description.]
*/
Function: function Function() {
this.skip();
},
/**
* [Please add a description.]
*/
SwitchCase: function SwitchCase(node, parent, scope, state) {
var oldInSwitchCase = state.inSwitchCase;
state.inSwitchCase = true;
this.traverse(loopVisitor, state);
state.inSwitchCase = oldInSwitchCase;
this.skip();
},
/**
* [Please add a description.]
*/
enter: function enter(node, parent, scope, state) {
var replace;
var loopText = loopNodeTo(node);
if (loopText) {
if (node.label) {
// we shouldn't be transforming this because it exists somewhere inside
if (state.innerLabels.indexOf(node.label.name) >= 0) {
return;
}
loopText = loopText + "|" + node.label.name;
} else {
// we shouldn't be transforming these statements because
// they don't refer to the actual loop we're scopifying
if (state.ignoreLabeless) return;
//
if (state.inSwitchCase) return;
// break statements mean something different in this context
if (t.isBreakStatement(node) && t.isSwitchCase(parent)) return;
}
state.hasBreakContinue = true;
state.map[loopText] = node;
replace = t.literal(loopText);
}
if (this.isReturnStatement()) {
state.hasReturn = true;
replace = t.objectExpression([t.property("init", t.identifier("v"), node.argument || t.identifier("undefined"))]);
}
if (replace) {
replace = t.returnStatement(replace);
this.skip();
return t.inherits(replace, node);
}
}
};
/**
* [Please add a description.]
*/
var BlockScoping = (function () {
function BlockScoping(loopPath, blockPath, parent, scope, file) {
_classCallCheck(this, BlockScoping);
this.parent = parent;
this.scope = scope;
this.file = file;
this.blockPath = blockPath;
this.block = blockPath.node;
this.outsideLetReferences = _helpersObject2["default"]();
this.hasLetReferences = false;
this.letReferences = this.block._letReferences = _helpersObject2["default"]();
this.body = [];
if (loopPath) {
this.loopParent = loopPath.parent;
this.loopLabel = t.isLabeledStatement(this.loopParent) && this.loopParent.label;
this.loopPath = loopPath;
this.loop = loopPath.node;
}
}
/**
* Start the ball rolling.
*/
BlockScoping.prototype.run = function run() {
var block = this.block;
if (block._letDone) return;
block._letDone = true;
var needsClosure = this.getLetReferences();
// this is a block within a `Function/Program` so we can safely leave it be
if (t.isFunction(this.parent) || t.isProgram(this.block)) return;
// we can skip everything
if (!this.hasLetReferences) return;
if (needsClosure) {
this.wrapClosure();
} else {
this.remap();
}
if (this.loopLabel && !t.isLabeledStatement(this.loopParent)) {
return t.labeledStatement(this.loopLabel, this.loop);
}
};
/**
* [Please add a description.]
*/
BlockScoping.prototype.remap = function remap() {
var hasRemaps = false;
var letRefs = this.letReferences;
var scope = this.scope;
// alright, so since we aren't wrapping this block in a closure
// we have to check if any of our let variables collide with
// those in upper scopes and then if they do, generate a uid
// for them and replace all references with it
var remaps = _helpersObject2["default"]();
for (var key in letRefs) {
// just an Identifier node we collected in `getLetReferences`
// this is the defining identifier of a declaration
var ref = letRefs[key];
// todo: could skip this if the colliding binding is in another function
if (scope.parentHasBinding(key) || scope.hasGlobal(key)) {
var uid = scope.generateUidIdentifier(ref.name).name;
ref.name = uid;
hasRemaps = true;
remaps[key] = remaps[uid] = {
binding: ref,
uid: uid
};
}
}
if (!hasRemaps) return;
//
var loop = this.loop;
if (loop) {
traverseReplace(loop.right, loop, scope, remaps);
traverseReplace(loop.test, loop, scope, remaps);
traverseReplace(loop.update, loop, scope, remaps);
}
this.blockPath.traverse(replaceVisitor, remaps);
};
/**
* [Please add a description.]
*/
BlockScoping.prototype.wrapClosure = function wrapClosure() {
var block = this.block;
var outsideRefs = this.outsideLetReferences;
// remap loop heads with colliding variables
if (this.loop) {
for (var name in outsideRefs) {
var id = outsideRefs[name];
if (this.scope.hasGlobal(id.name) || this.scope.parentHasBinding(id.name)) {
delete outsideRefs[id.name];
delete this.letReferences[id.name];
this.scope.rename(id.name);
this.letReferences[id.name] = id;
outsideRefs[id.name] = id;
}
}
}
// if we're inside of a for loop then we search to see if there are any
// `break`s, `continue`s, `return`s etc
this.has = this.checkLoop();
// hoist var references to retain scope
this.hoistVarDeclarations();
// turn outsideLetReferences into an array
var params = _lodashObjectValues2["default"](outsideRefs);
var args = _lodashObjectValues2["default"](outsideRefs);
// build the closure that we're going to wrap the block with
var fn = t.functionExpression(null, params, t.blockStatement(block.body));
fn.shadow = true;
// continuation
this.addContinuations(fn);
// replace the current block body with the one we're going to build
block.body = this.body;
var ref = fn;
if (this.loop) {
ref = this.scope.generateUidIdentifier("loop");
this.loopPath.insertBefore(t.variableDeclaration("var", [t.variableDeclarator(ref, fn)]));
}
// build a call and a unique id that we can assign the return value to
var call = t.callExpression(ref, args);
var ret = this.scope.generateUidIdentifier("ret");
// handle generators
var hasYield = _traversal2["default"].hasType(fn.body, this.scope, "YieldExpression", t.FUNCTION_TYPES);
if (hasYield) {
fn.generator = true;
call = t.yieldExpression(call, true);
}
// handlers async functions
var hasAsync = _traversal2["default"].hasType(fn.body, this.scope, "AwaitExpression", t.FUNCTION_TYPES);
if (hasAsync) {
fn.async = true;
call = t.awaitExpression(call);
}
this.buildClosure(ret, call);
};
/**
* Push the closure to the body.
*/
BlockScoping.prototype.buildClosure = function buildClosure(ret, call) {
var has = this.has;
if (has.hasReturn || has.hasBreakContinue) {
this.buildHas(ret, call);
} else {
this.body.push(t.expressionStatement(call));
}
};
/**
* If any of the outer let variables are reassigned then we need to rename them in
* the closure so we can get direct access to the outer variable to continue the
* iteration with bindings based on each iteration.
*
* Reference: https://github.com/babel/babel/issues/1078
*/
BlockScoping.prototype.addContinuations = function addContinuations(fn) {
var state = {
reassignments: {},
outsideReferences: this.outsideLetReferences
};
this.scope.traverse(fn, continuationVisitor, state);
for (var i = 0; i < fn.params.length; i++) {
var param = fn.params[i];
if (!state.reassignments[param.name]) continue;
var newParam = this.scope.generateUidIdentifier(param.name);
fn.params[i] = newParam;
this.scope.rename(param.name, newParam.name, fn);
// assign outer reference as it's been modified internally and needs to be retained
fn.body.body.push(t.expressionStatement(t.assignmentExpression("=", param, newParam)));
}
};
/**
* [Please add a description.]
*/
BlockScoping.prototype.getLetReferences = function getLetReferences() {
var block = this.block;
var declarators = block._letDeclarators || [];
//
for (var i = 0; i < declarators.length; i++) {
var declar = declarators[i];
_lodashObjectExtend2["default"](this.outsideLetReferences, t.getBindingIdentifiers(declar));
}
//
if (block.body) {
for (var i = 0; i < block.body.length; i++) {
var declar = block.body[i];
if (isLet(declar, block)) {
declarators = declarators.concat(declar.declarations);
}
}
}
//
for (var i = 0; i < declarators.length; i++) {
var declar = declarators[i];
var keys = t.getBindingIdentifiers(declar);
_lodashObjectExtend2["default"](this.letReferences, keys);
this.hasLetReferences = true;
}
// no let references so we can just quit
if (!this.hasLetReferences) return;
// set let references to plain var references
standardizeLets(declarators);
var state = {
letReferences: this.letReferences,
closurify: false
};
// traverse through this block, stopping on functions and checking if they
// contain any local let references
this.blockPath.traverse(letReferenceBlockVisitor, state);
return state.closurify;
};
/**
* If we're inside of a loop then traverse it and check if it has one of
* the following node types `ReturnStatement`, `BreakStatement`,
* `ContinueStatement` and replace it with a return value that we can track
* later on.
*
* @returns {Object}
*/
BlockScoping.prototype.checkLoop = function checkLoop() {
var state = {
hasBreakContinue: false,
ignoreLabeless: false,
inSwitchCase: false,
innerLabels: [],
hasReturn: false,
isLoop: !!this.loop,
map: {}
};
this.blockPath.traverse(loopLabelVisitor, state);
this.blockPath.traverse(loopVisitor, state);
return state;
};
/**
* Hoist all var declarations in this block to before it so they retain scope
* once we wrap everything in a closure.
*/
BlockScoping.prototype.hoistVarDeclarations = function hoistVarDeclarations() {
this.blockPath.traverse(hoistVarDeclarationsVisitor, this);
};
/**
* Turn a `VariableDeclaration` into an array of `AssignmentExpressions` with
* their declarations hoisted to before the closure wrapper.
*/
BlockScoping.prototype.pushDeclar = function pushDeclar(node) {
var declars = [];
var names = t.getBindingIdentifiers(node);
for (var name in names) {
declars.push(t.variableDeclarator(names[name]));
}
this.body.push(t.variableDeclaration(node.kind, declars));
var replace = [];
for (var i = 0; i < node.declarations.length; i++) {
var declar = node.declarations[i];
if (!declar.init) continue;
var expr = t.assignmentExpression("=", declar.id, declar.init);
replace.push(t.inherits(expr, declar));
}
return replace;
};
/**
* [Please add a description.]
*/
BlockScoping.prototype.buildHas = function buildHas(ret, call) {
var body = this.body;
body.push(t.variableDeclaration("var", [t.variableDeclarator(ret, call)]));
var retCheck;
var has = this.has;
var cases = [];
if (has.hasReturn) {
// typeof ret === "object"
retCheck = util.template("let-scoping-return", {
RETURN: ret
});
}
if (has.hasBreakContinue) {
for (var key in has.map) {
cases.push(t.switchCase(t.literal(key), [has.map[key]]));
}
if (has.hasReturn) {
cases.push(t.switchCase(null, [retCheck]));
}
if (cases.length === 1) {
var single = cases[0];
body.push(this.file.attachAuxiliaryComment(t.ifStatement(t.binaryExpression("===", ret, single.test), single.consequent[0])));
} else {
// https://github.com/babel/babel/issues/998
for (var i = 0; i < cases.length; i++) {
var caseConsequent = cases[i].consequent[0];
if (t.isBreakStatement(caseConsequent) && !caseConsequent.label) {
caseConsequent.label = this.loopLabel = this.loopLabel || this.file.scope.generateUidIdentifier("loop");
}
}
body.push(this.file.attachAuxiliaryComment(t.switchStatement(ret, cases)));
}
} else {
if (has.hasReturn) {
body.push(this.file.attachAuxiliaryComment(retCheck));
}
}
};
return BlockScoping;
})();
},{"148":148,"179":179,"182":182,"41":41,"511":511,"517":517}],91:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _loose = _dereq_(92);
var _loose2 = _interopRequireDefault(_loose);
var _vanilla = _dereq_(93);
var _vanilla2 = _interopRequireDefault(_vanilla);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
var _helpersNameMethod = _dereq_(61);
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
ClassDeclaration: function ClassDeclaration(node) {
return t.variableDeclaration("let", [t.variableDeclarator(node.id, t.toExpression(node))]);
},
/**
* [Please add a description.]
*/
ClassExpression: function ClassExpression(node, parent, scope, file) {
var inferred = _helpersNameMethod.bare(node, parent, scope);
if (inferred) return inferred;
if (file.isLoose("es6.classes")) {
return new _loose2["default"](this, file).run();
} else {
return new _vanilla2["default"](this, file).run();
}
}
};
exports.visitor = visitor;
},{"179":179,"61":61,"92":92,"93":93}],92:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// istanbul ignore next
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
// istanbul ignore next
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var _vanilla = _dereq_(93);
var _vanilla2 = _interopRequireDefault(_vanilla);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
var LooseClassTransformer = (function (_VanillaTransformer) {
_inherits(LooseClassTransformer, _VanillaTransformer);
function LooseClassTransformer() {
_classCallCheck(this, LooseClassTransformer);
_VanillaTransformer.apply(this, arguments);
this.isLoose = true;
}
/**
* [Please add a description.]
*/
LooseClassTransformer.prototype._processMethod = function _processMethod(node) {
if (!node.decorators) {
// use assignments instead of define properties for loose classes
var classRef = this.classRef;
if (!node["static"]) classRef = t.memberExpression(classRef, t.identifier("prototype"));
var methodName = t.memberExpression(classRef, node.key, node.computed || t.isLiteral(node.key));
var expr = t.expressionStatement(t.assignmentExpression("=", methodName, node.value));
t.inheritsComments(expr, node);
this.body.push(expr);
return true;
}
};
return LooseClassTransformer;
})(_vanilla2["default"]);
exports["default"] = LooseClassTransformer;
module.exports = exports["default"];
},{"179":179,"93":93}],93:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// istanbul ignore next
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _helpersMemoiseDecorators = _dereq_(60);
var _helpersMemoiseDecorators2 = _interopRequireDefault(_helpersMemoiseDecorators);
var _helpersReplaceSupers = _dereq_(65);
var _helpersReplaceSupers2 = _interopRequireDefault(_helpersReplaceSupers);
var _helpersNameMethod = _dereq_(61);
var nameMethod = _interopRequireWildcard(_helpersNameMethod);
var _helpersDefineMap = _dereq_(57);
var defineMap = _interopRequireWildcard(_helpersDefineMap);
var _messages = _dereq_(43);
var messages = _interopRequireWildcard(_messages);
var _util = _dereq_(182);
var util = _interopRequireWildcard(_util);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
var PROPERTY_COLLISION_METHOD_NAME = "__initializeProperties";
/**
* [Please add a description.]
*/
var collectPropertyReferencesVisitor = {
/**
* [Please add a description.]
*/
Identifier: {
enter: function enter(node, parent, scope, state) {
if (this.parentPath.isClassProperty({ key: node })) {
return;
}
if (this.isReferenced() && scope.getBinding(node.name) === state.scope.getBinding(node.name)) {
state.references[node.name] = true;
}
}
}
};
/**
* [Please add a description.]
*/
var verifyConstructorVisitor = {
/**
* [Please add a description.]
*/
MethodDefinition: function MethodDefinition() {
this.skip();
},
/**
* [Please add a description.]
*/
Property: function Property(node) {
if (node.method) this.skip();
},
/**
* [Please add a description.]
*/
CallExpression: {
exit: function exit(node, parent, scope, state) {
if (this.get("callee").isSuper()) {
state.hasBareSuper = true;
state.bareSuper = this;
if (!state.isDerived) {
throw this.errorWithNode("super call is only allowed in derived constructor");
}
}
}
},
/**
* [Please add a description.]
*/
"FunctionDeclaration|FunctionExpression": function FunctionDeclarationFunctionExpression() {
this.skip();
},
/**
* [Please add a description.]
*/
ThisExpression: function ThisExpression(node, parent, scope, state) {
if (state.isDerived && !state.hasBareSuper) {
if (this.inShadow()) {
// https://github.com/babel/babel/issues/1920
var thisAlias = state.constructorPath.getData("this");
if (!thisAlias) {
thisAlias = state.constructorPath.setData("this", state.constructorPath.scope.generateUidIdentifier("this"));
}
return thisAlias;
} else {
throw this.errorWithNode("'this' is not allowed before super()");
}
}
},
/**
* [Please add a description.]
*/
Super: function Super(node, parent, scope, state) {
if (state.isDerived && !state.hasBareSuper && !this.parentPath.isCallExpression({ callee: node })) {
throw this.errorWithNode("'super.*' is not allowed before super()");
}
}
};
/**
* [Please add a description.]
*/
var ClassTransformer = (function () {
function ClassTransformer(path, file) {
_classCallCheck(this, ClassTransformer);
this.parent = path.parent;
this.scope = path.scope;
this.node = path.node;
this.path = path;
this.file = file;
this.clearDescriptors();
this.instancePropBody = [];
this.instancePropRefs = {};
this.staticPropBody = [];
this.body = [];
this.pushedConstructor = false;
this.pushedInherits = false;
this.hasDecorators = false;
this.isLoose = false;
// class id
this.classId = this.node.id;
// this is the name of the binding that will **always** reference the class we've constructed
this.classRef = this.node.id || this.scope.generateUidIdentifier("class");
// this is a direct reference to the class we're building, class decorators can shadow the classRef
this.directRef = null;
this.superName = this.node.superClass || t.identifier("Function");
this.isDerived = !!this.node.superClass;
}
/**
* [Please add a description.]
* @returns {Array}
*/
ClassTransformer.prototype.run = function run() {
var superName = this.superName;
var file = this.file;
//
var body = this.body;
//
var constructorBody = this.constructorBody = t.blockStatement([]);
this.constructor = this.buildConstructor();
//
var closureParams = [];
var closureArgs = [];
//
if (this.isDerived) {
closureArgs.push(superName);
superName = this.scope.generateUidIdentifierBasedOnNode(superName);
closureParams.push(superName);
this.superName = superName;
}
//
var decorators = this.node.decorators;
if (decorators) {
// this is so super calls and the decorators have access to the raw function
this.directRef = this.scope.generateUidIdentifier(this.classRef);
} else {
this.directRef = this.classRef;
}
//
this.buildBody();
// make sure this class isn't directly called
constructorBody.body.unshift(t.expressionStatement(t.callExpression(file.addHelper("class-call-check"), [t.thisExpression(), this.directRef])));
//
this.pushDecorators();
body = body.concat(this.staticPropBody);
if (this.classId) {
// named class with only a constructor
if (body.length === 1) return t.toExpression(body[0]);
}
//
body.push(t.returnStatement(this.classRef));
var container = t.functionExpression(null, closureParams, t.blockStatement(body));
container.shadow = true;
return t.callExpression(container, closureArgs);
};
/**
* [Please add a description.]
*/
ClassTransformer.prototype.buildConstructor = function buildConstructor() {
var func = t.functionDeclaration(this.classRef, [], this.constructorBody);
t.inherits(func, this.node);
return func;
};
/**
* [Please add a description.]
*/
ClassTransformer.prototype.pushToMap = function pushToMap(node, enumerable) {
var kind = arguments.length <= 2 || arguments[2] === undefined ? "value" : arguments[2];
var mutatorMap;
if (node["static"]) {
this.hasStaticDescriptors = true;
mutatorMap = this.staticMutatorMap;
} else {
this.hasInstanceDescriptors = true;
mutatorMap = this.instanceMutatorMap;
}
var map = defineMap.push(mutatorMap, node, kind, this.file);
if (enumerable) {
map.enumerable = t.literal(true);
}
if (map.decorators) {
this.hasDecorators = true;
}
};
/**
* [Please add a description.]
* https://www.youtube.com/watch?v=fWNaR-rxAic
*/
ClassTransformer.prototype.constructorMeMaybe = function constructorMeMaybe() {
var hasConstructor = false;
var paths = this.path.get("body.body");
var _arr = paths;
for (var _i = 0; _i < _arr.length; _i++) {
var path = _arr[_i];
hasConstructor = path.equals("kind", "constructor");
if (hasConstructor) break;
}
if (hasConstructor) return;
var constructor;
if (this.isDerived) {
constructor = util.template("class-derived-default-constructor");
} else {
constructor = t.functionExpression(null, [], t.blockStatement([]));
}
this.path.get("body").unshiftContainer("body", t.methodDefinition(t.identifier("constructor"), constructor, "constructor"));
};
/**
* [Please add a description.]
*/
ClassTransformer.prototype.buildBody = function buildBody() {
this.constructorMeMaybe();
this.pushBody();
this.placePropertyInitializers();
if (this.userConstructor) {
var constructorBody = this.constructorBody;
constructorBody.body = constructorBody.body.concat(this.userConstructor.body.body);
t.inherits(this.constructor, this.userConstructor);
t.inherits(constructorBody, this.userConstructor.body);
}
this.pushDescriptors();
};
/**
* [Please add a description.]
*/
ClassTransformer.prototype.pushBody = function pushBody() {
var classBodyPaths = this.path.get("body.body");
var _arr2 = classBodyPaths;
for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
var path = _arr2[_i2];
var node = path.node;
if (node.decorators) {
_helpersMemoiseDecorators2["default"](node.decorators, this.scope);
}
if (t.isMethodDefinition(node)) {
var isConstructor = node.kind === "constructor";
if (isConstructor) this.verifyConstructor(path);
var replaceSupers = new _helpersReplaceSupers2["default"]({
methodPath: path,
methodNode: node,
objectRef: this.directRef,
superRef: this.superName,
isStatic: node["static"],
isLoose: this.isLoose,
scope: this.scope,
file: this.file
}, true);
replaceSupers.replace();
if (isConstructor) {
this.pushConstructor(node, path);
} else {
this.pushMethod(node, path);
}
} else if (t.isClassProperty(node)) {
this.pushProperty(node, path);
}
}
};
/**
* [Please add a description.]
*/
ClassTransformer.prototype.clearDescriptors = function clearDescriptors() {
this.hasInstanceDescriptors = false;
this.hasStaticDescriptors = false;
this.instanceMutatorMap = {};
this.staticMutatorMap = {};
};
/**
* [Please add a description.]
*/
ClassTransformer.prototype.pushDescriptors = function pushDescriptors() {
this.pushInherits();
var body = this.body;
var instanceProps;
var staticProps;
var classHelper = "create-class";
if (this.hasDecorators) classHelper = "create-decorated-class";
if (this.hasInstanceDescriptors) {
instanceProps = defineMap.toClassObject(this.instanceMutatorMap);
}
if (this.hasStaticDescriptors) {
staticProps = defineMap.toClassObject(this.staticMutatorMap);
}
if (instanceProps || staticProps) {
if (instanceProps) instanceProps = defineMap.toComputedObjectFromClass(instanceProps);
if (staticProps) staticProps = defineMap.toComputedObjectFromClass(staticProps);
var nullNode = t.literal(null);
// (Constructor, instanceDescriptors, staticDescriptors, instanceInitializers, staticInitializers)
var args = [this.classRef, nullNode, nullNode, nullNode, nullNode];
if (instanceProps) args[1] = instanceProps;
if (staticProps) args[2] = staticProps;
if (this.instanceInitializersId) {
args[3] = this.instanceInitializersId;
body.unshift(this.buildObjectAssignment(this.instanceInitializersId));
}
if (this.staticInitializersId) {
args[4] = this.staticInitializersId;
body.unshift(this.buildObjectAssignment(this.staticInitializersId));
}
var lastNonNullIndex = 0;
for (var i = 0; i < args.length; i++) {
if (args[i] !== nullNode) lastNonNullIndex = i;
}
args = args.slice(0, lastNonNullIndex + 1);
body.push(t.expressionStatement(t.callExpression(this.file.addHelper(classHelper), args)));
}
this.clearDescriptors();
};
/**
* [Please add a description.]
*/
ClassTransformer.prototype.buildObjectAssignment = function buildObjectAssignment(id) {
return t.variableDeclaration("var", [t.variableDeclarator(id, t.objectExpression([]))]);
};
/**
* [Please add a description.]
*/
ClassTransformer.prototype.placePropertyInitializers = function placePropertyInitializers() {
var body = this.instancePropBody;
if (!body.length) return;
if (this.hasPropertyCollision()) {
var call = t.expressionStatement(t.callExpression(t.memberExpression(t.thisExpression(), t.identifier(PROPERTY_COLLISION_METHOD_NAME)), []));
this.pushMethod(t.methodDefinition(t.identifier(PROPERTY_COLLISION_METHOD_NAME), t.functionExpression(null, [], t.blockStatement(body))), null, true);
if (this.isDerived) {
this.bareSuper.insertAfter(call);
} else {
this.constructorBody.body.unshift(call);
}
} else {
if (this.isDerived) {
this.bareSuper.insertAfter(body);
} else {
this.constructorBody.body = body.concat(this.constructorBody.body);
}
}
};
/**
* [Please add a description.]
*/
ClassTransformer.prototype.hasPropertyCollision = function hasPropertyCollision() {
if (this.userConstructorPath) {
for (var name in this.instancePropRefs) {
if (this.userConstructorPath.scope.hasOwnBinding(name)) {
return true;
}
}
}
return false;
};
/**
* [Please add a description.]
*/
ClassTransformer.prototype.verifyConstructor = function verifyConstructor(path) {
var state = {
constructorPath: path.get("value"),
hasBareSuper: false,
bareSuper: null,
isDerived: this.isDerived,
file: this.file
};
state.constructorPath.traverse(verifyConstructorVisitor, state);
var thisAlias = state.constructorPath.getData("this");
if (thisAlias && state.bareSuper) {
state.bareSuper.insertAfter(t.variableDeclaration("var", [t.variableDeclarator(thisAlias, t.thisExpression())]));
}
this.bareSuper = state.bareSuper;
if (!state.hasBareSuper && this.isDerived) {
throw path.errorWithNode("Derived constructor must call super()");
}
};
/**
* Push a method to its respective mutatorMap.
*/
ClassTransformer.prototype.pushMethod = function pushMethod(node, path, allowedIllegal) {
if (!allowedIllegal && t.isLiteral(t.toComputedKey(node), { value: PROPERTY_COLLISION_METHOD_NAME })) {
throw this.file.errorWithNode(node, messages.get("illegalMethodName", PROPERTY_COLLISION_METHOD_NAME));
}
if (node.kind === "method") {
nameMethod.property(node, this.file, path ? path.get("value").scope : this.scope);
if (this._processMethod(node)) return;
}
this.pushToMap(node);
};
/**
* [Please add a description.]
*/
ClassTransformer.prototype._processMethod = function _processMethod() {
return false;
};
/**
* [Please add a description.]
*/
ClassTransformer.prototype.pushProperty = function pushProperty(node, path) {
path.traverse(collectPropertyReferencesVisitor, {
references: this.instancePropRefs,
scope: this.scope
});
if (node.decorators) {
var body = [];
if (node.value) {
body.push(t.returnStatement(node.value));
node.value = t.functionExpression(null, [], t.blockStatement(body));
} else {
node.value = t.literal(null);
}
this.pushToMap(node, true, "initializer");
var initializers;
var target;
if (node["static"]) {
initializers = this.staticInitializersId = this.staticInitializersId || this.scope.generateUidIdentifier("staticInitializers");
body = this.staticPropBody;
target = this.classRef;
} else {
initializers = this.instanceInitializersId = this.instanceInitializersId || this.scope.generateUidIdentifier("instanceInitializers");
body = this.instancePropBody;
target = t.thisExpression();
}
body.push(t.expressionStatement(t.callExpression(this.file.addHelper("define-decorated-property-descriptor"), [target, t.literal(node.key.name), initializers])));
} else {
if (!node.value && !node.decorators) return;
if (node["static"]) {
// can just be added to the static map
this.pushToMap(node, true);
} else if (node.value) {
// add this to the instancePropBody which will be added after the super call in a derived constructor
// or at the start of a constructor for a non-derived constructor
this.instancePropBody.push(t.expressionStatement(t.assignmentExpression("=", t.memberExpression(t.thisExpression(), node.key), node.value)));
}
}
};
/**
* Replace the constructor body of our class.
*/
ClassTransformer.prototype.pushConstructor = function pushConstructor(method, path) {
// https://github.com/babel/babel/issues/1077
var fnPath = path.get("value");
if (fnPath.scope.hasOwnBinding(this.classRef.name)) {
fnPath.scope.rename(this.classRef.name);
}
var construct = this.constructor;
var fn = method.value;
this.userConstructorPath = fnPath;
this.userConstructor = fn;
this.hasConstructor = true;
t.inheritsComments(construct, method);
construct._ignoreUserWhitespace = true;
construct.params = fn.params;
t.inherits(construct.body, fn.body);
// push constructor to body
this._pushConstructor();
};
/**
* [Please add a description.]
*/
ClassTransformer.prototype._pushConstructor = function _pushConstructor() {
if (this.pushedConstructor) return;
this.pushedConstructor = true;
// we haven't pushed any descriptors yet
if (this.hasInstanceDescriptors || this.hasStaticDescriptors) {
this.pushDescriptors();
}
this.body.push(this.constructor);
this.pushInherits();
};
/**
* Push inherits helper to body.
*/
ClassTransformer.prototype.pushInherits = function pushInherits() {
if (!this.isDerived || this.pushedInherits) return;
// Unshift to ensure that the constructor inheritance is set up before
// any properties can be assigned to the prototype.
this.pushedInherits = true;
this.body.unshift(t.expressionStatement(t.callExpression(this.file.addHelper("inherits"), [this.classRef, this.superName])));
};
/**
* Push decorators to body.
*/
ClassTransformer.prototype.pushDecorators = function pushDecorators() {
var decorators = this.node.decorators;
if (!decorators) return;
this.body.push(t.variableDeclaration("var", [t.variableDeclarator(this.directRef, this.classRef)]));
// reverse the decorators so we execute them in the right order
decorators = decorators.reverse();
var _arr3 = decorators;
for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
var decorator = _arr3[_i3];
var decoratorNode = util.template("class-decorator", {
DECORATOR: decorator.expression,
CLASS_REF: this.classRef
}, true);
decoratorNode.expression._ignoreModulesRemap = true;
this.body.push(decoratorNode);
}
};
return ClassTransformer;
})();
exports["default"] = ClassTransformer;
module.exports = exports["default"];
},{"179":179,"182":182,"43":43,"57":57,"60":60,"61":61,"65":65}],94:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _messages = _dereq_(43);
var messages = _interopRequireWildcard(_messages);
/**
* Turn constants into variables.
* Ensure there are no constant violations in any scope.
*
* @example
*
* **In**
*
* ```javascript
* const MULTIPLIER = 5;
* ```
*
* **Out**
*
* ```javascript
* var MULTIPLIER = 5;
* ```
*/
var visitor = {
/**
* Look for any constants (or modules) in scope.
* If they have any `constantViolations` throw an error.
*/
Scope: function Scope(node, parent, scope) {
for (var name in scope.bindings) {
var binding = scope.bindings[name];
// not a constant
if (binding.kind !== "const" && binding.kind !== "module") continue;
var _arr = binding.constantViolations;
for (var _i = 0; _i < _arr.length; _i++) {
var violation = _arr[_i];
throw violation.errorWithNode(messages.get("readOnly", name));
}
}
},
/**
* Look for constants.
* Turn them into `let` variables.
*/
VariableDeclaration: function VariableDeclaration(node) {
if (node.kind === "const") node.kind = "let";
}
};
exports.visitor = visitor;
},{"43":43}],95:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _messages = _dereq_(43);
var messages = _interopRequireWildcard(_messages);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
var metadata = {
group: "builtin-advanced"
};
exports.metadata = metadata;
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
ForXStatement: function ForXStatement(node, parent, scope, file) {
var left = node.left;
if (t.isPattern(left)) {
// for ({ length: k } in { abc: 3 });
var temp = scope.generateUidIdentifier("ref");
node.left = t.variableDeclaration("var", [t.variableDeclarator(temp)]);
this.ensureBlock();
node.body.body.unshift(t.variableDeclaration("var", [t.variableDeclarator(left, temp)]));
return;
}
if (!t.isVariableDeclaration(left)) return;
var pattern = left.declarations[0].id;
if (!t.isPattern(pattern)) return;
var key = scope.generateUidIdentifier("ref");
node.left = t.variableDeclaration(left.kind, [t.variableDeclarator(key, null)]);
var nodes = [];
var destructuring = new DestructuringTransformer({
kind: left.kind,
file: file,
scope: scope,
nodes: nodes
});
destructuring.init(pattern, key);
this.ensureBlock();
var block = node.body;
block.body = nodes.concat(block.body);
},
/**
* [Please add a description.]
*/
Function: function Function(node, parent, scope, file) {
var hasDestructuring = false;
var _arr = node.params;
for (var _i = 0; _i < _arr.length; _i++) {
var pattern = _arr[_i];
if (t.isPattern(pattern)) {
hasDestructuring = true;
break;
}
}
if (!hasDestructuring) return;
var nodes = [];
for (var i = 0; i < node.params.length; i++) {
var pattern = node.params[i];
if (!t.isPattern(pattern)) continue;
var ref = scope.generateUidIdentifier("ref");
if (t.isAssignmentPattern(pattern)) {
var _pattern = pattern;
pattern = pattern.left;
_pattern.left = ref;
} else {
node.params[i] = ref;
}
t.inherits(ref, pattern);
var destructuring = new DestructuringTransformer({
blockHoist: node.params.length - i,
nodes: nodes,
scope: scope,
file: file,
kind: "let"
});
destructuring.init(pattern, ref);
}
this.ensureBlock();
var block = node.body;
block.body = nodes.concat(block.body);
},
/**
* [Please add a description.]
*/
CatchClause: function CatchClause(node, parent, scope, file) {
var pattern = node.param;
if (!t.isPattern(pattern)) return;
var ref = scope.generateUidIdentifier("ref");
node.param = ref;
var nodes = [];
var destructuring = new DestructuringTransformer({
kind: "let",
file: file,
scope: scope,
nodes: nodes
});
destructuring.init(pattern, ref);
node.body.body = nodes.concat(node.body.body);
},
/**
* [Please add a description.]
*/
AssignmentExpression: function AssignmentExpression(node, parent, scope, file) {
if (!t.isPattern(node.left)) return;
var nodes = [];
var destructuring = new DestructuringTransformer({
operator: node.operator,
file: file,
scope: scope,
nodes: nodes
});
var ref;
if (this.isCompletionRecord() || !this.parentPath.isExpressionStatement()) {
ref = scope.generateUidIdentifierBasedOnNode(node.right, "ref");
nodes.push(t.variableDeclaration("var", [t.variableDeclarator(ref, node.right)]));
if (t.isArrayExpression(node.right)) {
destructuring.arrays[ref.name] = true;
}
}
destructuring.init(node.left, ref || node.right);
if (ref) {
nodes.push(t.expressionStatement(ref));
}
return nodes;
},
/**
* [Please add a description.]
*/
VariableDeclaration: function VariableDeclaration(node, parent, scope, file) {
if (t.isForXStatement(parent)) return;
if (!variableDeclarationHasPattern(node)) return;
var nodes = [];
var declar;
for (var i = 0; i < node.declarations.length; i++) {
declar = node.declarations[i];
var patternId = declar.init;
var pattern = declar.id;
var destructuring = new DestructuringTransformer({
nodes: nodes,
scope: scope,
kind: node.kind,
file: file
});
if (t.isPattern(pattern)) {
destructuring.init(pattern, patternId);
if (+i !== node.declarations.length - 1) {
// we aren't the last declarator so let's just make the
// last transformed node inherit from us
t.inherits(nodes[nodes.length - 1], declar);
}
} else {
nodes.push(t.inherits(destructuring.buildVariableAssignment(declar.id, declar.init), declar));
}
}
if (!t.isProgram(parent) && !t.isBlockStatement(parent)) {
// https://github.com/babel/babel/issues/113
// for (let [x] = [0]; false;) {}
declar = null;
for (i = 0; i < nodes.length; i++) {
node = nodes[i];
declar = declar || t.variableDeclaration(node.kind, []);
if (!t.isVariableDeclaration(node) && declar.kind !== node.kind) {
throw file.errorWithNode(node, messages.get("invalidParentForThisNode"));
}
declar.declarations = declar.declarations.concat(node.declarations);
}
return declar;
}
return nodes;
}
};
exports.visitor = visitor;
/**
* Test if a VariableDeclaration's declarations contains any Patterns.
*/
function variableDeclarationHasPattern(node) {
for (var i = 0; i < node.declarations.length; i++) {
if (t.isPattern(node.declarations[i].id)) {
return true;
}
}
return false;
}
/**
* Test if an ArrayPattern's elements contain any RestElements.
*/
function hasRest(pattern) {
for (var i = 0; i < pattern.elements.length; i++) {
if (t.isRestElement(pattern.elements[i])) {
return true;
}
}
return false;
}
/**
* [Please add a description.]
*/
var arrayUnpackVisitor = {
/**
* [Please add a description.]
*/
ReferencedIdentifier: function ReferencedIdentifier(node, parent, scope, state) {
if (state.bindings[node.name]) {
state.deopt = true;
this.stop();
}
}
};
/**
* [Please add a description.]
*/
var DestructuringTransformer = (function () {
function DestructuringTransformer(opts) {
_classCallCheck(this, DestructuringTransformer);
this.blockHoist = opts.blockHoist;
this.operator = opts.operator;
this.arrays = {};
this.nodes = opts.nodes || [];
this.scope = opts.scope;
this.file = opts.file;
this.kind = opts.kind;
}
/**
* [Please add a description.]
*/
DestructuringTransformer.prototype.buildVariableAssignment = function buildVariableAssignment(id, init) {
var op = this.operator;
if (t.isMemberExpression(id)) op = "=";
var node;
if (op) {
node = t.expressionStatement(t.assignmentExpression(op, id, init));
} else {
node = t.variableDeclaration(this.kind, [t.variableDeclarator(id, init)]);
}
node._blockHoist = this.blockHoist;
return node;
};
/**
* [Please add a description.]
*/
DestructuringTransformer.prototype.buildVariableDeclaration = function buildVariableDeclaration(id, init) {
var declar = t.variableDeclaration("var", [t.variableDeclarator(id, init)]);
declar._blockHoist = this.blockHoist;
return declar;
};
/**
* [Please add a description.]
*/
DestructuringTransformer.prototype.push = function push(id, init) {
if (t.isObjectPattern(id)) {
this.pushObjectPattern(id, init);
} else if (t.isArrayPattern(id)) {
this.pushArrayPattern(id, init);
} else if (t.isAssignmentPattern(id)) {
this.pushAssignmentPattern(id, init);
} else {
this.nodes.push(this.buildVariableAssignment(id, init));
}
};
/**
* [Please add a description.]
*/
DestructuringTransformer.prototype.toArray = function toArray(node, count) {
if (this.file.isLoose("es6.destructuring") || t.isIdentifier(node) && this.arrays[node.name]) {
return node;
} else {
return this.scope.toArray(node, count);
}
};
/**
* [Please add a description.]
*/
DestructuringTransformer.prototype.pushAssignmentPattern = function pushAssignmentPattern(pattern, valueRef) {
// we need to assign the current value of the assignment to avoid evaluating
// it more than once
var tempValueRef = this.scope.generateUidIdentifierBasedOnNode(valueRef);
var declar = t.variableDeclaration("var", [t.variableDeclarator(tempValueRef, valueRef)]);
declar._blockHoist = this.blockHoist;
this.nodes.push(declar);
//
var tempConditional = t.conditionalExpression(t.binaryExpression("===", tempValueRef, t.identifier("undefined")), pattern.right, tempValueRef);
var left = pattern.left;
if (t.isPattern(left)) {
var tempValueDefault = t.expressionStatement(t.assignmentExpression("=", tempValueRef, tempConditional));
tempValueDefault._blockHoist = this.blockHoist;
this.nodes.push(tempValueDefault);
this.push(left, tempValueRef);
} else {
this.nodes.push(this.buildVariableAssignment(left, tempConditional));
}
};
/**
* [Please add a description.]
*/
DestructuringTransformer.prototype.pushObjectSpread = function pushObjectSpread(pattern, objRef, spreadProp, spreadPropIndex) {
// get all the keys that appear in this object before the current spread
var keys = [];
for (var i = 0; i < pattern.properties.length; i++) {
var prop = pattern.properties[i];
// we've exceeded the index of the spread property to all properties to the
// right need to be ignored
if (i >= spreadPropIndex) break;
// ignore other spread properties
if (t.isSpreadProperty(prop)) continue;
var key = prop.key;
if (t.isIdentifier(key) && !prop.computed) key = t.literal(prop.key.name);
keys.push(key);
}
keys = t.arrayExpression(keys);
//
var value = t.callExpression(this.file.addHelper("object-without-properties"), [objRef, keys]);
this.nodes.push(this.buildVariableAssignment(spreadProp.argument, value));
};
/**
* [Please add a description.]
*/
DestructuringTransformer.prototype.pushObjectProperty = function pushObjectProperty(prop, propRef) {
if (t.isLiteral(prop.key)) prop.computed = true;
var pattern = prop.value;
var objRef = t.memberExpression(propRef, prop.key, prop.computed);
if (t.isPattern(pattern)) {
this.push(pattern, objRef);
} else {
this.nodes.push(this.buildVariableAssignment(pattern, objRef));
}
};
/**
* [Please add a description.]
*/
DestructuringTransformer.prototype.pushObjectPattern = function pushObjectPattern(pattern, objRef) {
// https://github.com/babel/babel/issues/681
if (!pattern.properties.length) {
this.nodes.push(t.expressionStatement(t.callExpression(this.file.addHelper("object-destructuring-empty"), [objRef])));
}
// if we have more than one properties in this pattern and the objectRef is a
// member expression then we need to assign it to a temporary variable so it's
// only evaluated once
if (pattern.properties.length > 1 && !this.scope.isStatic(objRef)) {
var temp = this.scope.generateUidIdentifierBasedOnNode(objRef);
this.nodes.push(this.buildVariableDeclaration(temp, objRef));
objRef = temp;
}
//
for (var i = 0; i < pattern.properties.length; i++) {
var prop = pattern.properties[i];
if (t.isSpreadProperty(prop)) {
this.pushObjectSpread(pattern, objRef, prop, i);
} else {
this.pushObjectProperty(prop, objRef);
}
}
};
/**
* [Please add a description.]
*/
DestructuringTransformer.prototype.canUnpackArrayPattern = function canUnpackArrayPattern(pattern, arr) {
// not an array so there's no way we can deal with this
if (!t.isArrayExpression(arr)) return false;
// pattern has less elements than the array and doesn't have a rest so some
// elements wont be evaluated
if (pattern.elements.length > arr.elements.length) return;
if (pattern.elements.length < arr.elements.length && !hasRest(pattern)) return false;
var _arr2 = pattern.elements;
for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
var elem = _arr2[_i2];
// deopt on holes
if (!elem) return false;
// deopt on member expressions as they may be included in the RHS
if (t.isMemberExpression(elem)) return false;
}
var _arr3 = arr.elements;
for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
var elem = _arr3[_i3];
// deopt on spread elements
if (t.isSpreadElement(elem)) return false;
}
// deopt on reference to left side identifiers
var bindings = t.getBindingIdentifiers(pattern);
var state = { deopt: false, bindings: bindings };
this.scope.traverse(arr, arrayUnpackVisitor, state);
return !state.deopt;
};
/**
* [Please add a description.]
*/
DestructuringTransformer.prototype.pushUnpackedArrayPattern = function pushUnpackedArrayPattern(pattern, arr) {
for (var i = 0; i < pattern.elements.length; i++) {
var elem = pattern.elements[i];
if (t.isRestElement(elem)) {
this.push(elem.argument, t.arrayExpression(arr.elements.slice(i)));
} else {
this.push(elem, arr.elements[i]);
}
}
};
/**
* [Please add a description.]
*/
DestructuringTransformer.prototype.pushArrayPattern = function pushArrayPattern(pattern, arrayRef) {
if (!pattern.elements) return;
// optimise basic array destructuring of an array expression
//
// we can't do this to a pattern of unequal size to it's right hand
// array expression as then there will be values that wont be evaluated
//
// eg: var [a, b] = [1, 2];
if (this.canUnpackArrayPattern(pattern, arrayRef)) {
return this.pushUnpackedArrayPattern(pattern, arrayRef);
}
// if we have a rest then we need all the elements so don't tell
// `scope.toArray` to only get a certain amount
var count = !hasRest(pattern) && pattern.elements.length;
// so we need to ensure that the `arrayRef` is an array, `scope.toArray` will
// return a locally bound identifier if it's been inferred to be an array,
// otherwise it'll be a call to a helper that will ensure it's one
var toArray = this.toArray(arrayRef, count);
if (t.isIdentifier(toArray)) {
// we've been given an identifier so it must have been inferred to be an
// array
arrayRef = toArray;
} else {
arrayRef = this.scope.generateUidIdentifierBasedOnNode(arrayRef);
this.arrays[arrayRef.name] = true;
this.nodes.push(this.buildVariableDeclaration(arrayRef, toArray));
}
//
for (var i = 0; i < pattern.elements.length; i++) {
var elem = pattern.elements[i];
// hole
if (!elem) continue;
var elemRef;
if (t.isRestElement(elem)) {
elemRef = this.toArray(arrayRef);
if (i > 0) {
elemRef = t.callExpression(t.memberExpression(elemRef, t.identifier("slice")), [t.literal(i)]);
}
// set the element to the rest element argument since we've dealt with it
// being a rest already
elem = elem.argument;
} else {
elemRef = t.memberExpression(arrayRef, t.literal(i), true);
}
this.push(elem, elemRef);
}
};
/**
* [Please add a description.]
*/
DestructuringTransformer.prototype.init = function init(pattern, ref) {
// trying to destructure a value that we can't evaluate more than once so we
// need to save it to a variable
if (!t.isArrayExpression(ref) && !t.isMemberExpression(ref)) {
var memo = this.scope.maybeGenerateMemoised(ref, true);
if (memo) {
this.nodes.push(this.buildVariableDeclaration(memo, ref));
ref = memo;
}
}
//
this.push(pattern, ref);
return this.nodes;
};
return DestructuringTransformer;
})();
},{"179":179,"43":43}],96:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports._ForOfStatementArray = _ForOfStatementArray;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _messages = _dereq_(43);
var messages = _interopRequireWildcard(_messages);
var _util = _dereq_(182);
var util = _interopRequireWildcard(_util);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
ForOfStatement: function ForOfStatement(node, parent, scope, file) {
if (this.get("right").isArrayExpression()) {
return _ForOfStatementArray.call(this, node, scope, file);
}
var callback = spec;
if (file.isLoose("es6.forOf")) callback = loose;
var build = callback(node, parent, scope, file);
var declar = build.declar;
var loop = build.loop;
var block = loop.body;
// ensure that it's a block so we can take all its statements
this.ensureBlock();
// add the value declaration to the new loop body
if (declar) {
block.body.push(declar);
}
// push the rest of the original loop body onto our new body
block.body = block.body.concat(node.body.body);
t.inherits(loop, node);
t.inherits(loop.body, node.body);
if (build.replaceParent) {
this.parentPath.replaceWithMultiple(build.node);
this.dangerouslyRemove();
} else {
return build.node;
}
}
};
exports.visitor = visitor;
/**
* [Please add a description.]
*/
function _ForOfStatementArray(node, scope) {
var nodes = [];
var right = node.right;
if (!t.isIdentifier(right) || !scope.hasBinding(right.name)) {
var uid = scope.generateUidIdentifier("arr");
nodes.push(t.variableDeclaration("var", [t.variableDeclarator(uid, right)]));
right = uid;
}
var iterationKey = scope.generateUidIdentifier("i");
var loop = util.template("for-of-array", {
BODY: node.body,
KEY: iterationKey,
ARR: right
});
t.inherits(loop, node);
t.ensureBlock(loop);
var iterationValue = t.memberExpression(right, iterationKey, true);
var left = node.left;
if (t.isVariableDeclaration(left)) {
left.declarations[0].init = iterationValue;
loop.body.body.unshift(left);
} else {
loop.body.body.unshift(t.expressionStatement(t.assignmentExpression("=", left, iterationValue)));
}
if (this.parentPath.isLabeledStatement()) {
loop = t.labeledStatement(this.parentPath.node.label, loop);
}
nodes.push(loop);
return nodes;
}
/**
* [Please add a description.]
*/
var loose = function loose(node, parent, scope, file) {
var left = node.left;
var declar, id;
if (t.isIdentifier(left) || t.isPattern(left) || t.isMemberExpression(left)) {
// for (i of test), for ({ i } of test)
id = left;
} else if (t.isVariableDeclaration(left)) {
// for (var i of test)
id = scope.generateUidIdentifier("ref");
declar = t.variableDeclaration(left.kind, [t.variableDeclarator(left.declarations[0].id, id)]);
} else {
throw file.errorWithNode(left, messages.get("unknownForHead", left.type));
}
var iteratorKey = scope.generateUidIdentifier("iterator");
var isArrayKey = scope.generateUidIdentifier("isArray");
var loop = util.template("for-of-loose", {
LOOP_OBJECT: iteratorKey,
IS_ARRAY: isArrayKey,
OBJECT: node.right,
INDEX: scope.generateUidIdentifier("i"),
ID: id
});
if (!declar) {
// no declaration so we need to remove the variable declaration at the top of
// the for-of-loose template
loop.body.body.shift();
}
//
return {
declar: declar,
node: loop,
loop: loop
};
};
/**
* [Please add a description.]
*/
var spec = function spec(node, parent, scope, file) {
var left = node.left;
var declar;
var stepKey = scope.generateUidIdentifier("step");
var stepValue = t.memberExpression(stepKey, t.identifier("value"));
if (t.isIdentifier(left) || t.isPattern(left) || t.isMemberExpression(left)) {
// for (i of test), for ({ i } of test)
declar = t.expressionStatement(t.assignmentExpression("=", left, stepValue));
} else if (t.isVariableDeclaration(left)) {
// for (var i of test)
declar = t.variableDeclaration(left.kind, [t.variableDeclarator(left.declarations[0].id, stepValue)]);
} else {
throw file.errorWithNode(left, messages.get("unknownForHead", left.type));
}
//
var iteratorKey = scope.generateUidIdentifier("iterator");
var template = util.template("for-of", {
ITERATOR_HAD_ERROR_KEY: scope.generateUidIdentifier("didIteratorError"),
ITERATOR_COMPLETION: scope.generateUidIdentifier("iteratorNormalCompletion"),
ITERATOR_ERROR_KEY: scope.generateUidIdentifier("iteratorError"),
ITERATOR_KEY: iteratorKey,
STEP_KEY: stepKey,
OBJECT: node.right,
BODY: null
});
var isLabeledParent = t.isLabeledStatement(parent);
var tryBody = template[3].block.body;
var loop = tryBody[0];
if (isLabeledParent) {
tryBody[0] = t.labeledStatement(parent.label, loop);
}
//
return {
replaceParent: isLabeledParent,
declar: declar,
loop: loop,
node: template
};
};
},{"179":179,"182":182,"43":43}],97:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
var metadata = {
group: "builtin-pre"
};
exports.metadata = metadata;
var visitor = {
Literal: function Literal(node) {
// number octal like 0b10 or 0o70
if (typeof node.value === "number" && /^0[ob]/i.test(node.raw)) {
node.raw = undefined;
}
// unicode escape
if (typeof node.value === "string" && /\\[u]/gi.test(node.raw)) {
node.raw = undefined;
}
}
};
exports.visitor = visitor;
},{}],98:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
function keepBlockHoist(node, nodes) {
if (node._blockHoist) {
for (var i = 0; i < nodes.length; i++) {
nodes[i]._blockHoist = node._blockHoist;
}
}
}
var metadata = {
group: "builtin-modules"
};
exports.metadata = metadata;
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
ImportDeclaration: function ImportDeclaration(node, parent, scope, file) {
// flow type
if (node.importKind === "type" || node.importKind === "typeof") return;
var nodes = [];
if (node.specifiers.length) {
var _arr = node.specifiers;
for (var _i = 0; _i < _arr.length; _i++) {
var specifier = _arr[_i];
file.moduleFormatter.importSpecifier(specifier, node, nodes, scope);
}
} else {
file.moduleFormatter.importDeclaration(node, nodes, scope);
}
if (nodes.length === 1) {
// inherit `_blockHoist` - this is for `_blockHoist` in File.prototype.addImport
nodes[0]._blockHoist = node._blockHoist;
}
return nodes;
},
/**
* [Please add a description.]
*/
ExportAllDeclaration: function ExportAllDeclaration(node, parent, scope, file) {
var nodes = [];
file.moduleFormatter.exportAllDeclaration(node, nodes, scope);
keepBlockHoist(node, nodes);
return nodes;
},
/**
* [Please add a description.]
*/
ExportDefaultDeclaration: function ExportDefaultDeclaration(node, parent, scope, file) {
var nodes = [];
file.moduleFormatter.exportDeclaration(node, nodes, scope);
keepBlockHoist(node, nodes);
return nodes;
},
/**
* [Please add a description.]
*/
ExportNamedDeclaration: function ExportNamedDeclaration(node, parent, scope, file) {
// flow type
if (this.get("declaration").isTypeAlias()) return;
var nodes = [];
if (node.declaration) {
// make sure variable exports have an initializer
// this is done here to avoid duplicating it in the module formatters
if (t.isVariableDeclaration(node.declaration)) {
var declar = node.declaration.declarations[0];
declar.init = declar.init || t.identifier("undefined");
}
file.moduleFormatter.exportDeclaration(node, nodes, scope);
} else if (node.specifiers) {
for (var i = 0; i < node.specifiers.length; i++) {
file.moduleFormatter.exportSpecifier(node.specifiers[i], node, nodes, scope);
}
}
keepBlockHoist(node, nodes);
return nodes;
}
};
exports.visitor = visitor;
},{"179":179}],99:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _helpersReplaceSupers = _dereq_(65);
var _helpersReplaceSupers2 = _interopRequireDefault(_helpersReplaceSupers);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
function Property(path, node, scope, getObjectRef, file) {
if (!node.method && node.kind === "init") return;
if (!t.isFunction(node.value)) return;
var replaceSupers = new _helpersReplaceSupers2["default"]({
getObjectRef: getObjectRef,
methodNode: node,
methodPath: path,
isStatic: true,
scope: scope,
file: file
});
replaceSupers.replace();
}
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
ObjectExpression: function ObjectExpression(node, parent, scope, file) {
var objectRef;
var getObjectRef = function getObjectRef() {
return objectRef = objectRef || scope.generateUidIdentifier("obj");
};
var propPaths = this.get("properties");
for (var i = 0; i < node.properties.length; i++) {
Property(propPaths[i], node.properties[i], scope, getObjectRef, file);
}
if (objectRef) {
scope.push({ id: objectRef });
return t.assignmentExpression("=", objectRef, node);
}
}
};
exports.visitor = visitor;
},{"179":179,"65":65}],100:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _helpersCallDelegate = _dereq_(56);
var _helpersCallDelegate2 = _interopRequireDefault(_helpersCallDelegate);
var _helpersGetFunctionArity = _dereq_(59);
var _helpersGetFunctionArity2 = _interopRequireDefault(_helpersGetFunctionArity);
var _util = _dereq_(182);
var util = _interopRequireWildcard(_util);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
var hasDefaults = function hasDefaults(node) {
for (var i = 0; i < node.params.length; i++) {
if (!t.isIdentifier(node.params[i])) return true;
}
return false;
};
/**
* [Please add a description.]
*/
var iifeVisitor = {
/**
* [Please add a description.]
*/
ReferencedIdentifier: function ReferencedIdentifier(node, parent, scope, state) {
if (node.name !== "eval") {
if (!state.scope.hasOwnBinding(node.name)) return;
if (state.scope.bindingIdentifierEquals(node.name, node)) return;
}
state.iife = true;
this.stop();
}
};
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
Function: function Function(node, parent, scope, file) {
if (!hasDefaults(node)) return;
// ensure it's a block, useful for arrow functions
this.ensureBlock();
var state = {
iife: false,
scope: scope
};
var body = [];
//
var argsIdentifier = t.identifier("arguments");
argsIdentifier._shadowedFunctionLiteral = this;
// push a default parameter definition
function pushDefNode(left, right, i) {
var defNode;
if (exceedsLastNonDefault(i) || t.isPattern(left) || file.transformers["es6.spec.blockScoping"].canTransform()) {
defNode = util.template("default-parameter", {
VARIABLE_NAME: left,
DEFAULT_VALUE: right,
ARGUMENT_KEY: t.literal(i),
ARGUMENTS: argsIdentifier
}, true);
} else {
defNode = util.template("default-parameter-assign", {
VARIABLE_NAME: left,
DEFAULT_VALUE: right
}, true);
}
defNode._blockHoist = node.params.length - i;
body.push(defNode);
}
// check if an index exceeds the functions arity
function exceedsLastNonDefault(i) {
return i + 1 > lastNonDefaultParam;
}
//
var lastNonDefaultParam = _helpersGetFunctionArity2["default"](node);
//
var params = this.get("params");
for (var i = 0; i < params.length; i++) {
var param = params[i];
if (!param.isAssignmentPattern()) {
if (!param.isIdentifier()) {
param.traverse(iifeVisitor, state);
}
if (file.transformers["es6.spec.blockScoping"].canTransform() && param.isIdentifier()) {
pushDefNode(param.node, t.identifier("undefined"), i);
}
continue;
}
var left = param.get("left");
var right = param.get("right");
if (exceedsLastNonDefault(i) || left.isPattern()) {
var placeholder = scope.generateUidIdentifier("x");
placeholder._isDefaultPlaceholder = true;
node.params[i] = placeholder;
} else {
node.params[i] = left.node;
}
if (!state.iife) {
if (right.isIdentifier() && scope.hasOwnBinding(right.node.name)) {
state.iife = true;
} else {
right.traverse(iifeVisitor, state);
}
}
pushDefNode(left.node, right.node, i);
}
// we need to cut off all trailing default parameters
node.params = node.params.slice(0, lastNonDefaultParam);
if (state.iife) {
body.push(_helpersCallDelegate2["default"](node, scope));
node.body = t.blockStatement(body);
} else {
node.body.body = body.concat(node.body.body);
}
}
};
exports.visitor = visitor;
},{"179":179,"182":182,"56":56,"59":59}],101:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _traversalVisitors = _dereq_(168);
var visitors = _interopRequireWildcard(_traversalVisitors);
var _default = _dereq_(100);
var def = _interopRequireWildcard(_default);
var _rest = _dereq_(102);
var rest = _interopRequireWildcard(_rest);
var metadata = {
group: "builtin-advanced"
};
exports.metadata = metadata;
/**
* [Please add a description.]
*/
var visitor = visitors.merge([rest.visitor, def.visitor]);
exports.visitor = visitor;
},{"100":100,"102":102,"168":168}],102:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _util = _dereq_(182);
var util = _interopRequireWildcard(_util);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
var memberExpressionOptimisationVisitor = {
/**
* [Please add a description.]
*/
Scope: function Scope(node, parent, scope, state) {
// check if this scope has a local binding that will shadow the rest parameter
if (!scope.bindingIdentifierEquals(state.name, state.outerBinding)) {
this.skip();
}
},
/**
* [Please add a description.]
*/
Flow: function Flow() {
// don't touch reference in type annotations
this.skip();
},
/**
* [Please add a description.]
*/
Function: function Function(node, parent, scope, state) {
// skip over functions as whatever `arguments` we reference inside will refer
// to the wrong function
var oldNoOptimise = state.noOptimise;
state.noOptimise = true;
this.traverse(memberExpressionOptimisationVisitor, state);
state.noOptimise = oldNoOptimise;
this.skip();
},
/**
* [Please add a description.]
*/
ReferencedIdentifier: function ReferencedIdentifier(node, parent, scope, state) {
// we can't guarantee the purity of arguments
if (node.name === "arguments") {
state.deopted = true;
}
// is this a referenced identifier and is it referencing the rest parameter?
if (node.name !== state.name) return;
if (state.noOptimise) {
state.deopted = true;
} else {
if (this.parentPath.isMemberExpression({ computed: true, object: node })) {
// if we know that this member expression is referencing a number then we can safely
// optimise it
var prop = this.parentPath.get("property");
if (prop.isBaseType("number")) {
state.candidates.push(this);
return;
}
}
// optimise single spread args in calls
if (this.parentPath.isSpreadElement() && state.offset === 0) {
var call = this.parentPath.parentPath;
if (call.isCallExpression() && call.node.arguments.length === 1) {
state.candidates.push(this);
return;
}
}
state.references.push(this);
}
},
/**
* Deopt on use of a binding identifier with the same name as our rest param.
*
* See https://github.com/babel/babel/issues/2091
*/
BindingIdentifier: function BindingIdentifier(node, parent, scope, state) {
if (node.name === state.name) {
state.deopted = true;
}
}
};
/**
* [Please add a description.]
*/
function optimiseMemberExpression(parent, offset) {
if (offset === 0) return;
var newExpr;
var prop = parent.property;
if (t.isLiteral(prop)) {
prop.value += offset;
prop.raw = String(prop.value);
} else {
// // UnaryExpression, BinaryExpression
newExpr = t.binaryExpression("+", prop, t.literal(offset));
parent.property = newExpr;
}
}
/**
* [Please add a description.]
*/
function hasRest(node) {
return t.isRestElement(node.params[node.params.length - 1]);
}
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
Function: function Function(node, parent, scope) {
if (!hasRest(node)) return;
var restParam = node.params.pop();
var rest = restParam.argument;
var argsId = t.identifier("arguments");
// otherwise `arguments` will be remapped in arrow functions
argsId._shadowedFunctionLiteral = this;
// support patterns
if (t.isPattern(rest)) {
var pattern = rest;
rest = scope.generateUidIdentifier("ref");
var declar = t.variableDeclaration("let", pattern.elements.map(function (elem, index) {
var accessExpr = t.memberExpression(rest, t.literal(index), true);
return t.variableDeclarator(elem, accessExpr);
}));
node.body.body.unshift(declar);
}
// check and optimise for extremely common cases
var state = {
references: [],
offset: node.params.length,
argumentsNode: argsId,
outerBinding: scope.getBindingIdentifier(rest.name),
// candidate member expressions we could optimise if there are no other references
candidates: [],
// local rest binding name
name: rest.name,
// whether any references to the rest parameter were made in a function
deopted: false
};
this.traverse(memberExpressionOptimisationVisitor, state);
if (!state.deopted && !state.references.length) {
// we only have shorthands and there are no other references
if (state.candidates.length) {
var _arr = state.candidates;
for (var _i = 0; _i < _arr.length; _i++) {
var candidate = _arr[_i];
candidate.replaceWith(argsId);
if (candidate.parentPath.isMemberExpression()) {
optimiseMemberExpression(candidate.parent, state.offset);
}
}
}
return;
} else {
state.references = state.references.concat(state.candidates);
}
// deopt shadowed functions as transforms like regenerator may try touch the allocation loop
state.deopted = state.deopted || !!node.shadow;
//
var start = t.literal(node.params.length);
var key = scope.generateUidIdentifier("key");
var len = scope.generateUidIdentifier("len");
var arrKey = key;
var arrLen = len;
if (node.params.length) {
// this method has additional params, so we need to subtract
// the index of the current argument position from the
// position in the array that we want to populate
arrKey = t.binaryExpression("-", key, start);
// we need to work out the size of the array that we're
// going to store all the rest parameters
//
// we need to add a check to avoid constructing the array
// with <0 if there are less arguments than params as it'll
// cause an error
arrLen = t.conditionalExpression(t.binaryExpression(">", len, start), t.binaryExpression("-", len, start), t.literal(0));
}
var loop = util.template("rest", {
ARRAY_TYPE: restParam.typeAnnotation,
ARGUMENTS: argsId,
ARRAY_KEY: arrKey,
ARRAY_LEN: arrLen,
START: start,
ARRAY: rest,
KEY: key,
LEN: len
});
if (state.deopted) {
loop._blockHoist = node.params.length + 1;
node.body.body.unshift(loop);
} else {
// perform allocation at the lowest common denominator of all references
loop._blockHoist = 1;
var target = this.getEarliestCommonAncestorFrom(state.references).getStatementParent();
// don't perform the allocation inside a loop
var highestLoop;
target.findParent(function (path) {
if (path.isLoop()) {
highestLoop = path;
} else if (path.isFunction()) {
// stop crawling up for functions
return true;
}
});
if (highestLoop) target = highestLoop;
target.insertBefore(loop);
}
}
};
exports.visitor = visitor;
},{"179":179,"182":182}],103:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
function loose(node, body, objId) {
var _arr = node.properties;
for (var _i = 0; _i < _arr.length; _i++) {
var prop = _arr[_i];
body.push(t.expressionStatement(t.assignmentExpression("=", t.memberExpression(objId, prop.key, prop.computed || t.isLiteral(prop.key)), prop.value)));
}
}
/**
* [Please add a description.]
*/
function spec(node, body, objId, initProps, file) {
// add a simple assignment for all Symbol member expressions due to symbol polyfill limitations
// otherwise use Object.defineProperty
var _arr2 = node.properties;
for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
var prop = _arr2[_i2];
// this wont work with Object.defineProperty
if (t.isLiteral(t.toComputedKey(prop), { value: "__proto__" })) {
initProps.push(prop);
continue;
}
var key = prop.key;
if (t.isIdentifier(key) && !prop.computed) {
key = t.literal(key.name);
}
var bodyNode = t.callExpression(file.addHelper("define-property"), [objId, key, prop.value]);
body.push(t.expressionStatement(bodyNode));
}
// only one node and it's a Object.defineProperty that returns the object
if (body.length === 1) {
var first = body[0].expression;
if (t.isCallExpression(first)) {
first.arguments[0] = t.objectExpression(initProps);
return first;
}
}
}
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
ObjectExpression: {
exit: function exit(node, parent, scope, file) {
var hasComputed = false;
var _arr3 = node.properties;
for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
var prop = _arr3[_i3];
hasComputed = t.isProperty(prop, { computed: true, kind: "init" });
if (hasComputed) break;
}
if (!hasComputed) return;
// put all getters/setters into the first object expression as well as all initialisers up
// to the first computed property
var initProps = [];
var stopInits = false;
node.properties = node.properties.filter(function (prop) {
if (prop.computed) {
stopInits = true;
}
if (prop.kind !== "init" || !stopInits) {
initProps.push(prop);
return false;
} else {
return true;
}
});
//
var objId = scope.generateUidIdentifierBasedOnNode(parent);
//
var body = [];
//
var callback = spec;
if (file.isLoose("es6.properties.computed")) callback = loose;
var result = callback(node, body, objId, initProps, file);
if (result) return result;
//
body.unshift(t.variableDeclaration("var", [t.variableDeclarator(objId, t.objectExpression(initProps))]));
body.push(t.expressionStatement(objId));
return body;
}
}
};
exports.visitor = visitor;
},{"179":179}],104:[function(_dereq_,module,exports){
/**
* [Please add a description.]
*/
"use strict";
exports.__esModule = true;
var visitor = {
/**
* [Please add a description.]
*/
Property: function Property(node) {
if (node.method) {
node.method = false;
}
if (node.shorthand) {
node.shorthand = false;
}
}
};
exports.visitor = visitor;
},{}],105:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _helpersRegex = _dereq_(63);
var regex = _interopRequireWildcard(_helpersRegex);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
Literal: function Literal(node) {
if (!regex.is(node, "y")) return;
return t.newExpression(t.identifier("RegExp"), [t.literal(node.regex.pattern), t.literal(node.regex.flags)]);
}
};
exports.visitor = visitor;
},{"179":179,"63":63}],106:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _regexpuRewritePattern = _dereq_(583);
var _regexpuRewritePattern2 = _interopRequireDefault(_regexpuRewritePattern);
var _helpersRegex = _dereq_(63);
var regex = _interopRequireWildcard(_helpersRegex);
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
Literal: function Literal(node) {
if (!regex.is(node, "u")) return;
node.regex.pattern = _regexpuRewritePattern2["default"](node.regex.pattern, node.regex.flags);
regex.pullFlag(node, "u");
}
};
exports.visitor = visitor;
},{"583":583,"63":63}],107:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
var metadata = {
group: "builtin-pre",
optional: true
};
exports.metadata = metadata;
var visitor = {
ArrowFunctionExpression: function ArrowFunctionExpression(node, parent, scope, file) {
if (node.shadow) return;
node.shadow = { "this": false };
var boundThis = t.thisExpression();
boundThis._forceShadow = this;
// make sure that arrow function won't be instantiated
t.ensureBlock(node);
this.get("body").unshiftContainer("body", t.expressionStatement(t.callExpression(file.addHelper("new-arrow-check"), [t.thisExpression(), boundThis])));
return t.callExpression(t.memberExpression(node, t.identifier("bind")), [t.thisExpression()]);
}
};
exports.visitor = visitor;
},{"179":179}],108:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
function buildAssert(node, file) {
return t.callExpression(file.addHelper("temporal-assert-defined"), [node, t.literal(node.name), file.addHelper("temporal-undefined")]);
}
/**
* [Please add a description.]
*/
function references(node, scope, state) {
var declared = state.letRefs[node.name];
if (!declared) return false;
// declared node is different in this scope
return scope.getBindingIdentifier(node.name) === declared;
}
/**
* [Please add a description.]
*/
var refVisitor = {
/**
* [Please add a description.]
*/
ReferencedIdentifier: function ReferencedIdentifier(node, parent, scope, state) {
if (t.isFor(parent) && parent.left === node) return;
if (!references(node, scope, state)) return;
var assert = buildAssert(node, state.file);
this.skip();
if (t.isUpdateExpression(parent)) {
if (parent._ignoreBlockScopingTDZ) return;
this.parentPath.replaceWith(t.sequenceExpression([assert, parent]));
} else {
return t.logicalExpression("&&", assert, node);
}
},
/**
* [Please add a description.]
*/
AssignmentExpression: {
exit: function exit(node, parent, scope, state) {
if (node._ignoreBlockScopingTDZ) return;
var nodes = [];
var ids = this.getBindingIdentifiers();
for (var name in ids) {
var id = ids[name];
if (references(id, scope, state)) {
nodes.push(buildAssert(id, state.file));
}
}
if (nodes.length) {
node._ignoreBlockScopingTDZ = true;
nodes.push(node);
return nodes.map(t.expressionStatement);
}
}
}
};
var metadata = {
optional: true,
group: "builtin-advanced"
};
exports.metadata = metadata;
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
"Program|Loop|BlockStatement": {
exit: function exit(node, parent, scope, file) {
var letRefs = node._letReferences;
if (!letRefs) return;
this.traverse(refVisitor, {
letRefs: letRefs,
file: file
});
}
}
};
exports.visitor = visitor;
},{"179":179}],109:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
var metadata = {
group: "builtin-pre",
optional: true
};
exports.metadata = metadata;
var visitor = {
Program: function Program() {
var id = this.scope.generateUidIdentifier("null");
this.unshiftContainer("body", [t.variableDeclaration("var", [t.variableDeclarator(id, t.literal(null))]), t.exportNamedDeclaration(null, [t.exportSpecifier(id, t.identifier("__proto__"))])]);
}
};
exports.visitor = visitor;
},{"179":179}],110:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
var metadata = {
optional: true
};
exports.metadata = metadata;
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
UnaryExpression: function UnaryExpression(node, parent, scope, file) {
if (node._ignoreSpecSymbols) return;
if (this.parentPath.isBinaryExpression() && t.EQUALITY_BINARY_OPERATORS.indexOf(parent.operator) >= 0) {
// optimise `typeof foo === "string"` since we can determine that they'll never need to handle symbols
var opposite = this.getOpposite();
if (opposite.isLiteral() && opposite.node.value !== "symbol" && opposite.node.value !== "object") return;
}
if (node.operator === "typeof") {
var call = t.callExpression(file.addHelper("typeof"), [node.argument]);
if (this.get("argument").isIdentifier()) {
var undefLiteral = t.literal("undefined");
var unary = t.unaryExpression("typeof", node.argument);
unary._ignoreSpecSymbols = true;
return t.conditionalExpression(t.binaryExpression("===", unary, undefLiteral), undefLiteral, call);
} else {
return call;
}
}
},
/**
* [Please add a description.]
*/
BinaryExpression: function BinaryExpression(node, parent, scope, file) {
if (node.operator === "instanceof") {
return t.callExpression(file.addHelper("instanceof"), [node.left, node.right]);
}
},
/**
* [Please add a description.]
*/
"VariableDeclaration|FunctionDeclaration": function VariableDeclarationFunctionDeclaration(node) {
if (node._generated) this.skip();
}
};
exports.visitor = visitor;
},{"179":179}],111:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
var metadata = {
optional: true,
group: "builtin-pre"
};
exports.metadata = metadata;
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
TemplateLiteral: function TemplateLiteral(node, parent) {
if (t.isTaggedTemplateExpression(parent)) return;
for (var i = 0; i < node.expressions.length; i++) {
node.expressions[i] = t.callExpression(t.identifier("String"), [node.expressions[i]]);
}
}
};
exports.visitor = visitor;
},{"179":179}],112:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
function getSpreadLiteral(spread, scope) {
if (scope.hub.file.isLoose("es6.spread") && !t.isIdentifier(spread.argument, { name: "arguments" })) {
return spread.argument;
} else {
return scope.toArray(spread.argument, true);
}
}
/**
* [Please add a description.]
*/
function hasSpread(nodes) {
for (var i = 0; i < nodes.length; i++) {
if (t.isSpreadElement(nodes[i])) {
return true;
}
}
return false;
}
/**
* [Please add a description.]
*/
function build(props, scope) {
var nodes = [];
var _props = [];
var push = function push() {
if (!_props.length) return;
nodes.push(t.arrayExpression(_props));
_props = [];
};
for (var i = 0; i < props.length; i++) {
var prop = props[i];
if (t.isSpreadElement(prop)) {
push();
nodes.push(getSpreadLiteral(prop, scope));
} else {
_props.push(prop);
}
}
push();
return nodes;
}
var metadata = {
group: "builtin-advanced"
};
exports.metadata = metadata;
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
ArrayExpression: function ArrayExpression(node, parent, scope) {
var elements = node.elements;
if (!hasSpread(elements)) return;
var nodes = build(elements, scope);
var first = nodes.shift();
if (!t.isArrayExpression(first)) {
nodes.unshift(first);
first = t.arrayExpression([]);
}
return t.callExpression(t.memberExpression(first, t.identifier("concat")), nodes);
},
/**
* [Please add a description.]
*/
CallExpression: function CallExpression(node, parent, scope) {
var args = node.arguments;
if (!hasSpread(args)) return;
var contextLiteral = t.identifier("undefined");
node.arguments = [];
var nodes;
if (args.length === 1 && args[0].argument.name === "arguments") {
nodes = [args[0].argument];
} else {
nodes = build(args, scope);
}
var first = nodes.shift();
if (nodes.length) {
node.arguments.push(t.callExpression(t.memberExpression(first, t.identifier("concat")), nodes));
} else {
node.arguments.push(first);
}
var callee = node.callee;
if (this.get("callee").isMemberExpression()) {
var temp = scope.maybeGenerateMemoised(callee.object);
if (temp) {
callee.object = t.assignmentExpression("=", temp, callee.object);
contextLiteral = temp;
} else {
contextLiteral = callee.object;
}
t.appendToMemberExpression(callee, t.identifier("apply"));
} else {
node.callee = t.memberExpression(node.callee, t.identifier("apply"));
}
node.arguments.unshift(contextLiteral);
},
/**
* [Please add a description.]
*/
NewExpression: function NewExpression(node, parent, scope, file) {
var args = node.arguments;
if (!hasSpread(args)) return;
var nodes = build(args, scope);
var context = t.arrayExpression([t.literal(null)]);
args = t.callExpression(t.memberExpression(context, t.identifier("concat")), nodes);
return t.newExpression(t.callExpression(t.memberExpression(file.addHelper("bind"), t.identifier("apply")), [node.callee, args]), []);
}
};
exports.visitor = visitor;
},{"179":179}],113:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// istanbul ignore next
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _lodashCollectionReduceRight = _dereq_(415);
var _lodashCollectionReduceRight2 = _interopRequireDefault(_lodashCollectionReduceRight);
var _messages = _dereq_(43);
var messages = _interopRequireWildcard(_messages);
var _lodashArrayFlatten = _dereq_(406);
var _lodashArrayFlatten2 = _interopRequireDefault(_lodashArrayFlatten);
var _util = _dereq_(182);
var util = _interopRequireWildcard(_util);
var _lodashCollectionMap = _dereq_(414);
var _lodashCollectionMap2 = _interopRequireDefault(_lodashCollectionMap);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
var metadata = {
group: "builtin-trailing"
};
exports.metadata = metadata;
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
Function: function Function(node, parent, scope, file) {
if (node.generator || node.async) return;
var tailCall = new TailCallTransformer(this, scope, file);
tailCall.run();
}
};
exports.visitor = visitor;
/**
* [Please add a description.]
*/
function returnBlock(expr) {
return t.blockStatement([t.returnStatement(expr)]);
}
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
enter: function enter(node, parent) {
if (t.isTryStatement(parent)) {
if (node === parent.block) {
this.skip();
} else if (parent.finalizer && node !== parent.finalizer) {
this.skip();
}
}
},
/**
* [Please add a description.]
*/
ReturnStatement: function ReturnStatement(node, parent, scope, state) {
return state.subTransform(node.argument);
},
/**
* [Please add a description.]
*/
Function: function Function() {
this.skip();
},
/**
* [Please add a description.]
*/
VariableDeclaration: function VariableDeclaration(node, parent, scope, state) {
state.vars.push(node);
},
/**
* [Please add a description.]
*/
ThisExpression: function ThisExpression(node, parent, scope, state) {
if (!state.isShadowed) {
state.needsThis = true;
state.thisPaths.push(this);
}
},
/**
* [Please add a description.]
*/
ReferencedIdentifier: function ReferencedIdentifier(node, parent, scope, state) {
if (node.name === "arguments" && (!state.isShadowed || node._shadowedFunctionLiteral)) {
state.needsArguments = true;
state.argumentsPaths.push(this);
}
}
};
/**
* [Please add a description.]
*/
var TailCallTransformer = (function () {
function TailCallTransformer(path, scope, file) {
_classCallCheck(this, TailCallTransformer);
this.hasTailRecursion = false;
this.needsArguments = false;
this.argumentsPaths = [];
this.setsArguments = false;
this.needsThis = false;
this.thisPaths = [];
this.isShadowed = path.isArrowFunctionExpression() || path.is("shadow");
this.ownerId = path.node.id;
this.vars = [];
this.scope = scope;
this.path = path;
this.file = file;
this.node = path.node;
}
/**
* [Please add a description.]
*/
TailCallTransformer.prototype.getArgumentsId = function getArgumentsId() {
return this.argumentsId = this.argumentsId || this.scope.generateUidIdentifier("arguments");
};
/**
* [Please add a description.]
*/
TailCallTransformer.prototype.getThisId = function getThisId() {
return this.thisId = this.thisId || this.scope.generateUidIdentifier("this");
};
/**
* [Please add a description.]
*/
TailCallTransformer.prototype.getLeftId = function getLeftId() {
return this.leftId = this.leftId || this.scope.generateUidIdentifier("left");
};
/**
* [Please add a description.]
*/
TailCallTransformer.prototype.getFunctionId = function getFunctionId() {
return this.functionId = this.functionId || this.scope.generateUidIdentifier("function");
};
/**
* [Please add a description.]
*/
TailCallTransformer.prototype.getAgainId = function getAgainId() {
return this.againId = this.againId || this.scope.generateUidIdentifier("again");
};
/**
* [Please add a description.]
*/
TailCallTransformer.prototype.getParams = function getParams() {
var params = this.params;
if (!params) {
params = this.node.params;
this.paramDecls = [];
for (var i = 0; i < params.length; i++) {
var param = params[i];
if (!param._isDefaultPlaceholder) {
this.paramDecls.push(t.variableDeclarator(param, params[i] = this.scope.generateUidIdentifier("x")));
}
}
}
return this.params = params;
};
/**
* [Please add a description.]
*/
TailCallTransformer.prototype.hasDeopt = function hasDeopt() {
// check if the ownerId has been reassigned, if it has then it's not safe to
// perform optimisations
var ownerIdInfo = this.scope.getBinding(this.ownerId.name);
return ownerIdInfo && !ownerIdInfo.constant;
};
/**
* [Please add a description.]
*/
TailCallTransformer.prototype.run = function run() {
var node = this.node;
// only tail recursion can be optimized as for now, so we can skip anonymous
// functions entirely
var ownerId = this.ownerId;
if (!ownerId) return;
// traverse the function and look for tail recursion
this.path.traverse(visitor, this);
// has no tail call recursion
if (!this.hasTailRecursion) return;
// the function binding isn't constant so we can't be sure that it's the same function :(
if (this.hasDeopt()) {
this.file.log.deopt(node, messages.get("tailCallReassignmentDeopt"));
return;
}
//
var body = this.path.ensureBlock().body;
for (var i = 0; i < body.length; i++) {
var bodyNode = body[i];
if (!t.isFunctionDeclaration(bodyNode)) continue;
bodyNode = body[i] = t.variableDeclaration("var", [t.variableDeclarator(bodyNode.id, t.toExpression(bodyNode))]);
bodyNode._blockHoist = 2;
}
var paramDecls = this.paramDecls;
if (paramDecls.length > 0) {
var paramDecl = t.variableDeclaration("var", paramDecls);
paramDecl._blockHoist = Infinity;
body.unshift(paramDecl);
}
body.unshift(t.expressionStatement(t.assignmentExpression("=", this.getAgainId(), t.literal(false))));
node.body = util.template("tail-call-body", {
FUNCTION_ID: this.getFunctionId(),
AGAIN_ID: this.getAgainId(),
BLOCK: node.body
});
var topVars = [];
if (this.needsThis) {
var _arr = this.thisPaths;
for (var _i = 0; _i < _arr.length; _i++) {
var path = _arr[_i];
path.replaceWith(this.getThisId());
}
topVars.push(t.variableDeclarator(this.getThisId(), t.thisExpression()));
}
if (this.needsArguments || this.setsArguments) {
var _arr2 = this.argumentsPaths;
for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
var _path = _arr2[_i2];
_path.replaceWith(this.argumentsId);
}
var decl = t.variableDeclarator(this.argumentsId);
if (this.argumentsId) {
decl.init = t.identifier("arguments");
decl.init._shadowedFunctionLiteral = this.path;
}
topVars.push(decl);
}
var leftId = this.leftId;
if (leftId) {
topVars.push(t.variableDeclarator(leftId));
}
if (topVars.length > 0) {
node.body.body.unshift(t.variableDeclaration("var", topVars));
}
};
/**
* [Please add a description.]
*/
TailCallTransformer.prototype.subTransform = function subTransform(node) {
if (!node) return;
var handler = this["subTransform" + node.type];
if (handler) return handler.call(this, node);
};
/**
* [Please add a description.]
*/
TailCallTransformer.prototype.subTransformConditionalExpression = function subTransformConditionalExpression(node) {
var callConsequent = this.subTransform(node.consequent);
var callAlternate = this.subTransform(node.alternate);
if (!callConsequent && !callAlternate) {
return;
}
// if ternary operator had tail recursion in value, convert to optimized if-statement
node.type = "IfStatement";
node.consequent = callConsequent ? t.toBlock(callConsequent) : returnBlock(node.consequent);
if (callAlternate) {
node.alternate = t.isIfStatement(callAlternate) ? callAlternate : t.toBlock(callAlternate);
} else {
node.alternate = returnBlock(node.alternate);
}
return [node];
};
/**
* [Please add a description.]
*/
TailCallTransformer.prototype.subTransformLogicalExpression = function subTransformLogicalExpression(node) {
// only call in right-value of can be optimized
var callRight = this.subTransform(node.right);
if (!callRight) return;
// cache left value as it might have side-effects
var leftId = this.getLeftId();
var testExpr = t.assignmentExpression("=", leftId, node.left);
if (node.operator === "&&") {
testExpr = t.unaryExpression("!", testExpr);
}
return [t.ifStatement(testExpr, returnBlock(leftId))].concat(callRight);
};
/**
* [Please add a description.]
*/
TailCallTransformer.prototype.subTransformSequenceExpression = function subTransformSequenceExpression(node) {
var seq = node.expressions;
// only last element can be optimized
var lastCall = this.subTransform(seq[seq.length - 1]);
if (!lastCall) {
return;
}
// remove converted expression from sequence
// and convert to regular expression if needed
if (--seq.length === 1) {
node = seq[0];
}
return [t.expressionStatement(node)].concat(lastCall);
};
/**
* [Please add a description.]
*/
TailCallTransformer.prototype.subTransformCallExpression = function subTransformCallExpression(node) {
var callee = node.callee;
var thisBinding, args;
if (t.isMemberExpression(callee, { computed: false }) && t.isIdentifier(callee.property)) {
switch (callee.property.name) {
case "call":
args = t.arrayExpression(node.arguments.slice(1));
break;
case "apply":
args = node.arguments[1] || t.identifier("undefined");
this.needsArguments = true;
break;
default:
return;
}
thisBinding = node.arguments[0];
callee = callee.object;
}
// only tail recursion can be optimized as for now
if (!t.isIdentifier(callee) || !this.scope.bindingIdentifierEquals(callee.name, this.ownerId)) {
return;
}
this.hasTailRecursion = true;
if (this.hasDeopt()) return;
var body = [];
if (this.needsThis && !t.isThisExpression(thisBinding)) {
body.push(t.expressionStatement(t.assignmentExpression("=", this.getThisId(), thisBinding || t.identifier("undefined"))));
}
if (!args) {
args = t.arrayExpression(node.arguments);
}
var argumentsId = this.getArgumentsId();
var params = this.getParams();
if (this.needsArguments) {
body.push(t.expressionStatement(t.assignmentExpression("=", argumentsId, args)));
}
if (t.isArrayExpression(args)) {
var elems = args.elements;
// pad out the args so all the function args are reset - https://github.com/babel/babel/issues/1938
while (elems.length < params.length) {
elems.push(t.identifier("undefined"));
}
for (var i = 0; i < elems.length; i++) {
var param = params[i];
var elem = elems[i];
if (param && !param._isDefaultPlaceholder) {
elems[i] = t.assignmentExpression("=", param, elem);
} else {
// exceeds parameters but push it anyway to ensure correct execution
}
}
if (!this.needsArguments) {
var _arr3 = elems;
for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
var elem = _arr3[_i3];
// only push expressions that we really need, this will skip pure arguments that exceed the
// parameter length of the current function
if (!this.scope.isPure(elem)) {
body.push(t.expressionStatement(elem));
}
}
}
} else {
this.setsArguments = true;
for (var i = 0; i < params.length; i++) {
var param = params[i];
if (!param._isDefaultPlaceholder) {
body.push(t.expressionStatement(t.assignmentExpression("=", param, t.memberExpression(argumentsId, t.literal(i), true))));
}
}
}
body.push(t.expressionStatement(t.assignmentExpression("=", this.getAgainId(), t.literal(true))));
if (this.vars.length > 0) {
var declarations = _lodashArrayFlatten2["default"](_lodashCollectionMap2["default"](this.vars, function (decl) {
return decl.declarations;
}));
var assignment = _lodashCollectionReduceRight2["default"](declarations, function (expr, decl) {
return t.assignmentExpression("=", decl.id, expr);
}, t.identifier("undefined"));
var statement = t.expressionStatement(assignment);
body.push(statement);
}
body.push(t.continueStatement(this.getFunctionId()));
return body;
};
return TailCallTransformer;
})();
},{"179":179,"182":182,"406":406,"414":414,"415":415,"43":43}],114:[function(_dereq_,module,exports){
/* eslint no-unused-vars: 0 */
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
var metadata = {
group: "builtin-pre"
};
exports.metadata = metadata;
/**
* [Please add a description.]
*/
function isString(node) {
return t.isLiteral(node) && typeof node.value === "string";
}
/**
* [Please add a description.]
*/
function buildBinaryExpression(left, right) {
var node = t.binaryExpression("+", left, right);
node._templateLiteralProduced = true;
return node;
}
/**
* [Please add a description.]
*/
function crawl(path) {
if (path.is("_templateLiteralProduced")) {
crawl(path.get("left"));
crawl(path.get("right"));
} else if (!path.isBaseType("string") && !path.isBaseType("number")) {
path.replaceWith(t.callExpression(t.identifier("String"), [path.node]));
}
}
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
TaggedTemplateExpression: function TaggedTemplateExpression(node, parent, scope, file) {
var quasi = node.quasi;
var args = [];
var strings = [];
var raw = [];
var _arr = quasi.quasis;
for (var _i = 0; _i < _arr.length; _i++) {
var elem = _arr[_i];
strings.push(t.literal(elem.value.cooked));
raw.push(t.literal(elem.value.raw));
}
strings = t.arrayExpression(strings);
raw = t.arrayExpression(raw);
var templateName = "tagged-template-literal";
if (file.isLoose("es6.templateLiterals")) templateName += "-loose";
var templateObject = file.addTemplateObject(templateName, strings, raw);
args.push(templateObject);
args = args.concat(quasi.expressions);
return t.callExpression(node.tag, args);
},
/**
* [Please add a description.]
*/
TemplateLiteral: function TemplateLiteral(node, parent, scope, file) {
var nodes = [];
var _arr2 = node.quasis;
for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
var elem = _arr2[_i2];
nodes.push(t.literal(elem.value.cooked));
var expr = node.expressions.shift();
if (expr) nodes.push(expr);
}
// filter out empty string literals
nodes = nodes.filter(function (n) {
return !t.isLiteral(n, { value: "" });
});
// since `+` is left-to-right associative
// ensure the first node is a string if first/second isn't
if (!isString(nodes[0]) && !isString(nodes[1])) {
nodes.unshift(t.literal(""));
}
if (nodes.length > 1) {
var root = buildBinaryExpression(nodes.shift(), nodes.shift());
var _arr3 = nodes;
for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
var _node = _arr3[_i3];
root = buildBinaryExpression(root, _node);
}
this.replaceWith(root);
//crawl(this);
} else {
return nodes[0];
}
}
};
exports.visitor = visitor;
},{"179":179}],115:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
var metadata = {
stage: 3
};
exports.metadata = metadata;
},{}],116:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
var metadata = {
stage: 1,
dependencies: ["es6.classes"]
};
exports.metadata = metadata;
},{}],117:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _helpersBuildComprehension = _dereq_(54);
var _helpersBuildComprehension2 = _interopRequireDefault(_helpersBuildComprehension);
var _traversal = _dereq_(148);
var _traversal2 = _interopRequireDefault(_traversal);
var _util = _dereq_(182);
var util = _interopRequireWildcard(_util);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
var metadata = {
stage: 0
};
exports.metadata = metadata;
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
ComprehensionExpression: function ComprehensionExpression(node, parent, scope) {
var callback = array;
if (node.generator) callback = generator;
return callback(node, parent, scope);
}
};
exports.visitor = visitor;
/**
* [Please add a description.]
*/
function generator(node) {
var body = [];
var container = t.functionExpression(null, [], t.blockStatement(body), true);
container.shadow = true;
body.push(_helpersBuildComprehension2["default"](node, function () {
return t.expressionStatement(t.yieldExpression(node.body));
}));
return t.callExpression(container, []);
}
/**
* [Please add a description.]
*/
function array(node, parent, scope) {
var uid = scope.generateUidIdentifierBasedOnNode(parent);
var container = util.template("array-comprehension-container", {
KEY: uid
});
container.callee.shadow = true;
var block = container.callee.body;
var body = block.body;
if (_traversal2["default"].hasType(node, scope, "YieldExpression", t.FUNCTION_TYPES)) {
container.callee.generator = true;
container = t.yieldExpression(container, true);
}
var returnStatement = body.pop();
body.push(_helpersBuildComprehension2["default"](node, function () {
return util.template("array-push", {
STATEMENT: node.body,
KEY: uid
}, true);
}));
body.push(returnStatement);
return container;
}
},{"148":148,"179":179,"182":182,"54":54}],118:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _helpersMemoiseDecorators = _dereq_(60);
var _helpersMemoiseDecorators2 = _interopRequireDefault(_helpersMemoiseDecorators);
var _helpersDefineMap = _dereq_(57);
var defineMap = _interopRequireWildcard(_helpersDefineMap);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
var metadata = {
dependencies: ["es6.classes"],
optional: true,
stage: 1
};
exports.metadata = metadata;
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
ObjectExpression: function ObjectExpression(node, parent, scope, file) {
var hasDecorators = false;
for (var i = 0; i < node.properties.length; i++) {
var prop = node.properties[i];
if (prop.decorators) {
hasDecorators = true;
break;
}
}
if (!hasDecorators) return;
var mutatorMap = {};
for (var i = 0; i < node.properties.length; i++) {
var prop = node.properties[i];
if (prop.decorators) _helpersMemoiseDecorators2["default"](prop.decorators, scope);
if (prop.kind === "init" && !prop.method) {
prop.kind = "";
prop.value = t.functionExpression(null, [], t.blockStatement([t.returnStatement(prop.value)]));
}
defineMap.push(mutatorMap, prop, "initializer", file);
}
var obj = defineMap.toClassObject(mutatorMap);
obj = defineMap.toComputedObjectFromClass(obj);
return t.callExpression(file.addHelper("create-decorated-object"), [obj]);
}
};
exports.visitor = visitor;
},{"179":179,"57":57,"60":60}],119:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
var metadata = {
optional: true,
stage: 0
};
exports.metadata = metadata;
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
DoExpression: function DoExpression(node) {
var body = node.body.body;
if (body.length) {
return body;
} else {
return t.identifier("undefined");
}
}
};
exports.visitor = visitor;
},{"179":179}],120:[function(_dereq_,module,exports){
// https://github.com/rwaldron/exponentiation-operator
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _helpersBuildBinaryAssignmentOperatorTransformer = _dereq_(53);
var _helpersBuildBinaryAssignmentOperatorTransformer2 = _interopRequireDefault(_helpersBuildBinaryAssignmentOperatorTransformer);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
var metadata = {
stage: 3
};
exports.metadata = metadata;
var MATH_POW = t.memberExpression(t.identifier("Math"), t.identifier("pow"));
/**
* [Please add a description.]
*/
var visitor = _helpersBuildBinaryAssignmentOperatorTransformer2["default"]({
operator: "**",
/**
* [Please add a description.]
*/
build: function build(left, right) {
return t.callExpression(MATH_POW, [left, right]);
}
});
exports.visitor = visitor;
},{"179":179,"53":53}],121:[function(_dereq_,module,exports){
// https://github.com/leebyron/ecmascript-more-export-from
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
var metadata = {
stage: 1
};
exports.metadata = metadata;
/**
* [Please add a description.]
*/
function build(node, nodes, scope) {
var first = node.specifiers[0];
if (!t.isExportNamespaceSpecifier(first) && !t.isExportDefaultSpecifier(first)) return;
var specifier = node.specifiers.shift();
var uid = scope.generateUidIdentifier(specifier.exported.name);
var newSpecifier;
if (t.isExportNamespaceSpecifier(specifier)) {
newSpecifier = t.importNamespaceSpecifier(uid);
} else {
newSpecifier = t.importDefaultSpecifier(uid);
}
nodes.push(t.importDeclaration([newSpecifier], node.source));
nodes.push(t.exportNamedDeclaration(null, [t.exportSpecifier(uid, specifier.exported)]));
build(node, nodes, scope);
}
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
ExportNamedDeclaration: function ExportNamedDeclaration(node, parent, scope) {
var nodes = [];
build(node, nodes, scope);
if (!nodes.length) return;
if (node.specifiers.length >= 1) {
nodes.push(node);
}
return nodes;
}
};
exports.visitor = visitor;
},{"179":179}],122:[function(_dereq_,module,exports){
// https://github.com/zenparsing/es-function-bind
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
var metadata = {
optional: true,
stage: 0
};
exports.metadata = metadata;
/**
* [Please add a description.]
*/
function getTempId(scope) {
var id = scope.path.getData("functionBind");
if (id) return id;
id = scope.generateDeclaredUidIdentifier("context");
return scope.path.setData("functionBind", id);
}
/**
* [Please add a description.]
*/
function getStaticContext(bind, scope) {
var object = bind.object || bind.callee.object;
return scope.isStatic(object) && object;
}
/**
* [Please add a description.]
*/
function inferBindContext(bind, scope) {
var staticContext = getStaticContext(bind, scope);
if (staticContext) return staticContext;
var tempId = getTempId(scope);
if (bind.object) {
bind.callee = t.sequenceExpression([t.assignmentExpression("=", tempId, bind.object), bind.callee]);
} else {
bind.callee.object = t.assignmentExpression("=", tempId, bind.callee.object);
}
return tempId;
}
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
CallExpression: function CallExpression(node, parent, scope) {
var bind = node.callee;
if (!t.isBindExpression(bind)) return;
var context = inferBindContext(bind, scope);
node.callee = t.memberExpression(bind.callee, t.identifier("call"));
node.arguments.unshift(context);
},
/**
* [Please add a description.]
*/
BindExpression: function BindExpression(node, parent, scope) {
var context = inferBindContext(node, scope);
return t.callExpression(t.memberExpression(node.callee, t.identifier("bind")), [context]);
}
};
exports.visitor = visitor;
},{"179":179}],123:[function(_dereq_,module,exports){
// https://github.com/sebmarkbage/ecmascript-rest-spread
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
var metadata = {
stage: 2,
dependencies: ["es6.destructuring"]
};
exports.metadata = metadata;
/**
* [Please add a description.]
*/
var hasSpread = function hasSpread(node) {
for (var i = 0; i < node.properties.length; i++) {
if (t.isSpreadProperty(node.properties[i])) {
return true;
}
}
return false;
};
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
ObjectExpression: function ObjectExpression(node, parent, scope, file) {
if (!hasSpread(node)) return;
var args = [];
var props = [];
var push = function push() {
if (!props.length) return;
args.push(t.objectExpression(props));
props = [];
};
for (var i = 0; i < node.properties.length; i++) {
var prop = node.properties[i];
if (t.isSpreadProperty(prop)) {
push();
args.push(prop.argument);
} else {
props.push(prop);
}
}
push();
if (!t.isObjectExpression(args[0])) {
args.unshift(t.objectExpression([]));
}
return t.callExpression(file.addHelper("extends"), args);
}
};
exports.visitor = visitor;
},{"179":179}],124:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
var metadata = {
stage: 2
};
exports.metadata = metadata;
},{}],125:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports.internal = internal;
exports.blacklist = blacklist;
exports.whitelist = whitelist;
exports.stage = stage;
exports.optional = optional;
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _lodashCollectionIncludes = _dereq_(413);
var _lodashCollectionIncludes2 = _interopRequireDefault(_lodashCollectionIncludes);
/**
* [Please add a description.]
*/
function internal(transformer) {
if (transformer.key[0] === "_") return true;
}
/**
* [Please add a description.]
*/
function blacklist(transformer, opts) {
var blacklist = opts.blacklist;
if (blacklist.length && _lodashCollectionIncludes2["default"](blacklist, transformer.key)) return false;
}
/**
* [Please add a description.]
*/
function whitelist(transformer, opts) {
var whitelist = opts.whitelist;
if (whitelist) return _lodashCollectionIncludes2["default"](whitelist, transformer.key);
}
/**
* [Please add a description.]
*/
function stage(transformer, opts) {
var stage = transformer.metadata.stage;
if (stage != null && stage >= opts.stage) return true;
}
/**
* [Please add a description.]
*/
function optional(transformer, opts) {
if (transformer.metadata.optional && !_lodashCollectionIncludes2["default"](opts.optional, transformer.key)) return false;
}
},{"413":413}],126:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports["default"] = {
//- builtin-prepass
"minification.constantFolding": _dereq_(183),
//- builtin-pre
strict: _dereq_(142),
eval: _dereq_(185),
_validation: _dereq_(132),
_hoistDirectives: _dereq_(128),
"minification.removeDebugger": _dereq_(194),
"minification.removeConsole": _dereq_(193),
"utility.inlineEnvironmentVariables": _dereq_(186),
"minification.deadCodeElimination": _dereq_(184),
_modules: _dereq_(130),
"react.displayName": _dereq_(192),
"es6.spec.modules": _dereq_(109),
"es6.spec.arrowFunctions": _dereq_(107),
"es6.spec.templateLiterals": _dereq_(111),
"es6.templateLiterals": _dereq_(114),
"es6.literals": _dereq_(97),
"validation.undeclaredVariableCheck": _dereq_(197),
//- builtin-basic
// this is where the bulk of the ES6 transformations take place, none of them require traversal state
// so they can all be concatenated together for performance
"spec.functionName": _dereq_(144),
"es7.classProperties": _dereq_(116),
"es7.trailingFunctionCommas": _dereq_(124),
"es7.asyncFunctions": _dereq_(115),
"es7.decorators": _dereq_(118),
"validation.react": _dereq_(145),
"es6.arrowFunctions": _dereq_(89),
"spec.blockScopedFunctions": _dereq_(143),
"optimisation.react.constantElements": _dereq_(191),
"optimisation.react.inlineElements": _dereq_(135),
"es7.comprehensions": _dereq_(117),
"es6.classes": _dereq_(91),
asyncToGenerator: _dereq_(136),
bluebirdCoroutines: _dereq_(137),
"es6.objectSuper": _dereq_(99),
"es7.objectRestSpread": _dereq_(123),
"es7.exponentiationOperator": _dereq_(120),
"es5.properties.mutators": _dereq_(88),
"es6.properties.shorthand": _dereq_(104),
"es6.properties.computed": _dereq_(103),
"optimisation.flow.forOf": _dereq_(133),
"es6.forOf": _dereq_(96),
"es6.regex.sticky": _dereq_(105),
"es6.regex.unicode": _dereq_(106),
"es6.constants": _dereq_(94),
"es7.exportExtensions": _dereq_(121),
"spec.protoToAssign": _dereq_(190),
"es7.doExpressions": _dereq_(119),
"es6.spec.symbols": _dereq_(110),
"es7.functionBind": _dereq_(122),
"spec.undefinedToVoid": _dereq_(199),
//- builtin-advanced
"es6.spread": _dereq_(112),
"es6.parameters": _dereq_(101),
"es6.destructuring": _dereq_(95),
"es6.blockScoping": _dereq_(90),
"es6.spec.blockScoping": _dereq_(108),
reactCompat: _dereq_(139),
react: _dereq_(140),
regenerator: _dereq_(141),
// es6 syntax transformation is **forbidden** past this point since regenerator will chuck a massive
// hissy fit
//- builtin-modules
runtime: _dereq_(196),
"es6.modules": _dereq_(98),
_moduleFormatter: _dereq_(129),
//- builtin-trailing
// these clean up the output and do finishing up transformations, it's important to note that by this
// stage you can't import any new modules or insert new ES6 as all those transformers have already
// been ran
"es6.tailCall": _dereq_(113),
_shadowFunctions: _dereq_(131),
"es3.propertyLiterals": _dereq_(87),
"es3.memberExpressionLiterals": _dereq_(86),
"minification.memberExpressionLiterals": _dereq_(188),
"minification.propertyLiterals": _dereq_(189),
_blockHoist: _dereq_(127),
jscript: _dereq_(187),
flow: _dereq_(138),
"optimisation.modules.system": _dereq_(134)
};
module.exports = exports["default"];
},{"101":101,"103":103,"104":104,"105":105,"106":106,"107":107,"108":108,"109":109,"110":110,"111":111,"112":112,"113":113,"114":114,"115":115,"116":116,"117":117,"118":118,"119":119,"120":120,"121":121,"122":122,"123":123,"124":124,"127":127,"128":128,"129":129,"130":130,"131":131,"132":132,"133":133,"134":134,"135":135,"136":136,"137":137,"138":138,"139":139,"140":140,"141":141,"142":142,"143":143,"144":144,"145":145,"183":183,"184":184,"185":185,"186":186,"187":187,"188":188,"189":189,"190":190,"191":191,"192":192,"193":193,"194":194,"196":196,"197":197,"199":199,"86":86,"87":87,"88":88,"89":89,"90":90,"91":91,"94":94,"95":95,"96":96,"97":97,"98":98,"99":99}],127:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _lodashCollectionSortBy = _dereq_(417);
var _lodashCollectionSortBy2 = _interopRequireDefault(_lodashCollectionSortBy);
var metadata = {
group: "builtin-trailing"
};
exports.metadata = metadata;
/**
* [Please add a description.]
*
* Priority:
*
* - 0 We want this to be at the **very** bottom
* - 1 Default node position
* - 2 Priority over normal nodes
* - 3 We want this to be at the **very** top
*/
var visitor = {
/**
* [Please add a description.]
*/
Block: {
exit: function exit(node) {
var hasChange = false;
for (var i = 0; i < node.body.length; i++) {
var bodyNode = node.body[i];
if (bodyNode && bodyNode._blockHoist != null) {
hasChange = true;
break;
}
}
if (!hasChange) return;
node.body = _lodashCollectionSortBy2["default"](node.body, function (bodyNode) {
var priority = bodyNode && bodyNode._blockHoist;
if (priority == null) priority = 1;
if (priority === true) priority = 2;
// Higher priorities should move toward the top.
return -1 * priority;
});
}
}
};
exports.visitor = visitor;
},{"417":417}],128:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
var metadata = {
group: "builtin-pre"
};
exports.metadata = metadata;
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
Block: {
exit: function exit(node) {
for (var i = 0; i < node.body.length; i++) {
var bodyNode = node.body[i];
if (t.isExpressionStatement(bodyNode) && t.isLiteral(bodyNode.expression)) {
bodyNode._blockHoist = Infinity;
} else {
return;
}
}
}
}
};
exports.visitor = visitor;
},{"179":179}],129:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
var metadata = {
group: "builtin-modules"
};
exports.metadata = metadata;
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
Program: {
exit: function exit(program, parent, scope, file) {
// ensure that these are at the top, just like normal imports
var _arr = file.dynamicImports;
for (var _i = 0; _i < _arr.length; _i++) {
var node = _arr[_i];
node._blockHoist = 3;
}
program.body = file.dynamicImports.concat(program.body);
if (!file.transformers["es6.modules"].canTransform()) return;
if (file.moduleFormatter.transform) {
file.moduleFormatter.transform(program);
}
}
}
};
exports.visitor = visitor;
},{}],130:[function(_dereq_,module,exports){
// in this transformer we have to split up classes and function declarations
// from their exports. why? because sometimes we need to replace classes with
// nodes that aren't allowed in the same contexts. also, if you're exporting
// a generator function as a default then regenerator will destroy the export
// declaration and leave a variable declaration in it's place... yeah, handy.
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
function getDeclar(node) {
var declar = node.declaration;
t.inheritsComments(declar, node);
t.removeComments(node);
declar._ignoreUserWhitespace = true;
return declar;
}
/**
* [Please add a description.]
*/
function buildExportSpecifier(id) {
return t.exportSpecifier(cloneIdentifier(id), cloneIdentifier(id));
}
function cloneIdentifier(_ref) {
var name = _ref.name;
var loc = _ref.loc;
var id = t.identifier(name);
id._loc = loc;
return id;
}
var metadata = {
group: "builtin-pre"
};
exports.metadata = metadata;
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
ExportDefaultDeclaration: function ExportDefaultDeclaration(node, parent, scope) {
var declar = node.declaration;
if (t.isClassDeclaration(declar)) {
// export default class Foo {};
var nodes = [getDeclar(node), node];
node.declaration = declar.id;
return nodes;
} else if (t.isClassExpression(declar)) {
// export default class {};
var temp = scope.generateUidIdentifier("default");
node.declaration = t.variableDeclaration("var", [t.variableDeclarator(temp, declar)]);
var nodes = [getDeclar(node), node];
node.declaration = temp;
return nodes;
} else if (t.isFunctionDeclaration(declar)) {
// export default function Foo() {}
node._blockHoist = 2;
var nodes = [getDeclar(node), node];
node.declaration = declar.id;
return nodes;
}
},
/**
* [Please add a description.]
*/
ExportNamedDeclaration: function ExportNamedDeclaration(node) {
var declar = node.declaration;
if (t.isClassDeclaration(declar)) {
// export class Foo {}
node.specifiers = [buildExportSpecifier(declar.id)];
var nodes = [getDeclar(node), node];
node.declaration = null;
return nodes;
} else if (t.isFunctionDeclaration(declar)) {
// export function Foo() {}
var newExport = t.exportNamedDeclaration(null, [buildExportSpecifier(declar.id)]);
newExport._blockHoist = 2;
return [getDeclar(node), newExport];
} else if (t.isVariableDeclaration(declar)) {
// export var foo = "bar";
var specifiers = [];
var bindings = this.get("declaration").getBindingIdentifiers();
for (var key in bindings) {
specifiers.push(buildExportSpecifier(bindings[key]));
}
return [declar, t.exportNamedDeclaration(null, specifiers)];
}
},
/**
* [Please add a description.]
*/
Program: {
enter: function enter(node) {
var imports = [];
var rest = [];
for (var i = 0; i < node.body.length; i++) {
var bodyNode = node.body[i];
if (t.isImportDeclaration(bodyNode)) {
imports.push(bodyNode);
} else {
rest.push(bodyNode);
}
}
node.body = imports.concat(rest);
},
exit: function exit(node, parent, scope, file) {
if (!file.transformers["es6.modules"].canTransform()) return;
if (file.moduleFormatter.setup) {
file.moduleFormatter.setup();
}
}
}
};
exports.visitor = visitor;
},{"179":179}],131:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
var metadata = {
group: "builtin-trailing"
};
exports.metadata = metadata;
function shouldShadow(path, shadowPath) {
if (path.is("_forceShadow")) {
return true;
} else {
return shadowPath && !shadowPath.isArrowFunctionExpression();
}
}
/**
* [Please add a description.]
*/
function remap(path, key, create) {
// ensure that we're shadowed
var shadowPath = path.inShadow(key);
if (!shouldShadow(path, shadowPath)) return;
var shadowFunction = path.node._shadowedFunctionLiteral;
var currentFunction;
var fnPath = path.findParent(function (path) {
if (path.isProgram() || path.isFunction()) {
// catch current function in case this is the shadowed one and we can ignore it
currentFunction = currentFunction || path;
}
if (path.isProgram()) {
return true;
} else if (path.isFunction()) {
if (shadowFunction) {
return path === shadowFunction || path.node === shadowFunction.node;
} else {
return !path.is("shadow");
}
}
return false;
});
// no point in realiasing if we're in this function
if (fnPath === currentFunction) return;
var cached = fnPath.getData(key);
if (cached) return cached;
var init = create();
var id = path.scope.generateUidIdentifier(key);
fnPath.setData(key, id);
fnPath.scope.push({ id: id, init: init });
return id;
}
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
ThisExpression: function ThisExpression() {
return remap(this, "this", function () {
return t.thisExpression();
});
},
/**
* [Please add a description.]
*/
ReferencedIdentifier: function ReferencedIdentifier(node) {
if (node.name === "arguments") {
return remap(this, "arguments", function () {
return t.identifier("arguments");
});
}
}
};
exports.visitor = visitor;
},{"179":179}],132:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _messages = _dereq_(43);
var messages = _interopRequireWildcard(_messages);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
var metadata = {
group: "builtin-pre"
};
exports.metadata = metadata;
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
ForXStatement: function ForXStatement(node, parent, scope, file) {
var left = node.left;
if (t.isVariableDeclaration(left)) {
var declar = left.declarations[0];
if (declar.init) throw file.errorWithNode(declar, messages.get("noAssignmentsInForHead"));
}
},
/**
* [Please add a description.]
*/
Property: function Property(node, parent, scope, file) {
if (node.kind === "set") {
var first = node.value.params[0];
if (t.isRestElement(first)) {
throw file.errorWithNode(first, messages.get("settersNoRest"));
}
}
}
};
exports.visitor = visitor;
},{"179":179,"43":43}],133:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
var _es6ForOf = _dereq_(96);
var metadata = {
optional: true
};
exports.metadata = metadata;
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
ForOfStatement: function ForOfStatement(node, parent, scope, file) {
if (this.get("right").isGenericType("Array")) {
return _es6ForOf._ForOfStatementArray.call(this, node, scope, file);
}
}
};
exports.visitor = visitor;
},{"96":96}],134:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
var metadata = {
optional: true,
group: "builtin-trailing"
};
exports.metadata = metadata;
var visitor = {
Program: function Program(node, parent, scope, file) {
if (file.moduleFormatter._setters) {
scope.traverse(file.moduleFormatter._setters, optimizeSettersVisitor, {
exportFunctionIdentifier: file.moduleFormatter.exportIdentifier
});
}
}
};
exports.visitor = visitor;
/**
* Setters are optimized to avoid slow export behavior in modules that rely on deep hierarchies
* of export-from declarations.
* More info in https://github.com/babel/babel/pull/1722 and
* https://github.com/ModuleLoader/es6-module-loader/issues/386.
*
* TODO: Ideally this would be optimized during construction of the setters, but the current
* architecture of the module formatters make that difficult.
*/
var optimizeSettersVisitor = {
FunctionExpression: {
enter: function enter(node, parent, scope, state) {
state.hasExports = false;
state.exportObjectIdentifier = scope.generateUidIdentifier("exportObj");
},
exit: function exit(node, parent, scope, state) {
if (!state.hasExports) return;
node.body.body.unshift(t.variableDeclaration("var", [t.variableDeclarator(t.cloneDeep(state.exportObjectIdentifier), t.objectExpression([]))]));
node.body.body.push(t.expressionStatement(t.callExpression(t.cloneDeep(state.exportFunctionIdentifier), [t.cloneDeep(state.exportObjectIdentifier)])));
}
},
CallExpression: function CallExpression(node, parent, scope, state) {
if (!t.isIdentifier(node.callee, { name: state.exportFunctionIdentifier.name })) return;
state.hasExports = true;
var memberNode = t.memberExpression(t.cloneDeep(state.exportObjectIdentifier), node.arguments[0], true);
return t.assignmentExpression("=", memberNode, node.arguments[1]);
}
};
},{"179":179}],135:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _helpersReact = _dereq_(62);
var react = _interopRequireWildcard(_helpersReact);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
var metadata = {
optional: true
};
exports.metadata = metadata;
/**
* [Please add a description.]
*/
function hasRefOrSpread(attrs) {
for (var i = 0; i < attrs.length; i++) {
var attr = attrs[i];
if (t.isJSXSpreadAttribute(attr)) return true;
if (isJSXAttributeOfName(attr, "ref")) return true;
}
return false;
}
/**
* [Please add a description.]
*/
function isJSXAttributeOfName(attr, name) {
return t.isJSXAttribute(attr) && t.isJSXIdentifier(attr.name, { name: name });
}
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
JSXElement: function JSXElement(node, parent, scope, file) {
// filter
var open = node.openingElement;
if (hasRefOrSpread(open.attributes)) return;
// init
var isComponent = true;
var props = t.objectExpression([]);
var obj = t.objectExpression([]);
var key = t.literal(null);
var type = open.name;
if (t.isJSXIdentifier(type) && react.isCompatTag(type.name)) {
type = t.literal(type.name);
isComponent = false;
}
function pushElemProp(key, value) {
pushProp(obj.properties, t.identifier(key), value);
}
function pushProp(objProps, key, value) {
objProps.push(t.property("init", key, value));
}
if (node.children.length) {
var children = react.buildChildren(node);
children = children.length === 1 ? children[0] : t.arrayExpression(children);
pushProp(props.properties, t.identifier("children"), children);
}
// props
for (var i = 0; i < open.attributes.length; i++) {
var attr = open.attributes[i];
if (isJSXAttributeOfName(attr, "key")) {
key = attr.value;
} else {
pushProp(props.properties, attr.name, attr.value || t.identifier("true"));
}
}
if (isComponent) {
props = t.callExpression(file.addHelper("default-props"), [t.memberExpression(type, t.identifier("defaultProps")), props]);
}
// metadata
pushElemProp("$$typeof", file.addHelper("typeof-react-element"));
pushElemProp("type", type);
pushElemProp("key", key);
pushElemProp("ref", t.literal(null));
pushElemProp("props", props);
pushElemProp("_owner", t.literal(null));
return obj;
}
};
exports.visitor = visitor;
},{"179":179,"62":62}],136:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _helpersRemapAsyncToGenerator = _dereq_(64);
var _helpersRemapAsyncToGenerator2 = _interopRequireDefault(_helpersRemapAsyncToGenerator);
var _bluebirdCoroutines = _dereq_(137);
exports.manipulateOptions = _bluebirdCoroutines.manipulateOptions;
var metadata = {
optional: true,
dependencies: ["es7.asyncFunctions", "es6.classes"]
};
exports.metadata = metadata;
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
Function: function Function(node, parent, scope, file) {
if (!node.async || node.generator) return;
return _helpersRemapAsyncToGenerator2["default"](this, file.addHelper("async-to-generator"));
}
};
exports.visitor = visitor;
},{"137":137,"64":64}],137:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports.manipulateOptions = manipulateOptions;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _helpersRemapAsyncToGenerator = _dereq_(64);
var _helpersRemapAsyncToGenerator2 = _interopRequireDefault(_helpersRemapAsyncToGenerator);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
function manipulateOptions(opts) {
opts.blacklist.push("regenerator");
}
var metadata = {
optional: true,
dependencies: ["es7.asyncFunctions", "es6.classes"]
};
exports.metadata = metadata;
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
Function: function Function(node, parent, scope, file) {
if (!node.async || node.generator) return;
return _helpersRemapAsyncToGenerator2["default"](this, t.memberExpression(file.addImport("bluebird", null, "absolute"), t.identifier("coroutine")));
}
};
exports.visitor = visitor;
},{"179":179,"64":64}],138:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
var metadata = {
group: "builtin-trailing"
};
exports.metadata = metadata;
var FLOW_DIRECTIVE = "@flow";
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
Program: function Program(node, parent, scope, file) {
var _arr = file.ast.comments;
for (var _i = 0; _i < _arr.length; _i++) {
var comment = _arr[_i];
if (comment.value.indexOf(FLOW_DIRECTIVE) >= 0) {
// remove flow directive
comment.value = comment.value.replace(FLOW_DIRECTIVE, "");
// remove the comment completely if it only consists of whitespace and/or stars
if (!comment.value.replace(/\*/g, "").trim()) comment._displayed = true;
}
}
},
/**
* [Please add a description.]
*/
Flow: function Flow() {
this.dangerouslyRemove();
},
/**
* [Please add a description.]
*/
ClassProperty: function ClassProperty(node) {
node.typeAnnotation = null;
if (!node.value) this.dangerouslyRemove();
},
/**
* [Please add a description.]
*/
Class: function Class(node) {
node["implements"] = null;
},
/**
* [Please add a description.]
*/
Function: function Function(node) {
for (var i = 0; i < node.params.length; i++) {
var param = node.params[i];
param.optional = false;
}
},
/**
* [Please add a description.]
*/
TypeCastExpression: function TypeCastExpression(node) {
do {
node = node.expression;
} while (t.isTypeCastExpression(node));
return node;
}
};
exports.visitor = visitor;
},{"179":179}],139:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports.manipulateOptions = manipulateOptions;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _helpersReact = _dereq_(62);
var react = _interopRequireWildcard(_helpersReact);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
function manipulateOptions(opts) {
opts.blacklist.push("react");
}
var metadata = {
optional: true,
group: "builtin-advanced"
};
exports.metadata = metadata;
/**
* [Please add a description.]
*/
var visitor = _dereq_(55)({
/**
* [Please add a description.]
*/
pre: function pre(state) {
state.callee = state.tagExpr;
},
/**
* [Please add a description.]
*/
post: function post(state) {
if (react.isCompatTag(state.tagName)) {
state.call = t.callExpression(t.memberExpression(t.memberExpression(t.identifier("React"), t.identifier("DOM")), state.tagExpr, t.isLiteral(state.tagExpr)), state.args);
}
}
});
exports.visitor = visitor;
},{"179":179,"55":55,"62":62}],140:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _helpersReact = _dereq_(62);
var react = _interopRequireWildcard(_helpersReact);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
var JSX_ANNOTATION_REGEX = /^\*\s*@jsx\s+([^\s]+)/;
var metadata = {
group: "builtin-advanced"
};
exports.metadata = metadata;
/**
* [Please add a description.]
*/
var visitor = _dereq_(55)({
/**
* [Please add a description.]
*/
pre: function pre(state) {
var tagName = state.tagName;
var args = state.args;
if (react.isCompatTag(tagName)) {
args.push(t.literal(tagName));
} else {
args.push(state.tagExpr);
}
},
/**
* [Please add a description.]
*/
post: function post(state, file) {
state.callee = file.get("jsxIdentifier");
}
});
exports.visitor = visitor;
/**
* [Please add a description.]
*/
visitor.Program = function (node, parent, scope, file) {
var id = file.opts.jsxPragma;
for (var i = 0; i < file.ast.comments.length; i++) {
var comment = file.ast.comments[i];
var matches = JSX_ANNOTATION_REGEX.exec(comment.value);
if (matches) {
id = matches[1];
if (id === "React.DOM") {
throw file.errorWithNode(comment, "The @jsx React.DOM pragma has been deprecated as of React 0.12");
} else {
break;
}
}
}
file.set("jsxIdentifier", id.split(".").map(t.identifier).reduce(function (object, property) {
return t.memberExpression(object, property);
}));
};
},{"179":179,"55":55,"62":62}],141:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _regenerator = _dereq_(535);
var _regenerator2 = _interopRequireDefault(_regenerator);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
// It's important to use the exact same NodePath constructor that
// Regenerator uses, rather than require("ast-types").NodePath, because
// the version of ast-types that Babel knows about might be different from
// the version that Regenerator depends on. See for example #1958.
var NodePath = _regenerator2["default"].types.NodePath;
var metadata = {
group: "builtin-advanced"
};
exports.metadata = metadata;
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
Function: {
exit: function exit(node) {
if (node.async || node.generator) {
// Although this code transforms only the subtree rooted at the given
// Function node, that node might contain other generator functions
// that will also be transformed. It might help performance to ignore
// nested functions, and rely on the traversal to visit them later,
// but that's a small optimization. Starting here instead of at the
// root of the AST is the key optimization, since huge async/generator
// functions are relatively rare.
_regenerator2["default"].transform(convertNodePath(this));
}
}
}
};
exports.visitor = visitor;
// Given a Babel NodePath, return an ast-types NodePath that includes full
// ancestry information (up to and including the Program node). This is
// complicated by having to include intermediate objects like blockStatement.body
// arrays, in addition to Node objects.
function convertNodePath(path) {
var programNode;
var keysAlongPath = [];
while (path) {
var pp = path.parentPath;
var parentNode = pp && pp.node;
if (parentNode) {
keysAlongPath.push(path.key);
if (parentNode !== path.container) {
var found = Object.keys(parentNode).some(function (listKey) {
if (parentNode[listKey] === path.container) {
keysAlongPath.push(listKey);
return true;
}
});
if (!found) {
throw new Error("Failed to find container object in parent node");
}
}
if (t.isProgram(parentNode)) {
programNode = parentNode;
break;
}
}
path = pp;
}
if (!programNode) {
throw new Error("Failed to find root Program node");
}
var nodePath = new NodePath(programNode);
while (keysAlongPath.length > 0) {
nodePath = nodePath.get(keysAlongPath.pop());
}
return nodePath;
}
},{"179":179,"535":535}],142:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
var metadata = {
group: "builtin-pre"
};
exports.metadata = metadata;
var THIS_BREAK_KEYS = ["FunctionExpression", "FunctionDeclaration", "ClassProperty"];
function isUseStrict(node) {
if (!t.isLiteral(node)) return false;
if (node.raw && node.rawValue === node.value) {
return node.rawValue === "use strict";
} else {
return node.value === "use strict";
}
}
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
Program: {
enter: function enter(program) {
var first = program.body[0];
var directive;
if (t.isExpressionStatement(first) && isUseStrict(first.expression)) {
directive = first;
} else {
directive = t.expressionStatement(t.literal("use strict"));
this.unshiftContainer("body", directive);
if (first) {
directive.leadingComments = first.leadingComments;
first.leadingComments = [];
}
}
directive._blockHoist = Infinity;
}
},
/**
* [Please add a description.]
*/
ThisExpression: function ThisExpression() {
if (!this.findParent(function (path) {
return !path.is("shadow") && THIS_BREAK_KEYS.indexOf(path.type) >= 0;
})) {
return t.identifier("undefined");
}
}
};
exports.visitor = visitor;
},{"179":179}],143:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
function statementList(key, path) {
var paths = path.get(key);
for (var i = 0; i < paths.length; i++) {
var _path = paths[i];
var func = _path.node;
if (!t.isFunctionDeclaration(func)) continue;
var declar = t.variableDeclaration("let", [t.variableDeclarator(func.id, t.toExpression(func))]);
// hoist it up above everything else
declar._blockHoist = 2;
// todo: name this
func.id = null;
_path.replaceWith(declar);
}
}
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
BlockStatement: function BlockStatement(node, parent) {
if (t.isFunction(parent) && parent.body === node || t.isExportDeclaration(parent)) {
return;
}
statementList("body", this);
},
/**
* [Please add a description.]
*/
SwitchCase: function SwitchCase() {
statementList("consequent", this);
}
};
exports.visitor = visitor;
},{"179":179}],144:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
var _helpersNameMethod = _dereq_(61);
var metadata = {
group: "builtin-basic"
};
exports.metadata = metadata;
// visit Property functions first - https://github.com/babel/babel/issues/1860
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
"ArrowFunctionExpression|FunctionExpression": {
exit: function exit() {
if (!this.parentPath.isProperty()) {
return _helpersNameMethod.bare.apply(this, arguments);
}
}
},
/**
* [Please add a description.]
*/
ObjectExpression: function ObjectExpression() {
var props = this.get("properties");
var _arr = props;
for (var _i = 0; _i < _arr.length; _i++) {
var prop = _arr[_i];
var value = prop.get("value");
if (value.isFunction()) {
var newNode = _helpersNameMethod.bare(value.node, prop.node, value.scope);
if (newNode) value.replaceWith(newNode);
}
}
}
};
exports.visitor = visitor;
},{"61":61}],145:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _messages = _dereq_(43);
var messages = _interopRequireWildcard(_messages);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
// check if the input Literal `source` is an alternate casing of "react"
function check(source, file) {
if (t.isLiteral(source)) {
var name = source.value;
var lower = name.toLowerCase();
if (lower === "react" && name !== lower) {
throw file.errorWithNode(source, messages.get("didYouMean", "react"));
}
}
}
/**
* [Please add a description.]
*/
var visitor = {
/**
* [Please add a description.]
*/
CallExpression: function CallExpression(node, parent, scope, file) {
if (this.get("callee").isIdentifier({ name: "require" }) && node.arguments.length === 1) {
check(node.arguments[0], file);
}
},
/**
* [Please add a description.]
*/
ModuleDeclaration: function ModuleDeclaration(node, parent, scope, file) {
check(node.source, file);
}
};
exports.visitor = visitor;
},{"179":179,"43":43}],146:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// istanbul ignore next
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _path = _dereq_(155);
var _path2 = _interopRequireDefault(_path);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
var TraversalContext = (function () {
function TraversalContext(scope, opts, state, parentPath) {
_classCallCheck(this, TraversalContext);
this.queue = null;
this.parentPath = parentPath;
this.scope = scope;
this.state = state;
this.opts = opts;
}
/**
* [Please add a description.]
*/
TraversalContext.prototype.shouldVisit = function shouldVisit(node) {
var opts = this.opts;
if (opts.enter || opts.exit) return true;
if (opts[node.type]) return true;
var keys = t.VISITOR_KEYS[node.type];
if (!keys || !keys.length) return false;
var _arr = keys;
for (var _i = 0; _i < _arr.length; _i++) {
var key = _arr[_i];
if (node[key]) return true;
}
return false;
};
/**
* [Please add a description.]
*/
TraversalContext.prototype.create = function create(node, obj, key, listKey) {
var path = _path2["default"].get({
parentPath: this.parentPath,
parent: node,
container: obj,
key: key,
listKey: listKey
});
path.unshiftContext(this);
return path;
};
/**
* [Please add a description.]
*/
TraversalContext.prototype.visitMultiple = function visitMultiple(container, parent, listKey) {
// nothing to traverse!
if (container.length === 0) return false;
var visited = [];
var queue = this.queue = [];
var stop = false;
// build up initial queue
for (var key = 0; key < container.length; key++) {
var self = container[key];
if (self && this.shouldVisit(self)) {
queue.push(this.create(parent, container, key, listKey));
}
}
// visit the queue
var _arr2 = queue;
for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
var path = _arr2[_i2];
path.resync();
if (visited.indexOf(path.node) >= 0) continue;
visited.push(path.node);
if (path.visit()) {
stop = true;
break;
}
}
var _arr3 = queue;
for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
var path = _arr3[_i3];
path.shiftContext();
}
this.queue = null;
return stop;
};
/**
* [Please add a description.]
*/
TraversalContext.prototype.visitSingle = function visitSingle(node, key) {
if (this.shouldVisit(node[key])) {
var path = this.create(node, node, key);
path.visit();
path.shiftContext();
}
};
/**
* [Please add a description.]
*/
TraversalContext.prototype.visit = function visit(node, key) {
var nodes = node[key];
if (!nodes) return;
if (Array.isArray(nodes)) {
return this.visitMultiple(nodes, node, key);
} else {
return this.visitSingle(node, key);
}
};
return TraversalContext;
})();
exports["default"] = TraversalContext;
module.exports = exports["default"];
},{"155":155,"179":179}],147:[function(_dereq_,module,exports){
/**
* [Please add a description.]
*/
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Hub = function Hub(file) {
_classCallCheck(this, Hub);
this.file = file;
};
exports["default"] = Hub;
module.exports = exports["default"];
},{}],148:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports["default"] = traverse;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _context = _dereq_(146);
var _context2 = _interopRequireDefault(_context);
var _visitors = _dereq_(168);
var visitors = _interopRequireWildcard(_visitors);
var _messages = _dereq_(43);
var messages = _interopRequireWildcard(_messages);
var _lodashCollectionIncludes = _dereq_(413);
var _lodashCollectionIncludes2 = _interopRequireDefault(_lodashCollectionIncludes);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
function traverse(parent, opts, scope, state, parentPath) {
if (!parent) return;
if (!opts) opts = {};
if (!opts.noScope && !scope) {
if (parent.type !== "Program" && parent.type !== "File") {
throw new Error(messages.get("traverseNeedsParent", parent.type));
}
}
visitors.explode(opts);
// array of nodes
if (Array.isArray(parent)) {
for (var i = 0; i < parent.length; i++) {
traverse.node(parent[i], opts, scope, state, parentPath);
}
} else {
traverse.node(parent, opts, scope, state, parentPath);
}
}
traverse.visitors = visitors;
traverse.verify = visitors.verify;
traverse.explode = visitors.explode;
/**
* [Please add a description.]
*/
traverse.node = function (node, opts, scope, state, parentPath, skipKeys) {
var keys = t.VISITOR_KEYS[node.type];
if (!keys) return;
var context = new _context2["default"](scope, opts, state, parentPath);
var _arr = keys;
for (var _i = 0; _i < _arr.length; _i++) {
var key = _arr[_i];
if (skipKeys && skipKeys[key]) continue;
if (context.visit(node, key)) return;
}
};
/**
* [Please add a description.]
*/
var CLEAR_KEYS = t.COMMENT_KEYS.concat(["_scopeInfo", "_paths", "tokens", "comments", "start", "end", "loc", "raw", "rawValue"]);
/**
* [Please add a description.]
*/
traverse.clearNode = function (node) {
for (var i = 0; i < CLEAR_KEYS.length; i++) {
var key = CLEAR_KEYS[i];
if (node[key] != null) node[key] = undefined;
}
};
/**
* [Please add a description.]
*/
var clearVisitor = {
noScope: true,
exit: traverse.clearNode
};
/**
* [Please add a description.]
*/
traverse.removeProperties = function (tree) {
traverse(tree, clearVisitor);
traverse.clearNode(tree);
return tree;
};
/**
* [Please add a description.]
*/
function hasBlacklistedType(node, parent, scope, state) {
if (node.type === state.type) {
state.has = true;
this.skip();
}
}
/**
* [Please add a description.]
*/
traverse.hasType = function (tree, scope, type, blacklistTypes) {
// the node we're searching in is blacklisted
if (_lodashCollectionIncludes2["default"](blacklistTypes, tree.type)) return false;
// the type we're looking for is the same as the passed node
if (tree.type === type) return true;
var state = {
has: false,
type: type
};
traverse(tree, {
blacklist: blacklistTypes,
enter: hasBlacklistedType
}, scope, state);
return state.has;
};
module.exports = exports["default"];
},{"146":146,"168":168,"179":179,"413":413,"43":43}],149:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports.findParent = findParent;
exports.getFunctionParent = getFunctionParent;
exports.getStatementParent = getStatementParent;
exports.getEarliestCommonAncestorFrom = getEarliestCommonAncestorFrom;
exports.getDeepestCommonAncestorFrom = getDeepestCommonAncestorFrom;
exports.getAncestry = getAncestry;
exports.inType = inType;
exports.inShadow = inShadow;
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
var _index = _dereq_(155);
var _index2 = _interopRequireDefault(_index);
/**
* Call the provided `callback` with the `NodePath`s of all the parents.
* When the `callback` returns a truthy value, we return that node path.
*/
function findParent(callback) {
var path = this;
while (path = path.parentPath) {
if (callback(path)) return path;
}
return null;
}
/**
* Get the parent function of the current path.
*/
function getFunctionParent() {
return this.findParent(function (path) {
return path.isFunction() || path.isProgram();
});
}
/**
* Walk up the tree until we hit a parent node path in a list.
*/
function getStatementParent() {
var path = this;
do {
if (Array.isArray(path.container)) {
return path;
}
} while (path = path.parentPath);
}
/**
* Get the deepest common ancestor and then from it, get the earliest relationship path
* to that ancestor.
*
* Earliest is defined as being "before" all the other nodes in terms of list container
* position and visiting key.
*/
function getEarliestCommonAncestorFrom(paths) {
return this.getDeepestCommonAncestorFrom(paths, function (deepest, i, ancestries) {
var earliest;
var keys = t.VISITOR_KEYS[deepest.type];
var _arr = ancestries;
for (var _i = 0; _i < _arr.length; _i++) {
var ancestry = _arr[_i];
var path = ancestry[i + 1];
// first path
if (!earliest) {
earliest = path;
continue;
}
// handle containers
if (path.listKey && earliest.listKey === path.listKey) {
// we're in the same container so check if we're earlier
if (path.key < earliest.key) {
earliest = path;
continue;
}
}
// handle keys
var earliestKeyIndex = keys.indexOf(earliest.parentKey);
var currentKeyIndex = keys.indexOf(path.parentKey);
if (earliestKeyIndex > currentKeyIndex) {
// key appears before so it's earlier
earliest = path;
}
}
return earliest;
});
}
/**
* Get the earliest path in the tree where the provided `paths` intersect.
*
* TODO: Possible optimisation target.
*/
function getDeepestCommonAncestorFrom(paths, filter) {
// istanbul ignore next
var _this = this;
if (!paths.length) {
return this;
}
if (paths.length === 1) {
return paths[0];
}
// minimum depth of the tree so we know the highest node
var minDepth = Infinity;
// last common ancestor
var lastCommonIndex, lastCommon;
// get the ancestors of the path, breaking when the parent exceeds ourselves
var ancestries = paths.map(function (path) {
var ancestry = [];
do {
ancestry.unshift(path);
} while ((path = path.parentPath) && path !== _this);
// save min depth to avoid going too far in
if (ancestry.length < minDepth) {
minDepth = ancestry.length;
}
return ancestry;
});
// get the first ancestry so we have a seed to assess all other ancestries with
var first = ancestries[0];
// check ancestor equality
depthLoop: for (var i = 0; i < minDepth; i++) {
var shouldMatch = first[i];
var _arr2 = ancestries;
for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
var ancestry = _arr2[_i2];
if (ancestry[i] !== shouldMatch) {
// we've hit a snag
break depthLoop;
}
}
// next iteration may break so store these so they can be returned
lastCommonIndex = i;
lastCommon = shouldMatch;
}
if (lastCommon) {
if (filter) {
return filter(lastCommon, lastCommonIndex, ancestries);
} else {
return lastCommon;
}
} else {
throw new Error("Couldn't find intersection");
}
}
/**
* Build an array of node paths containing the entire ancestry of the current node path.
*
* NOTE: The current node path is included in this.
*/
function getAncestry() {
var path = this;
var paths = [];
do {
paths.push(path);
} while (path = path.parentPath);
return paths;
}
/**
* [Please add a description.]
*/
function inType() {
var path = this;
while (path) {
var _arr3 = arguments;
for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
var type = _arr3[_i3];
if (path.node.type === type) return true;
}
path = path.parentPath;
}
return false;
}
/**
* Check if we're inside a shadowed function.
*/
function inShadow(key) {
var path = this;
do {
if (path.isFunction()) {
var shadow = path.node.shadow;
if (shadow) {
// this is because sometimes we may have a `shadow` value of:
//
// { this: false }
//
// we need to catch this case if `inShadow` has been passed a `key`
if (!key || shadow[key] !== false) {
return path;
}
} else if (path.isArrowFunctionExpression()) {
return path;
}
// normal function, we've found our function context
return null;
}
} while (path = path.parentPath);
return null;
}
},{"155":155,"179":179}],150:[function(_dereq_,module,exports){
/**
* Share comments amongst siblings.
*/
"use strict";
exports.__esModule = true;
exports.shareCommentsWithSiblings = shareCommentsWithSiblings;
exports.addComment = addComment;
exports.addComments = addComments;
function shareCommentsWithSiblings() {
var node = this.node;
if (!node) return;
var trailing = node.trailingComments;
var leading = node.leadingComments;
if (!trailing && !leading) return;
var prev = this.getSibling(this.key - 1);
var next = this.getSibling(this.key + 1);
if (!prev.node) prev = next;
if (!next.node) next = prev;
prev.addComments("trailing", leading);
next.addComments("leading", trailing);
}
/**
* [Please add a description.]
*/
function addComment(type, content, line) {
this.addComments(type, [{
type: line ? "CommentLine" : "CommentBlock",
value: content
}]);
}
/**
* Give node `comments` of the specified `type`.
*/
function addComments(type, comments) {
if (!comments) return;
var node = this.node;
if (!node) return;
var key = type + "Comments";
if (node[key]) {
node[key] = node[key].concat(comments);
} else {
node[key] = comments;
}
}
},{}],151:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports.call = call;
exports.isBlacklisted = isBlacklisted;
exports.visit = visit;
exports.skip = skip;
exports.skipKey = skipKey;
exports.stop = stop;
exports.setScope = setScope;
exports.setContext = setContext;
exports.resync = resync;
exports._resyncParent = _resyncParent;
exports._resyncKey = _resyncKey;
exports._resyncList = _resyncList;
exports._resyncRemoved = _resyncRemoved;
exports.shiftContext = shiftContext;
exports.unshiftContext = unshiftContext;
exports.setup = setup;
exports.setKey = setKey;
exports.queueNode = queueNode;
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _index = _dereq_(148);
var _index2 = _interopRequireDefault(_index);
/**
* [Please add a description.]
*/
function call(key) {
var node = this.node;
if (!node) return;
var opts = this.opts;
var _arr = [opts[key], opts[node.type] && opts[node.type][key]];
for (var _i = 0; _i < _arr.length; _i++) {
var fns = _arr[_i];
if (!fns) continue;
var _arr2 = fns;
for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
var fn = _arr2[_i2];
if (!fn) continue;
var _node = this.node;
if (!_node) return;
var previousType = this.type;
// call the function with the params (node, parent, scope, state)
var replacement = fn.call(this, _node, this.parent, this.scope, this.state);
if (replacement) {
this.replaceWith(replacement, true);
}
if (this.shouldStop || this.shouldSkip || this.removed) return;
if (previousType !== this.type) {
this.queueNode(this);
return;
}
}
}
}
/**
* [Please add a description.]
*/
function isBlacklisted() {
var blacklist = this.opts.blacklist;
return blacklist && blacklist.indexOf(this.node.type) > -1;
}
/**
* Visits a node and calls appropriate enter and exit callbacks
* as required.
*/
function visit() {
if (this.isBlacklisted()) return false;
if (this.opts.shouldSkip && this.opts.shouldSkip(this)) return false;
this.call("enter");
if (this.shouldSkip) {
return this.shouldStop;
}
var node = this.node;
var opts = this.opts;
if (node) {
if (Array.isArray(node)) {
// traverse over these replacement nodes we purposely don't call exitNode
// as the original node has been destroyed
for (var i = 0; i < node.length; i++) {
_index2["default"].node(node[i], opts, this.scope, this.state, this, this.skipKeys);
}
} else {
_index2["default"].node(node, opts, this.scope, this.state, this, this.skipKeys);
this.call("exit");
}
}
return this.shouldStop;
}
/**
* Sets shouldSkip flag true so that this node will be skipped while visiting.
*/
function skip() {
this.shouldSkip = true;
}
/**
* Adds given key to the list of keys to be skipped.
*/
function skipKey(key) {
this.skipKeys[key] = true;
}
/**
* [Please add a description.]
*/
function stop() {
this.shouldStop = true;
this.shouldSkip = true;
}
/**
* [Please add a description.]
*/
function setScope() {
if (this.opts && this.opts.noScope) return;
var target = this.context || this.parentPath;
this.scope = this.getScope(target && target.scope);
if (this.scope) this.scope.init();
}
/**
* [Please add a description.]
*/
function setContext(context) {
this.shouldSkip = false;
this.shouldStop = false;
this.removed = false;
this.skipKeys = {};
if (context) {
this.context = context;
this.state = context.state;
this.opts = context.opts;
}
this.setScope();
return this;
}
/**
* Here we resync the node paths `key` and `container`. If they've changed according
* to what we have stored internally then we attempt to resync by crawling and looking
* for the new values.
*/
function resync() {
if (this.removed) return;
this._resyncParent();
this._resyncList();
this._resyncKey();
//this._resyncRemoved();
}
/**
* [Please add a description.]
*/
function _resyncParent() {
if (this.parentPath) {
this.parent = this.parentPath.node;
}
}
/**
* [Please add a description.]
*/
function _resyncKey() {
if (!this.container) return;
if (this.node === this.container[this.key]) return;
// grrr, path key is out of sync. this is likely due to a modification to the AST
// not done through our path APIs
if (Array.isArray(this.container)) {
for (var i = 0; i < this.container.length; i++) {
if (this.container[i] === this.node) {
return this.setKey(i);
}
}
} else {
for (var key in this.container) {
if (this.container[key] === this.node) {
return this.setKey(key);
}
}
}
this.key = null;
}
/**
* [Please add a description.]
*/
function _resyncList() {
var listKey = this.listKey;
var parentPath = this.parentPath;
if (!listKey || !parentPath) return;
var newContainer = parentPath.node[listKey];
if (this.container === newContainer) return;
// container is out of sync. this is likely the result of it being reassigned
if (newContainer) {
this.container = newContainer;
} else {
this.container = null;
}
}
/**
* [Please add a description.]
*/
function _resyncRemoved() {
if (this.key == null || !this.container || this.container[this.key] !== this.node) {
this._markRemoved();
}
}
/**
* [Please add a description.]
*/
function shiftContext() {
this.contexts.shift();
this.setContext(this.contexts[0]);
}
/**
* [Please add a description.]
*/
function unshiftContext(context) {
this.contexts.unshift(context);
this.setContext(context);
}
/**
* [Please add a description.]
*/
function setup(parentPath, container, listKey, key) {
this.inList = !!listKey;
this.listKey = listKey;
this.parentKey = listKey || key;
this.container = container;
this.parentPath = parentPath || this.parentPath;
this.setKey(key);
}
/**
* [Please add a description.]
*/
function setKey(key) {
this.key = key;
this.node = this.container[this.key];
this.type = this.node && this.node.type;
}
/**
* [Please add a description.]
*/
function queueNode(path) {
var _arr3 = this.contexts;
for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
var context = _arr3[_i3];
if (context.queue) {
context.queue.push(path);
}
}
}
},{"148":148}],152:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports.toComputedKey = toComputedKey;
exports.ensureBlock = ensureBlock;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
function toComputedKey() {
var node = this.node;
var key;
if (this.isMemberExpression()) {
key = node.property;
} else if (this.isProperty()) {
key = node.key;
} else {
throw new ReferenceError("todo");
}
if (!node.computed) {
if (t.isIdentifier(key)) key = t.literal(key.name);
}
return key;
}
/**
* [Please add a description.]
*/
function ensureBlock() {
return t.ensureBlock(this.node);
}
},{"179":179}],153:[function(_dereq_,module,exports){
(function (global){
/* eslint eqeqeq: 0 */
"use strict";
exports.__esModule = true;
exports.evaluateTruthy = evaluateTruthy;
exports.evaluate = evaluate;
var VALID_CALLEES = ["String", "Number", "Math"];
/**
* Walk the input `node` and statically evaluate if it's truthy.
*
* Returning `true` when we're sure that the expression will evaluate to a
* truthy value, `false` if we're sure that it will evaluate to a falsy
* value and `undefined` if we aren't sure. Because of this please do not
* rely on coercion when using this method and check with === if it's false.
*
* For example do:
*
* if (t.evaluateTruthy(node) === false) falsyLogic();
*
* **AND NOT**
*
* if (!t.evaluateTruthy(node)) falsyLogic();
*
*/
function evaluateTruthy() {
var res = this.evaluate();
if (res.confident) return !!res.value;
}
/**
* Walk the input `node` and statically evaluate it.
*
* Returns an object in the form `{ confident, value }`. `confident` indicates
* whether or not we had to drop out of evaluating the expression because of
* hitting an unknown node that we couldn't confidently find the value of.
*
* Example:
*
* t.evaluate(parse("5 + 5")) // { confident: true, value: 10 }
* t.evaluate(parse("!true")) // { confident: true, value: false }
* t.evaluate(parse("foo + foo")) // { confident: false, value: undefined }
*
*/
function evaluate() {
var confident = true;
var value = evaluate(this);
if (!confident) value = undefined;
return {
confident: confident,
value: value
};
function evaluate(path) {
if (!confident) return;
var node = path.node;
if (path.isSequenceExpression()) {
var exprs = path.get("expressions");
return evaluate(exprs[exprs.length - 1]);
}
if (path.isLiteral()) {
if (node.regex) {
// we have a regex and we can't represent it natively
} else {
return node.value;
}
}
if (path.isConditionalExpression()) {
if (evaluate(path.get("test"))) {
return evaluate(path.get("consequent"));
} else {
return evaluate(path.get("alternate"));
}
}
if (path.isTypeCastExpression()) {
return evaluate(path.get("expression"));
}
if (path.isIdentifier() && !path.scope.hasBinding(node.name, true)) {
if (node.name === "undefined") {
return undefined;
} else if (node.name === "Infinity") {
return Infinity;
} else if (node.name === "NaN") {
return NaN;
}
}
// "foo".length
if (path.isMemberExpression() && !path.parentPath.isCallExpression({ callee: node })) {
var _property = path.get("property");
var object = path.get("object");
if (object.isLiteral() && _property.isIdentifier()) {
var _value = object.node.value;
var type = typeof _value;
if (type === "number" || type === "string") {
return _value[_property.node.name];
}
}
}
if (path.isReferencedIdentifier()) {
var binding = path.scope.getBinding(node.name);
if (binding && binding.hasValue) {
return binding.value;
} else {
var resolved = path.resolve();
if (resolved === path) {
return confident = false;
} else {
return evaluate(resolved);
}
}
}
if (path.isUnaryExpression({ prefix: true })) {
var argument = path.get("argument");
var arg = evaluate(argument);
switch (node.operator) {
case "void":
return undefined;
case "!":
return !arg;
case "+":
return +arg;
case "-":
return -arg;
case "~":
return ~arg;
case "typeof":
if (argument.isFunction()) {
return "function";
} else {
return typeof arg;
}
}
}
if (path.isArrayExpression() || path.isObjectExpression()) {
// we could evaluate these but it's probably impractical and not very useful
}
if (path.isLogicalExpression()) {
// If we are confident that one side of an && is false, or one side of
// an || is true, we can be confident about the entire expression
var wasConfident = confident;
var left = evaluate(path.get("left"));
var leftConfident = confident;
confident = wasConfident;
var right = evaluate(path.get("right"));
var rightConfident = confident;
var uncertain = leftConfident !== rightConfident;
confident = leftConfident && rightConfident;
switch (node.operator) {
case "||":
if ((left || right) && uncertain) {
confident = true;
}
return left || right;
case "&&":
if (!left && leftConfident || !right && rightConfident) {
confident = true;
}
return left && right;
}
}
if (path.isBinaryExpression()) {
var left = evaluate(path.get("left"));
var right = evaluate(path.get("right"));
switch (node.operator) {
case "-":
return left - right;
case "+":
return left + right;
case "/":
return left / right;
case "*":
return left * right;
case "%":
return left % right;
case "**":
return Math.pow(left, right);
case "<":
return left < right;
case ">":
return left > right;
case "<=":
return left <= right;
case ">=":
return left >= right;
case "==":
return left == right;
case "!=":
return left != right;
case "===":
return left === right;
case "!==":
return left !== right;
case "|":
return left | right;
case "&":
return left & right;
case "^":
return left ^ right;
case "<<":
return left << right;
case ">>":
return left >> right;
case ">>>":
return left >>> right;
}
}
if (path.isCallExpression()) {
var callee = path.get("callee");
var context;
var func;
// Number(1);
if (callee.isIdentifier() && !path.scope.getBinding(callee.node.name, true) && VALID_CALLEES.indexOf(callee.node.name) >= 0) {
func = global[node.callee.name];
}
if (callee.isMemberExpression()) {
var object = callee.get("object");
var property = callee.get("property");
// Math.min(1, 2)
if (object.isIdentifier() && property.isIdentifier() && VALID_CALLEES.indexOf(object.node.name) >= 0) {
context = global[object.node.name];
func = context[property.node.name];
}
// "abc".charCodeAt(4)
if (object.isLiteral() && property.isIdentifier()) {
var type = typeof object.node.value;
if (type === "string" || type === "number") {
context = object.node.value;
func = context[property.node.name];
}
}
}
if (func) {
var args = path.get("arguments").map(evaluate);
if (!confident) return;
return func.apply(context, args);
}
}
confident = false;
}
}
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{}],154:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports.getStatementParent = getStatementParent;
exports.getOpposite = getOpposite;
exports.getCompletionRecords = getCompletionRecords;
exports.getSibling = getSibling;
exports.get = get;
exports._getKey = _getKey;
exports._getPattern = _getPattern;
exports.getBindingIdentifiers = getBindingIdentifiers;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _index = _dereq_(155);
var _index2 = _interopRequireDefault(_index);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
function getStatementParent() {
var path = this;
do {
if (!path.parentPath || Array.isArray(path.container) && path.isStatement()) {
break;
} else {
path = path.parentPath;
}
} while (path);
if (path && (path.isProgram() || path.isFile())) {
throw new Error("File/Program node, we can't possibly find a statement parent to this");
}
return path;
}
/**
* [Please add a description.]
*/
function getOpposite() {
if (this.key === "left") {
return this.getSibling("right");
} else if (this.key === "right") {
return this.getSibling("left");
}
}
/**
* [Please add a description.]
*/
function getCompletionRecords() {
var paths = [];
var add = function add(path) {
if (path) paths = paths.concat(path.getCompletionRecords());
};
if (this.isIfStatement()) {
add(this.get("consequent"));
add(this.get("alternate"));
} else if (this.isDoExpression() || this.isFor() || this.isWhile()) {
add(this.get("body"));
} else if (this.isProgram() || this.isBlockStatement()) {
add(this.get("body").pop());
} else if (this.isFunction()) {
return this.get("body").getCompletionRecords();
} else if (this.isTryStatement()) {
add(this.get("block"));
add(this.get("handler"));
add(this.get("finalizer"));
} else {
paths.push(this);
}
return paths;
}
/**
* [Please add a description.]
*/
function getSibling(key) {
return _index2["default"].get({
parentPath: this.parentPath,
parent: this.parent,
container: this.container,
listKey: this.listKey,
key: key
});
}
/**
* [Please add a description.]
*/
function get(key, context) {
if (context === true) context = this.context;
var parts = key.split(".");
if (parts.length === 1) {
// "foo"
return this._getKey(key, context);
} else {
// "foo.bar"
return this._getPattern(parts, context);
}
}
/**
* [Please add a description.]
*/
function _getKey(key, context) {
// istanbul ignore next
var _this = this;
var node = this.node;
var container = node[key];
if (Array.isArray(container)) {
// requested a container so give them all the paths
return container.map(function (_, i) {
return _index2["default"].get({
listKey: key,
parentPath: _this,
parent: node,
container: container,
key: i
}).setContext(context);
});
} else {
return _index2["default"].get({
parentPath: this,
parent: node,
container: node,
key: key
}).setContext(context);
}
}
/**
* [Please add a description.]
*/
function _getPattern(parts, context) {
var path = this;
var _arr = parts;
for (var _i = 0; _i < _arr.length; _i++) {
var part = _arr[_i];
if (part === ".") {
path = path.parentPath;
} else {
if (Array.isArray(path)) {
path = path[part];
} else {
path = path.get(part, context);
}
}
}
return path;
}
/**
* [Please add a description.]
*/
function getBindingIdentifiers(duplicates) {
return t.getBindingIdentifiers(this.node, duplicates);
}
},{"155":155,"179":179}],155:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _libVirtualTypes = _dereq_(162);
var virtualTypes = _interopRequireWildcard(_libVirtualTypes);
var _index = _dereq_(148);
var _index2 = _interopRequireDefault(_index);
var _lodashObjectAssign = _dereq_(509);
var _lodashObjectAssign2 = _interopRequireDefault(_lodashObjectAssign);
var _scope = _dereq_(167);
var _scope2 = _interopRequireDefault(_scope);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
var NodePath = (function () {
/**
* [Please add a description.]
*/
function NodePath(hub, parent) {
_classCallCheck(this, NodePath);
this.contexts = [];
this.parent = parent;
this.data = {};
this.hub = hub;
this.shouldSkip = false;
this.shouldStop = false;
this.removed = false;
this.state = null;
this.opts = null;
this.skipKeys = null;
this.parentPath = null;
this.context = null;
this.container = null;
this.listKey = null;
this.inList = false;
this.parentKey = null;
this.key = null;
this.node = null;
this.scope = null;
this.type = null;
this.typeAnnotation = null;
}
/**
* [Please add a description.]
*/
/**
* [Please add a description.]
*/
NodePath.get = function get(_ref) {
var hub = _ref.hub;
var parentPath = _ref.parentPath;
var parent = _ref.parent;
var container = _ref.container;
var listKey = _ref.listKey;
var key = _ref.key;
if (!hub && parentPath) {
hub = parentPath.hub;
}
var targetNode = container[key];
var paths = parent._paths = parent._paths || [];
var path;
for (var i = 0; i < paths.length; i++) {
var pathCheck = paths[i];
if (pathCheck.node === targetNode) {
path = pathCheck;
break;
}
}
if (!path) {
path = new NodePath(hub, parent);
paths.push(path);
}
path.setup(parentPath, container, listKey, key);
return path;
};
/**
* [Please add a description.]
*/
NodePath.prototype.getScope = function getScope(scope) {
var ourScope = scope;
// we're entering a new scope so let's construct it!
if (this.isScope()) {
ourScope = new _scope2["default"](this, scope);
}
return ourScope;
};
/**
* [Please add a description.]
*/
NodePath.prototype.setData = function setData(key, val) {
return this.data[key] = val;
};
/**
* [Please add a description.]
*/
NodePath.prototype.getData = function getData(key, def) {
var val = this.data[key];
if (!val && def) val = this.data[key] = def;
return val;
};
/**
* [Please add a description.]
*/
NodePath.prototype.errorWithNode = function errorWithNode(msg) {
var Error = arguments.length <= 1 || arguments[1] === undefined ? SyntaxError : arguments[1];
return this.hub.file.errorWithNode(this.node, msg, Error);
};
/**
* [Please add a description.]
*/
NodePath.prototype.traverse = function traverse(visitor, state) {
_index2["default"](this.node, visitor, this.scope, state, this);
};
return NodePath;
})();
exports["default"] = NodePath;
_lodashObjectAssign2["default"](NodePath.prototype, _dereq_(149));
_lodashObjectAssign2["default"](NodePath.prototype, _dereq_(156));
_lodashObjectAssign2["default"](NodePath.prototype, _dereq_(165));
_lodashObjectAssign2["default"](NodePath.prototype, _dereq_(153));
_lodashObjectAssign2["default"](NodePath.prototype, _dereq_(152));
_lodashObjectAssign2["default"](NodePath.prototype, _dereq_(159));
_lodashObjectAssign2["default"](NodePath.prototype, _dereq_(151));
_lodashObjectAssign2["default"](NodePath.prototype, _dereq_(164));
_lodashObjectAssign2["default"](NodePath.prototype, _dereq_(163));
_lodashObjectAssign2["default"](NodePath.prototype, _dereq_(154));
_lodashObjectAssign2["default"](NodePath.prototype, _dereq_(150));
var _arr = t.TYPES;
var _loop = function () {
var type = _arr[_i];
var typeKey = "is" + type;
NodePath.prototype[typeKey] = function (opts) {
return t[typeKey](this.node, opts);
};
};
for (var _i = 0; _i < _arr.length; _i++) {
_loop();
}
var _loop2 = function (type) {
if (type[0] === "_") return "continue";
if (t.TYPES.indexOf(type) < 0) t.TYPES.push(type);
NodePath.prototype["is" + type] = function (opts) {
return virtualTypes[type].checkPath(this, opts);
};
};
for (var type in virtualTypes) {
var _ret2 = _loop2(type);
// istanbul ignore next
if (_ret2 === "continue") continue;
}
module.exports = exports["default"];
},{"148":148,"149":149,"150":150,"151":151,"152":152,"153":153,"154":154,"156":156,"159":159,"162":162,"163":163,"164":164,"165":165,"167":167,"179":179,"509":509}],156:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports.getTypeAnnotation = getTypeAnnotation;
exports._getTypeAnnotation = _getTypeAnnotation;
exports.isBaseType = isBaseType;
exports.couldBeBaseType = couldBeBaseType;
exports.baseTypeStrictlyMatches = baseTypeStrictlyMatches;
exports.isGenericType = isGenericType;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _inferers = _dereq_(158);
var inferers = _interopRequireWildcard(_inferers);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* Infer the type of the current `NodePath`.
*/
function getTypeAnnotation() {
if (this.typeAnnotation) return this.typeAnnotation;
var type = this._getTypeAnnotation() || t.anyTypeAnnotation();
if (t.isTypeAnnotation(type)) type = type.typeAnnotation;
return this.typeAnnotation = type;
}
/**
* todo: split up this method
*/
function _getTypeAnnotation() {
var node = this.node;
if (!node) {
// handle initializerless variables, add in checks for loop initializers too
if (this.key === "init" && this.parentPath.isVariableDeclarator()) {
var declar = this.parentPath.parentPath;
var declarParent = declar.parentPath;
// for (var NODE in bar) {}
if (declar.key === "left" && declarParent.isForInStatement()) {
return t.stringTypeAnnotation();
}
// for (var NODE of bar) {}
if (declar.key === "left" && declarParent.isForOfStatement()) {
return t.anyTypeAnnotation();
}
return t.voidTypeAnnotation();
} else {
return;
}
}
if (node.typeAnnotation) {
return node.typeAnnotation;
}
var inferer = inferers[node.type];
if (inferer) {
return inferer.call(this, node);
}
inferer = inferers[this.parentPath.type];
if (inferer && inferer.validParent) {
return this.parentPath.getTypeAnnotation();
}
}
/**
* [Please add a description.]
*/
function isBaseType(baseName, soft) {
return _isBaseType(baseName, this.getTypeAnnotation(), soft);
}
/**
* [Please add a description.]
*/
function _isBaseType(baseName, type, soft) {
if (baseName === "string") {
return t.isStringTypeAnnotation(type);
} else if (baseName === "number") {
return t.isNumberTypeAnnotation(type);
} else if (baseName === "boolean") {
return t.isBooleanTypeAnnotation(type);
} else if (baseName === "any") {
return t.isAnyTypeAnnotation(type);
} else if (baseName === "mixed") {
return t.isMixedTypeAnnotation(type);
} else if (baseName === "void") {
return t.isVoidTypeAnnotation(type);
} else {
if (soft) {
return false;
} else {
throw new Error("Unknown base type " + baseName);
}
}
}
/**
* [Please add a description.]
*/
function couldBeBaseType(name) {
var type = this.getTypeAnnotation();
if (t.isAnyTypeAnnotation(type)) return true;
if (t.isUnionTypeAnnotation(type)) {
var _arr = type.types;
for (var _i = 0; _i < _arr.length; _i++) {
var type2 = _arr[_i];
if (t.isAnyTypeAnnotation(type2) || _isBaseType(name, type2, true)) {
return true;
}
}
return false;
} else {
return _isBaseType(name, type, true);
}
}
/**
* [Please add a description.]
*/
function baseTypeStrictlyMatches(right) {
var left = this.getTypeAnnotation();
right = right.getTypeAnnotation();
if (!t.isAnyTypeAnnotation() && t.isFlowBaseAnnotation(left)) {
return right.type === left.type;
}
}
/**
* [Please add a description.]
*/
function isGenericType(genericName) {
var type = this.getTypeAnnotation();
return t.isGenericTypeAnnotation(type) && t.isIdentifier(type.id, { name: genericName });
}
},{"158":158,"179":179}],157:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
exports["default"] = function (node) {
if (!this.isReferenced()) return;
// check if a binding exists of this value and if so then return a union type of all
// possible types that the binding could be
var binding = this.scope.getBinding(node.name);
if (binding) {
if (binding.identifier.typeAnnotation) {
return binding.identifier.typeAnnotation;
} else {
return getTypeAnnotationBindingConstantViolations(this, node.name);
}
}
// built-in values
if (node.name === "undefined") {
return t.voidTypeAnnotation();
} else if (node.name === "NaN" || node.name === "Infinity") {
return t.numberTypeAnnotation();
} else if (node.name === "arguments") {
// todo
}
};
/**
* [Please add a description.]
*/
function getTypeAnnotationBindingConstantViolations(path, name) {
var binding = path.scope.getBinding(name);
var types = [];
path.typeAnnotation = t.unionTypeAnnotation(types);
var functionConstantViolations = [];
var constantViolations = getConstantViolationsBefore(binding, path, functionConstantViolations);
var testType = getConditionalAnnotation(path, name);
if (testType) {
var testConstantViolations = getConstantViolationsBefore(binding, testType.ifStatement);
// remove constant violations observed before the IfStatement
constantViolations = constantViolations.filter(function (path) {
return testConstantViolations.indexOf(path) < 0;
});
// clear current types and add in observed test type
types.push(testType.typeAnnotation);
}
if (constantViolations.length) {
// pick one constant from each scope which will represent the last possible
// control flow path that it could've taken/been
var rawConstantViolations = constantViolations.reverse();
var visitedScopes = [];
constantViolations = [];
var _arr = rawConstantViolations;
for (var _i = 0; _i < _arr.length; _i++) {
var violation = _arr[_i];
var violationScope = violation.scope;
if (visitedScopes.indexOf(violationScope) >= 0) continue;
visitedScopes.push(violationScope);
constantViolations.push(violation);
if (violationScope === path.scope) {
constantViolations = [violation];
break;
}
}
// add back on function constant violations since we can't track calls
constantViolations = constantViolations.concat(functionConstantViolations);
// push on inferred types of violated paths
var _arr2 = constantViolations;
for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
var violation = _arr2[_i2];
types.push(violation.getTypeAnnotation());
}
}
if (types.length) {
return t.createUnionTypeAnnotation(types);
}
}
/**
* [Please add a description.]
*/
function getConstantViolationsBefore(binding, path, functions) {
var violations = binding.constantViolations.slice();
violations.unshift(binding.path);
return violations.filter(function (violation) {
violation = violation.resolve();
var status = violation._guessExecutionStatusRelativeTo(path);
if (functions && status === "function") functions.push(violation);
return status === "before";
});
}
/**
* [Please add a description.]
*/
function inferAnnotationFromBinaryExpression(name, path) {
var operator = path.node.operator;
var right = path.get("right").resolve();
var left = path.get("left").resolve();
var target;
if (left.isIdentifier({ name: name })) {
target = right;
} else if (right.isIdentifier({ name: name })) {
target = left;
}
if (target) {
if (operator === "===") {
return target.getTypeAnnotation();
} else if (t.BOOLEAN_NUMBER_BINARY_OPERATORS.indexOf(operator) >= 0) {
return t.numberTypeAnnotation();
} else {
return;
}
} else {
if (operator !== "===") return;
}
//
var typeofPath;
var typePath;
if (left.isUnaryExpression({ operator: "typeof" })) {
typeofPath = left;
typePath = right;
} else if (right.isUnaryExpression({ operator: "typeof" })) {
typeofPath = right;
typePath = left;
}
if (!typePath && !typeofPath) return;
// ensure that the type path is a Literal
typePath = typePath.resolve();
if (!typePath.isLiteral()) return;
// and that it's a string so we can infer it
var typeValue = typePath.node.value;
if (typeof typeValue !== "string") return;
// and that the argument of the typeof path references us!
if (!typeofPath.get("argument").isIdentifier({ name: name })) return;
// turn type value into a type annotation
return t.createTypeAnnotationBasedOnTypeof(typePath.node.value);
}
/**
* [Please add a description.]
*/
function getParentConditionalPath(path) {
var parentPath;
while (parentPath = path.parentPath) {
if (parentPath.isIfStatement() || parentPath.isConditionalExpression()) {
if (path.key === "test") {
return;
} else {
return parentPath;
}
} else {
path = parentPath;
}
}
}
/**
* [Please add a description.]
*/
function getConditionalAnnotation(path, name) {
var ifStatement = getParentConditionalPath(path);
if (!ifStatement) return;
var test = ifStatement.get("test");
var paths = [test];
var types = [];
do {
var _path = paths.shift().resolve();
if (_path.isLogicalExpression()) {
paths.push(_path.get("left"));
paths.push(_path.get("right"));
}
if (_path.isBinaryExpression()) {
var type = inferAnnotationFromBinaryExpression(name, _path);
if (type) types.push(type);
}
} while (paths.length);
if (types.length) {
return {
typeAnnotation: t.createUnionTypeAnnotation(types),
ifStatement: ifStatement
};
} else {
return getConditionalAnnotation(ifStatement, name);
}
}
module.exports = exports["default"];
},{"179":179}],158:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports.VariableDeclarator = VariableDeclarator;
exports.TypeCastExpression = TypeCastExpression;
exports.NewExpression = NewExpression;
exports.TemplateLiteral = TemplateLiteral;
exports.UnaryExpression = UnaryExpression;
exports.BinaryExpression = BinaryExpression;
exports.LogicalExpression = LogicalExpression;
exports.ConditionalExpression = ConditionalExpression;
exports.SequenceExpression = SequenceExpression;
exports.AssignmentExpression = AssignmentExpression;
exports.UpdateExpression = UpdateExpression;
exports.Literal = Literal;
exports.ObjectExpression = ObjectExpression;
exports.ArrayExpression = ArrayExpression;
exports.RestElement = RestElement;
exports.CallExpression = CallExpression;
exports.TaggedTemplateExpression = TaggedTemplateExpression;
// istanbul ignore next
function _interopRequire(obj) { return obj && obj.__esModule ? obj["default"] : obj; }
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
var _infererReference = _dereq_(157);
exports.Identifier = _interopRequire(_infererReference);
/**
* [Please add a description.]
*/
function VariableDeclarator() {
var id = this.get("id");
if (id.isIdentifier()) {
return this.get("init").getTypeAnnotation();
} else {
return;
}
}
/**
* [Please add a description.]
*/
function TypeCastExpression(node) {
return node.typeAnnotation;
}
TypeCastExpression.validParent = true;
/**
* [Please add a description.]
*/
function NewExpression(node) {
if (this.get("callee").isIdentifier()) {
// only resolve identifier callee
return t.genericTypeAnnotation(node.callee);
}
}
/**
* [Please add a description.]
*/
function TemplateLiteral() {
return t.stringTypeAnnotation();
}
/**
* [Please add a description.]
*/
function UnaryExpression(node) {
var operator = node.operator;
if (operator === "void") {
return t.voidTypeAnnotation();
} else if (t.NUMBER_UNARY_OPERATORS.indexOf(operator) >= 0) {
return t.numberTypeAnnotation();
} else if (t.STRING_UNARY_OPERATORS.indexOf(operator) >= 0) {
return t.stringTypeAnnotation();
} else if (t.BOOLEAN_UNARY_OPERATORS.indexOf(operator) >= 0) {
return t.booleanTypeAnnotation();
}
}
/**
* [Please add a description.]
*/
function BinaryExpression(node) {
var operator = node.operator;
if (t.NUMBER_BINARY_OPERATORS.indexOf(operator) >= 0) {
return t.numberTypeAnnotation();
} else if (t.BOOLEAN_BINARY_OPERATORS.indexOf(operator) >= 0) {
return t.booleanTypeAnnotation();
} else if (operator === "+") {
var right = this.get("right");
var left = this.get("left");
if (left.isBaseType("number") && right.isBaseType("number")) {
// both numbers so this will be a number
return t.numberTypeAnnotation();
} else if (left.isBaseType("string") || right.isBaseType("string")) {
// one is a string so the result will be a string
return t.stringTypeAnnotation();
}
// unsure if left and right are strings or numbers so stay on the safe side
return t.unionTypeAnnotation([t.stringTypeAnnotation(), t.numberTypeAnnotation()]);
}
}
/**
* [Please add a description.]
*/
function LogicalExpression() {
return t.createUnionTypeAnnotation([this.get("left").getTypeAnnotation(), this.get("right").getTypeAnnotation()]);
}
/**
* [Please add a description.]
*/
function ConditionalExpression() {
return t.createUnionTypeAnnotation([this.get("consequent").getTypeAnnotation(), this.get("alternate").getTypeAnnotation()]);
}
/**
* [Please add a description.]
*/
function SequenceExpression() {
return this.get("expressions").pop().getTypeAnnotation();
}
/**
* [Please add a description.]
*/
function AssignmentExpression() {
return this.get("right").getTypeAnnotation();
}
/**
* [Please add a description.]
*/
function UpdateExpression(node) {
var operator = node.operator;
if (operator === "++" || operator === "--") {
return t.numberTypeAnnotation();
}
}
/**
* [Please add a description.]
*/
function Literal(node) {
var value = node.value;
if (typeof value === "string") return t.stringTypeAnnotation();
if (typeof value === "number") return t.numberTypeAnnotation();
if (typeof value === "boolean") return t.booleanTypeAnnotation();
if (value === null) return t.voidTypeAnnotation();
if (node.regex) return t.genericTypeAnnotation(t.identifier("RegExp"));
}
/**
* [Please add a description.]
*/
function ObjectExpression() {
return t.genericTypeAnnotation(t.identifier("Object"));
}
/**
* [Please add a description.]
*/
function ArrayExpression() {
return t.genericTypeAnnotation(t.identifier("Array"));
}
/**
* [Please add a description.]
*/
function RestElement() {
return ArrayExpression();
}
RestElement.validParent = true;
/**
* [Please add a description.]
*/
function Func() {
return t.genericTypeAnnotation(t.identifier("Function"));
}
exports.Function = Func;
exports.Class = Func;
/**
* [Please add a description.]
*/
function CallExpression() {
return resolveCall(this.get("callee"));
}
/**
* [Please add a description.]
*/
function TaggedTemplateExpression() {
return resolveCall(this.get("tag"));
}
/**
* [Please add a description.]
*/
function resolveCall(callee) {
callee = callee.resolve();
if (callee.isFunction()) {
if (callee.is("async")) {
if (callee.is("generator")) {
return t.genericTypeAnnotation(t.identifier("AsyncIterator"));
} else {
return t.genericTypeAnnotation(t.identifier("Promise"));
}
} else {
if (callee.node.returnType) {
return callee.node.returnType;
} else {
// todo: get union type of all return arguments
}
}
}
}
},{"157":157,"179":179}],159:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports.matchesPattern = matchesPattern;
exports.has = has;
exports.isnt = isnt;
exports.equals = equals;
exports.isNodeType = isNodeType;
exports.canHaveVariableDeclarationOrExpression = canHaveVariableDeclarationOrExpression;
exports.canSwapBetweenExpressionAndStatement = canSwapBetweenExpressionAndStatement;
exports.isCompletionRecord = isCompletionRecord;
exports.isStatementOrBlock = isStatementOrBlock;
exports.referencesImport = referencesImport;
exports.getSource = getSource;
exports.willIMaybeExecuteBefore = willIMaybeExecuteBefore;
exports._guessExecutionStatusRelativeTo = _guessExecutionStatusRelativeTo;
exports.resolve = resolve;
exports._resolve = _resolve;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _lodashCollectionIncludes = _dereq_(413);
var _lodashCollectionIncludes2 = _interopRequireDefault(_lodashCollectionIncludes);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* Match the current node if it matches the provided `pattern`.
*
* For example, given the match `React.createClass` it would match the
* parsed nodes of `React.createClass` and `React["createClass"]`.
*/
function matchesPattern(pattern, allowPartial) {
// not a member expression
if (!this.isMemberExpression()) return false;
var parts = pattern.split(".");
var search = [this.node];
var i = 0;
function matches(name) {
var part = parts[i];
return part === "*" || name === part;
}
while (search.length) {
var node = search.shift();
if (allowPartial && i === parts.length) {
return true;
}
if (t.isIdentifier(node)) {
// this part doesn't match
if (!matches(node.name)) return false;
} else if (t.isLiteral(node)) {
// this part doesn't match
if (!matches(node.value)) return false;
} else if (t.isMemberExpression(node)) {
if (node.computed && !t.isLiteral(node.property)) {
// we can't deal with this
return false;
} else {
search.unshift(node.property);
search.unshift(node.object);
continue;
}
} else if (t.isThisExpression(node)) {
if (!matches("this")) return false;
} else {
// we can't deal with this
return false;
}
// too many parts
if (++i > parts.length) {
return false;
}
}
return i === parts.length;
}
/**
* Check whether we have the input `key`. If the `key` references an array then we check
* if the array has any items, otherwise we just check if it's falsy.
*/
function has(key) {
var val = this.node[key];
if (val && Array.isArray(val)) {
return !!val.length;
} else {
return !!val;
}
}
/**
* Alias of `has`.
*/
var is = has;
exports.is = is;
/**
* Opposite of `has`.
*/
function isnt(key) {
return !this.has(key);
}
/**
* Check whether the path node `key` strict equals `value`.
*/
function equals(key, value) {
return this.node[key] === value;
}
/**
* Check the type against our stored internal type of the node. This is handy when a node has
* been removed yet we still internally know the type and need it to calculate node replacement.
*/
function isNodeType(type) {
return t.isType(this.type, type);
}
/**
* This checks whether or not we're in one of the following positions:
*
* for (KEY in right);
* for (KEY;;);
*
* This is because these spots allow VariableDeclarations AND normal expressions so we need
* to tell the path replacement that it's ok to replace this with an expression.
*/
function canHaveVariableDeclarationOrExpression() {
return (this.key === "init" || this.key === "left") && this.parentPath.isFor();
}
/**
* This checks whether we are swapping an arrow function's body between an
* expression and a block statement (or vice versa).
*
* This is because arrow functions may implicitly return an expression, which
* is the same as containing a block statement.
*/
function canSwapBetweenExpressionAndStatement(replacement) {
if (this.key !== "body" || !this.parentPath.isArrowFunctionExpression()) {
return false;
}
if (this.isExpression()) {
return t.isBlockStatement(replacement);
} else if (this.isBlockStatement()) {
return t.isExpression(replacement);
}
return false;
}
/**
* Check whether the current path references a completion record
*/
function isCompletionRecord(allowInsideFunction) {
var path = this;
var first = true;
do {
var container = path.container;
// we're in a function so can't be a completion record
if (path.isFunction() && !first) {
return !!allowInsideFunction;
}
first = false;
// check to see if we're the last item in the container and if we are
// we're a completion record!
if (Array.isArray(container) && path.key !== container.length - 1) {
return false;
}
} while ((path = path.parentPath) && !path.isProgram());
return true;
}
/**
* Check whether or not the current `key` allows either a single statement or block statement
* so we can explode it if necessary.
*/
function isStatementOrBlock() {
if (this.parentPath.isLabeledStatement() || t.isBlockStatement(this.container)) {
return false;
} else {
return _lodashCollectionIncludes2["default"](t.STATEMENT_OR_BLOCK_KEYS, this.key);
}
}
/**
* Check if the currently assigned path references the `importName` of `moduleSource`.
*/
function referencesImport(moduleSource, importName) {
if (!this.isReferencedIdentifier()) return false;
var binding = this.scope.getBinding(this.node.name);
if (!binding || binding.kind !== "module") return false;
var path = binding.path;
var parent = path.parentPath;
if (!parent.isImportDeclaration()) return false;
// check moduleSource
if (parent.node.source.value === moduleSource) {
if (!importName) return true;
} else {
return false;
}
if (path.isImportDefaultSpecifier() && importName === "default") {
return true;
}
if (path.isImportNamespaceSpecifier() && importName === "*") {
return true;
}
if (path.isImportSpecifier() && path.node.imported.name === importName) {
return true;
}
return false;
}
/**
* Get the source code associated with this node.
*/
function getSource() {
var node = this.node;
if (node.end) {
return this.hub.file.code.slice(node.start, node.end);
} else {
return "";
}
}
/**
* [Please add a description.]
*/
function willIMaybeExecuteBefore(target) {
return this._guessExecutionStatusRelativeTo(target) !== "after";
}
/**
* Given a `target` check the execution status of it relative to the current path.
*
* "Execution status" simply refers to where or not we **think** this will execuete
* before or after the input `target` element.
*/
function _guessExecutionStatusRelativeTo(target) {
// check if the two paths are in different functions, we can't track execution of these
var targetFuncParent = target.scope.getFunctionParent();
var selfFuncParent = this.scope.getFunctionParent();
if (targetFuncParent !== selfFuncParent) {
return "function";
}
var targetPaths = target.getAncestry();
//if (targetPaths.indexOf(this) >= 0) return "after";
var selfPaths = this.getAncestry();
// get ancestor where the branches intersect
var commonPath;
var targetIndex;
var selfIndex;
for (selfIndex = 0; selfIndex < selfPaths.length; selfIndex++) {
var selfPath = selfPaths[selfIndex];
targetIndex = targetPaths.indexOf(selfPath);
if (targetIndex >= 0) {
commonPath = selfPath;
break;
}
}
if (!commonPath) {
return "before";
}
// get the relationship paths that associate these nodes to their common ancestor
var targetRelationship = targetPaths[targetIndex - 1];
var selfRelationship = selfPaths[selfIndex - 1];
if (!targetRelationship || !selfRelationship) {
return "before";
}
// container list so let's see which one is after the other
if (targetRelationship.listKey && targetRelationship.container === selfRelationship.container) {
return targetRelationship.key > selfRelationship.key ? "before" : "after";
}
// otherwise we're associated by a parent node, check which key comes before the other
var targetKeyPosition = t.VISITOR_KEYS[targetRelationship.type].indexOf(targetRelationship.key);
var selfKeyPosition = t.VISITOR_KEYS[selfRelationship.type].indexOf(selfRelationship.key);
return targetKeyPosition > selfKeyPosition ? "before" : "after";
}
/**
* Resolve a "pointer" `NodePath` to it's absolute path.
*/
function resolve(dangerous, resolved) {
return this._resolve(dangerous, resolved) || this;
}
/**
* [Please add a description.]
*/
function _resolve(dangerous, resolved) {
// detect infinite recursion
// todo: possibly have a max length on this just to be safe
if (resolved && resolved.indexOf(this) >= 0) return;
// we store all the paths we've "resolved" in this array to prevent infinite recursion
resolved = resolved || [];
resolved.push(this);
if (this.isVariableDeclarator()) {
if (this.get("id").isIdentifier()) {
return this.get("init").resolve(dangerous, resolved);
} else {
// otherwise it's a request for a pattern and that's a bit more tricky
}
} else if (this.isReferencedIdentifier()) {
var binding = this.scope.getBinding(this.node.name);
if (!binding) return;
// reassigned so we can't really resolve it
if (!binding.constant) return;
// todo - lookup module in dependency graph
if (binding.kind === "module") return;
if (binding.path !== this) {
return binding.path.resolve(dangerous, resolved);
}
} else if (this.isTypeCastExpression()) {
return this.get("expression").resolve(dangerous, resolved);
} else if (dangerous && this.isMemberExpression()) {
// this is dangerous, as non-direct target assignments will mutate it's state
// making this resolution inaccurate
var targetKey = this.toComputedKey();
if (!t.isLiteral(targetKey)) return;
var targetName = targetKey.value;
var target = this.get("object").resolve(dangerous, resolved);
if (target.isObjectExpression()) {
var props = target.get("properties");
var _arr = props;
for (var _i = 0; _i < _arr.length; _i++) {
var prop = _arr[_i];
if (!prop.isProperty()) continue;
var key = prop.get("key");
// { foo: obj }
var match = prop.isnt("computed") && key.isIdentifier({ name: targetName });
// { "foo": "obj" } or { ["foo"]: "obj" }
match = match || key.isLiteral({ value: targetName });
if (match) return prop.get("value").resolve(dangerous, resolved);
}
} else if (target.isArrayExpression() && !isNaN(+targetName)) {
var elems = target.get("elements");
var elem = elems[targetName];
if (elem) return elem.resolve(dangerous, resolved);
}
}
}
},{"179":179,"413":413}],160:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _transformationHelpersReact = _dereq_(62);
var react = _interopRequireWildcard(_transformationHelpersReact);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
var referenceVisitor = {
/**
* [Please add a description.]
*/
ReferencedIdentifier: function ReferencedIdentifier(node, parent, scope, state) {
if (this.isJSXIdentifier() && react.isCompatTag(node.name)) {
return;
}
// direct references that we need to track to hoist this to the highest scope we can
var binding = scope.getBinding(node.name);
if (!binding) return;
// this binding isn't accessible from the parent scope so we can safely ignore it
// eg. it's in a closure etc
if (binding !== state.scope.getBinding(node.name)) return;
if (binding.constant) {
state.bindings[node.name] = binding;
} else {
var _arr = binding.constantViolations;
for (var _i = 0; _i < _arr.length; _i++) {
var violationPath = _arr[_i];
state.breakOnScopePaths = state.breakOnScopePaths.concat(violationPath.getAncestry());
}
}
}
};
/**
* [Please add a description.]
*/
var PathHoister = (function () {
function PathHoister(path, scope) {
_classCallCheck(this, PathHoister);
this.breakOnScopePaths = [];
this.bindings = {};
this.scopes = [];
this.scope = scope;
this.path = path;
}
/**
* [Please add a description.]
*/
PathHoister.prototype.isCompatibleScope = function isCompatibleScope(scope) {
for (var key in this.bindings) {
var binding = this.bindings[key];
if (!scope.bindingIdentifierEquals(key, binding.identifier)) {
return false;
}
}
return true;
};
/**
* [Please add a description.]
*/
PathHoister.prototype.getCompatibleScopes = function getCompatibleScopes() {
var scope = this.path.scope;
do {
if (this.isCompatibleScope(scope)) {
this.scopes.push(scope);
} else {
break;
}
if (this.breakOnScopePaths.indexOf(scope.path) >= 0) {
break;
}
} while (scope = scope.parent);
};
/**
* [Please add a description.]
*/
PathHoister.prototype.getAttachmentPath = function getAttachmentPath() {
var scopes = this.scopes;
var scope = scopes.pop();
if (!scope) return;
if (scope.path.isFunction()) {
if (this.hasOwnParamBindings(scope)) {
// should ignore this scope since it's ourselves
if (this.scope === scope) return;
// needs to be attached to the body
return scope.path.get("body").get("body")[0];
} else {
// doesn't need to be be attached to this scope
return this.getNextScopeStatementParent();
}
} else if (scope.path.isProgram()) {
return this.getNextScopeStatementParent();
}
};
/**
* [Please add a description.]
*/
PathHoister.prototype.getNextScopeStatementParent = function getNextScopeStatementParent() {
var scope = this.scopes.pop();
if (scope) return scope.path.getStatementParent();
};
/**
* [Please add a description.]
*/
PathHoister.prototype.hasOwnParamBindings = function hasOwnParamBindings(scope) {
for (var name in this.bindings) {
if (!scope.hasOwnBinding(name)) continue;
var binding = this.bindings[name];
if (binding.kind === "param") return true;
}
return false;
};
/**
* [Please add a description.]
*/
PathHoister.prototype.run = function run() {
var node = this.path.node;
if (node._hoisted) return;
node._hoisted = true;
this.path.traverse(referenceVisitor, this);
this.getCompatibleScopes();
var attachTo = this.getAttachmentPath();
if (!attachTo) return;
// don't bother hoisting to the same function as this will cause multiple branches to be evaluated more than once leading to a bad optimisation
if (attachTo.getFunctionParent() === this.path.getFunctionParent()) return;
var uid = attachTo.scope.generateUidIdentifier("ref");
attachTo.insertBefore([t.variableDeclaration("var", [t.variableDeclarator(uid, this.path.node)])]);
var parent = this.path.parentPath;
if (parent.isJSXElement() && this.path.container === parent.node.children) {
// turning the `span` in `<div><span /></div>` to an expression so we need to wrap it with
// an expression container
uid = t.JSXExpressionContainer(uid);
}
this.path.replaceWith(uid);
};
return PathHoister;
})();
exports["default"] = PathHoister;
module.exports = exports["default"];
},{"179":179,"62":62}],161:[function(_dereq_,module,exports){
// this file contains hooks that handle ancestry cleanup of parent nodes when removing children
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* Pre hooks should be used for either rejecting removal or delegating removal
*/
var pre = [
/**
* [Please add a description.]
*/
function (self) {
if (self.key === "body" && (self.isBlockStatement() || self.isClassBody())) {
// function () NODE
// class NODE
// attempting to remove a block statement that's someones body so let's just clear all the inner
// statements instead
self.node.body = [];
return true;
}
},
/**
* [Please add a description.]
*/
function (self, parent) {
var replace = false;
// () => NODE;
// removing the body of an arrow function
replace = replace || self.key === "body" && parent.isArrowFunctionExpression();
// throw NODE;
// removing a throw statement argument
replace = replace || self.key === "argument" && parent.isThrowStatement();
if (replace) {
self.replaceWith(t.identifier("undefined"));
return true;
}
}];
exports.pre = pre;
/**
* Post hooks should be used for cleaning up parents
*/
var post = [
/**
* [Please add a description.]
*/
function (self, parent) {
var removeParent = false;
// while (NODE);
// removing the test of a while/switch, we can either just remove it entirely *or* turn the `test` into `true`
// unlikely that the latter will ever be what's wanted so we just remove the loop to avoid infinite recursion
removeParent = removeParent || self.key === "test" && (parent.isWhile() || parent.isSwitchCase());
// export NODE;
// just remove a declaration for an export as this is no longer valid
removeParent = removeParent || self.key === "declaration" && parent.isExportDeclaration();
// label: NODE
// stray labeled statement with no body
removeParent = removeParent || self.key === "body" && parent.isLabeledStatement();
// var NODE;
// remove an entire declaration if there are no declarators left
removeParent = removeParent || self.listKey === "declarations" && parent.isVariableDeclaration() && parent.node.declarations.length === 0;
// NODE;
// remove the entire expression statement if there's no expression
removeParent = removeParent || self.key === "expression" && parent.isExpressionStatement();
// if (NODE);
// remove the entire if since the consequent is never going to be hit, if there's an alternate then it's already been
// handled with the `pre` hook
removeParent = removeParent || self.key === "test" && parent.isIfStatement();
if (removeParent) {
parent.dangerouslyRemove();
return true;
}
},
/**
* [Please add a description.]
*/
function (self, parent) {
if (parent.isSequenceExpression() && parent.node.expressions.length === 1) {
// (node, NODE);
// we've just removed the second element of a sequence expression so let's turn that sequence
// expression into a regular expression
parent.replaceWith(parent.node.expressions[0]);
return true;
}
},
/**
* [Please add a description.]
*/
function (self, parent) {
if (parent.isBinary()) {
// left + NODE;
// NODE + right;
// we're in a binary expression, better remove it and replace it with the last expression
if (self.key === "left") {
parent.replaceWith(parent.node.right);
} else {
// key === "right"
parent.replaceWith(parent.node.left);
}
return true;
}
}];
exports.post = post;
},{"179":179}],162:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _transformationHelpersReact = _dereq_(62);
var react = _interopRequireWildcard(_transformationHelpersReact);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
var ReferencedIdentifier = {
types: ["Identifier", "JSXIdentifier"],
checkPath: function checkPath(_ref, opts) {
var node = _ref.node;
var parent = _ref.parent;
if (!t.isIdentifier(node, opts)) {
if (t.isJSXIdentifier(node, opts)) {
if (react.isCompatTag(node.name)) return false;
} else {
// not a JSXIdentifier or an Identifier
return false;
}
}
// check if node is referenced
return t.isReferenced(node, parent);
}
};
exports.ReferencedIdentifier = ReferencedIdentifier;
/**
* [Please add a description.]
*/
var BindingIdentifier = {
types: ["Identifier"],
checkPath: function checkPath(_ref2) {
var node = _ref2.node;
var parent = _ref2.parent;
return t.isBinding(node, parent);
}
};
exports.BindingIdentifier = BindingIdentifier;
/**
* [Please add a description.]
*/
var Statement = {
types: ["Statement"],
checkPath: function checkPath(_ref3) {
var node = _ref3.node;
var parent = _ref3.parent;
if (t.isStatement(node)) {
if (t.isVariableDeclaration(node)) {
if (t.isForXStatement(parent, { left: node })) return false;
if (t.isForStatement(parent, { init: node })) return false;
}
return true;
} else {
return false;
}
}
};
exports.Statement = Statement;
/**
* [Please add a description.]
*/
var Expression = {
types: ["Expression"],
checkPath: function checkPath(path) {
if (path.isIdentifier()) {
return path.isReferencedIdentifier();
} else {
return t.isExpression(path.node);
}
}
};
exports.Expression = Expression;
/**
* [Please add a description.]
*/
var Scope = {
types: ["Scopable"],
checkPath: function checkPath(path) {
return t.isScope(path.node, path.parent);
}
};
exports.Scope = Scope;
/**
* [Please add a description.]
*/
var Referenced = {
checkPath: function checkPath(path) {
return t.isReferenced(path.node, path.parent);
}
};
exports.Referenced = Referenced;
/**
* [Please add a description.]
*/
var BlockScoped = {
checkPath: function checkPath(path) {
return t.isBlockScoped(path.node);
}
};
exports.BlockScoped = BlockScoped;
/**
* [Please add a description.]
*/
var Var = {
types: ["VariableDeclaration"],
checkPath: function checkPath(path) {
return t.isVar(path.node);
}
};
exports.Var = Var;
/**
* [Please add a description.]
*/
var DirectiveLiteral = {
types: ["Literal"],
checkPath: function checkPath(path) {
return path.isLiteral() && path.parentPath.isExpressionStatement();
}
};
exports.DirectiveLiteral = DirectiveLiteral;
/**
* [Please add a description.]
*/
var Directive = {
types: ["ExpressionStatement"],
checkPath: function checkPath(path) {
return path.get("expression").isLiteral();
}
};
exports.Directive = Directive;
/**
* [Please add a description.]
*/
var User = {
checkPath: function checkPath(path) {
return path.node && !!path.node.loc;
}
};
exports.User = User;
/**
* [Please add a description.]
*/
var Generated = {
checkPath: function checkPath(path) {
return !path.isUser();
}
};
exports.Generated = Generated;
/**
* [Please add a description.]
*/
var Flow = {
types: ["Flow", "ImportDeclaration", "ExportDeclaration"],
checkPath: function checkPath(_ref4) {
var node = _ref4.node;
if (t.isFlow(node)) {
return true;
} else if (t.isImportDeclaration(node)) {
return node.importKind === "type" || node.importKind === "typeof";
} else if (t.isExportDeclaration(node)) {
return node.exportKind === "type";
} else {
return false;
}
}
};
exports.Flow = Flow;
},{"179":179,"62":62}],163:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports.insertBefore = insertBefore;
exports._containerInsert = _containerInsert;
exports._containerInsertBefore = _containerInsertBefore;
exports._containerInsertAfter = _containerInsertAfter;
exports._maybePopFromStatements = _maybePopFromStatements;
exports.insertAfter = insertAfter;
exports.updateSiblingKeys = updateSiblingKeys;
exports._verifyNodeList = _verifyNodeList;
exports.unshiftContainer = unshiftContainer;
exports.pushContainer = pushContainer;
exports.hoist = hoist;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _libHoister = _dereq_(160);
var _libHoister2 = _interopRequireDefault(_libHoister);
var _index = _dereq_(155);
var _index2 = _interopRequireDefault(_index);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* Insert the provided nodes before the current one.
*/
function insertBefore(nodes) {
this._assertUnremoved();
nodes = this._verifyNodeList(nodes);
if (this.parentPath.isExpressionStatement() || this.parentPath.isLabeledStatement()) {
return this.parentPath.insertBefore(nodes);
} else if (this.isNodeType("Expression") || this.parentPath.isForStatement() && this.key === "init") {
if (this.node) nodes.push(this.node);
this.replaceExpressionWithStatements(nodes);
} else {
this._maybePopFromStatements(nodes);
if (Array.isArray(this.container)) {
return this._containerInsertBefore(nodes);
} else if (this.isStatementOrBlock()) {
if (this.node) nodes.push(this.node);
this.node = this.container[this.key] = t.blockStatement(nodes);
} else {
throw new Error("We don't know what to do with this node type. We were previously a Statement but we can't fit in here?");
}
}
return [this];
}
/**
* [Please add a description.]
*/
function _containerInsert(from, nodes) {
this.updateSiblingKeys(from, nodes.length);
var paths = [];
for (var i = 0; i < nodes.length; i++) {
var to = from + i;
var node = nodes[i];
this.container.splice(to, 0, node);
if (this.context) {
var path = this.context.create(this.parent, this.container, to, this.listKey);
paths.push(path);
this.queueNode(path);
} else {
paths.push(_index2["default"].get({
parentPath: this,
parent: node,
container: this.container,
listKey: this.listKey,
key: to
}));
}
}
return paths;
}
/**
* [Please add a description.]
*/
function _containerInsertBefore(nodes) {
return this._containerInsert(this.key, nodes);
}
/**
* [Please add a description.]
*/
function _containerInsertAfter(nodes) {
return this._containerInsert(this.key + 1, nodes);
}
/**
* [Please add a description.]
*/
function _maybePopFromStatements(nodes) {
var last = nodes[nodes.length - 1];
if (t.isExpressionStatement(last) && t.isIdentifier(last.expression) && !this.isCompletionRecord()) {
nodes.pop();
}
}
/**
* Insert the provided nodes after the current one. When inserting nodes after an
* expression, ensure that the completion record is correct by pushing the current node.
*/
function insertAfter(nodes) {
this._assertUnremoved();
nodes = this._verifyNodeList(nodes);
if (this.parentPath.isExpressionStatement() || this.parentPath.isLabeledStatement()) {
return this.parentPath.insertAfter(nodes);
} else if (this.isNodeType("Expression") || this.parentPath.isForStatement() && this.key === "init") {
if (this.node) {
var temp = this.scope.generateDeclaredUidIdentifier();
nodes.unshift(t.expressionStatement(t.assignmentExpression("=", temp, this.node)));
nodes.push(t.expressionStatement(temp));
}
this.replaceExpressionWithStatements(nodes);
} else {
this._maybePopFromStatements(nodes);
if (Array.isArray(this.container)) {
return this._containerInsertAfter(nodes);
} else if (this.isStatementOrBlock()) {
if (this.node) nodes.unshift(this.node);
this.node = this.container[this.key] = t.blockStatement(nodes);
} else {
throw new Error("We don't know what to do with this node type. We were previously a Statement but we can't fit in here?");
}
}
return [this];
}
/**
* Update all sibling node paths after `fromIndex` by `incrementBy`.
*/
function updateSiblingKeys(fromIndex, incrementBy) {
var paths = this.parent._paths;
for (var i = 0; i < paths.length; i++) {
var path = paths[i];
if (path.key >= fromIndex) {
path.key += incrementBy;
}
}
}
/**
* [Please add a description.]
*/
function _verifyNodeList(nodes) {
if (nodes.constructor !== Array) {
nodes = [nodes];
}
for (var i = 0; i < nodes.length; i++) {
var node = nodes[i];
if (!node) {
throw new Error("Node list has falsy node with the index of " + i);
} else if (typeof node !== "object") {
throw new Error("Node list contains a non-object node with the index of " + i);
} else if (!node.type) {
throw new Error("Node list contains a node without a type with the index of " + i);
} else if (node instanceof _index2["default"]) {
nodes[i] = node.node;
}
}
return nodes;
}
/**
* [Please add a description.]
*/
function unshiftContainer(listKey, nodes) {
this._assertUnremoved();
nodes = this._verifyNodeList(nodes);
// get the first path and insert our nodes before it, if it doesn't exist then it
// doesn't matter, our nodes will be inserted anyway
var container = this.node[listKey];
var path = _index2["default"].get({
parentPath: this,
parent: this.node,
container: container,
listKey: listKey,
key: 0
});
return path.insertBefore(nodes);
}
/**
* [Please add a description.]
*/
function pushContainer(listKey, nodes) {
this._assertUnremoved();
nodes = this._verifyNodeList(nodes);
// get an invisible path that represents the last node + 1 and replace it with our
// nodes, effectively inlining it
var container = this.node[listKey];
var i = container.length;
var path = _index2["default"].get({
parentPath: this,
parent: this.node,
container: container,
listKey: listKey,
key: i
});
return path.replaceWith(nodes, true);
}
/**
* Hoist the current node to the highest scope possible and return a UID
* referencing it.
*/
function hoist() {
var scope = arguments.length <= 0 || arguments[0] === undefined ? this.scope : arguments[0];
var hoister = new _libHoister2["default"](this, scope);
return hoister.run();
}
},{"155":155,"160":160,"179":179}],164:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports.remove = remove;
exports.dangerouslyRemove = dangerouslyRemove;
exports._callRemovalHooks = _callRemovalHooks;
exports._remove = _remove;
exports._markRemoved = _markRemoved;
exports._assertUnremoved = _assertUnremoved;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _libRemovalHooks = _dereq_(161);
var removalHooks = _interopRequireWildcard(_libRemovalHooks);
/**
* Deprecated in favor of `dangerouslyRemove` as it's far more scary and more accurately portrays
* the risk.
*/
function remove() {
console.trace("Path#remove has been renamed to Path#dangerouslyRemove, removing a node is extremely dangerous so please refrain using it.");
return this.dangerouslyRemove();
}
/**
* Dangerously remove the current node. This may sometimes result in a tainted
* invalid AST so use with caution.
*/
function dangerouslyRemove() {
this._assertUnremoved();
this.resync();
if (this._callRemovalHooks("pre")) {
this._markRemoved();
return;
}
this.shareCommentsWithSiblings();
this._remove();
this._markRemoved();
this._callRemovalHooks("post");
}
/**
* [Please add a description.]
*/
function _callRemovalHooks(position) {
var _arr = removalHooks[position];
for (var _i = 0; _i < _arr.length; _i++) {
var fn = _arr[_i];
if (fn(this, this.parentPath)) return true;
}
}
/**
* [Please add a description.]
*/
function _remove() {
if (Array.isArray(this.container)) {
this.container.splice(this.key, 1);
this.updateSiblingKeys(this.key, -1);
} else {
this.container[this.key] = null;
}
}
/**
* [Please add a description.]
*/
function _markRemoved() {
this.shouldSkip = true;
this.removed = true;
this.node = null;
}
/**
* [Please add a description.]
*/
function _assertUnremoved() {
if (this.removed) {
throw this.errorWithNode("NodePath has been removed so is read-only.");
}
}
},{"161":161}],165:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports.replaceWithMultiple = replaceWithMultiple;
exports.replaceWithSourceString = replaceWithSourceString;
exports.replaceWith = replaceWith;
exports.replaceExpressionWithStatements = replaceExpressionWithStatements;
exports.replaceInline = replaceInline;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _helpersCodeFrame = _dereq_(38);
var _helpersCodeFrame2 = _interopRequireDefault(_helpersCodeFrame);
var _index = _dereq_(148);
var _index2 = _interopRequireDefault(_index);
var _index3 = _dereq_(155);
var _index4 = _interopRequireDefault(_index3);
var _helpersParse = _dereq_(42);
var _helpersParse2 = _interopRequireDefault(_helpersParse);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
/**
* [Please add a description.]
*/
var hoistVariablesVisitor = {
/**
* [Please add a description.]
*/
Function: function Function() {
this.skip();
},
/**
* [Please add a description.]
*/
VariableDeclaration: function VariableDeclaration(node, parent, scope) {
if (node.kind !== "var") return;
var bindings = this.getBindingIdentifiers();
for (var key in bindings) {
scope.push({ id: bindings[key] });
}
var exprs = [];
var _arr = node.declarations;
for (var _i = 0; _i < _arr.length; _i++) {
var declar = _arr[_i];
if (declar.init) {
exprs.push(t.expressionStatement(t.assignmentExpression("=", declar.id, declar.init)));
}
}
return exprs;
}
};
/**
* Replace a node with an array of multiple. This method performs the following steps:
*
* - Inherit the comments of first provided node with that of the current node.
* - Insert the provided nodes after the current node.
* - Remove the current node.
*/
function replaceWithMultiple(nodes) {
this.resync();
nodes = this._verifyNodeList(nodes);
t.inheritLeadingComments(nodes[0], this.node);
t.inheritTrailingComments(nodes[nodes.length - 1], this.node);
this.node = this.container[this.key] = null;
this.insertAfter(nodes);
if (!this.node) this.dangerouslyRemove();
}
/**
* Parse a string as an expression and replace the current node with the result.
*
* NOTE: This is typically not a good idea to use. Building source strings when
* transforming ASTs is an antipattern and SHOULD NOT be encouraged. Even if it's
* easier to use, your transforms will be extremely brittle.
*/
function replaceWithSourceString(replacement) {
this.resync();
try {
replacement = "(" + replacement + ")";
replacement = _helpersParse2["default"](replacement);
} catch (err) {
var loc = err.loc;
if (loc) {
err.message += " - make sure this is an expression.";
err.message += "\n" + _helpersCodeFrame2["default"](replacement, loc.line, loc.column + 1);
}
throw err;
}
replacement = replacement.program.body[0].expression;
_index2["default"].removeProperties(replacement);
return this.replaceWith(replacement);
}
/**
* Replace the current node with another.
*/
function replaceWith(replacement, whateverAllowed) {
this.resync();
if (this.removed) {
throw new Error("You can't replace this node, we've already removed it");
}
if (replacement instanceof _index4["default"]) {
replacement = replacement.node;
}
if (!replacement) {
throw new Error("You passed `path.replaceWith()` a falsy node, use `path.dangerouslyRemove()` instead");
}
if (this.node === replacement) {
return;
}
if (this.isProgram() && !t.isProgram(replacement)) {
throw new Error("You can only replace a Program root node with another Program node");
}
// normalise inserting an entire AST
if (t.isProgram(replacement) && !this.isProgram()) {
replacement = replacement.body;
whateverAllowed = true;
}
if (Array.isArray(replacement)) {
if (whateverAllowed) {
return this.replaceWithMultiple(replacement);
} else {
throw new Error("Don't use `path.replaceWith()` with an array of nodes, use `path.replaceWithMultiple()`");
}
}
if (typeof replacement === "string") {
// triggers an error
return this.replaceWithSourceString();
}
if (this.isNodeType("Statement") && t.isExpression(replacement)) {
if (!this.canHaveVariableDeclarationOrExpression() && !this.canSwapBetweenExpressionAndStatement(replacement)) {
// replacing a statement with an expression so wrap it in an expression statement
replacement = t.expressionStatement(replacement);
}
}
if (this.isNodeType("Expression") && t.isStatement(replacement)) {
if (!this.canSwapBetweenExpressionAndStatement(replacement)) {
// replacing an expression with a statement so let's explode it
return this.replaceExpressionWithStatements([replacement]);
}
}
var oldNode = this.node;
if (oldNode) t.inheritsComments(replacement, oldNode);
// replace the node
this.node = this.container[this.key] = replacement;
this.type = replacement.type;
// potentially create new scope
this.setScope();
}
/**
* This method takes an array of statements nodes and then explodes it
* into expressions. This method retains completion records which is
* extremely important to retain original semantics.
*/
function replaceExpressionWithStatements(nodes) {
this.resync();
var toSequenceExpression = t.toSequenceExpression(nodes, this.scope);
if (toSequenceExpression) {
return this.replaceWith(toSequenceExpression);
} else {
var container = t.functionExpression(null, [], t.blockStatement(nodes));
container.shadow = true;
this.replaceWith(t.callExpression(container, []));
this.traverse(hoistVariablesVisitor);
// add implicit returns to all ending expression statements
var last = this.get("callee").getCompletionRecords();
var _arr2 = last;
for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
var lastNode = _arr2[_i2];
if (!lastNode.isExpressionStatement()) continue;
var loop = lastNode.findParent(function (path) {
return path.isLoop();
});
if (loop) {
var uid = this.get("callee").scope.generateDeclaredUidIdentifier("ret");
this.get("callee.body").pushContainer("body", t.returnStatement(uid));
lastNode.get("expression").replaceWith(t.assignmentExpression("=", uid, lastNode.node.expression));
} else {
lastNode.replaceWith(t.returnStatement(lastNode.node.expression));
}
}
return this.node;
}
}
/**
* [Please add a description.]
*/
function replaceInline(nodes) {
this.resync();
if (Array.isArray(nodes)) {
if (Array.isArray(this.container)) {
nodes = this._verifyNodeList(nodes);
this._containerInsertAfter(nodes);
return this.dangerouslyRemove();
} else {
return this.replaceWithMultiple(nodes);
}
} else {
return this.replaceWith(nodes);
}
}
},{"148":148,"155":155,"179":179,"38":38,"42":42}],166:[function(_dereq_,module,exports){
/**
* This class is responsible for a binding inside of a scope.
*
* It tracks the following:
*
* * Node path.
* * Amount of times referenced by other nodes.
* * Paths to nodes that reassign or modify this binding.
* * The kind of binding. (Is it a parameter, declaration etc)
*/
"use strict";
exports.__esModule = true;
// istanbul ignore next
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Binding = (function () {
function Binding(_ref) {
var existing = _ref.existing;
var identifier = _ref.identifier;
var scope = _ref.scope;
var path = _ref.path;
var kind = _ref.kind;
_classCallCheck(this, Binding);
this.constantViolations = [];
this.constant = true;
this.identifier = identifier;
this.references = 0;
this.referenced = false;
this.scope = scope;
this.path = path;
this.kind = kind;
this.hasValue = false;
this.hasDeoptedValue = false;
this.value = null;
this.clearValue();
if (existing) {
this.constantViolations = [].concat(existing.path, existing.constantViolations, this.constantViolations);
}
}
/**
* [Please add a description.]
*/
Binding.prototype.deoptValue = function deoptValue() {
this.clearValue();
this.hasDeoptedValue = true;
};
/**
* [Please add a description.]
*/
Binding.prototype.setValue = function setValue(value) {
if (this.hasDeoptedValue) return;
this.hasValue = true;
this.value = value;
};
/**
* [Please add a description.]
*/
Binding.prototype.clearValue = function clearValue() {
this.hasDeoptedValue = false;
this.hasValue = false;
this.value = null;
};
/**
* Register a constant violation with the provided `path`.
*/
Binding.prototype.reassign = function reassign(path) {
this.constant = false;
this.constantViolations.push(path);
};
/**
* Increment the amount of references to this binding.
*/
Binding.prototype.reference = function reference() {
this.referenced = true;
this.references++;
};
/**
* Decrement the amount of references to this binding.
*/
Binding.prototype.dereference = function dereference() {
this.references--;
this.referenced = !!this.references;
};
return Binding;
})();
exports["default"] = Binding;
module.exports = exports["default"];
},{}],167:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
// istanbul ignore next
var _createClass = (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, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// istanbul ignore next
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _lodashCollectionIncludes = _dereq_(413);
var _lodashCollectionIncludes2 = _interopRequireDefault(_lodashCollectionIncludes);
var _repeating = _dereq_(584);
var _repeating2 = _interopRequireDefault(_repeating);
var _index = _dereq_(148);
var _index2 = _interopRequireDefault(_index);
var _lodashObjectDefaults = _dereq_(510);
var _lodashObjectDefaults2 = _interopRequireDefault(_lodashObjectDefaults);
var _messages = _dereq_(43);
var messages = _interopRequireWildcard(_messages);
var _binding = _dereq_(166);
var _binding2 = _interopRequireDefault(_binding);
var _globals = _dereq_(397);
var _globals2 = _interopRequireDefault(_globals);
var _lodashArrayFlatten = _dereq_(406);
var _lodashArrayFlatten2 = _interopRequireDefault(_lodashArrayFlatten);
var _lodashObjectExtend = _dereq_(511);
var _lodashObjectExtend2 = _interopRequireDefault(_lodashObjectExtend);
var _helpersObject = _dereq_(41);
var _helpersObject2 = _interopRequireDefault(_helpersObject);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
var collectorVisitor = {
For: function For() {
var _arr = t.FOR_INIT_KEYS;
for (var _i = 0; _i < _arr.length; _i++) {
var key = _arr[_i];
var declar = this.get(key);
if (declar.isVar()) this.scope.getFunctionParent().registerBinding("var", declar);
}
},
Declaration: function Declaration() {
// delegate block scope handling to the `blockVariableVisitor`
if (this.isBlockScoped()) return;
// this will be hit again once we traverse into it after this iteration
if (this.isExportDeclaration() && this.get("declaration").isDeclaration()) return;
// we've ran into a declaration!
this.scope.getFunctionParent().registerDeclaration(this);
},
ReferencedIdentifier: function ReferencedIdentifier(node, parent, scope, state) {
state.references.push(this);
},
ForXStatement: function ForXStatement(node, parent, scope, state) {
var left = this.get("left");
if (left.isPattern() || left.isIdentifier()) {
state.constantViolations.push(left);
}
},
ExportDeclaration: {
exit: function exit(node, parent, scope) {
var declar = node.declaration;
if (t.isClassDeclaration(declar) || t.isFunctionDeclaration(declar)) {
var binding = scope.getBinding(declar.id.name);
if (binding) binding.reference();
} else if (t.isVariableDeclaration(declar)) {
var _arr2 = declar.declarations;
for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
var decl = _arr2[_i2];
var ids = t.getBindingIdentifiers(decl);
for (var _name in ids) {
var binding = scope.getBinding(_name);
if (binding) binding.reference();
}
}
}
}
},
LabeledStatement: function LabeledStatement() {
this.scope.getProgramParent().addGlobal(this.node);
this.scope.getBlockParent().registerDeclaration(this);
},
AssignmentExpression: function AssignmentExpression(node, parent, scope, state) {
state.assignments.push(this);
},
UpdateExpression: function UpdateExpression(node, parent, scope, state) {
state.constantViolations.push(this.get("argument"));
},
UnaryExpression: function UnaryExpression(node, parent, scope, state) {
if (this.node.operator === "delete") {
state.constantViolations.push(this.get("argument"));
}
},
BlockScoped: function BlockScoped() {
var scope = this.scope;
if (scope.path === this) scope = scope.parent;
scope.getBlockParent().registerDeclaration(this);
},
ClassDeclaration: function ClassDeclaration() {
var name = this.node.id.name;
this.scope.bindings[name] = this.scope.getBinding(name);
},
Block: function Block() {
var paths = this.get("body");
var _arr3 = paths;
for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
var bodyPath = _arr3[_i3];
if (bodyPath.isFunctionDeclaration()) {
this.scope.getBlockParent().registerDeclaration(bodyPath);
}
}
}
};
/**
* [Please add a description.]
*/
var renameVisitor = {
/**
* [Please add a description.]
*/
ReferencedIdentifier: function ReferencedIdentifier(node, parent, scope, state) {
if (node.name === state.oldName) {
node.name = state.newName;
}
},
/**
* [Please add a description.]
*/
Scope: function Scope(node, parent, scope, state) {
if (!scope.bindingIdentifierEquals(state.oldName, state.binding)) {
this.skip();
}
},
"AssignmentExpression|Declaration": function AssignmentExpressionDeclaration(node, parent, scope, state) {
var ids = this.getBindingIdentifiers();
for (var name in ids) {
if (name === state.oldName) ids[name].name = state.newName;
}
}
};
/**
* [Please add a description.]
*/
var Scope = (function () {
/**
* This searches the current "scope" and collects all references/bindings
* within.
*/
function Scope(path, parent) {
_classCallCheck(this, Scope);
if (parent && parent.block === path.node) {
return parent;
}
var cached = path.getData("scope");
if (cached && cached.parent === parent && cached.block === path.node) {
return cached;
} else {
path.setData("scope", this);
}
this.parent = parent;
this.hub = path.hub;
this.parentBlock = path.parent;
this.block = path.node;
this.path = path;
}
/**
* Globals.
*/
/**
* Traverse node with current scope and path.
*/
Scope.prototype.traverse = function traverse(node, opts, state) {
_index2["default"](node, opts, this, state, this.path);
};
/**
* Generate a unique identifier and add it to the current scope.
*/
Scope.prototype.generateDeclaredUidIdentifier = function generateDeclaredUidIdentifier() {
var name = arguments.length <= 0 || arguments[0] === undefined ? "temp" : arguments[0];
var id = this.generateUidIdentifier(name);
this.push({ id: id });
return id;
};
/**
* Generate a unique identifier.
*/
Scope.prototype.generateUidIdentifier = function generateUidIdentifier(name) {
return t.identifier(this.generateUid(name));
};
/**
* Generate a unique `_id1` binding.
*/
Scope.prototype.generateUid = function generateUid(name) {
name = t.toIdentifier(name).replace(/^_+/, "");
var uid;
var i = 0;
do {
uid = this._generateUid(name, i);
i++;
} while (this.hasBinding(uid) || this.hasGlobal(uid) || this.hasReference(uid));
var program = this.getProgramParent();
program.references[uid] = true;
program.uids[uid] = true;
return uid;
};
/**
* Generate an `_id1`.
*/
Scope.prototype._generateUid = function _generateUid(name, i) {
var id = name;
if (i > 1) id += i;
return "_" + id;
};
/**
* Generate a unique identifier based on a node.
*/
Scope.prototype.generateUidIdentifierBasedOnNode = function generateUidIdentifierBasedOnNode(parent, defaultName) {
var node = parent;
if (t.isAssignmentExpression(parent)) {
node = parent.left;
} else if (t.isVariableDeclarator(parent)) {
node = parent.id;
} else if (t.isProperty(node)) {
node = node.key;
}
var parts = [];
var add = function add(node) {
if (t.isModuleDeclaration(node)) {
if (node.source) {
add(node.source);
} else if (node.specifiers && node.specifiers.length) {
var _arr4 = node.specifiers;
for (var _i4 = 0; _i4 < _arr4.length; _i4++) {
var specifier = _arr4[_i4];
add(specifier);
}
} else if (node.declaration) {
add(node.declaration);
}
} else if (t.isModuleSpecifier(node)) {
add(node.local);
} else if (t.isMemberExpression(node)) {
add(node.object);
add(node.property);
} else if (t.isIdentifier(node)) {
parts.push(node.name);
} else if (t.isLiteral(node)) {
parts.push(node.value);
} else if (t.isCallExpression(node)) {
add(node.callee);
} else if (t.isObjectExpression(node) || t.isObjectPattern(node)) {
var _arr5 = node.properties;
for (var _i5 = 0; _i5 < _arr5.length; _i5++) {
var prop = _arr5[_i5];
add(prop.key || prop.argument);
}
}
};
add(node);
var id = parts.join("$");
id = id.replace(/^_/, "") || defaultName || "ref";
return this.generateUidIdentifier(id);
};
/**
* Determine whether evaluating the specific input `node` is a consequenceless reference. ie.
* evaluating it wont result in potentially arbitrary code from being ran. The following are
* whitelisted and determined not to cause side effects:
*
* - `this` expressions
* - `super` expressions
* - Bound identifiers
*/
Scope.prototype.isStatic = function isStatic(node) {
if (t.isThisExpression(node) || t.isSuper(node)) {
return true;
}
if (t.isIdentifier(node)) {
var binding = this.getBinding(node.name);
if (binding) {
return binding.constant;
} else {
return this.hasBinding(node.name);
}
}
return false;
};
/**
* Possibly generate a memoised identifier if it is not static and has consequences.
*/
Scope.prototype.maybeGenerateMemoised = function maybeGenerateMemoised(node, dontPush) {
if (this.isStatic(node)) {
return null;
} else {
var id = this.generateUidIdentifierBasedOnNode(node);
if (!dontPush) this.push({ id: id });
return id;
}
};
/**
* [Please add a description.]
*/
Scope.prototype.checkBlockScopedCollisions = function checkBlockScopedCollisions(local, kind, name, id) {
// ignore parameters
if (kind === "param") return;
// ignore hoisted functions if there's also a local let
if (kind === "hoisted" && local.kind === "let") return;
var duplicate = false;
// don't allow duplicate bindings to exist alongside
if (!duplicate) duplicate = kind === "let" || local.kind === "let" || local.kind === "const" || local.kind === "module";
// don't allow a local of param with a kind of let
if (!duplicate) duplicate = local.kind === "param" && (kind === "let" || kind === "const");
if (duplicate) {
throw this.hub.file.errorWithNode(id, messages.get("scopeDuplicateDeclaration", name), TypeError);
}
};
/**
* [Please add a description.]
*/
Scope.prototype.rename = function rename(oldName, newName, block) {
newName = newName || this.generateUidIdentifier(oldName).name;
var info = this.getBinding(oldName);
if (!info) return;
var state = {
newName: newName,
oldName: oldName,
binding: info.identifier,
info: info
};
var scope = info.scope;
scope.traverse(block || scope.block, renameVisitor, state);
if (!block) {
scope.removeOwnBinding(oldName);
scope.bindings[newName] = info;
state.binding.name = newName;
}
var file = this.hub.file;
if (file) {
this._renameFromMap(file.moduleFormatter.localImports, oldName, newName, state.binding);
//this._renameFromMap(file.moduleFormatter.localExports, oldName, newName);
}
};
/**
* [Please add a description.]
*/
Scope.prototype._renameFromMap = function _renameFromMap(map, oldName, newName, value) {
if (map[oldName]) {
map[newName] = value;
map[oldName] = null;
}
};
/**
* [Please add a description.]
*/
Scope.prototype.dump = function dump() {
var sep = _repeating2["default"]("-", 60);
console.log(sep);
var scope = this;
do {
console.log("#", scope.block.type);
for (var name in scope.bindings) {
var binding = scope.bindings[name];
console.log(" -", name, {
constant: binding.constant,
references: binding.references,
kind: binding.kind
});
}
} while (scope = scope.parent);
console.log(sep);
};
/**
* [Please add a description.]
*/
Scope.prototype.toArray = function toArray(node, i) {
var file = this.hub.file;
if (t.isIdentifier(node)) {
var binding = this.getBinding(node.name);
if (binding && binding.constant && binding.path.isGenericType("Array")) return node;
}
if (t.isArrayExpression(node)) {
return node;
}
if (t.isIdentifier(node, { name: "arguments" })) {
return t.callExpression(t.memberExpression(file.addHelper("slice"), t.identifier("call")), [node]);
}
var helperName = "to-array";
var args = [node];
if (i === true) {
helperName = "to-consumable-array";
} else if (i) {
args.push(t.literal(i));
helperName = "sliced-to-array";
if (this.hub.file.isLoose("es6.forOf")) helperName += "-loose";
}
return t.callExpression(file.addHelper(helperName), args);
};
/**
* [Please add a description.]
*/
Scope.prototype.registerDeclaration = function registerDeclaration(path) {
if (path.isLabeledStatement()) {
this.registerBinding("label", path);
} else if (path.isFunctionDeclaration()) {
this.registerBinding("hoisted", path.get("id"));
} else if (path.isVariableDeclaration()) {
var declarations = path.get("declarations");
var _arr6 = declarations;
for (var _i6 = 0; _i6 < _arr6.length; _i6++) {
var declar = _arr6[_i6];
this.registerBinding(path.node.kind, declar);
}
} else if (path.isClassDeclaration()) {
this.registerBinding("let", path);
} else if (path.isImportDeclaration()) {
var specifiers = path.get("specifiers");
var _arr7 = specifiers;
for (var _i7 = 0; _i7 < _arr7.length; _i7++) {
var specifier = _arr7[_i7];
this.registerBinding("module", specifier);
}
} else if (path.isExportDeclaration()) {
var declar = path.get("declaration");
if (declar.isClassDeclaration() || declar.isFunctionDeclaration() || declar.isVariableDeclaration()) {
this.registerDeclaration(declar);
}
} else {
this.registerBinding("unknown", path);
}
};
/**
* [Please add a description.]
*/
Scope.prototype.registerConstantViolation = function registerConstantViolation(path) {
var ids = path.getBindingIdentifiers();
for (var _name2 in ids) {
var binding = this.getBinding(_name2);
if (binding) binding.reassign(path);
}
};
/**
* [Please add a description.]
*/
Scope.prototype.registerBinding = function registerBinding(kind, path) {
if (!kind) throw new ReferenceError("no `kind`");
if (path.isVariableDeclaration()) {
var declarators = path.get("declarations");
var _arr8 = declarators;
for (var _i8 = 0; _i8 < _arr8.length; _i8++) {
var declar = _arr8[_i8];
this.registerBinding(kind, declar);
}
return;
}
var parent = this.getProgramParent();
var ids = path.getBindingIdentifiers(true);
for (var name in ids) {
var _arr9 = ids[name];
for (var _i9 = 0; _i9 < _arr9.length; _i9++) {
var id = _arr9[_i9];
var local = this.getOwnBinding(name);
if (local) {
// same identifier so continue safely as we're likely trying to register it
// multiple times
if (local.identifier === id) continue;
this.checkBlockScopedCollisions(local, kind, name, id);
}
parent.references[name] = true;
this.bindings[name] = new _binding2["default"]({
identifier: id,
existing: local,
scope: this,
path: path,
kind: kind
});
}
}
};
/**
* [Please add a description.]
*/
Scope.prototype.addGlobal = function addGlobal(node) {
this.globals[node.name] = node;
};
/**
* [Please add a description.]
*/
Scope.prototype.hasUid = function hasUid(name) {
var scope = this;
do {
if (scope.uids[name]) return true;
} while (scope = scope.parent);
return false;
};
/**
* [Please add a description.]
*/
Scope.prototype.hasGlobal = function hasGlobal(name) {
var scope = this;
do {
if (scope.globals[name]) return true;
} while (scope = scope.parent);
return false;
};
/**
* [Please add a description.]
*/
Scope.prototype.hasReference = function hasReference(name) {
var scope = this;
do {
if (scope.references[name]) return true;
} while (scope = scope.parent);
return false;
};
/**
* [Please add a description.]
*/
Scope.prototype.isPure = function isPure(node, constantsOnly) {
if (t.isIdentifier(node)) {
var binding = this.getBinding(node.name);
if (!binding) return false;
if (constantsOnly) return binding.constant;
return true;
} else if (t.isClass(node)) {
return !node.superClass || this.isPure(node.superClass, constantsOnly);
} else if (t.isBinary(node)) {
return this.isPure(node.left, constantsOnly) && this.isPure(node.right, constantsOnly);
} else if (t.isArrayExpression(node)) {
var _arr10 = node.elements;
for (var _i10 = 0; _i10 < _arr10.length; _i10++) {
var elem = _arr10[_i10];
if (!this.isPure(elem, constantsOnly)) return false;
}
return true;
} else if (t.isObjectExpression(node)) {
var _arr11 = node.properties;
for (var _i11 = 0; _i11 < _arr11.length; _i11++) {
var prop = _arr11[_i11];
if (!this.isPure(prop, constantsOnly)) return false;
}
return true;
} else if (t.isProperty(node)) {
if (node.computed && !this.isPure(node.key, constantsOnly)) return false;
return this.isPure(node.value, constantsOnly);
} else {
return t.isPure(node);
}
};
/**
* Set some arbitrary data on the current scope.
*/
Scope.prototype.setData = function setData(key, val) {
return this.data[key] = val;
};
/**
* Recursively walk up scope tree looking for the data `key`.
*/
Scope.prototype.getData = function getData(key) {
var scope = this;
do {
var data = scope.data[key];
if (data != null) return data;
} while (scope = scope.parent);
};
/**
* Recursively walk up scope tree looking for the data `key` and if it exists,
* remove it.
*/
Scope.prototype.removeData = function removeData(key) {
var scope = this;
do {
var data = scope.data[key];
if (data != null) scope.data[key] = null;
} while (scope = scope.parent);
};
/**
* [Please add a description.]
*/
Scope.prototype.init = function init() {
if (!this.references) this.crawl();
};
/**
* [Please add a description.]
*/
Scope.prototype.crawl = function crawl() {
var path = this.path;
//
var info = this.block._scopeInfo;
if (info) return _lodashObjectExtend2["default"](this, info);
info = this.block._scopeInfo = {
references: _helpersObject2["default"](),
bindings: _helpersObject2["default"](),
globals: _helpersObject2["default"](),
uids: _helpersObject2["default"](),
data: _helpersObject2["default"]()
};
_lodashObjectExtend2["default"](this, info);
// ForStatement - left, init
if (path.isLoop()) {
var _arr12 = t.FOR_INIT_KEYS;
for (var _i12 = 0; _i12 < _arr12.length; _i12++) {
var key = _arr12[_i12];
var node = path.get(key);
if (node.isBlockScoped()) this.registerBinding(node.node.kind, node);
}
}
// FunctionExpression - id
if (path.isFunctionExpression() && path.has("id")) {
this.registerBinding("local", path);
}
// Class
if (path.isClassExpression() && path.has("id")) {
this.registerBinding("local", path);
}
// Function - params, rest
if (path.isFunction()) {
var params = path.get("params");
var _arr13 = params;
for (var _i13 = 0; _i13 < _arr13.length; _i13++) {
var param = _arr13[_i13];
this.registerBinding("param", param);
}
}
// CatchClause - param
if (path.isCatchClause()) {
this.registerBinding("let", path);
}
// ComprehensionExpression - blocks
if (path.isComprehensionExpression()) {
this.registerBinding("let", path);
}
// Program
var parent = this.getProgramParent();
if (parent.crawling) return;
var state = {
references: [],
constantViolations: [],
assignments: []
};
this.crawling = true;
path.traverse(collectorVisitor, state);
this.crawling = false;
// register assignments
for (var _iterator = state.assignments, _isArray = Array.isArray(_iterator), _i14 = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref;
if (_isArray) {
if (_i14 >= _iterator.length) break;
_ref = _iterator[_i14++];
} else {
_i14 = _iterator.next();
if (_i14.done) break;
_ref = _i14.value;
}
var _path = _ref;
// register undeclared bindings as globals
var ids = _path.getBindingIdentifiers();
var programParent = undefined;
for (var _name3 in ids) {
if (_path.scope.getBinding(_name3)) continue;
programParent = programParent || _path.scope.getProgramParent();
programParent.addGlobal(ids[_name3]);
}
// register as constant violation
_path.scope.registerConstantViolation(_path);
}
// register references
for (var _iterator2 = state.references, _isArray2 = Array.isArray(_iterator2), _i15 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
var _ref2;
if (_isArray2) {
if (_i15 >= _iterator2.length) break;
_ref2 = _iterator2[_i15++];
} else {
_i15 = _iterator2.next();
if (_i15.done) break;
_ref2 = _i15.value;
}
var ref = _ref2;
var binding = ref.scope.getBinding(ref.node.name);
if (binding) {
binding.reference(ref);
} else {
ref.scope.getProgramParent().addGlobal(ref.node);
}
}
// register constant violations
for (var _iterator3 = state.constantViolations, _isArray3 = Array.isArray(_iterator3), _i16 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) {
var _ref3;
if (_isArray3) {
if (_i16 >= _iterator3.length) break;
_ref3 = _iterator3[_i16++];
} else {
_i16 = _iterator3.next();
if (_i16.done) break;
_ref3 = _i16.value;
}
var _path2 = _ref3;
_path2.scope.registerConstantViolation(_path2);
}
};
/**
* [Please add a description.]
*/
Scope.prototype.push = function push(opts) {
var path = this.path;
if (path.isSwitchStatement()) {
path = this.getFunctionParent().path;
}
if (path.isLoop() || path.isCatchClause() || path.isFunction()) {
t.ensureBlock(path.node);
path = path.get("body");
}
if (!path.isBlockStatement() && !path.isProgram()) {
path = this.getBlockParent().path;
}
var unique = opts.unique;
var kind = opts.kind || "var";
var blockHoist = opts._blockHoist == null ? 2 : opts._blockHoist;
var dataKey = "declaration:" + kind + ":" + blockHoist;
var declarPath = !unique && path.getData(dataKey);
if (!declarPath) {
var declar = t.variableDeclaration(kind, []);
declar._generated = true;
declar._blockHoist = blockHoist;
this.hub.file.attachAuxiliaryComment(declar);
var _path$unshiftContainer = path.unshiftContainer("body", [declar]);
declarPath = _path$unshiftContainer[0];
if (!unique) path.setData(dataKey, declarPath);
}
var declarator = t.variableDeclarator(opts.id, opts.init);
declarPath.node.declarations.push(declarator);
this.registerBinding(kind, declarPath.get("declarations").pop());
};
/**
* Walk up to the top of the scope tree and get the `Program`.
*/
Scope.prototype.getProgramParent = function getProgramParent() {
var scope = this;
do {
if (scope.path.isProgram()) {
return scope;
}
} while (scope = scope.parent);
throw new Error("We couldn't find a Function or Program...");
};
/**
* Walk up the scope tree until we hit either a Function or reach the
* very top and hit Program.
*/
Scope.prototype.getFunctionParent = function getFunctionParent() {
var scope = this;
do {
if (scope.path.isFunctionParent()) {
return scope;
}
} while (scope = scope.parent);
throw new Error("We couldn't find a Function or Program...");
};
/**
* Walk up the scope tree until we hit either a BlockStatement/Loop/Program/Function/Switch or reach the
* very top and hit Program.
*/
Scope.prototype.getBlockParent = function getBlockParent() {
var scope = this;
do {
if (scope.path.isBlockParent()) {
return scope;
}
} while (scope = scope.parent);
throw new Error("We couldn't find a BlockStatement, For, Switch, Function, Loop or Program...");
};
/**
* Walks the scope tree and gathers **all** bindings.
*/
Scope.prototype.getAllBindings = function getAllBindings() {
var ids = _helpersObject2["default"]();
var scope = this;
do {
_lodashObjectDefaults2["default"](ids, scope.bindings);
scope = scope.parent;
} while (scope);
return ids;
};
/**
* Walks the scope tree and gathers all declarations of `kind`.
*/
Scope.prototype.getAllBindingsOfKind = function getAllBindingsOfKind() {
var ids = _helpersObject2["default"]();
var _arr14 = arguments;
for (var _i17 = 0; _i17 < _arr14.length; _i17++) {
var kind = _arr14[_i17];
var scope = this;
do {
for (var name in scope.bindings) {
var binding = scope.bindings[name];
if (binding.kind === kind) ids[name] = binding;
}
scope = scope.parent;
} while (scope);
}
return ids;
};
/**
* [Please add a description.]
*/
Scope.prototype.bindingIdentifierEquals = function bindingIdentifierEquals(name, node) {
return this.getBindingIdentifier(name) === node;
};
/**
* [Please add a description.]
*/
Scope.prototype.getBinding = function getBinding(name) {
var scope = this;
do {
var binding = scope.getOwnBinding(name);
if (binding) return binding;
} while (scope = scope.parent);
};
/**
* [Please add a description.]
*/
Scope.prototype.getOwnBinding = function getOwnBinding(name) {
return this.bindings[name];
};
/**
* [Please add a description.]
*/
Scope.prototype.getBindingIdentifier = function getBindingIdentifier(name) {
var info = this.getBinding(name);
return info && info.identifier;
};
/**
* [Please add a description.]
*/
Scope.prototype.getOwnBindingIdentifier = function getOwnBindingIdentifier(name) {
var binding = this.bindings[name];
return binding && binding.identifier;
};
/**
* [Please add a description.]
*/
Scope.prototype.hasOwnBinding = function hasOwnBinding(name) {
return !!this.getOwnBinding(name);
};
/**
* [Please add a description.]
*/
Scope.prototype.hasBinding = function hasBinding(name, noGlobals) {
if (!name) return false;
if (this.hasOwnBinding(name)) return true;
if (this.parentHasBinding(name, noGlobals)) return true;
if (this.hasUid(name)) return true;
if (!noGlobals && _lodashCollectionIncludes2["default"](Scope.globals, name)) return true;
if (!noGlobals && _lodashCollectionIncludes2["default"](Scope.contextVariables, name)) return true;
return false;
};
/**
* [Please add a description.]
*/
Scope.prototype.parentHasBinding = function parentHasBinding(name, noGlobals) {
return this.parent && this.parent.hasBinding(name, noGlobals);
};
/**
* Move a binding of `name` to another `scope`.
*/
Scope.prototype.moveBindingTo = function moveBindingTo(name, scope) {
var info = this.getBinding(name);
if (info) {
info.scope.removeOwnBinding(name);
info.scope = scope;
scope.bindings[name] = info;
}
};
/**
* [Please add a description.]
*/
Scope.prototype.removeOwnBinding = function removeOwnBinding(name) {
delete this.bindings[name];
};
/**
* [Please add a description.]
*/
Scope.prototype.removeBinding = function removeBinding(name) {
// clear literal binding
var info = this.getBinding(name);
if (info) {
info.scope.removeOwnBinding(name);
}
// clear uids with this name - https://github.com/babel/babel/issues/2101
var scope = this;
do {
if (scope.uids[name]) {
scope.uids[name] = false;
}
} while (scope = scope.parent);
};
_createClass(Scope, null, [{
key: "globals",
value: _lodashArrayFlatten2["default"]([_globals2["default"].builtin, _globals2["default"].browser, _globals2["default"].node].map(Object.keys)),
/**
* Variables available in current context.
*/
enumerable: true
}, {
key: "contextVariables",
value: ["arguments", "undefined", "Infinity", "NaN"],
enumerable: true
}]);
return Scope;
})();
exports["default"] = Scope;
module.exports = exports["default"];
},{"148":148,"166":166,"179":179,"397":397,"406":406,"41":41,"413":413,"43":43,"510":510,"511":511,"584":584}],168:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports.explode = explode;
exports.verify = verify;
exports.merge = merge;
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _pathLibVirtualTypes = _dereq_(162);
var virtualTypes = _interopRequireWildcard(_pathLibVirtualTypes);
var _messages = _dereq_(43);
var messages = _interopRequireWildcard(_messages);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
var _lodashLangClone = _dereq_(494);
var _lodashLangClone2 = _interopRequireDefault(_lodashLangClone);
/**
* [Please add a description.]
*/
function explode(visitor) {
if (visitor._exploded) return visitor;
visitor._exploded = true;
// normalise pipes
for (var nodeType in visitor) {
if (shouldIgnoreKey(nodeType)) continue;
var parts = nodeType.split("|");
if (parts.length === 1) continue;
var fns = visitor[nodeType];
delete visitor[nodeType];
var _arr = parts;
for (var _i = 0; _i < _arr.length; _i++) {
var part = _arr[_i];
visitor[part] = fns;
}
}
// verify data structure
verify(visitor);
// make sure there's no __esModule type since this is because we're using loose mode
// and it sets __esModule to be enumerable on all modules :(
delete visitor.__esModule;
// ensure visitors are objects
ensureEntranceObjects(visitor);
// ensure enter/exit callbacks are arrays
ensureCallbackArrays(visitor);
// add type wrappers
var _arr2 = Object.keys(visitor);
for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
var nodeType = _arr2[_i2];
if (shouldIgnoreKey(nodeType)) continue;
var wrapper = virtualTypes[nodeType];
if (!wrapper) continue;
// wrap all the functions
var fns = visitor[nodeType];
for (var type in fns) {
fns[type] = wrapCheck(wrapper, fns[type]);
}
// clear it from the visitor
delete visitor[nodeType];
if (wrapper.types) {
var _arr4 = wrapper.types;
for (var _i4 = 0; _i4 < _arr4.length; _i4++) {
var type = _arr4[_i4];
// merge the visitor if necessary or just put it back in
if (visitor[type]) {
mergePair(visitor[type], fns);
} else {
visitor[type] = fns;
}
}
} else {
mergePair(visitor, fns);
}
}
// add aliases
for (var nodeType in visitor) {
if (shouldIgnoreKey(nodeType)) continue;
var fns = visitor[nodeType];
var aliases = t.FLIPPED_ALIAS_KEYS[nodeType];
if (!aliases) continue;
// clear it from the visitor
delete visitor[nodeType];
var _arr3 = aliases;
for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
var alias = _arr3[_i3];
var existing = visitor[alias];
if (existing) {
mergePair(existing, fns);
} else {
visitor[alias] = _lodashLangClone2["default"](fns);
}
}
}
for (var nodeType in visitor) {
if (shouldIgnoreKey(nodeType)) continue;
ensureCallbackArrays(visitor[nodeType]);
}
return visitor;
}
/**
* [Please add a description.]
*/
function verify(visitor) {
if (visitor._verified) return;
if (typeof visitor === "function") {
throw new Error(messages.get("traverseVerifyRootFunction"));
}
for (var nodeType in visitor) {
if (shouldIgnoreKey(nodeType)) continue;
if (t.TYPES.indexOf(nodeType) < 0) {
throw new Error(messages.get("traverseVerifyNodeType", nodeType));
}
var visitors = visitor[nodeType];
if (typeof visitors === "object") {
for (var visitorKey in visitors) {
if (visitorKey === "enter" || visitorKey === "exit") continue;
throw new Error(messages.get("traverseVerifyVisitorProperty", nodeType, visitorKey));
}
}
}
visitor._verified = true;
}
/**
* [Please add a description.]
*/
function merge(visitors) {
var rootVisitor = {};
var _arr5 = visitors;
for (var _i5 = 0; _i5 < _arr5.length; _i5++) {
var visitor = _arr5[_i5];
explode(visitor);
for (var type in visitor) {
var nodeVisitor = rootVisitor[type] = rootVisitor[type] || {};
mergePair(nodeVisitor, visitor[type]);
}
}
return rootVisitor;
}
/**
* [Please add a description.]
*/
function ensureEntranceObjects(obj) {
for (var key in obj) {
if (shouldIgnoreKey(key)) continue;
var fns = obj[key];
if (typeof fns === "function") {
obj[key] = { enter: fns };
}
}
}
/**
* Makes sure that enter and exit callbacks are arrays.
*/
function ensureCallbackArrays(obj) {
if (obj.enter && !Array.isArray(obj.enter)) obj.enter = [obj.enter];
if (obj.exit && !Array.isArray(obj.exit)) obj.exit = [obj.exit];
}
/**
* [Please add a description.]
*/
function wrapCheck(wrapper, fn) {
return function () {
if (wrapper.checkPath(this)) {
return fn.apply(this, arguments);
}
};
}
/**
* [Please add a description.]
*/
function shouldIgnoreKey(key) {
// internal/hidden key
if (key[0] === "_") return true;
// ignore function keys
if (key === "enter" || key === "exit" || key === "shouldSkip") return true;
// ignore other options
if (key === "blacklist" || key === "noScope" || key === "skipKeys") return true;
return false;
}
/**
* [Please add a description.]
*/
function mergePair(dest, src) {
for (var key in src) {
dest[key] = [].concat(dest[key] || [], src[key]);
}
}
},{"162":162,"179":179,"43":43,"494":494}],169:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports.toComputedKey = toComputedKey;
exports.toSequenceExpression = toSequenceExpression;
exports.toKeyAlias = toKeyAlias;
exports.toIdentifier = toIdentifier;
exports.toBindingIdentifierName = toBindingIdentifierName;
exports.toStatement = toStatement;
exports.toExpression = toExpression;
exports.toBlock = toBlock;
exports.valueToNode = valueToNode;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _lodashLangIsPlainObject = _dereq_(504);
var _lodashLangIsPlainObject2 = _interopRequireDefault(_lodashLangIsPlainObject);
var _lodashLangIsNumber = _dereq_(502);
var _lodashLangIsNumber2 = _interopRequireDefault(_lodashLangIsNumber);
var _lodashLangIsRegExp = _dereq_(505);
var _lodashLangIsRegExp2 = _interopRequireDefault(_lodashLangIsRegExp);
var _lodashLangIsString = _dereq_(506);
var _lodashLangIsString2 = _interopRequireDefault(_lodashLangIsString);
var _traversal = _dereq_(148);
var _traversal2 = _interopRequireDefault(_traversal);
var _index = _dereq_(179);
var t = _interopRequireWildcard(_index);
/**
* [Please add a description.]
*/
function toComputedKey(node) {
var key = arguments.length <= 1 || arguments[1] === undefined ? node.key || node.property : arguments[1];
return (function () {
if (!node.computed) {
if (t.isIdentifier(key)) key = t.literal(key.name);
}
return key;
})();
}
/**
* Turn an array of statement `nodes` into a `SequenceExpression`.
*
* Variable declarations are turned into simple assignments and their
* declarations hoisted to the top of the current scope.
*
* Expression statements are just resolved to their expression.
*/
function toSequenceExpression(nodes, scope) {
var declars = [];
var bailed = false;
var result = convert(nodes);
if (bailed) return;
for (var i = 0; i < declars.length; i++) {
scope.push(declars[i]);
}
return result;
function convert(nodes) {
var ensureLastUndefined = false;
var exprs = [];
var _arr = nodes;
for (var _i = 0; _i < _arr.length; _i++) {
var node = _arr[_i];
if (t.isExpression(node)) {
exprs.push(node);
} else if (t.isExpressionStatement(node)) {
exprs.push(node.expression);
} else if (t.isVariableDeclaration(node)) {
if (node.kind !== "var") return bailed = true; // bailed
var _arr2 = node.declarations;
for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
var declar = _arr2[_i2];
var bindings = t.getBindingIdentifiers(declar);
for (var key in bindings) {
declars.push({
kind: node.kind,
id: bindings[key]
});
}
if (declar.init) {
exprs.push(t.assignmentExpression("=", declar.id, declar.init));
}
}
ensureLastUndefined = true;
continue;
} else if (t.isIfStatement(node)) {
var consequent = node.consequent ? convert([node.consequent]) : t.identifier("undefined");
var alternate = node.alternate ? convert([node.alternate]) : t.identifier("undefined");
if (!consequent || !alternate) return bailed = true;
exprs.push(t.conditionalExpression(node.test, consequent, alternate));
} else if (t.isBlockStatement(node)) {
exprs.push(convert(node.body));
} else if (t.isEmptyStatement(node)) {
// empty statement so ensure the last item is undefined if we're last
ensureLastUndefined = true;
continue;
} else {
// bailed, we can't turn this statement into an expression
return bailed = true;
}
ensureLastUndefined = false;
}
if (ensureLastUndefined) {
exprs.push(t.identifier("undefined"));
}
//
if (exprs.length === 1) {
return exprs[0];
} else {
return t.sequenceExpression(exprs);
}
}
}
/**
* [Please add a description.]
*/
function toKeyAlias(node) {
var key = arguments.length <= 1 || arguments[1] === undefined ? node.key : arguments[1];
return (function () {
var alias;
if (node.kind === "method") {
return toKeyAlias.uid++;
} else if (t.isIdentifier(key)) {
alias = key.name;
} else if (t.isLiteral(key)) {
alias = JSON.stringify(key.value);
} else {
alias = JSON.stringify(_traversal2["default"].removeProperties(t.cloneDeep(key)));
}
if (node.computed) {
alias = "[" + alias + "]";
}
return alias;
})();
}
toKeyAlias.uid = 0;
/**
* [Please add a description.]
*/
function toIdentifier(name) {
if (t.isIdentifier(name)) return name.name;
name = name + "";
// replace all non-valid identifiers with dashes
name = name.replace(/[^a-zA-Z0-9$_]/g, "-");
// remove all dashes and numbers from start of name
name = name.replace(/^[-0-9]+/, "");
// camel case
name = name.replace(/[-\s]+(.)?/g, function (match, c) {
return c ? c.toUpperCase() : "";
});
if (!t.isValidIdentifier(name)) {
name = "_" + name;
}
return name || "_";
}
/**
* [Please add a description.]
*/
function toBindingIdentifierName(name) {
name = toIdentifier(name);
if (name === "eval" || name === "arguments") name = "_" + name;
return name;
}
/**
* [Please add a description.]
* @returns {Object|Boolean}
*/
function toStatement(node, ignore) {
if (t.isStatement(node)) {
return node;
}
var mustHaveId = false;
var newType;
if (t.isClass(node)) {
mustHaveId = true;
newType = "ClassDeclaration";
} else if (t.isFunction(node)) {
mustHaveId = true;
newType = "FunctionDeclaration";
} else if (t.isAssignmentExpression(node)) {
return t.expressionStatement(node);
}
if (mustHaveId && !node.id) {
newType = false;
}
if (!newType) {
if (ignore) {
return false;
} else {
throw new Error("cannot turn " + node.type + " to a statement");
}
}
node.type = newType;
return node;
}
/**
* [Please add a description.]
*/
function toExpression(node) {
if (t.isExpressionStatement(node)) {
node = node.expression;
}
if (t.isClass(node)) {
node.type = "ClassExpression";
} else if (t.isFunction(node)) {
node.type = "FunctionExpression";
}
if (t.isExpression(node)) {
return node;
} else {
throw new Error("cannot turn " + node.type + " to an expression");
}
}
/**
* [Please add a description.]
*/
function toBlock(node, parent) {
if (t.isBlockStatement(node)) {
return node;
}
if (t.isEmptyStatement(node)) {
node = [];
}
if (!Array.isArray(node)) {
if (!t.isStatement(node)) {
if (t.isFunction(parent)) {
node = t.returnStatement(node);
} else {
node = t.expressionStatement(node);
}
}
node = [node];
}
return t.blockStatement(node);
}
/**
* [Please add a description.]
*/
function valueToNode(value) {
// undefined
if (value === undefined) {
return t.identifier("undefined");
}
// null, booleans, strings, numbers, regexs
if (value === true || value === false || value === null || _lodashLangIsString2["default"](value) || _lodashLangIsNumber2["default"](value) || _lodashLangIsRegExp2["default"](value)) {
return t.literal(value);
}
// array
if (Array.isArray(value)) {
return t.arrayExpression(value.map(t.valueToNode));
}
// object
if (_lodashLangIsPlainObject2["default"](value)) {
var props = [];
for (var key in value) {
var nodeKey;
if (t.isValidIdentifier(key)) {
nodeKey = t.identifier(key);
} else {
nodeKey = t.literal(key);
}
props.push(t.property("init", nodeKey, t.valueToNode(value[key])));
}
return t.objectExpression(props);
}
throw new Error("don't know how to turn this value into a node");
}
},{"148":148,"179":179,"502":502,"504":504,"505":505,"506":506}],170:[function(_dereq_,module,exports){
"use strict";
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _index = _dereq_(174);
var _index2 = _interopRequireDefault(_index);
_index2["default"]("ArrayExpression", {
visitor: ["elements"],
aliases: ["Expression"]
});
_index2["default"]("AssignmentExpression", {
builder: ["operator", "left", "right"],
visitor: ["left", "right"],
aliases: ["Expression"]
});
_index2["default"]("BinaryExpression", {
builder: ["operator", "left", "right"],
visitor: ["left", "right"],
aliases: ["Binary", "Expression"]
});
_index2["default"]("BlockStatement", {
visitor: ["body"],
aliases: ["Scopable", "BlockParent", "Block", "Statement"]
});
_index2["default"]("BreakStatement", {
visitor: ["label"],
aliases: ["Statement", "Terminatorless", "CompletionStatement"]
});
_index2["default"]("CallExpression", {
visitor: ["callee", "arguments"],
aliases: ["Expression"]
});
_index2["default"]("CatchClause", {
visitor: ["param", "body"],
aliases: ["Scopable"]
});
_index2["default"]("ConditionalExpression", {
visitor: ["test", "consequent", "alternate"],
aliases: ["Expression"]
});
_index2["default"]("ContinueStatement", {
visitor: ["label"],
aliases: ["Statement", "Terminatorless", "CompletionStatement"]
});
_index2["default"]("DebuggerStatement", {
aliases: ["Statement"]
});
_index2["default"]("DoWhileStatement", {
visitor: ["body", "test"],
aliases: ["Statement", "BlockParent", "Loop", "While", "Scopable"]
});
_index2["default"]("EmptyStatement", {
aliases: ["Statement"]
});
_index2["default"]("ExpressionStatement", {
visitor: ["expression"],
aliases: ["Statement"]
});
_index2["default"]("File", {
builder: ["program", "comments", "tokens"],
visitor: ["program"]
});
_index2["default"]("ForInStatement", {
visitor: ["left", "right", "body"],
aliases: ["Scopable", "Statement", "For", "BlockParent", "Loop", "ForXStatement"]
});
_index2["default"]("ForStatement", {
visitor: ["init", "test", "update", "body"],
aliases: ["Scopable", "Statement", "For", "BlockParent", "Loop"]
});
_index2["default"]("FunctionDeclaration", {
builder: {
id: null,
params: null,
body: null,
generator: false,
async: false
},
visitor: ["id", "params", "body", "returnType", "typeParameters"],
aliases: ["Scopable", "Function", "Func", "BlockParent", "FunctionParent", "Statement", "Pure", "Declaration"]
});
_index2["default"]("FunctionExpression", {
builder: {
id: null,
params: null,
body: null,
generator: false,
async: false
},
visitor: ["id", "params", "body", "returnType", "typeParameters"],
aliases: ["Scopable", "Function", "Func", "BlockParent", "FunctionParent", "Expression", "Pure"]
});
_index2["default"]("Identifier", {
builder: ["name"],
visitor: ["typeAnnotation"],
aliases: ["Expression"]
});
_index2["default"]("IfStatement", {
visitor: ["test", "consequent", "alternate"],
aliases: ["Statement"]
});
_index2["default"]("LabeledStatement", {
visitor: ["label", "body"],
aliases: ["Statement"]
});
_index2["default"]("Literal", {
builder: ["value"],
aliases: ["Expression", "Pure"]
});
_index2["default"]("LogicalExpression", {
builder: ["operator", "left", "right"],
visitor: ["left", "right"],
aliases: ["Binary", "Expression"]
});
_index2["default"]("MemberExpression", {
builder: {
object: null,
property: null,
computed: false
},
visitor: ["object", "property"],
aliases: ["Expression"]
});
_index2["default"]("NewExpression", {
visitor: ["callee", "arguments"],
aliases: ["Expression"]
});
_index2["default"]("ObjectExpression", {
visitor: ["properties"],
aliases: ["Expression"]
});
_index2["default"]("Program", {
visitor: ["body"],
aliases: ["Scopable", "BlockParent", "Block", "FunctionParent"]
});
_index2["default"]("Property", {
builder: {
kind: "init",
key: null,
value: null,
computed: false
},
visitor: ["key", "value", "decorators"],
aliases: ["UserWhitespacable"]
});
_index2["default"]("RestElement", {
visitor: ["argument", "typeAnnotation"]
});
_index2["default"]("ReturnStatement", {
visitor: ["argument"],
aliases: ["Statement", "Terminatorless", "CompletionStatement"]
});
_index2["default"]("SequenceExpression", {
visitor: ["expressions"],
aliases: ["Expression"]
});
_index2["default"]("SwitchCase", {
visitor: ["test", "consequent"]
});
_index2["default"]("SwitchStatement", {
visitor: ["discriminant", "cases"],
aliases: ["Statement", "BlockParent", "Scopable"]
});
_index2["default"]("ThisExpression", {
aliases: ["Expression"]
});
_index2["default"]("ThrowStatement", {
visitor: ["argument"],
aliases: ["Statement", "Terminatorless", "CompletionStatement"]
});
_index2["default"]("TryStatement", {
builder: ["block", "handler", "finalizer"],
visitor: ["block", "handlers", "handler", "guardedHandlers", "finalizer"],
aliases: ["Statement"]
});
_index2["default"]("UnaryExpression", {
builder: {
operator: null,
argument: null,
prefix: false
},
visitor: ["argument"],
aliases: ["UnaryLike", "Expression"]
});
_index2["default"]("UpdateExpression", {
builder: {
operator: null,
argument: null,
prefix: false
},
visitor: ["argument"],
aliases: ["Expression"]
});
_index2["default"]("VariableDeclaration", {
builder: ["kind", "declarations"],
visitor: ["declarations"],
aliases: ["Statement", "Declaration"]
});
_index2["default"]("VariableDeclarator", {
visitor: ["id", "init"]
});
_index2["default"]("WhileStatement", {
visitor: ["test", "body"],
aliases: ["Statement", "BlockParent", "Loop", "While", "Scopable"]
});
_index2["default"]("WithStatement", {
visitor: ["object", "body"],
aliases: ["Statement"]
});
},{"174":174}],171:[function(_dereq_,module,exports){
"use strict";
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _index = _dereq_(174);
var _index2 = _interopRequireDefault(_index);
_index2["default"]("AssignmentPattern", {
visitor: ["left", "right"],
aliases: ["Pattern"]
});
_index2["default"]("ArrayPattern", {
visitor: ["elements", "typeAnnotation"],
aliases: ["Pattern"]
});
_index2["default"]("ArrowFunctionExpression", {
builder: ["params", "body", "async"],
visitor: ["params", "body", "returnType"],
aliases: ["Scopable", "Function", "Func", "BlockParent", "FunctionParent", "Expression", "Pure"]
});
_index2["default"]("ClassBody", {
visitor: ["body"]
});
_index2["default"]("ClassDeclaration", {
visitor: ["id", "body", "superClass", "typeParameters", "superTypeParameters", "implements", "decorators"],
aliases: ["Scopable", "Class", "Statement", "Declaration"]
});
_index2["default"]("ClassExpression", {
visitor: ["id", "body", "superClass", "typeParameters", "superTypeParameters", "implements", "decorators"],
aliases: ["Scopable", "Class", "Expression"]
});
_index2["default"]("ExportAllDeclaration", {
visitor: ["source", "exported"],
aliases: ["Statement", "Declaration", "ModuleDeclaration", "ExportDeclaration"]
});
_index2["default"]("ExportDefaultDeclaration", {
visitor: ["declaration"],
aliases: ["Statement", "Declaration", "ModuleDeclaration", "ExportDeclaration"]
});
_index2["default"]("ExportNamedDeclaration", {
visitor: ["declaration", "specifiers", "source"],
aliases: ["Statement", "Declaration", "ModuleDeclaration", "ExportDeclaration"]
});
_index2["default"]("ExportDefaultSpecifier", {
visitor: ["exported"],
aliases: ["ModuleSpecifier"]
});
_index2["default"]("ExportNamespaceSpecifier", {
visitor: ["exported"],
aliases: ["ModuleSpecifier"]
});
_index2["default"]("ExportSpecifier", {
visitor: ["local", "exported"],
aliases: ["ModuleSpecifier"]
});
_index2["default"]("ForOfStatement", {
visitor: ["left", "right", "body"],
aliases: ["Scopable", "Statement", "For", "BlockParent", "Loop", "ForXStatement"]
});
_index2["default"]("ImportDeclaration", {
visitor: ["specifiers", "source"],
aliases: ["Statement", "Declaration", "ModuleDeclaration"]
});
_index2["default"]("ImportDefaultSpecifier", {
visitor: ["local"],
aliases: ["ModuleSpecifier"]
});
_index2["default"]("ImportNamespaceSpecifier", {
visitor: ["local"],
aliases: ["ModuleSpecifier"]
});
_index2["default"]("ImportSpecifier", {
visitor: ["local", "imported"],
aliases: ["ModuleSpecifier"]
});
_index2["default"]("MetaProperty", {
visitor: ["meta", "property"],
aliases: ["Expression"]
});
_index2["default"]("MethodDefinition", {
builder: {
key: null,
value: null,
kind: "method",
computed: false,
"static": false
},
visitor: ["key", "value", "decorators"]
});
_index2["default"]("ObjectPattern", {
visitor: ["properties", "typeAnnotation"],
aliases: ["Pattern"]
});
_index2["default"]("SpreadElement", {
visitor: ["argument"],
aliases: ["UnaryLike"]
});
_index2["default"]("Super", {
aliases: ["Expression"]
});
_index2["default"]("TaggedTemplateExpression", {
visitor: ["tag", "quasi"],
aliases: ["Expression"]
});
_index2["default"]("TemplateElement");
_index2["default"]("TemplateLiteral", {
visitor: ["quasis", "expressions"],
aliases: ["Expression"]
});
_index2["default"]("YieldExpression", {
builder: ["argument", "delegate"],
visitor: ["argument"],
aliases: ["Expression", "Terminatorless"]
});
},{"174":174}],172:[function(_dereq_,module,exports){
"use strict";
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _index = _dereq_(174);
var _index2 = _interopRequireDefault(_index);
_index2["default"]("AwaitExpression", {
builder: ["argument", "all"],
visitor: ["argument"],
aliases: ["Expression", "Terminatorless"]
});
_index2["default"]("BindExpression", {
visitor: ["object", "callee"]
});
_index2["default"]("ComprehensionBlock", {
visitor: ["left", "right"]
});
_index2["default"]("ComprehensionExpression", {
visitor: ["filter", "blocks", "body"],
aliases: ["Expression", "Scopable"]
});
_index2["default"]("Decorator", {
visitor: ["expression"]
});
_index2["default"]("DoExpression", {
visitor: ["body"],
aliases: ["Expression"]
});
_index2["default"]("SpreadProperty", {
visitor: ["argument"],
aliases: ["UnaryLike"]
});
},{"174":174}],173:[function(_dereq_,module,exports){
"use strict";
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _index = _dereq_(174);
var _index2 = _interopRequireDefault(_index);
_index2["default"]("AnyTypeAnnotation", {
aliases: ["Flow", "FlowBaseAnnotation"]
});
_index2["default"]("ArrayTypeAnnotation", {
visitor: ["elementType"],
aliases: ["Flow"]
});
_index2["default"]("BooleanTypeAnnotation", {
aliases: ["Flow", "FlowBaseAnnotation"]
});
_index2["default"]("BooleanLiteralTypeAnnotation", {
aliases: ["Flow"]
});
_index2["default"]("ClassImplements", {
visitor: ["id", "typeParameters"],
aliases: ["Flow"]
});
_index2["default"]("ClassProperty", {
visitor: ["key", "value", "typeAnnotation", "decorators"],
aliases: ["Flow"]
});
_index2["default"]("DeclareClass", {
visitor: ["id", "typeParameters", "extends", "body"],
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"]
});
_index2["default"]("DeclareFunction", {
visitor: ["id"],
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"]
});
_index2["default"]("DeclareModule", {
visitor: ["id", "body"],
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"]
});
_index2["default"]("DeclareVariable", {
visitor: ["id"],
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"]
});
_index2["default"]("FunctionTypeAnnotation", {
visitor: ["typeParameters", "params", "rest", "returnType"],
aliases: ["Flow"]
});
_index2["default"]("FunctionTypeParam", {
visitor: ["name", "typeAnnotation"],
aliases: ["Flow"]
});
_index2["default"]("GenericTypeAnnotation", {
visitor: ["id", "typeParameters"],
aliases: ["Flow"]
});
_index2["default"]("InterfaceExtends", {
visitor: ["id", "typeParameters"],
aliases: ["Flow"]
});
_index2["default"]("InterfaceDeclaration", {
visitor: ["id", "typeParameters", "extends", "body"],
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"]
});
_index2["default"]("IntersectionTypeAnnotation", {
visitor: ["types"],
aliases: ["Flow"]
});
_index2["default"]("MixedTypeAnnotation", {
aliases: ["Flow", "FlowBaseAnnotation"]
});
_index2["default"]("NullableTypeAnnotation", {
visitor: ["typeAnnotation"],
aliases: ["Flow"]
});
_index2["default"]("NumberLiteralTypeAnnotation", {
aliases: ["Flow"]
});
_index2["default"]("NumberTypeAnnotation", {
aliases: ["Flow", "FlowBaseAnnotation"]
});
_index2["default"]("StringLiteralTypeAnnotation", {
aliases: ["Flow"]
});
_index2["default"]("StringTypeAnnotation", {
aliases: ["Flow", "FlowBaseAnnotation"]
});
_index2["default"]("TupleTypeAnnotation", {
visitor: ["types"],
aliases: ["Flow"]
});
_index2["default"]("TypeofTypeAnnotation", {
visitor: ["argument"],
aliases: ["Flow"]
});
_index2["default"]("TypeAlias", {
visitor: ["id", "typeParameters", "right"],
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"]
});
_index2["default"]("TypeAnnotation", {
visitor: ["typeAnnotation"],
aliases: ["Flow"]
});
_index2["default"]("TypeCastExpression", {
visitor: ["expression", "typeAnnotation"],
aliases: ["Flow"]
});
_index2["default"]("TypeParameterDeclaration", {
visitor: ["params"],
aliases: ["Flow"]
});
_index2["default"]("TypeParameterInstantiation", {
visitor: ["params"],
aliases: ["Flow"]
});
_index2["default"]("ObjectTypeAnnotation", {
visitor: ["properties", "indexers", "callProperties"],
aliases: ["Flow"]
});
_index2["default"]("ObjectTypeCallProperty", {
visitor: ["value"],
aliases: ["Flow", "UserWhitespacable"]
});
_index2["default"]("ObjectTypeIndexer", {
visitor: ["id", "key", "value"],
aliases: ["Flow", "UserWhitespacable"]
});
_index2["default"]("ObjectTypeProperty", {
visitor: ["key", "value"],
aliases: ["Flow", "UserWhitespacable"]
});
_index2["default"]("QualifiedTypeIdentifier", {
visitor: ["id", "qualification"],
aliases: ["Flow"]
});
_index2["default"]("UnionTypeAnnotation", {
visitor: ["types"],
aliases: ["Flow"]
});
_index2["default"]("VoidTypeAnnotation", {
aliases: ["Flow", "FlowBaseAnnotation"]
});
},{"174":174}],174:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports["default"] = defineType;
var VISITOR_KEYS = {};
exports.VISITOR_KEYS = VISITOR_KEYS;
var ALIAS_KEYS = {};
exports.ALIAS_KEYS = ALIAS_KEYS;
var BUILDER_KEYS = {};
exports.BUILDER_KEYS = BUILDER_KEYS;
function builderFromArray(arr) {
var builder = {};
var _arr = arr;
for (var _i = 0; _i < _arr.length; _i++) {
var key = _arr[_i];builder[key] = null;
}return builder;
}
function defineType(type) {
var opts = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
opts.visitor = opts.visitor || [];
opts.aliases = opts.aliases || [];
if (!opts.builder) opts.builder = builderFromArray(opts.visitor);
if (Array.isArray(opts.builder)) opts.builder = builderFromArray(opts.builder);
VISITOR_KEYS[type] = opts.visitor;
ALIAS_KEYS[type] = opts.aliases;
BUILDER_KEYS[type] = opts.builder;
}
},{}],175:[function(_dereq_,module,exports){
"use strict";
_dereq_(174);
_dereq_(170);
_dereq_(171);
_dereq_(173);
_dereq_(176);
_dereq_(177);
_dereq_(172);
},{"170":170,"171":171,"172":172,"173":173,"174":174,"176":176,"177":177}],176:[function(_dereq_,module,exports){
"use strict";
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _index = _dereq_(174);
var _index2 = _interopRequireDefault(_index);
_index2["default"]("JSXAttribute", {
visitor: ["name", "value"],
aliases: ["JSX", "Immutable"]
});
_index2["default"]("JSXClosingElement", {
visitor: ["name"],
aliases: ["JSX", "Immutable"]
});
_index2["default"]("JSXElement", {
visitor: ["openingElement", "closingElement", "children"],
aliases: ["JSX", "Immutable", "Expression"]
});
_index2["default"]("JSXEmptyExpression", {
aliases: ["JSX", "Expression"]
});
_index2["default"]("JSXExpressionContainer", {
visitor: ["expression"],
aliases: ["JSX", "Immutable"]
});
_index2["default"]("JSXIdentifier", {
aliases: ["JSX", "Expression"]
});
_index2["default"]("JSXMemberExpression", {
visitor: ["object", "property"],
aliases: ["JSX", "Expression"]
});
_index2["default"]("JSXNamespacedName", {
visitor: ["namespace", "name"],
aliases: ["JSX"]
});
_index2["default"]("JSXOpeningElement", {
visitor: ["name", "attributes"],
aliases: ["JSX", "Immutable"]
});
_index2["default"]("JSXSpreadAttribute", {
visitor: ["argument"],
aliases: ["JSX"]
});
},{"174":174}],177:[function(_dereq_,module,exports){
"use strict";
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _index = _dereq_(174);
var _index2 = _interopRequireDefault(_index);
_index2["default"]("Noop", {
visitor: []
});
_index2["default"]("ParenthesizedExpression", {
visitor: ["expression"],
aliases: ["Expression"]
});
},{"174":174}],178:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports.createUnionTypeAnnotation = createUnionTypeAnnotation;
exports.removeTypeDuplicates = removeTypeDuplicates;
exports.createTypeAnnotationBasedOnTypeof = createTypeAnnotationBasedOnTypeof;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _index = _dereq_(179);
var t = _interopRequireWildcard(_index);
/**
* Takes an array of `types` and flattens them, removing duplicates and
* returns a `UnionTypeAnnotation` node containg them.
*/
function createUnionTypeAnnotation(types) {
var flattened = removeTypeDuplicates(types);
if (flattened.length === 1) {
return flattened[0];
} else {
return t.unionTypeAnnotation(flattened);
}
}
/**
* Dedupe type annotations.
*/
function removeTypeDuplicates(nodes) {
var generics = {};
var bases = {};
// store union type groups to circular references
var typeGroups = [];
var types = [];
for (var i = 0; i < nodes.length; i++) {
var node = nodes[i];
if (!node) continue;
// detect duplicates
if (types.indexOf(node) >= 0) {
continue;
}
// this type matches anything
if (t.isAnyTypeAnnotation(node)) {
return [node];
}
//
if (t.isFlowBaseAnnotation(node)) {
bases[node.type] = node;
continue;
}
//
if (t.isUnionTypeAnnotation(node)) {
if (typeGroups.indexOf(node.types) < 0) {
nodes = nodes.concat(node.types);
typeGroups.push(node.types);
}
continue;
}
// find a matching generic type and merge and deduplicate the type parameters
if (t.isGenericTypeAnnotation(node)) {
var _name = node.id.name;
if (generics[_name]) {
var existing = generics[_name];
if (existing.typeParameters) {
if (node.typeParameters) {
existing.typeParameters.params = removeTypeDuplicates(existing.typeParameters.params.concat(node.typeParameters.params));
}
} else {
existing = node.typeParameters;
}
} else {
generics[_name] = node;
}
continue;
}
types.push(node);
}
// add back in bases
for (var type in bases) {
types.push(bases[type]);
}
// add back in generics
for (var _name2 in generics) {
types.push(generics[_name2]);
}
return types;
}
/**
* Create a type anotation based on typeof expression.
*/
function createTypeAnnotationBasedOnTypeof(type) {
if (type === "string") {
return t.stringTypeAnnotation();
} else if (type === "number") {
return t.numberTypeAnnotation();
} else if (type === "undefined") {
return t.voidTypeAnnotation();
} else if (type === "boolean") {
return t.booleanTypeAnnotation();
} else if (type === "function") {
return t.genericTypeAnnotation(t.identifier("Function"));
} else if (type === "object") {
return t.genericTypeAnnotation(t.identifier("Object"));
} else if (type === "symbol") {
return t.genericTypeAnnotation(t.identifier("Symbol"));
} else {
throw new Error("Invalid typeof value");
}
}
},{"179":179}],179:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports.is = is;
exports.isType = isType;
exports.shallowEqual = shallowEqual;
exports.appendToMemberExpression = appendToMemberExpression;
exports.prependToMemberExpression = prependToMemberExpression;
exports.ensureBlock = ensureBlock;
exports.clone = clone;
exports.cloneDeep = cloneDeep;
exports.buildMatchMemberExpression = buildMatchMemberExpression;
exports.removeComments = removeComments;
exports.inheritsComments = inheritsComments;
exports.inheritTrailingComments = inheritTrailingComments;
exports.inheritLeadingComments = inheritLeadingComments;
exports.inheritInnerComments = inheritInnerComments;
exports.inherits = inherits;
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _toFastProperties = _dereq_(600);
var _toFastProperties2 = _interopRequireDefault(_toFastProperties);
var _lodashArrayCompact = _dereq_(405);
var _lodashArrayCompact2 = _interopRequireDefault(_lodashArrayCompact);
var _lodashObjectAssign = _dereq_(509);
var _lodashObjectAssign2 = _interopRequireDefault(_lodashObjectAssign);
var _lodashCollectionEach = _dereq_(411);
var _lodashCollectionEach2 = _interopRequireDefault(_lodashCollectionEach);
var _lodashArrayUniq = _dereq_(409);
var _lodashArrayUniq2 = _interopRequireDefault(_lodashArrayUniq);
_dereq_(175);
var _definitions = _dereq_(174);
var t = exports;
/**
* Registers `is[Type]` and `assert[Type]` generated functions for a given `type`.
* Pass `skipAliasCheck` to force it to directly compare `node.type` with `type`.
*/
function registerType(type, skipAliasCheck) {
var is = t["is" + type] = function (node, opts) {
return t.is(type, node, opts, skipAliasCheck);
};
t["assert" + type] = function (node, opts) {
opts = opts || {};
if (!is(node, opts)) {
throw new Error("Expected type " + JSON.stringify(type) + " with option " + JSON.stringify(opts));
}
};
}
/**
* Constants.
*/
var STATEMENT_OR_BLOCK_KEYS = ["consequent", "body", "alternate"];
exports.STATEMENT_OR_BLOCK_KEYS = STATEMENT_OR_BLOCK_KEYS;
var FLATTENABLE_KEYS = ["body", "expressions"];
exports.FLATTENABLE_KEYS = FLATTENABLE_KEYS;
var FOR_INIT_KEYS = ["left", "init"];
exports.FOR_INIT_KEYS = FOR_INIT_KEYS;
var COMMENT_KEYS = ["leadingComments", "trailingComments", "innerComments"];
exports.COMMENT_KEYS = COMMENT_KEYS;
var INHERIT_KEYS = {
optional: ["typeAnnotation", "typeParameters", "returnType"],
force: ["_scopeInfo", "_paths", "start", "loc", "end"]
};
exports.INHERIT_KEYS = INHERIT_KEYS;
var BOOLEAN_NUMBER_BINARY_OPERATORS = [">", "<", ">=", "<="];
exports.BOOLEAN_NUMBER_BINARY_OPERATORS = BOOLEAN_NUMBER_BINARY_OPERATORS;
var EQUALITY_BINARY_OPERATORS = ["==", "===", "!=", "!=="];
exports.EQUALITY_BINARY_OPERATORS = EQUALITY_BINARY_OPERATORS;
var COMPARISON_BINARY_OPERATORS = EQUALITY_BINARY_OPERATORS.concat(["in", "instanceof"]);
exports.COMPARISON_BINARY_OPERATORS = COMPARISON_BINARY_OPERATORS;
var BOOLEAN_BINARY_OPERATORS = [].concat(COMPARISON_BINARY_OPERATORS, BOOLEAN_NUMBER_BINARY_OPERATORS);
exports.BOOLEAN_BINARY_OPERATORS = BOOLEAN_BINARY_OPERATORS;
var NUMBER_BINARY_OPERATORS = ["-", "/", "*", "**", "&", "|", ">>", ">>>", "<<", "^"];
exports.NUMBER_BINARY_OPERATORS = NUMBER_BINARY_OPERATORS;
var BOOLEAN_UNARY_OPERATORS = ["delete", "!"];
exports.BOOLEAN_UNARY_OPERATORS = BOOLEAN_UNARY_OPERATORS;
var NUMBER_UNARY_OPERATORS = ["+", "-", "++", "--", "~"];
exports.NUMBER_UNARY_OPERATORS = NUMBER_UNARY_OPERATORS;
var STRING_UNARY_OPERATORS = ["typeof"];
exports.STRING_UNARY_OPERATORS = STRING_UNARY_OPERATORS;
exports.VISITOR_KEYS = _definitions.VISITOR_KEYS;
exports.BUILDER_KEYS = _definitions.BUILDER_KEYS;
exports.ALIAS_KEYS = _definitions.ALIAS_KEYS;
/**
* Registers `is[Type]` and `assert[Type]` for all types.
*/
_lodashCollectionEach2["default"](t.VISITOR_KEYS, function (keys, type) {
registerType(type, true);
});
/**
* Flip `ALIAS_KEYS` for faster access in the reverse direction.
*/
t.FLIPPED_ALIAS_KEYS = {};
_lodashCollectionEach2["default"](t.ALIAS_KEYS, function (aliases, type) {
_lodashCollectionEach2["default"](aliases, function (alias) {
var types = t.FLIPPED_ALIAS_KEYS[alias] = t.FLIPPED_ALIAS_KEYS[alias] || [];
types.push(type);
});
});
/**
* Registers `is[Alias]` and `assert[Alias]` functions for all aliases.
*/
_lodashCollectionEach2["default"](t.FLIPPED_ALIAS_KEYS, function (types, type) {
t[type.toUpperCase() + "_TYPES"] = types;
registerType(type, false);
});
var TYPES = Object.keys(t.VISITOR_KEYS).concat(Object.keys(t.FLIPPED_ALIAS_KEYS));
exports.TYPES = TYPES;
/**
* Returns whether `node` is of given `type`.
*
* For better performance, use this instead of `is[Type]` when `type` is unknown.
* Optionally, pass `skipAliasCheck` to directly compare `node.type` with `type`.
*/
// @TODO should `skipAliasCheck` be removed?
/*eslint-disable no-unused-vars */
function is(type, node, opts, skipAliasCheck) {
if (!node) return false;
var matches = isType(node.type, type);
if (!matches) return false;
if (typeof opts === "undefined") {
return true;
} else {
return t.shallowEqual(node, opts);
}
}
/*eslint-enable no-unused-vars */
/**
* Test if a `nodeType` is a `targetType` or if `targetType` is an alias of `nodeType`.
*/
function isType(nodeType, targetType) {
if (nodeType === targetType) return true;
var aliases = t.FLIPPED_ALIAS_KEYS[targetType];
if (aliases) {
if (aliases[0] === nodeType) return true;
var _arr = aliases;
for (var _i = 0; _i < _arr.length; _i++) {
var alias = _arr[_i];
if (nodeType === alias) return true;
}
}
return false;
}
/**
* [Please add a description.]
*/
_lodashCollectionEach2["default"](t.VISITOR_KEYS, function (keys, type) {
if (t.BUILDER_KEYS[type]) return;
var defs = {};
_lodashCollectionEach2["default"](keys, function (key) {
defs[key] = null;
});
t.BUILDER_KEYS[type] = defs;
});
/**
* [Please add a description.]
*/
_lodashCollectionEach2["default"](t.BUILDER_KEYS, function (keys, type) {
var builder = function builder() {
var node = {};
node.type = type;
var i = 0;
for (var key in keys) {
var arg = arguments[i++];
if (arg === undefined) arg = keys[key];
node[key] = arg;
}
return node;
};
t[type] = builder;
t[type[0].toLowerCase() + type.slice(1)] = builder;
});
/**
* Test if an object is shallowly equal.
*/
function shallowEqual(actual, expected) {
var keys = Object.keys(expected);
var _arr2 = keys;
for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
var key = _arr2[_i2];
if (actual[key] !== expected[key]) {
return false;
}
}
return true;
}
/**
* Append a node to a member expression.
*/
function appendToMemberExpression(member, append, computed) {
member.object = t.memberExpression(member.object, member.property, member.computed);
member.property = append;
member.computed = !!computed;
return member;
}
/**
* Prepend a node to a member expression.
*/
function prependToMemberExpression(member, prepend) {
member.object = t.memberExpression(prepend, member.object);
return member;
}
/**
* Ensure the `key` (defaults to "body") of a `node` is a block.
* Casting it to a block if it is not.
*/
function ensureBlock(node) {
var key = arguments.length <= 1 || arguments[1] === undefined ? "body" : arguments[1];
return node[key] = t.toBlock(node[key], node);
}
/**
* Create a shallow clone of a `node` excluding `_private` properties.
*/
function clone(node) {
var newNode = {};
for (var key in node) {
if (key[0] === "_") continue;
newNode[key] = node[key];
}
return newNode;
}
/**
* Create a deep clone of a `node` and all of it's child nodes
* exluding `_private` properties.
*/
function cloneDeep(node) {
var newNode = {};
for (var key in node) {
if (key[0] === "_") continue;
var val = node[key];
if (val) {
if (val.type) {
val = t.cloneDeep(val);
} else if (Array.isArray(val)) {
val = val.map(t.cloneDeep);
}
}
newNode[key] = val;
}
return newNode;
}
/**
* Build a function that when called will return whether or not the
* input `node` `MemberExpression` matches the input `match`.
*
* For example, given the match `React.createClass` it would match the
* parsed nodes of `React.createClass` and `React["createClass"]`.
*/
function buildMatchMemberExpression(match, allowPartial) {
var parts = match.split(".");
return function (member) {
// not a member expression
if (!t.isMemberExpression(member)) return false;
var search = [member];
var i = 0;
while (search.length) {
var node = search.shift();
if (allowPartial && i === parts.length) {
return true;
}
if (t.isIdentifier(node)) {
// this part doesn't match
if (parts[i] !== node.name) return false;
} else if (t.isLiteral(node)) {
// this part doesn't match
if (parts[i] !== node.value) return false;
} else if (t.isMemberExpression(node)) {
if (node.computed && !t.isLiteral(node.property)) {
// we can't deal with this
return false;
} else {
search.push(node.object);
search.push(node.property);
continue;
}
} else {
// we can't deal with this
return false;
}
// too many parts
if (++i > parts.length) {
return false;
}
}
return true;
};
}
/**
* Remove comment properties from a node.
*/
function removeComments(node) {
var _arr3 = COMMENT_KEYS;
for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
var key = _arr3[_i3];
delete node[key];
}
return node;
}
/**
* Inherit all unique comments from `parent` node to `child` node.
*/
function inheritsComments(child, parent) {
inheritTrailingComments(child, parent);
inheritLeadingComments(child, parent);
inheritInnerComments(child, parent);
return child;
}
function inheritTrailingComments(child, parent) {
_inheritComments("trailingComments", child, parent);
}
function inheritLeadingComments(child, parent) {
_inheritComments("leadingComments", child, parent);
}
function inheritInnerComments(child, parent) {
_inheritComments("innerComments", child, parent);
}
function _inheritComments(key, child, parent) {
if (child && parent) {
child[key] = _lodashArrayUniq2["default"](_lodashArrayCompact2["default"]([].concat(child[key], parent[key])));
}
}
/**
* Inherit all contextual properties from `parent` node to `child` node.
*/
function inherits(child, parent) {
if (!child || !parent) return child;
var _arr4 = t.INHERIT_KEYS.optional;
for (var _i4 = 0; _i4 < _arr4.length; _i4++) {
var key = _arr4[_i4];
if (child[key] == null) {
child[key] = parent[key];
}
}
var _arr5 = t.INHERIT_KEYS.force;
for (var _i5 = 0; _i5 < _arr5.length; _i5++) {
var key = _arr5[_i5];
child[key] = parent[key];
}
t.inheritsComments(child, parent);
return child;
}
// Optimize property access.
_toFastProperties2["default"](t);
_toFastProperties2["default"](t.VISITOR_KEYS);
// Export all type checkers from other files.
_lodashObjectAssign2["default"](t, _dereq_(180));
_lodashObjectAssign2["default"](t, _dereq_(181));
_lodashObjectAssign2["default"](t, _dereq_(169));
_lodashObjectAssign2["default"](t, _dereq_(178));
},{"169":169,"174":174,"175":175,"178":178,"180":180,"181":181,"405":405,"409":409,"411":411,"509":509,"600":600}],180:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports.getBindingIdentifiers = getBindingIdentifiers;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
var _index = _dereq_(179);
var t = _interopRequireWildcard(_index);
/**
* Return a list of binding identifiers associated with the input `node`.
*/
function getBindingIdentifiers(node, duplicates) {
var search = [].concat(node);
var ids = Object.create(null);
while (search.length) {
var id = search.shift();
if (!id) continue;
var keys = t.getBindingIdentifiers.keys[id.type];
if (t.isIdentifier(id)) {
if (duplicates) {
var _ids = ids[id.name] = ids[id.name] || [];
_ids.push(id);
} else {
ids[id.name] = id;
}
} else if (t.isExportDeclaration(id)) {
if (t.isDeclaration(node.declaration)) {
search.push(node.declaration);
}
} else if (keys) {
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
if (id[key]) {
search = search.concat(id[key]);
}
}
}
}
return ids;
}
/**
* Mapping of types to their identifier keys.
*/
getBindingIdentifiers.keys = {
DeclareClass: ["id"],
DeclareFunction: ["id"],
DeclareModule: ["id"],
DeclareVariable: ["id"],
InterfaceDeclaration: ["id"],
TypeAlias: ["id"],
ComprehensionExpression: ["blocks"],
ComprehensionBlock: ["left"],
CatchClause: ["param"],
LabeledStatement: ["label"],
UnaryExpression: ["argument"],
AssignmentExpression: ["left"],
ImportSpecifier: ["local"],
ImportNamespaceSpecifier: ["local"],
ImportDefaultSpecifier: ["local"],
ImportDeclaration: ["specifiers"],
FunctionDeclaration: ["id", "params"],
FunctionExpression: ["id", "params"],
ClassDeclaration: ["id"],
ClassExpression: ["id"],
RestElement: ["argument"],
UpdateExpression: ["argument"],
SpreadProperty: ["argument"],
Property: ["value"],
AssignmentPattern: ["left"],
ArrayPattern: ["elements"],
ObjectPattern: ["properties"],
VariableDeclaration: ["declarations"],
VariableDeclarator: ["id"]
};
},{"179":179}],181:[function(_dereq_,module,exports){
"use strict";
exports.__esModule = true;
exports.isBinding = isBinding;
exports.isReferenced = isReferenced;
exports.isValidIdentifier = isValidIdentifier;
exports.isLet = isLet;
exports.isBlockScoped = isBlockScoped;
exports.isVar = isVar;
exports.isSpecifierDefault = isSpecifierDefault;
exports.isScope = isScope;
exports.isImmutable = isImmutable;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _retrievers = _dereq_(180);
var _esutils = _dereq_(395);
var _esutils2 = _interopRequireDefault(_esutils);
var _index = _dereq_(179);
var t = _interopRequireWildcard(_index);
/**
* Check if the input `node` is a binding identifier.
*/
function isBinding(node, parent) {
var keys = _retrievers.getBindingIdentifiers.keys[parent.type];
if (keys) {
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
var val = parent[key];
if (Array.isArray(val)) {
if (val.indexOf(node) >= 0) return true;
} else {
if (val === node) return true;
}
}
}
return false;
}
/**
* Check if the input `node` is a reference to a bound variable.
*/
function isReferenced(node, parent) {
switch (parent.type) {
// yes: PARENT[NODE]
// yes: NODE.child
// no: parent.NODE
case "MemberExpression":
case "JSXMemberExpression":
if (parent.property === node && parent.computed) {
return true;
} else if (parent.object === node) {
return true;
} else {
return false;
}
// no: new.NODE
// no: NODE.target
case "MetaProperty":
return false;
// yes: { [NODE]: "" }
// yes: { NODE }
// no: { NODE: "" }
case "Property":
if (parent.key === node) {
return parent.computed;
}
// no: var NODE = init;
// yes: var id = NODE;
case "VariableDeclarator":
return parent.id !== node;
// no: function NODE() {}
// no: function foo(NODE) {}
case "ArrowFunctionExpression":
case "FunctionDeclaration":
case "FunctionExpression":
var _arr = parent.params;
for (var _i = 0; _i < _arr.length; _i++) {
var param = _arr[_i];
if (param === node) return false;
}
return parent.id !== node;
// no: export { foo as NODE };
// yes: export { NODE as foo };
// no: export { NODE as foo } from "foo";
case "ExportSpecifier":
if (parent.source) {
return false;
} else {
return parent.local === node;
}
// no: <div NODE="foo" />
case "JSXAttribute":
return parent.name !== node;
// no: class { NODE = value; }
// yes: class { key = NODE; }
case "ClassProperty":
return parent.value === node;
// no: import NODE from "foo";
// no: import * as NODE from "foo";
// no: import { NODE as foo } from "foo";
// no: import { foo as NODE } from "foo";
// no: import NODE from "bar";
case "ImportDefaultSpecifier":
case "ImportNamespaceSpecifier":
case "ImportSpecifier":
return false;
// no: class NODE {}
case "ClassDeclaration":
case "ClassExpression":
return parent.id !== node;
// yes: class { [NODE](){} }
case "MethodDefinition":
return parent.key === node && parent.computed;
// no: NODE: for (;;) {}
case "LabeledStatement":
return false;
// no: try {} catch (NODE) {}
case "CatchClause":
return parent.param !== node;
// no: function foo(...NODE) {}
case "RestElement":
return false;
// yes: left = NODE;
// no: NODE = right;
case "AssignmentExpression":
return parent.right === node;
// no: [NODE = foo] = [];
// yes: [foo = NODE] = [];
case "AssignmentPattern":
return parent.right === node;
// no: [NODE] = [];
// no: ({ NODE }) = [];
case "ObjectPattern":
case "ArrayPattern":
return false;
}
return true;
}
/**
* Check if the input `name` is a valid identifier name
* and isn't a reserved word.
*/
function isValidIdentifier(name) {
if (typeof name !== "string" || _esutils2["default"].keyword.isReservedWordES6(name, true)) {
return false;
} else {
return _esutils2["default"].keyword.isIdentifierNameES6(name);
}
}
/**
* Check if the input `node` is a `let` variable declaration.
*/
function isLet(node) {
return t.isVariableDeclaration(node) && (node.kind !== "var" || node._let);
}
/**
* Check if the input `node` is block scoped.
*/
function isBlockScoped(node) {
return t.isFunctionDeclaration(node) || t.isClassDeclaration(node) || t.isLet(node);
}
/**
* Check if the input `node` is a variable declaration.
*/
function isVar(node) {
return t.isVariableDeclaration(node, { kind: "var" }) && !node._let;
}
/**
* Check if the input `specifier` is a `default` import or export.
*/
function isSpecifierDefault(specifier) {
return t.isImportDefaultSpecifier(specifier) || t.isIdentifier(specifier.imported || specifier.exported, { name: "default" });
}
/**
* Check if the input `node` is a scope.
*/
function isScope(node, parent) {
if (t.isBlockStatement(node) && t.isFunction(parent, { body: node })) {
return false;
}
return t.isScopable(node);
}
/**
* Check if the input `node` is definitely immutable.
*/
function isImmutable(node) {
if (t.isType(node.type, "Immutable")) return true;
if (t.isLiteral(node)) {
if (node.regex) {
// regexs are mutable
return false;
} else {
// immutable!
return true;
}
} else if (t.isIdentifier(node)) {
if (node.name === "undefined") {
// immutable!
return true;
} else {
// no idea...
return false;
}
}
return false;
}
},{"179":179,"180":180,"395":395}],182:[function(_dereq_,module,exports){
(function (__dirname){
"use strict";
exports.__esModule = true;
exports.canCompile = canCompile;
exports.list = list;
exports.regexify = regexify;
exports.arrayify = arrayify;
exports.booleanify = booleanify;
exports.shouldIgnore = shouldIgnore;
exports.template = template;
exports.parseTemplate = parseTemplate;
// istanbul ignore next
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj["default"] = obj; return newObj; } }
// istanbul ignore next
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _lodashStringEscapeRegExp = _dereq_(518);
var _lodashStringEscapeRegExp2 = _interopRequireDefault(_lodashStringEscapeRegExp);
var _lodashStringStartsWith = _dereq_(519);
var _lodashStringStartsWith2 = _interopRequireDefault(_lodashStringStartsWith);
var _lodashLangCloneDeep = _dereq_(495);
var _lodashLangCloneDeep2 = _interopRequireDefault(_lodashLangCloneDeep);
var _lodashLangIsBoolean = _dereq_(498);
var _lodashLangIsBoolean2 = _interopRequireDefault(_lodashLangIsBoolean);
var _messages = _dereq_(43);
var messages = _interopRequireWildcard(_messages);
var _minimatch = _dereq_(522);
var _minimatch2 = _interopRequireDefault(_minimatch);
var _lodashCollectionContains = _dereq_(410);
var _lodashCollectionContains2 = _interopRequireDefault(_lodashCollectionContains);
var _traversal = _dereq_(148);
var _traversal2 = _interopRequireDefault(_traversal);
var _lodashLangIsString = _dereq_(506);
var _lodashLangIsString2 = _interopRequireDefault(_lodashLangIsString);
var _lodashLangIsRegExp = _dereq_(505);
var _lodashLangIsRegExp2 = _interopRequireDefault(_lodashLangIsRegExp);
var _lodashLangIsEmpty = _dereq_(499);
var _lodashLangIsEmpty2 = _interopRequireDefault(_lodashLangIsEmpty);
var _helpersParse = _dereq_(42);
var _helpersParse2 = _interopRequireDefault(_helpersParse);
var _path = _dereq_(9);
var _path2 = _interopRequireDefault(_path);
var _lodashObjectHas = _dereq_(512);
var _lodashObjectHas2 = _interopRequireDefault(_lodashObjectHas);
var _fs = _dereq_(1);
var _fs2 = _interopRequireDefault(_fs);
var _types = _dereq_(179);
var t = _interopRequireWildcard(_types);
var _slash = _dereq_(588);
var _slash2 = _interopRequireDefault(_slash);
var _pathExists = _dereq_(526);
var _pathExists2 = _interopRequireDefault(_pathExists);
var _util = _dereq_(13);
exports.inherits = _util.inherits;
exports.inspect = _util.inspect;
/**
* Test if a filename ends with a compilable extension.
*/
function canCompile(filename, altExts) {
var exts = altExts || canCompile.EXTENSIONS;
var ext = _path2["default"].extname(filename);
return _lodashCollectionContains2["default"](exts, ext);
}
/**
* Default set of compilable extensions.
*/
canCompile.EXTENSIONS = [".js", ".jsx", ".es6", ".es"];
/**
* Create an array from any value, splitting strings by ",".
*/
function list(val) {
if (!val) {
return [];
} else if (Array.isArray(val)) {
return val;
} else if (typeof val === "string") {
return val.split(",");
} else {
return [val];
}
}
/**
* Create a RegExp from a string, array, or regexp.
*/
function regexify(val) {
if (!val) return new RegExp(/.^/);
if (Array.isArray(val)) val = new RegExp(val.map(_lodashStringEscapeRegExp2["default"]).join("|"), "i");
if (_lodashLangIsString2["default"](val)) {
// normalise path separators
val = _slash2["default"](val);
// remove starting wildcards or relative separator if present
if (_lodashStringStartsWith2["default"](val, "./") || _lodashStringStartsWith2["default"](val, "*/")) val = val.slice(2);
if (_lodashStringStartsWith2["default"](val, "**/")) val = val.slice(3);
var regex = _minimatch2["default"].makeRe(val, { nocase: true });
return new RegExp(regex.source.slice(1, -1), "i");
}
if (_lodashLangIsRegExp2["default"](val)) return val;
throw new TypeError("illegal type for regexify");
}
/**
* Create an array from a boolean, string, or array, mapped by and optional function.
*/
function arrayify(val, mapFn) {
if (!val) return [];
if (_lodashLangIsBoolean2["default"](val)) return arrayify([val], mapFn);
if (_lodashLangIsString2["default"](val)) return arrayify(list(val), mapFn);
if (Array.isArray(val)) {
if (mapFn) val = val.map(mapFn);
return val;
}
return [val];
}
/**
* Makes boolean-like strings into booleans.
*/
function booleanify(val) {
if (val === "true") return true;
if (val === "false") return false;
return val;
}
/**
* Tests if a filename should be ignored based on "ignore" and "only" options.
*/
function shouldIgnore(filename, ignore, only) {
filename = _slash2["default"](filename);
if (only) {
var _arr = only;
for (var _i = 0; _i < _arr.length; _i++) {
var pattern = _arr[_i];
if (_shouldIgnore(pattern, filename)) return false;
}
return true;
} else if (ignore.length) {
var _arr2 = ignore;
for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
var pattern = _arr2[_i2];
if (_shouldIgnore(pattern, filename)) return true;
}
}
return false;
}
/**
* Returns result of calling function with filename if pattern is a function.
* Otherwise returns result of matching pattern Regex with filename.
*/
function _shouldIgnore(pattern, filename) {
if (typeof pattern === "function") {
return pattern(filename);
} else {
return pattern.test(filename);
}
}
/**
* A visitor for Babel templates, replaces placeholder references.
*/
var templateVisitor = {
/**
* 360 NoScope PWNd
*/
noScope: true,
enter: function enter(node, parent, scope, nodes) {
if (t.isExpressionStatement(node)) {
node = node.expression;
}
if (t.isIdentifier(node) && _lodashObjectHas2["default"](nodes, node.name)) {
this.skip();
this.replaceInline(nodes[node.name]);
}
},
exit: function exit(node) {
_traversal2["default"].clearNode(node);
}
};
/**
* Create an instance of a template to use in a transformer.
*/
function template(name, nodes, keepExpression) {
var ast = exports.templates[name];
if (!ast) throw new ReferenceError("unknown template " + name);
if (nodes === true) {
keepExpression = true;
nodes = null;
}
ast = _lodashLangCloneDeep2["default"](ast);
if (!_lodashLangIsEmpty2["default"](nodes)) {
_traversal2["default"](ast, templateVisitor, null, nodes);
}
if (ast.body.length > 1) return ast.body;
var node = ast.body[0];
if (!keepExpression && t.isExpressionStatement(node)) {
return node.expression;
} else {
return node;
}
}
/**
* Parse a template.
*/
function parseTemplate(loc, code) {
var ast = _helpersParse2["default"](code, { filename: loc, looseModules: true }).program;
ast = _traversal2["default"].removeProperties(ast);
return ast;
}
/**
* Load templates from transformation/templates directory.
*/
function loadTemplates() {
var templates = {};
var templatesLoc = _path2["default"].join(__dirname, "transformation/templates");
if (!_pathExists2["default"].sync(templatesLoc)) {
throw new ReferenceError(messages.get("missingTemplatesDirectory"));
}
var _arr3 = _fs2["default"].readdirSync(templatesLoc);
for (var _i3 = 0; _i3 < _arr3.length; _i3++) {
var name = _arr3[_i3];
if (name[0] === ".") return;
var key = _path2["default"].basename(name, _path2["default"].extname(name));
var loc = _path2["default"].join(templatesLoc, name);
var code = _fs2["default"].readFileSync(loc, "utf8");
templates[key] = parseTemplate(loc, code);
}
return templates;
}
try {
exports.templates = _dereq_(604);
} catch (err) {
if (err.code !== "MODULE_NOT_FOUND") throw err;
exports.templates = loadTemplates();
}
}).call(this,"/lib")
},{"1":1,"13":13,"148":148,"179":179,"410":410,"42":42,"43":43,"495":495,"498":498,"499":499,"505":505,"506":506,"512":512,"518":518,"519":519,"522":522,"526":526,"588":588,"604":604,"9":9}],183:[function(_dereq_,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = function (_ref) {
var Plugin = _ref.Plugin;
var t = _ref.types;
return new Plugin("constant-folding", {
metadata: {
group: "builtin-prepass",
experimental: true
},
visitor: {
AssignmentExpression: function AssignmentExpression() {
var left = this.get("left");
if (!left.isIdentifier()) return;
var binding = this.scope.getBinding(left.node.name);
if (!binding || binding.hasDeoptValue) return;
var evaluated = this.get("right").evaluate();
if (evaluated.confident) {
binding.setValue(evaluated.value);
} else {
binding.deoptValue();
}
},
IfStatement: function IfStatement() {
var evaluated = this.get("test").evaluate();
if (!evaluated.confident) {
// todo: deopt binding values for constant violations inside
return this.skip();
}
if (evaluated.value) {
this.skipKey("alternate");
} else {
this.skipKey("consequent");
}
},
Scopable: {
enter: function enter() {
var funcScope = this.scope.getFunctionParent();
for (var name in this.scope.bindings) {
var binding = this.scope.bindings[name];
var deopt = false;
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = binding.constantViolations[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var path = _step.value;
var funcViolationScope = path.scope.getFunctionParent();
if (funcViolationScope !== funcScope) {
deopt = true;
break;
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator["return"]) {
_iterator["return"]();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
if (deopt) binding.deoptValue();
}
},
exit: function exit() {
for (var name in this.scope.bindings) {
var binding = this.scope.bindings[name];
binding.clearValue();
}
}
},
Expression: {
exit: function exit() {
var res = this.evaluate();
if (res.confident) return t.valueToNode(res.value);
}
}
}
});
};
module.exports = exports["default"];
},{}],184:[function(_dereq_,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = function (_ref) {
var Plugin = _ref.Plugin;
var t = _ref.types;
function toStatements(node) {
if (t.isBlockStatement(node)) {
var hasBlockScoped = false;
for (var i = 0; i < node.body.length; i++) {
var bodyNode = node.body[i];
if (t.isBlockScoped(bodyNode)) hasBlockScoped = true;
}
if (!hasBlockScoped) {
return node.body;
}
}
return node;
}
var visitor = {
ReferencedIdentifier: function ReferencedIdentifier(node, parent, scope) {
var binding = scope.getBinding(node.name);
if (!binding || binding.references > 1 || !binding.constant) return;
if (binding.kind === "param" || binding.kind === "module") return;
var replacement = binding.path.node;
if (t.isVariableDeclarator(replacement)) {
replacement = replacement.init;
}
if (!replacement) return;
// ensure it's a "pure" type
if (!scope.isPure(replacement, true)) return;
if (t.isClass(replacement) || t.isFunction(replacement)) {
// don't change this if it's in a different scope, this can be bad
// for performance since it may be inside a loop or deeply nested in
// hot code
if (binding.path.scope.parent !== scope) return;
}
if (this.findParent(function (path) {
return path.node === replacement;
})) {
return;
}
t.toExpression(replacement);
scope.removeBinding(node.name);
binding.path.dangerouslyRemove();
return replacement;
},
"ClassDeclaration|FunctionDeclaration": function ClassDeclarationFunctionDeclaration(node, parent, scope) {
var binding = scope.getBinding(node.id.name);
if (binding && !binding.referenced) {
this.dangerouslyRemove();
}
},
VariableDeclarator: function VariableDeclarator(node, parent, scope) {
if (!t.isIdentifier(node.id) || !scope.isPure(node.init, true)) return;
visitor["ClassDeclaration|FunctionDeclaration"].apply(this, arguments);
},
ConditionalExpression: function ConditionalExpression(node) {
var evaluateTest = this.get("test").evaluateTruthy();
if (evaluateTest === true) {
return node.consequent;
} else if (evaluateTest === false) {
return node.alternate;
}
},
BlockStatement: function BlockStatement() {
var paths = this.get("body");
var purge = false;
for (var i = 0; i < paths.length; i++) {
var path = paths[i];
if (!purge && path.isCompletionStatement()) {
purge = true;
continue;
}
if (purge && !path.isFunctionDeclaration()) {
path.dangerouslyRemove();
}
}
},
IfStatement: {
exit: function exit(node) {
var consequent = node.consequent;
var alternate = node.alternate;
var test = node.test;
var evaluateTest = this.get("test").evaluateTruthy();
// we can check if a test will be truthy 100% and if so then we can inline
// the consequent and completely ignore the alternate
//
// if (true) { foo; } -> { foo; }
// if ("foo") { foo; } -> { foo; }
//
if (evaluateTest === true) {
return toStatements(consequent);
}
// we can check if a test will be falsy 100% and if so we can inline the
// alternate if there is one and completely remove the consequent
//
// if ("") { bar; } else { foo; } -> { foo; }
// if ("") { bar; } ->
//
if (evaluateTest === false) {
if (alternate) {
return toStatements(alternate);
} else {
return this.dangerouslyRemove();
}
}
// remove alternate blocks that are empty
//
// if (foo) { foo; } else {} -> if (foo) { foo; }
//
if (t.isBlockStatement(alternate) && !alternate.body.length) {
alternate = node.alternate = null;
}
// if the consequent block is empty turn alternate blocks into a consequent
// and flip the test
//
// if (foo) {} else { bar; } -> if (!foo) { bar; }
//
if (t.isBlockStatement(consequent) && !consequent.body.length && t.isBlockStatement(alternate) && alternate.body.length) {
node.consequent = node.alternate;
node.alternate = null;
node.test = t.unaryExpression("!", test, true);
}
}
}
};
return new Plugin("dead-code-elimination", {
metadata: {
group: "builtin-pre",
experimental: true
},
visitor: visitor
});
};
module.exports = exports["default"];
},{}],185:[function(_dereq_,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = function (_ref) {
var Plugin = _ref.Plugin;
var parse = _ref.parse;
var traverse = _ref.traverse;
return new Plugin("eval", {
metadata: {
group: "builtin-pre"
},
visitor: {
CallExpression: function CallExpression(node) {
if (this.get("callee").isIdentifier({ name: "eval" }) && node.arguments.length === 1) {
var evaluate = this.get("arguments")[0].evaluate();
if (!evaluate.confident) return;
var code = evaluate.value;
if (typeof code !== "string") return;
var ast = parse(code);
traverse.removeProperties(ast);
return ast.program;
}
}
}
});
};
module.exports = exports["default"];
},{}],186:[function(_dereq_,module,exports){
(function (process){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = function (_ref) {
var Plugin = _ref.Plugin;
var t = _ref.types;
return new Plugin("inline-environment-variables", {
metadata: {
group: "builtin-pre"
},
visitor: {
MemberExpression: function MemberExpression(node) {
if (this.get("object").matchesPattern("process.env")) {
var key = this.toComputedKey();
if (t.isLiteral(key)) {
return t.valueToNode(process.env[key.value]);
}
}
}
}
});
};
module.exports = exports["default"];
}).call(this,_dereq_(10))
},{"10":10}],187:[function(_dereq_,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = function (_ref) {
var Plugin = _ref.Plugin;
var t = _ref.types;
return new Plugin("jscript", {
metadata: {
group: "builtin-trailing"
},
visitor: {
FunctionExpression: {
exit: function exit(node) {
if (!node.id) return;
node._ignoreUserWhitespace = true;
return t.callExpression(t.functionExpression(null, [], t.blockStatement([t.toStatement(node), t.returnStatement(node.id)])), []);
}
}
}
});
};
module.exports = exports["default"];
},{}],188:[function(_dereq_,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = function (_ref) {
var Plugin = _ref.Plugin;
var t = _ref.types;
return new Plugin("member-expression-literals", {
metadata: {
group: "builtin-trailing"
},
visitor: {
MemberExpression: {
exit: function exit(node) {
var prop = node.property;
if (node.computed && t.isLiteral(prop) && t.isValidIdentifier(prop.value)) {
// foo["bar"] => foo.bar
node.property = t.identifier(prop.value);
node.computed = false;
}
}
}
}
});
};
module.exports = exports["default"];
},{}],189:[function(_dereq_,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = function (_ref) {
var Plugin = _ref.Plugin;
var t = _ref.types;
return new Plugin("property-literals", {
metadata: {
group: "builtin-trailing"
},
visitor: {
Property: {
exit: function exit(node) {
var key = node.key;
if (t.isLiteral(key) && t.isValidIdentifier(key.value)) {
// "foo": "bar" -> foo: "bar"
node.key = t.identifier(key.value);
node.computed = false;
}
}
}
}
});
};
module.exports = exports["default"];
},{}],190:[function(_dereq_,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _lodashArrayPull = _dereq_(408);
var _lodashArrayPull2 = _interopRequireDefault(_lodashArrayPull);
exports["default"] = function (_ref) {
var Plugin = _ref.Plugin;
var t = _ref.types;
function isProtoKey(node) {
return t.isLiteral(t.toComputedKey(node, node.key), { value: "__proto__" });
}
function isProtoAssignmentExpression(node) {
var left = node.left;
return t.isMemberExpression(left) && t.isLiteral(t.toComputedKey(left, left.property), { value: "__proto__" });
}
function buildDefaultsCallExpression(expr, ref, file) {
return t.expressionStatement(t.callExpression(file.addHelper("defaults"), [ref, expr.right]));
}
return new Plugin("proto-to-assign", {
metadata: {
secondPass: true
},
visitor: {
AssignmentExpression: function AssignmentExpression(node, parent, scope, file) {
if (!isProtoAssignmentExpression(node)) return;
var nodes = [];
var left = node.left.object;
var temp = scope.maybeGenerateMemoised(left);
if (temp) nodes.push(t.expressionStatement(t.assignmentExpression("=", temp, left)));
nodes.push(buildDefaultsCallExpression(node, temp || left, file));
if (temp) nodes.push(temp);
return nodes;
},
ExpressionStatement: function ExpressionStatement(node, parent, scope, file) {
var expr = node.expression;
if (!t.isAssignmentExpression(expr, { operator: "=" })) return;
if (isProtoAssignmentExpression(expr)) {
return buildDefaultsCallExpression(expr, expr.left.object, file);
}
},
ObjectExpression: function ObjectExpression(node, parent, scope, file) {
var proto;
for (var i = 0; i < node.properties.length; i++) {
var prop = node.properties[i];
if (isProtoKey(prop)) {
proto = prop.value;
(0, _lodashArrayPull2["default"])(node.properties, prop);
}
}
if (proto) {
var args = [t.objectExpression([]), proto];
if (node.properties.length) args.push(node);
return t.callExpression(file.addHelper("extends"), args);
}
}
}
});
};
module.exports = exports["default"];
},{"408":408}],191:[function(_dereq_,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = function (_ref) {
var Plugin = _ref.Plugin;
var immutabilityVisitor = {
enter: function enter(node, parent, scope, state) {
var _this = this;
var stop = function stop() {
state.isImmutable = false;
_this.stop();
};
if (this.isJSXClosingElement()) {
this.skip();
return;
}
if (this.isJSXIdentifier({ name: "ref" }) && this.parentPath.isJSXAttribute({ name: node })) {
return stop();
}
if (this.isJSXIdentifier() || this.isIdentifier() || this.isJSXMemberExpression()) {
return;
}
if (!this.isImmutable()) stop();
}
};
return new Plugin("react-constant-elements", {
metadata: {
group: "builtin-basic"
},
visitor: {
JSXElement: function JSXElement(node) {
if (node._hoisted) return;
var state = { isImmutable: true };
this.traverse(immutabilityVisitor, state);
if (state.isImmutable) {
this.hoist();
} else {
node._hoisted = true;
}
}
}
});
};
module.exports = exports["default"];
},{}],192:[function(_dereq_,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = function (_ref) {
var Plugin = _ref.Plugin;
var t = _ref.types;
function addDisplayName(id, call) {
var props = call.arguments[0].properties;
var safe = true;
for (var i = 0; i < props.length; i++) {
var prop = props[i];
var key = t.toComputedKey(prop);
if (t.isLiteral(key, { value: "displayName" })) {
safe = false;
break;
}
}
if (safe) {
props.unshift(t.property("init", t.identifier("displayName"), t.literal(id)));
}
}
var isCreateClassCallExpression = t.buildMatchMemberExpression("React.createClass");
function isCreateClass(node) {
if (!node || !t.isCallExpression(node)) return false;
// not React.createClass call member object
if (!isCreateClassCallExpression(node.callee)) return false;
// no call arguments
var args = node.arguments;
if (args.length !== 1) return false;
// first node arg is not an object
var first = args[0];
if (!t.isObjectExpression(first)) return false;
return true;
}
return new Plugin("react-display-name", {
metadata: {
group: "builtin-pre"
},
visitor: {
ExportDefaultDeclaration: function ExportDefaultDeclaration(node, parent, scope, file) {
if (isCreateClass(node.declaration)) {
addDisplayName(file.opts.basename, node.declaration);
}
},
"AssignmentExpression|Property|VariableDeclarator": function AssignmentExpressionPropertyVariableDeclarator(node) {
var left, right;
if (t.isAssignmentExpression(node)) {
left = node.left;
right = node.right;
} else if (t.isProperty(node)) {
left = node.key;
right = node.value;
} else if (t.isVariableDeclarator(node)) {
left = node.id;
right = node.init;
}
if (t.isMemberExpression(left)) {
left = left.property;
}
if (t.isIdentifier(left) && isCreateClass(right)) {
addDisplayName(left.name, right);
}
}
}
});
};
module.exports = exports["default"];
},{}],193:[function(_dereq_,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = function (_ref) {
var Plugin = _ref.Plugin;
var t = _ref.types;
return new Plugin("remove-console", {
metadata: {
group: "builtin-pre"
},
visitor: {
CallExpression: function CallExpression() {
if (this.get("callee").matchesPattern("console", true)) {
this.dangerouslyRemove();
}
}
}
});
};
module.exports = exports["default"];
},{}],194:[function(_dereq_,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = function (_ref) {
var Plugin = _ref.Plugin;
var t = _ref.types;
return new Plugin("remove-debugger", {
metadata: {
group: "builtin-pre"
},
visitor: {
DebuggerStatement: function DebuggerStatement() {
this.dangerouslyRemove();
}
}
});
};
module.exports = exports["default"];
},{}],195:[function(_dereq_,module,exports){
module.exports={
"builtins": {
"Symbol": "symbol",
"Promise": "promise",
"Map": "map",
"WeakMap": "weak-map",
"Set": "set",
"WeakSet": "weak-set"
},
"methods": {
"Array": {
"concat": "array/concat",
"copyWithin": "array/copy-within",
"entries": "array/entries",
"every": "array/every",
"fill": "array/fill",
"filter": "array/filter",
"findIndex": "array/find-index",
"find": "array/find",
"forEach": "array/for-each",
"from": "array/from",
"includes": "array/includes",
"indexOf": "array/index-of",
"join": "array/join",
"keys": "array/keys",
"lastIndexOf": "array/last-index-of",
"map": "array/map",
"of": "array/of",
"pop": "array/pop",
"push": "array/push",
"reduceRight": "array/reduce-right",
"reduce": "array/reduce",
"reverse": "array/reverse",
"shift": "array/shift",
"slice": "array/slice",
"some": "array/some",
"sort": "array/sort",
"splice": "array/splice",
"turn": "array/turn",
"unshift": "array/unshift",
"values": "array/values"
},
"Object": {
"assign": "object/assign",
"classof": "object/classof",
"create": "object/create",
"define": "object/define",
"defineProperties": "object/define-properties",
"defineProperty": "object/define-property",
"entries": "object/entries",
"freeze": "object/freeze",
"getOwnPropertyDescriptor": "object/get-own-property-descriptor",
"getOwnPropertyDescriptors": "object/get-own-property-descriptors",
"getOwnPropertyNames": "object/get-own-property-names",
"getOwnPropertySymbols": "object/get-own-property-symbols",
"getPrototypePf": "object/get-prototype-of",
"index": "object/index",
"isExtensible": "object/is-extensible",
"isFrozen": "object/is-frozen",
"isObject": "object/is-object",
"isSealed": "object/is-sealed",
"is": "object/is",
"keys": "object/keys",
"make": "object/make",
"preventExtensions": "object/prevent-extensions",
"seal": "object/seal",
"setPrototypeOf": "object/set-prototype-of",
"values": "object/values"
},
"RegExp": {
"escape": "regexp/escape"
},
"Function": {
"only": "function/only",
"part": "function/part"
},
"Math": {
"acosh": "math/acosh",
"asinh": "math/asinh",
"atanh": "math/atanh",
"cbrt": "math/cbrt",
"clz32": "math/clz32",
"cosh": "math/cosh",
"expm1": "math/expm1",
"fround": "math/fround",
"hypot": "math/hypot",
"pot": "math/pot",
"imul": "math/imul",
"log10": "math/log10",
"log1p": "math/log1p",
"log2": "math/log2",
"sign": "math/sign",
"sinh": "math/sinh",
"tanh": "math/tanh",
"trunc": "math/trunc"
},
"Date": {
"addLocale": "date/add-locale",
"formatUTC": "date/format-utc",
"format": "date/format"
},
"Symbol": {
"for": "symbol/for",
"hasInstance": "symbol/has-instance",
"is-concat-spreadable": "symbol/is-concat-spreadable",
"iterator": "symbol/iterator",
"keyFor": "symbol/key-for",
"match": "symbol/match",
"replace": "symbol/replace",
"search": "symbol/search",
"species": "symbol/species",
"split": "symbol/split",
"toPrimitive": "symbol/to-primitive",
"toStringTag": "symbol/to-string-tag",
"unscopables": "symbol/unscopables"
},
"String": {
"at": "string/at",
"codePointAt": "string/code-point-at",
"endsWith": "string/ends-with",
"escapeHTML": "string/escape-html",
"fromCodePoint": "string/from-code-point",
"includes": "string/includes",
"raw": "string/raw",
"repeat": "string/repeat",
"startsWith": "string/starts-with",
"unescapeHTML": "string/unescape-html"
},
"Number": {
"EPSILON": "number/epsilon",
"isFinite": "number/is-finite",
"isInteger": "number/is-integer",
"isNaN": "number/is-nan",
"isSafeInteger": "number/is-safe-integer",
"MAX_SAFE_INTEGER": "number/max-safe-integer",
"MIN_SAFE_INTEGER": "number/min-safe-integer",
"parseFloat": "number/parse-float",
"parseInt": "number/parse-int",
"random": "number/random"
},
"Reflect": {
"apply": "reflect/apply",
"construct": "reflect/construct",
"defineProperty": "reflect/define-property",
"deleteProperty": "reflect/delete-property",
"enumerate": "reflect/enumerate",
"getOwnPropertyDescriptor": "reflect/get-own-property-descriptor",
"getPrototypeOf": "reflect/get-prototype-of",
"get": "reflect/get",
"has": "reflect/has",
"isExtensible": "reflect/is-extensible",
"ownKeys": "reflect/own-keys",
"preventExtensions": "reflect/prevent-extensions",
"setPrototypeOf": "reflect/set-prototype-of",
"set": "reflect/set"
}
}
}
},{}],196:[function(_dereq_,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _definitions = _dereq_(195);
var _definitions2 = _interopRequireDefault(_definitions);
exports["default"] = function (_ref) {
var Plugin = _ref.Plugin;
var t = _ref.types;
var RUNTIME_MODULE_NAME = "babel-runtime";
function has(obj, key) {
return Object.prototype.hasOwnProperty.call(obj, key);
}
return new Plugin("runtime", {
metadata: {
group: "builtin-post-modules"
},
pre: function pre(file) {
file.set("helperGenerator", function (name) {
return file.addImport(RUNTIME_MODULE_NAME + "/helpers/" + name, name, "absoluteDefault");
});
file.setDynamic("regeneratorIdentifier", function () {
return file.addImport(RUNTIME_MODULE_NAME + "/regenerator", "regeneratorRuntime", "absoluteDefault");
});
},
visitor: {
ReferencedIdentifier: function ReferencedIdentifier(node, parent, scope, file) {
if (node.name === "regeneratorRuntime") {
return file.get("regeneratorIdentifier");
}
if (t.isMemberExpression(parent)) return;
if (!has(_definitions2["default"].builtins, node.name)) return;
if (scope.getBindingIdentifier(node.name)) return;
// Symbol() -> _core.Symbol(); new Promise -> new _core.Promise
var modulePath = _definitions2["default"].builtins[node.name];
return file.addImport(RUNTIME_MODULE_NAME + "/core-js/" + modulePath, node.name, "absoluteDefault");
},
CallExpression: function CallExpression(node, parent, scope, file) {
// arr[Symbol.iterator]() -> _core.$for.getIterator(arr)
if (node.arguments.length) return;
var callee = node.callee;
if (!t.isMemberExpression(callee)) return;
if (!callee.computed) return;
if (!this.get("callee.property").matchesPattern("Symbol.iterator")) return;
return t.callExpression(file.addImport(RUNTIME_MODULE_NAME + "/core-js/get-iterator", "getIterator", "absoluteDefault"), [callee.object]);
},
BinaryExpression: function BinaryExpression(node, parent, scope, file) {
// Symbol.iterator in arr -> core.$for.isIterable(arr)
if (node.operator !== "in") return;
if (!this.get("left").matchesPattern("Symbol.iterator")) return;
return t.callExpression(file.addImport(RUNTIME_MODULE_NAME + "/core-js/is-iterable", "isIterable", "absoluteDefault"), [node.right]);
},
MemberExpression: {
enter: function enter(node, parent, scope, file) {
// Array.from -> _core.Array.from
if (!this.isReferenced()) return;
var obj = node.object;
var prop = node.property;
if (!t.isReferenced(obj, node)) return;
if (node.computed) return;
if (!has(_definitions2["default"].methods, obj.name)) return;
var methods = _definitions2["default"].methods[obj.name];
if (!has(methods, prop.name)) return;
// doesn't reference the global
if (scope.getBindingIdentifier(obj.name)) return;
// special case Object.defineProperty to not use core-js when using string keys
if (obj.name === "Object" && prop.name === "defineProperty" && this.parentPath.isCallExpression()) {
var call = this.parentPath.node;
if (call.arguments.length === 3 && t.isLiteral(call.arguments[1])) return;
}
var modulePath = methods[prop.name];
return file.addImport(RUNTIME_MODULE_NAME + "/core-js/" + modulePath, obj.name + "$" + prop.name, "absoluteDefault");
},
exit: function exit(node, parent, scope, file) {
if (!this.isReferenced()) return;
var prop = node.property;
var obj = node.object;
if (!has(_definitions2["default"].builtins, obj.name)) return;
if (scope.getBindingIdentifier(obj.name)) return;
var modulePath = _definitions2["default"].builtins[obj.name];
return t.memberExpression(file.addImport(RUNTIME_MODULE_NAME + "/core-js/" + modulePath, "" + obj.name, "absoluteDefault"), prop, node.computed);
}
}
}
});
};
module.exports = exports["default"];
},{"195":195}],197:[function(_dereq_,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var _leven = _dereq_(198);
var _leven2 = _interopRequireDefault(_leven);
exports["default"] = function (_ref) {
var Plugin = _ref.Plugin;
var t = _ref.types;
var messages = _ref.messages;
return new Plugin("undeclared-variables-check", {
metadata: {
group: "builtin-pre"
},
visitor: {
ReferencedIdentifier: function ReferencedIdentifier(node, parent, scope) {
var binding = scope.getBinding(node.name);
if (binding && binding.kind === "type" && !this.parentPath.isFlow()) {
throw this.errorWithNode(messages.get("undeclaredVariableType", node.name), ReferenceError);
}
if (scope.hasBinding(node.name)) return;
// get the closest declaration to offer as a suggestion
// the variable name may have just been mistyped
var bindings = scope.getAllBindings();
var closest;
var shortest = -1;
for (var name in bindings) {
var distance = (0, _leven2["default"])(node.name, name);
if (distance <= 0 || distance > 3) continue;
if (distance <= shortest) continue;
closest = name;
shortest = distance;
}
var msg;
if (closest) {
msg = messages.get("undeclaredVariableSuggestion", node.name, closest);
} else {
msg = messages.get("undeclaredVariable", node.name);
}
//
throw this.errorWithNode(msg, ReferenceError);
}
}
});
};
module.exports = exports["default"];
},{"198":198}],198:[function(_dereq_,module,exports){
'use strict';
var arr = [];
var charCodeCache = [];
module.exports = function (a, b) {
if (a === b) {
return 0;
}
var aLen = a.length;
var bLen = b.length;
if (aLen === 0) {
return bLen;
}
if (bLen === 0) {
return aLen;
}
var bCharCode;
var ret;
var tmp;
var tmp2;
var i = 0;
var j = 0;
while (i < aLen) {
charCodeCache[i] = a.charCodeAt(i);
arr[i] = ++i;
}
while (j < bLen) {
bCharCode = b.charCodeAt(j);
tmp = j++;
ret = j;
for (i = 0; i < aLen; i++) {
tmp2 = bCharCode === charCodeCache[i] ? tmp : tmp + 1;
tmp = arr[i];
ret = arr[i] = tmp > ret ? tmp2 > ret ? ret + 1 : tmp2 : tmp2 > tmp ? tmp + 1 : tmp2;
}
}
return ret;
};
},{}],199:[function(_dereq_,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = function (_ref) {
var Plugin = _ref.Plugin;
var t = _ref.types;
return new Plugin("undefined-to-void", {
metadata: {
group: "builtin-basic"
},
visitor: {
ReferencedIdentifier: function ReferencedIdentifier(node, parent) {
if (node.name === "undefined") {
return t.unaryExpression("void", t.literal(0), true);
}
}
}
});
};
module.exports = exports["default"];
},{}],200:[function(_dereq_,module,exports){
(function (process){
'use strict';
var escapeStringRegexp = _dereq_(202);
var ansiStyles = _dereq_(201);
var stripAnsi = _dereq_(205);
var hasAnsi = _dereq_(203);
var supportsColor = _dereq_(207);
var defineProps = Object.defineProperties;
var isSimpleWindowsTerm = process.platform === 'win32' && !/^xterm/i.test(process.env.TERM);
function Chalk(options) {
// detect mode if not set manually
this.enabled = !options || options.enabled === undefined ? supportsColor : options.enabled;
}
// use bright blue on Windows as the normal blue color is illegible
if (isSimpleWindowsTerm) {
ansiStyles.blue.open = '\u001b[94m';
}
var styles = (function () {
var ret = {};
Object.keys(ansiStyles).forEach(function (key) {
ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
ret[key] = {
get: function () {
return build.call(this, this._styles.concat(key));
}
};
});
return ret;
})();
var proto = defineProps(function chalk() {}, styles);
function build(_styles) {
var builder = function () {
return applyStyle.apply(builder, arguments);
};
builder._styles = _styles;
builder.enabled = this.enabled;
// __proto__ is used because we must return a function, but there is
// no way to create a function with a different prototype.
/* eslint-disable no-proto */
builder.__proto__ = proto;
return builder;
}
function applyStyle() {
// support varags, but simply cast to string in case there's only one arg
var args = arguments;
var argsLen = args.length;
var str = argsLen !== 0 && String(arguments[0]);
if (argsLen > 1) {
// don't slice `arguments`, it prevents v8 optimizations
for (var a = 1; a < argsLen; a++) {
str += ' ' + args[a];
}
}
if (!this.enabled || !str) {
return str;
}
var nestedStyles = this._styles;
var i = nestedStyles.length;
// Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
// see https://github.com/chalk/chalk/issues/58
// If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.
var originalDim = ansiStyles.dim.open;
if (isSimpleWindowsTerm && (nestedStyles.indexOf('gray') !== -1 || nestedStyles.indexOf('grey') !== -1)) {
ansiStyles.dim.open = '';
}
while (i--) {
var code = ansiStyles[nestedStyles[i]];
// Replace any instances already present with a re-opening code
// otherwise only the part of the string until said closing code
// will be colored, and the rest will simply be 'plain'.
str = code.open + str.replace(code.closeRe, code.open) + code.close;
}
// Reset the original 'dim' if we changed it to work around the Windows dimmed gray issue.
ansiStyles.dim.open = originalDim;
return str;
}
function init() {
var ret = {};
Object.keys(styles).forEach(function (name) {
ret[name] = {
get: function () {
return build.call(this, [name]);
}
};
});
return ret;
}
defineProps(Chalk.prototype, init());
module.exports = new Chalk();
module.exports.styles = ansiStyles;
module.exports.hasColor = hasAnsi;
module.exports.stripColor = stripAnsi;
module.exports.supportsColor = supportsColor;
}).call(this,_dereq_(10))
},{"10":10,"201":201,"202":202,"203":203,"205":205,"207":207}],201:[function(_dereq_,module,exports){
'use strict';
function assembleStyles () {
var styles = {
modifiers: {
reset: [0, 0],
bold: [1, 22], // 21 isn't widely supported and 22 does the same thing
dim: [2, 22],
italic: [3, 23],
underline: [4, 24],
inverse: [7, 27],
hidden: [8, 28],
strikethrough: [9, 29]
},
colors: {
black: [30, 39],
red: [31, 39],
green: [32, 39],
yellow: [33, 39],
blue: [34, 39],
magenta: [35, 39],
cyan: [36, 39],
white: [37, 39],
gray: [90, 39]
},
bgColors: {
bgBlack: [40, 49],
bgRed: [41, 49],
bgGreen: [42, 49],
bgYellow: [43, 49],
bgBlue: [44, 49],
bgMagenta: [45, 49],
bgCyan: [46, 49],
bgWhite: [47, 49]
}
};
// fix humans
styles.colors.grey = styles.colors.gray;
Object.keys(styles).forEach(function (groupName) {
var group = styles[groupName];
Object.keys(group).forEach(function (styleName) {
var style = group[styleName];
styles[styleName] = group[styleName] = {
open: '\u001b[' + style[0] + 'm',
close: '\u001b[' + style[1] + 'm'
};
});
Object.defineProperty(styles, groupName, {
value: group,
enumerable: false
});
});
return styles;
}
Object.defineProperty(module, 'exports', {
enumerable: true,
get: assembleStyles
});
},{}],202:[function(_dereq_,module,exports){
'use strict';
var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
module.exports = function (str) {
if (typeof str !== 'string') {
throw new TypeError('Expected a string');
}
return str.replace(matchOperatorsRe, '\\$&');
};
},{}],203:[function(_dereq_,module,exports){
'use strict';
var ansiRegex = _dereq_(204);
var re = new RegExp(ansiRegex().source); // remove the `g` flag
module.exports = re.test.bind(re);
},{"204":204}],204:[function(_dereq_,module,exports){
'use strict';
module.exports = function () {
return /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g;
};
},{}],205:[function(_dereq_,module,exports){
'use strict';
var ansiRegex = _dereq_(206)();
module.exports = function (str) {
return typeof str === 'string' ? str.replace(ansiRegex, '') : str;
};
},{"206":206}],206:[function(_dereq_,module,exports){
arguments[4][204][0].apply(exports,arguments)
},{"204":204}],207:[function(_dereq_,module,exports){
(function (process){
'use strict';
var argv = process.argv;
var terminator = argv.indexOf('--');
var hasFlag = function (flag) {
flag = '--' + flag;
var pos = argv.indexOf(flag);
return pos !== -1 && (terminator !== -1 ? pos < terminator : true);
};
module.exports = (function () {
if ('FORCE_COLOR' in process.env) {
return true;
}
if (hasFlag('no-color') ||
hasFlag('no-colors') ||
hasFlag('color=false')) {
return false;
}
if (hasFlag('color') ||
hasFlag('colors') ||
hasFlag('color=true') ||
hasFlag('color=always')) {
return true;
}
if (process.stdout && !process.stdout.isTTY) {
return false;
}
if (process.platform === 'win32') {
return true;
}
if ('COLORTERM' in process.env) {
return true;
}
if (process.env.TERM === 'dumb') {
return false;
}
if (/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)) {
return true;
}
return false;
})();
}).call(this,_dereq_(10))
},{"10":10}],208:[function(_dereq_,module,exports){
(function (Buffer){
'use strict';
var fs = _dereq_(1);
var path = _dereq_(9);
var commentRx = /^\s*\/(?:\/|\*)[@#]\s+sourceMappingURL=data:(?:application|text)\/json;(?:charset[:=]\S+;)?base64,(.*)$/mg;
var mapFileCommentRx =
// //# sourceMappingURL=foo.js.map
/(?:\/\/[@#][ \t]+sourceMappingURL=([^\s'"]+?)[ \t]*$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^\*]+?)[ \t]*(?:\*\/){1}[ \t]*$)/mg
function decodeBase64(base64) {
return new Buffer(base64, 'base64').toString();
}
function stripComment(sm) {
return sm.split(',').pop();
}
function readFromFileMap(sm, dir) {
// NOTE: this will only work on the server since it attempts to read the map file
var r = mapFileCommentRx.exec(sm);
mapFileCommentRx.lastIndex = 0;
// for some odd reason //# .. captures in 1 and /* .. */ in 2
var filename = r[1] || r[2];
var filepath = path.join(dir, filename);
try {
return fs.readFileSync(filepath, 'utf8');
} catch (e) {
throw new Error('An error occurred while trying to read the map file at ' + filepath + '\n' + e);
}
}
function Converter (sm, opts) {
opts = opts || {};
if (opts.isFileComment) sm = readFromFileMap(sm, opts.commentFileDir);
if (opts.hasComment) sm = stripComment(sm);
if (opts.isEncoded) sm = decodeBase64(sm);
if (opts.isJSON || opts.isEncoded) sm = JSON.parse(sm);
this.sourcemap = sm;
}
function convertFromLargeSource(content){
var lines = content.split('\n');
var line;
// find first line which contains a source map starting at end of content
for (var i = lines.length - 1; i > 0; i--) {
line = lines[i]
if (~line.indexOf('sourceMappingURL=data:')) return exports.fromComment(line);
}
}
Converter.prototype.toJSON = function (space) {
return JSON.stringify(this.sourcemap, null, space);
};
Converter.prototype.toBase64 = function () {
var json = this.toJSON();
return new Buffer(json).toString('base64');
};
Converter.prototype.toComment = function (options) {
var base64 = this.toBase64();
var data = 'sourceMappingURL=data:application/json;base64,' + base64;
return options && options.multiline ? '/*# ' + data + ' */' : '//# ' + data;
};
// returns copy instead of original
Converter.prototype.toObject = function () {
return JSON.parse(this.toJSON());
};
Converter.prototype.addProperty = function (key, value) {
if (this.sourcemap.hasOwnProperty(key)) throw new Error('property %s already exists on the sourcemap, use set property instead');
return this.setProperty(key, value);
};
Converter.prototype.setProperty = function (key, value) {
this.sourcemap[key] = value;
return this;
};
Converter.prototype.getProperty = function (key) {
return this.sourcemap[key];
};
exports.fromObject = function (obj) {
return new Converter(obj);
};
exports.fromJSON = function (json) {
return new Converter(json, { isJSON: true });
};
exports.fromBase64 = function (base64) {
return new Converter(base64, { isEncoded: true });
};
exports.fromComment = function (comment) {
comment = comment
.replace(/^\/\*/g, '//')
.replace(/\*\/$/g, '');
return new Converter(comment, { isEncoded: true, hasComment: true });
};
exports.fromMapFileComment = function (comment, dir) {
return new Converter(comment, { commentFileDir: dir, isFileComment: true, isJSON: true });
};
// Finds last sourcemap comment in file or returns null if none was found
exports.fromSource = function (content, largeSource) {
if (largeSource) return convertFromLargeSource(content);
var m = content.match(commentRx);
commentRx.lastIndex = 0;
return m ? exports.fromComment(m.pop()) : null;
};
// Finds last sourcemap comment in file or returns null if none was found
exports.fromMapFileSource = function (content, dir) {
var m = content.match(mapFileCommentRx);
mapFileCommentRx.lastIndex = 0;
return m ? exports.fromMapFileComment(m.pop(), dir) : null;
};
exports.removeComments = function (src) {
commentRx.lastIndex = 0;
return src.replace(commentRx, '');
};
exports.removeMapFileComments = function (src) {
mapFileCommentRx.lastIndex = 0;
return src.replace(mapFileCommentRx, '');
};
Object.defineProperty(exports, 'commentRegex', {
get: function getCommentRegex () {
commentRx.lastIndex = 0;
return commentRx;
}
});
Object.defineProperty(exports, 'mapFileCommentRegex', {
get: function getMapFileCommentRegex () {
mapFileCommentRx.lastIndex = 0;
return mapFileCommentRx;
}
});
}).call(this,_dereq_(3).Buffer)
},{"1":1,"3":3,"9":9}],209:[function(_dereq_,module,exports){
module.exports = function(it){
if(typeof it != 'function')throw TypeError(it + ' is not a function!');
return it;
};
},{}],210:[function(_dereq_,module,exports){
var isObject = _dereq_(240);
module.exports = function(it){
if(!isObject(it))throw TypeError(it + ' is not an object!');
return it;
};
},{"240":240}],211:[function(_dereq_,module,exports){
// false -> Array#indexOf
// true -> Array#includes
var toIObject = _dereq_(277)
, toLength = _dereq_(278)
, toIndex = _dereq_(275);
module.exports = function(IS_INCLUDES){
return function($this, el, fromIndex){
var O = toIObject($this)
, length = toLength(O.length)
, index = toIndex(fromIndex, length)
, value;
// Array#includes uses SameValueZero equality algorithm
if(IS_INCLUDES && el != el)while(length > index){
value = O[index++];
if(value != value)return true;
// Array#toIndex ignores holes, Array#includes - not
} else for(;length > index; index++)if(IS_INCLUDES || index in O){
if(O[index] === el)return IS_INCLUDES || index;
} return !IS_INCLUDES && -1;
};
};
},{"275":275,"277":277,"278":278}],212:[function(_dereq_,module,exports){
// 0 -> Array#forEach
// 1 -> Array#map
// 2 -> Array#filter
// 3 -> Array#some
// 4 -> Array#every
// 5 -> Array#find
// 6 -> Array#findIndex
var ctx = _dereq_(221)
, IObject = _dereq_(237)
, toObject = _dereq_(279)
, toLength = _dereq_(278);
module.exports = function(TYPE){
var IS_MAP = TYPE == 1
, IS_FILTER = TYPE == 2
, IS_SOME = TYPE == 3
, IS_EVERY = TYPE == 4
, IS_FIND_INDEX = TYPE == 6
, NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
return function($this, callbackfn, that){
var O = toObject($this)
, self = IObject(O)
, f = ctx(callbackfn, that, 3)
, length = toLength(self.length)
, index = 0
, result = IS_MAP ? Array(length) : IS_FILTER ? [] : undefined
, val, res;
for(;length > index; index++)if(NO_HOLES || index in self){
val = self[index];
res = f(val, index, O);
if(TYPE){
if(IS_MAP)result[index] = res; // map
else if(res)switch(TYPE){
case 3: return true; // some
case 5: return val; // find
case 6: return index; // findIndex
case 2: result.push(val); // filter
} else if(IS_EVERY)return false; // every
}
}
return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;
};
};
},{"221":221,"237":237,"278":278,"279":279}],213:[function(_dereq_,module,exports){
// 19.1.2.1 Object.assign(target, source, ...)
var toObject = _dereq_(279)
, IObject = _dereq_(237)
, enumKeys = _dereq_(225);
module.exports = _dereq_(227)(function(){
return Symbol() in Object.assign({}); // Object.assign available and Symbol is native
}) ? function assign(target, source){ // eslint-disable-line no-unused-vars
var T = toObject(target)
, l = arguments.length
, i = 1;
while(l > i){
var S = IObject(arguments[i++])
, keys = enumKeys(S)
, length = keys.length
, j = 0
, key;
while(length > j)T[key = keys[j++]] = S[key];
}
return T;
} : Object.assign;
},{"225":225,"227":227,"237":237,"279":279}],214:[function(_dereq_,module,exports){
// getting tag from 19.1.3.6 Object.prototype.toString()
var cof = _dereq_(215)
, TAG = _dereq_(282)('toStringTag')
// ES3 wrong here
, ARG = cof(function(){ return arguments; }()) == 'Arguments';
module.exports = function(it){
var O, T, B;
return it === undefined ? 'Undefined' : it === null ? 'Null'
// @@toStringTag case
: typeof (T = (O = Object(it))[TAG]) == 'string' ? T
// builtinTag case
: ARG ? cof(O)
// ES3 arguments fallback
: (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
};
},{"215":215,"282":282}],215:[function(_dereq_,module,exports){
var toString = {}.toString;
module.exports = function(it){
return toString.call(it).slice(8, -1);
};
},{}],216:[function(_dereq_,module,exports){
'use strict';
var $ = _dereq_(247)
, hide = _dereq_(234)
, ctx = _dereq_(221)
, species = _dereq_(265)
, strictNew = _dereq_(266)
, defined = _dereq_(223)
, forOf = _dereq_(230)
, step = _dereq_(245)
, ID = _dereq_(280)('id')
, $has = _dereq_(233)
, isObject = _dereq_(240)
, isExtensible = Object.isExtensible || isObject
, SUPPORT_DESC = _dereq_(272)
, SIZE = SUPPORT_DESC ? '_s' : 'size'
, id = 0;
var fastKey = function(it, create){
// return primitive with prefix
if(!isObject(it))return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
if(!$has(it, ID)){
// can't set id to frozen object
if(!isExtensible(it))return 'F';
// not necessary to add id
if(!create)return 'E';
// add missing object id
hide(it, ID, ++id);
// return object id with prefix
} return 'O' + it[ID];
};
var getEntry = function(that, key){
// fast case
var index = fastKey(key), entry;
if(index !== 'F')return that._i[index];
// frozen object case
for(entry = that._f; entry; entry = entry.n){
if(entry.k == key)return entry;
}
};
module.exports = {
getConstructor: function(wrapper, NAME, IS_MAP, ADDER){
var C = wrapper(function(that, iterable){
strictNew(that, C, NAME);
that._i = $.create(null); // index
that._f = undefined; // first entry
that._l = undefined; // last entry
that[SIZE] = 0; // size
if(iterable != undefined)forOf(iterable, IS_MAP, that[ADDER], that);
});
_dereq_(252)(C.prototype, {
// 23.1.3.1 Map.prototype.clear()
// 23.2.3.2 Set.prototype.clear()
clear: function clear(){
for(var that = this, data = that._i, entry = that._f; entry; entry = entry.n){
entry.r = true;
if(entry.p)entry.p = entry.p.n = undefined;
delete data[entry.i];
}
that._f = that._l = undefined;
that[SIZE] = 0;
},
// 23.1.3.3 Map.prototype.delete(key)
// 23.2.3.4 Set.prototype.delete(value)
'delete': function(key){
var that = this
, entry = getEntry(that, key);
if(entry){
var next = entry.n
, prev = entry.p;
delete that._i[entry.i];
entry.r = true;
if(prev)prev.n = next;
if(next)next.p = prev;
if(that._f == entry)that._f = next;
if(that._l == entry)that._l = prev;
that[SIZE]--;
} return !!entry;
},
// 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined)
// 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined)
forEach: function forEach(callbackfn /*, that = undefined */){
var f = ctx(callbackfn, arguments[1], 3)
, entry;
while(entry = entry ? entry.n : this._f){
f(entry.v, entry.k, this);
// revert to the last existing entry
while(entry && entry.r)entry = entry.p;
}
},
// 23.1.3.7 Map.prototype.has(key)
// 23.2.3.7 Set.prototype.has(value)
has: function has(key){
return !!getEntry(this, key);
}
});
if(SUPPORT_DESC)$.setDesc(C.prototype, 'size', {
get: function(){
return defined(this[SIZE]);
}
});
return C;
},
def: function(that, key, value){
var entry = getEntry(that, key)
, prev, index;
// change existing entry
if(entry){
entry.v = value;
// create new entry
} else {
that._l = entry = {
i: index = fastKey(key, true), // <- index
k: key, // <- key
v: value, // <- value
p: prev = that._l, // <- previous entry
n: undefined, // <- next entry
r: false // <- removed
};
if(!that._f)that._f = entry;
if(prev)prev.n = entry;
that[SIZE]++;
// add to index
if(index !== 'F')that._i[index] = entry;
} return that;
},
getEntry: getEntry,
setStrong: function(C, NAME, IS_MAP){
// add .keys, .values, .entries, [@@iterator]
// 23.1.3.4, 23.1.3.8, 23.1.3.11, 23.1.3.12, 23.2.3.5, 23.2.3.8, 23.2.3.10, 23.2.3.11
_dereq_(243)(C, NAME, function(iterated, kind){
this._t = iterated; // target
this._k = kind; // kind
this._l = undefined; // previous
}, function(){
var that = this
, kind = that._k
, entry = that._l;
// revert to the last existing entry
while(entry && entry.r)entry = entry.p;
// get next entry
if(!that._t || !(that._l = entry = entry ? entry.n : that._t._f)){
// or finish the iteration
that._t = undefined;
return step(1);
}
// return step by kind
if(kind == 'keys' )return step(0, entry.k);
if(kind == 'values')return step(0, entry.v);
return step(0, [entry.k, entry.v]);
}, IS_MAP ? 'entries' : 'values' , !IS_MAP, true);
// add [@@species], 23.1.2.2, 23.2.2.2
species(C);
species(_dereq_(220)[NAME]); // for wrapper
}
};
},{"220":220,"221":221,"223":223,"230":230,"233":233,"234":234,"240":240,"243":243,"245":245,"247":247,"252":252,"265":265,"266":266,"272":272,"280":280}],217:[function(_dereq_,module,exports){
// https://github.com/DavidBruant/Map-Set.prototype.toJSON
var forOf = _dereq_(230)
, classof = _dereq_(214);
module.exports = function(NAME){
return function toJSON(){
if(classof(this) != NAME)throw TypeError(NAME + "#toJSON isn't generic");
var arr = [];
forOf(this, false, arr.push, arr);
return arr;
};
};
},{"214":214,"230":230}],218:[function(_dereq_,module,exports){
'use strict';
var hide = _dereq_(234)
, anObject = _dereq_(210)
, strictNew = _dereq_(266)
, forOf = _dereq_(230)
, method = _dereq_(212)
, WEAK = _dereq_(280)('weak')
, isObject = _dereq_(240)
, $has = _dereq_(233)
, isExtensible = Object.isExtensible || isObject
, find = method(5)
, findIndex = method(6)
, id = 0;
// fallback for frozen keys
var frozenStore = function(that){
return that._l || (that._l = new FrozenStore);
};
var FrozenStore = function(){
this.a = [];
};
var findFrozen = function(store, key){
return find(store.a, function(it){
return it[0] === key;
});
};
FrozenStore.prototype = {
get: function(key){
var entry = findFrozen(this, key);
if(entry)return entry[1];
},
has: function(key){
return !!findFrozen(this, key);
},
set: function(key, value){
var entry = findFrozen(this, key);
if(entry)entry[1] = value;
else this.a.push([key, value]);
},
'delete': function(key){
var index = findIndex(this.a, function(it){
return it[0] === key;
});
if(~index)this.a.splice(index, 1);
return !!~index;
}
};
module.exports = {
getConstructor: function(wrapper, NAME, IS_MAP, ADDER){
var C = wrapper(function(that, iterable){
strictNew(that, C, NAME);
that._i = id++; // collection id
that._l = undefined; // leak store for frozen objects
if(iterable != undefined)forOf(iterable, IS_MAP, that[ADDER], that);
});
_dereq_(252)(C.prototype, {
// 23.3.3.2 WeakMap.prototype.delete(key)
// 23.4.3.3 WeakSet.prototype.delete(value)
'delete': function(key){
if(!isObject(key))return false;
if(!isExtensible(key))return frozenStore(this)['delete'](key);
return $has(key, WEAK) && $has(key[WEAK], this._i) && delete key[WEAK][this._i];
},
// 23.3.3.4 WeakMap.prototype.has(key)
// 23.4.3.4 WeakSet.prototype.has(value)
has: function has(key){
if(!isObject(key))return false;
if(!isExtensible(key))return frozenStore(this).has(key);
return $has(key, WEAK) && $has(key[WEAK], this._i);
}
});
return C;
},
def: function(that, key, value){
if(!isExtensible(anObject(key))){
frozenStore(that).set(key, value);
} else {
$has(key, WEAK) || hide(key, WEAK, {});
key[WEAK][that._i] = value;
} return that;
},
frozenStore: frozenStore,
WEAK: WEAK
};
},{"210":210,"212":212,"230":230,"233":233,"234":234,"240":240,"252":252,"266":266,"280":280}],219:[function(_dereq_,module,exports){
'use strict';
var global = _dereq_(232)
, $def = _dereq_(222)
, forOf = _dereq_(230)
, strictNew = _dereq_(266);
module.exports = function(NAME, wrapper, methods, common, IS_MAP, IS_WEAK){
var Base = global[NAME]
, C = Base
, ADDER = IS_MAP ? 'set' : 'add'
, proto = C && C.prototype
, O = {};
var fixMethod = function(KEY){
var fn = proto[KEY];
_dereq_(259)(proto, KEY,
KEY == 'delete' ? function(a){ return fn.call(this, a === 0 ? 0 : a); }
: KEY == 'has' ? function has(a){ return fn.call(this, a === 0 ? 0 : a); }
: KEY == 'get' ? function get(a){ return fn.call(this, a === 0 ? 0 : a); }
: KEY == 'add' ? function add(a){ fn.call(this, a === 0 ? 0 : a); return this; }
: function set(a, b){ fn.call(this, a === 0 ? 0 : a, b); return this; }
);
};
if(typeof C != 'function' || !(IS_WEAK || proto.forEach && !_dereq_(227)(function(){
new C().entries().next();
}))){
// create collection constructor
C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER);
_dereq_(252)(C.prototype, methods);
} else {
var inst = new C
, chain = inst[ADDER](IS_WEAK ? {} : -0, 1)
, buggyZero;
// wrap for init collections from iterable
if(!_dereq_(244)(function(iter){ new C(iter); })){ // eslint-disable-line no-new
C = wrapper(function(target, iterable){
strictNew(target, C, NAME);
var that = new Base;
if(iterable != undefined)forOf(iterable, IS_MAP, that[ADDER], that);
return that;
});
C.prototype = proto;
proto.constructor = C;
}
IS_WEAK || inst.forEach(function(val, key){
buggyZero = 1 / key === -Infinity;
});
// fix converting -0 key to +0
if(buggyZero){
fixMethod('delete');
fixMethod('has');
IS_MAP && fixMethod('get');
}
// + fix .add & .set for chaining
if(buggyZero || chain !== inst)fixMethod(ADDER);
// weak collections should not contains .clear method
if(IS_WEAK && proto.clear)delete proto.clear;
}
_dereq_(273)(C, NAME);
O[NAME] = C;
$def($def.G + $def.W + $def.F * (C != Base), O);
if(!IS_WEAK)common.setStrong(C, NAME, IS_MAP);
return C;
};
},{"222":222,"227":227,"230":230,"232":232,"244":244,"252":252,"259":259,"266":266,"273":273}],220:[function(_dereq_,module,exports){
var core = module.exports = {};
if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef
},{}],221:[function(_dereq_,module,exports){
// optional / simple context binding
var aFunction = _dereq_(209);
module.exports = function(fn, that, length){
aFunction(fn);
if(that === undefined)return fn;
switch(length){
case 1: return function(a){
return fn.call(that, a);
};
case 2: return function(a, b){
return fn.call(that, a, b);
};
case 3: return function(a, b, c){
return fn.call(that, a, b, c);
};
} return function(/* ...args */){
return fn.apply(that, arguments);
};
};
},{"209":209}],222:[function(_dereq_,module,exports){
var global = _dereq_(232)
, core = _dereq_(220)
, hide = _dereq_(234)
, $redef = _dereq_(259)
, PROTOTYPE = 'prototype';
var ctx = function(fn, that){
return function(){
return fn.apply(that, arguments);
};
};
var $def = function(type, name, source){
var key, own, out, exp
, isGlobal = type & $def.G
, isProto = type & $def.P
, target = isGlobal ? global : type & $def.S
? global[name] || (global[name] = {}) : (global[name] || {})[PROTOTYPE]
, exports = isGlobal ? core : core[name] || (core[name] = {});
if(isGlobal)source = name;
for(key in source){
// contains in native
own = !(type & $def.F) && target && key in target;
// export native or passed
out = (own ? target : source)[key];
// bind timers to global for call from export context
if(type & $def.B && own)exp = ctx(out, global);
else exp = isProto && typeof out == 'function' ? ctx(Function.call, out) : out;
// extend global
if(target && !own)$redef(target, key, out);
// export
if(exports[key] != out)hide(exports, key, exp);
if(isProto)(exports[PROTOTYPE] || (exports[PROTOTYPE] = {}))[key] = out;
}
};
global.core = core;
// type bitmap
$def.F = 1; // forced
$def.G = 2; // global
$def.S = 4; // static
$def.P = 8; // proto
$def.B = 16; // bind
$def.W = 32; // wrap
module.exports = $def;
},{"220":220,"232":232,"234":234,"259":259}],223:[function(_dereq_,module,exports){
// 7.2.1 RequireObjectCoercible(argument)
module.exports = function(it){
if(it == undefined)throw TypeError("Can't call method on " + it);
return it;
};
},{}],224:[function(_dereq_,module,exports){
var isObject = _dereq_(240)
, document = _dereq_(232).document
// in old IE typeof document.createElement is 'object'
, is = isObject(document) && isObject(document.createElement);
module.exports = function(it){
return is ? document.createElement(it) : {};
};
},{"232":232,"240":240}],225:[function(_dereq_,module,exports){
// all enumerable object keys, includes symbols
var $ = _dereq_(247);
module.exports = function(it){
var keys = $.getKeys(it)
, getSymbols = $.getSymbols;
if(getSymbols){
var symbols = getSymbols(it)
, isEnum = $.isEnum
, i = 0
, key;
while(symbols.length > i)if(isEnum.call(it, key = symbols[i++]))keys.push(key);
}
return keys;
};
},{"247":247}],226:[function(_dereq_,module,exports){
// 20.2.2.14 Math.expm1(x)
module.exports = Math.expm1 || function expm1(x){
return (x = +x) == 0 ? x : x > -1e-6 && x < 1e-6 ? x + x * x / 2 : Math.exp(x) - 1;
};
},{}],227:[function(_dereq_,module,exports){
module.exports = function(exec){
try {
return !!exec();
} catch(e){
return true;
}
};
},{}],228:[function(_dereq_,module,exports){
'use strict';
module.exports = function(KEY, length, exec){
var defined = _dereq_(223)
, SYMBOL = _dereq_(282)(KEY)
, original = ''[KEY];
if(_dereq_(227)(function(){
var O = {};
O[SYMBOL] = function(){ return 7; };
return ''[KEY](O) != 7;
})){
_dereq_(259)(String.prototype, KEY, exec(defined, SYMBOL, original));
_dereq_(234)(RegExp.prototype, SYMBOL, length == 2
// 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue)
// 21.2.5.11 RegExp.prototype[@@split](string, limit)
? function(string, arg){ return original.call(string, this, arg); }
// 21.2.5.6 RegExp.prototype[@@match](string)
// 21.2.5.9 RegExp.prototype[@@search](string)
: function(string){ return original.call(string, this); }
);
}
};
},{"223":223,"227":227,"234":234,"259":259,"282":282}],229:[function(_dereq_,module,exports){
'use strict';
// 21.2.5.3 get RegExp.prototype.flags
var anObject = _dereq_(210);
module.exports = function(){
var that = anObject(this)
, result = '';
if(that.global)result += 'g';
if(that.ignoreCase)result += 'i';
if(that.multiline)result += 'm';
if(that.unicode)result += 'u';
if(that.sticky)result += 'y';
return result;
};
},{"210":210}],230:[function(_dereq_,module,exports){
var ctx = _dereq_(221)
, call = _dereq_(241)
, isArrayIter = _dereq_(238)
, anObject = _dereq_(210)
, toLength = _dereq_(278)
, getIterFn = _dereq_(283);
module.exports = function(iterable, entries, fn, that){
var iterFn = getIterFn(iterable)
, f = ctx(fn, that, entries ? 2 : 1)
, index = 0
, length, step, iterator;
if(typeof iterFn != 'function')throw TypeError(iterable + ' is not iterable!');
// fast case for arrays with default iterator
if(isArrayIter(iterFn))for(length = toLength(iterable.length); length > index; index++){
entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
} else for(iterator = iterFn.call(iterable); !(step = iterator.next()).done; ){
call(iterator, f, step.value, entries);
}
};
},{"210":210,"221":221,"238":238,"241":241,"278":278,"283":283}],231:[function(_dereq_,module,exports){
// fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
var toString = {}.toString
, toIObject = _dereq_(277)
, getNames = _dereq_(247).getNames;
var windowNames = typeof window == 'object' && Object.getOwnPropertyNames
? Object.getOwnPropertyNames(window) : [];
var getWindowNames = function(it){
try {
return getNames(it);
} catch(e){
return windowNames.slice();
}
};
module.exports.get = function getOwnPropertyNames(it){
if(windowNames && toString.call(it) == '[object Window]')return getWindowNames(it);
return getNames(toIObject(it));
};
},{"247":247,"277":277}],232:[function(_dereq_,module,exports){
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
var UNDEFINED = 'undefined';
var global = module.exports = typeof window != UNDEFINED && window.Math == Math
? window : typeof self != UNDEFINED && self.Math == Math ? self : Function('return this')();
if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef
},{}],233:[function(_dereq_,module,exports){
var hasOwnProperty = {}.hasOwnProperty;
module.exports = function(it, key){
return hasOwnProperty.call(it, key);
};
},{}],234:[function(_dereq_,module,exports){
var $ = _dereq_(247)
, createDesc = _dereq_(258);
module.exports = _dereq_(272) ? function(object, key, value){
return $.setDesc(object, key, createDesc(1, value));
} : function(object, key, value){
object[key] = value;
return object;
};
},{"247":247,"258":258,"272":272}],235:[function(_dereq_,module,exports){
module.exports = _dereq_(232).document && document.documentElement;
},{"232":232}],236:[function(_dereq_,module,exports){
// fast apply, http://jsperf.lnkit.com/fast-apply/5
module.exports = function(fn, args, that){
var un = that === undefined;
switch(args.length){
case 0: return un ? fn()
: fn.call(that);
case 1: return un ? fn(args[0])
: fn.call(that, args[0]);
case 2: return un ? fn(args[0], args[1])
: fn.call(that, args[0], args[1]);
case 3: return un ? fn(args[0], args[1], args[2])
: fn.call(that, args[0], args[1], args[2]);
case 4: return un ? fn(args[0], args[1], args[2], args[3])
: fn.call(that, args[0], args[1], args[2], args[3]);
} return fn.apply(that, args);
};
},{}],237:[function(_dereq_,module,exports){
// indexed object, fallback for non-array-like ES3 strings
var cof = _dereq_(215);
module.exports = 0 in Object('z') ? Object : function(it){
return cof(it) == 'String' ? it.split('') : Object(it);
};
},{"215":215}],238:[function(_dereq_,module,exports){
// check on default Array iterator
var Iterators = _dereq_(246)
, ITERATOR = _dereq_(282)('iterator');
module.exports = function(it){
return (Iterators.Array || Array.prototype[ITERATOR]) === it;
};
},{"246":246,"282":282}],239:[function(_dereq_,module,exports){
// 20.1.2.3 Number.isInteger(number)
var isObject = _dereq_(240)
, floor = Math.floor;
module.exports = function isInteger(it){
return !isObject(it) && isFinite(it) && floor(it) === it;
};
},{"240":240}],240:[function(_dereq_,module,exports){
// http://jsperf.com/core-js-isobject
module.exports = function(it){
return it !== null && (typeof it == 'object' || typeof it == 'function');
};
},{}],241:[function(_dereq_,module,exports){
// call something on iterator step with safe closing on error
var anObject = _dereq_(210);
module.exports = function(iterator, fn, value, entries){
try {
return entries ? fn(anObject(value)[0], value[1]) : fn(value);
// 7.4.6 IteratorClose(iterator, completion)
} catch(e){
var ret = iterator['return'];
if(ret !== undefined)anObject(ret.call(iterator));
throw e;
}
};
},{"210":210}],242:[function(_dereq_,module,exports){
'use strict';
var $ = _dereq_(247)
, IteratorPrototype = {};
// 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
_dereq_(234)(IteratorPrototype, _dereq_(282)('iterator'), function(){ return this; });
module.exports = function(Constructor, NAME, next){
Constructor.prototype = $.create(IteratorPrototype, {next: _dereq_(258)(1,next)});
_dereq_(273)(Constructor, NAME + ' Iterator');
};
},{"234":234,"247":247,"258":258,"273":273,"282":282}],243:[function(_dereq_,module,exports){
'use strict';
var LIBRARY = _dereq_(249)
, $def = _dereq_(222)
, $redef = _dereq_(259)
, hide = _dereq_(234)
, has = _dereq_(233)
, SYMBOL_ITERATOR = _dereq_(282)('iterator')
, Iterators = _dereq_(246)
, BUGGY = !([].keys && 'next' in [].keys()) // Safari has buggy iterators w/o `next`
, FF_ITERATOR = '@@iterator'
, KEYS = 'keys'
, VALUES = 'values';
var returnThis = function(){ return this; };
module.exports = function(Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCE){
_dereq_(242)(Constructor, NAME, next);
var createMethod = function(kind){
switch(kind){
case KEYS: return function keys(){ return new Constructor(this, kind); };
case VALUES: return function values(){ return new Constructor(this, kind); };
} return function entries(){ return new Constructor(this, kind); };
};
var TAG = NAME + ' Iterator'
, proto = Base.prototype
, _native = proto[SYMBOL_ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT]
, _default = _native || createMethod(DEFAULT)
, methods, key;
// Fix native
if(_native){
var IteratorPrototype = _dereq_(247).getProto(_default.call(new Base));
// Set @@toStringTag to native iterators
_dereq_(273)(IteratorPrototype, TAG, true);
// FF fix
if(!LIBRARY && has(proto, FF_ITERATOR))hide(IteratorPrototype, SYMBOL_ITERATOR, returnThis);
}
// Define iterator
if(!LIBRARY || FORCE)hide(proto, SYMBOL_ITERATOR, _default);
// Plug for library
Iterators[NAME] = _default;
Iterators[TAG] = returnThis;
if(DEFAULT){
methods = {
keys: IS_SET ? _default : createMethod(KEYS),
values: DEFAULT == VALUES ? _default : createMethod(VALUES),
entries: DEFAULT != VALUES ? _default : createMethod('entries')
};
if(FORCE)for(key in methods){
if(!(key in proto))$redef(proto, key, methods[key]);
} else $def($def.P + $def.F * BUGGY, NAME, methods);
}
};
},{"222":222,"233":233,"234":234,"242":242,"246":246,"247":247,"249":249,"259":259,"273":273,"282":282}],244:[function(_dereq_,module,exports){
var SYMBOL_ITERATOR = _dereq_(282)('iterator')
, SAFE_CLOSING = false;
try {
var riter = [7][SYMBOL_ITERATOR]();
riter['return'] = function(){ SAFE_CLOSING = true; };
Array.from(riter, function(){ throw 2; });
} catch(e){ /* empty */ }
module.exports = function(exec){
if(!SAFE_CLOSING)return false;
var safe = false;
try {
var arr = [7]
, iter = arr[SYMBOL_ITERATOR]();
iter.next = function(){ safe = true; };
arr[SYMBOL_ITERATOR] = function(){ return iter; };
exec(arr);
} catch(e){ /* empty */ }
return safe;
};
},{"282":282}],245:[function(_dereq_,module,exports){
module.exports = function(done, value){
return {value: value, done: !!done};
};
},{}],246:[function(_dereq_,module,exports){
module.exports = {};
},{}],247:[function(_dereq_,module,exports){
var $Object = Object;
module.exports = {
create: $Object.create,
getProto: $Object.getPrototypeOf,
isEnum: {}.propertyIsEnumerable,
getDesc: $Object.getOwnPropertyDescriptor,
setDesc: $Object.defineProperty,
setDescs: $Object.defineProperties,
getKeys: $Object.keys,
getNames: $Object.getOwnPropertyNames,
getSymbols: $Object.getOwnPropertySymbols,
each: [].forEach
};
},{}],248:[function(_dereq_,module,exports){
var $ = _dereq_(247)
, toIObject = _dereq_(277);
module.exports = function(object, el){
var O = toIObject(object)
, keys = $.getKeys(O)
, length = keys.length
, index = 0
, key;
while(length > index)if(O[key = keys[index++]] === el)return key;
};
},{"247":247,"277":277}],249:[function(_dereq_,module,exports){
module.exports = false;
},{}],250:[function(_dereq_,module,exports){
// 20.2.2.20 Math.log1p(x)
module.exports = Math.log1p || function log1p(x){
return (x = +x) > -1e-8 && x < 1e-8 ? x - x * x / 2 : Math.log(1 + x);
};
},{}],251:[function(_dereq_,module,exports){
var global = _dereq_(232)
, macrotask = _dereq_(274).set
, Observer = global.MutationObserver || global.WebKitMutationObserver
, process = global.process
, isNode = _dereq_(215)(process) == 'process'
, head, last, notify;
var flush = function(){
var parent, domain;
if(isNode && (parent = process.domain)){
process.domain = null;
parent.exit();
}
while(head){
domain = head.domain;
if(domain)domain.enter();
head.fn.call(); // <- currently we use it only for Promise - try / catch not required
if(domain)domain.exit();
head = head.next;
} last = undefined;
if(parent)parent.enter();
}
// Node.js
if(isNode){
notify = function(){
process.nextTick(flush);
};
// browsers with MutationObserver
} else if(Observer){
var toggle = 1
, node = document.createTextNode('');
new Observer(flush).observe(node, {characterData: true}); // eslint-disable-line no-new
notify = function(){
node.data = toggle = -toggle;
};
// for other environments - macrotask based on:
// - setImmediate
// - MessageChannel
// - window.postMessag
// - onreadystatechange
// - setTimeout
} else {
notify = function(){
// strange IE + webpack dev server bug - use .call(global)
macrotask.call(global, flush);
};
}
module.exports = function asap(fn){
var task = {fn: fn, next: undefined, domain: isNode && process.domain};
if(last)last.next = task;
if(!head){
head = task;
notify();
} last = task;
};
},{"215":215,"232":232,"274":274}],252:[function(_dereq_,module,exports){
var $redef = _dereq_(259);
module.exports = function(target, src){
for(var key in src)$redef(target, key, src[key]);
return target;
};
},{"259":259}],253:[function(_dereq_,module,exports){
// most Object methods by ES6 should accept primitives
module.exports = function(KEY, exec){
var $def = _dereq_(222)
, fn = (_dereq_(220).Object || {})[KEY] || Object[KEY]
, exp = {};
exp[KEY] = exec(fn);
$def($def.S + $def.F * _dereq_(227)(function(){ fn(1); }), 'Object', exp);
};
},{"220":220,"222":222,"227":227}],254:[function(_dereq_,module,exports){
var $ = _dereq_(247)
, toIObject = _dereq_(277);
module.exports = function(isEntries){
return function(it){
var O = toIObject(it)
, keys = $.getKeys(O)
, length = keys.length
, i = 0
, result = Array(length)
, key;
if(isEntries)while(length > i)result[i] = [key = keys[i++], O[key]];
else while(length > i)result[i] = O[keys[i++]];
return result;
};
};
},{"247":247,"277":277}],255:[function(_dereq_,module,exports){
// all object keys, includes non-enumerable and symbols
var $ = _dereq_(247)
, anObject = _dereq_(210)
, Reflect = _dereq_(232).Reflect;
module.exports = Reflect && Reflect.ownKeys || function ownKeys(it){
var keys = $.getNames(anObject(it))
, getSymbols = $.getSymbols;
return getSymbols ? keys.concat(getSymbols(it)) : keys;
};
},{"210":210,"232":232,"247":247}],256:[function(_dereq_,module,exports){
'use strict';
var path = _dereq_(257)
, invoke = _dereq_(236)
, aFunction = _dereq_(209);
module.exports = function(/* ...pargs */){
var fn = aFunction(this)
, length = arguments.length
, pargs = Array(length)
, i = 0
, _ = path._
, holder = false;
while(length > i)if((pargs[i] = arguments[i++]) === _)holder = true;
return function(/* ...args */){
var that = this
, _length = arguments.length
, j = 0, k = 0, args;
if(!holder && !_length)return invoke(fn, pargs, that);
args = pargs.slice();
if(holder)for(;length > j; j++)if(args[j] === _)args[j] = arguments[k++];
while(_length > k)args.push(arguments[k++]);
return invoke(fn, args, that);
};
};
},{"209":209,"236":236,"257":257}],257:[function(_dereq_,module,exports){
module.exports = _dereq_(232);
},{"232":232}],258:[function(_dereq_,module,exports){
module.exports = function(bitmap, value){
return {
enumerable : !(bitmap & 1),
configurable: !(bitmap & 2),
writable : !(bitmap & 4),
value : value
};
};
},{}],259:[function(_dereq_,module,exports){
// add fake Function#toString
// for correct work wrapped methods / constructors with methods like LoDash isNative
var global = _dereq_(232)
, hide = _dereq_(234)
, SRC = _dereq_(280)('src')
, TO_STRING = 'toString'
, $toString = Function[TO_STRING]
, TPL = ('' + $toString).split(TO_STRING);
_dereq_(220).inspectSource = function(it){
return $toString.call(it);
};
(module.exports = function(O, key, val, safe){
if(typeof val == 'function'){
hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key)));
if(!('name' in val))val.name = key;
}
if(O === global){
O[key] = val;
} else {
if(!safe)delete O[key];
hide(O, key, val);
}
})(Function.prototype, TO_STRING, function toString(){
return typeof this == 'function' && this[SRC] || $toString.call(this);
});
},{"220":220,"232":232,"234":234,"280":280}],260:[function(_dereq_,module,exports){
module.exports = function(regExp, replace){
var replacer = replace === Object(replace) ? function(part){
return replace[part];
} : replace;
return function(it){
return String(it).replace(regExp, replacer);
};
};
},{}],261:[function(_dereq_,module,exports){
module.exports = Object.is || function is(x, y){
return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y;
};
},{}],262:[function(_dereq_,module,exports){
// Works with __proto__ only. Old v8 can't work with null proto objects.
/* eslint-disable no-proto */
var getDesc = _dereq_(247).getDesc
, isObject = _dereq_(240)
, anObject = _dereq_(210);
var check = function(O, proto){
anObject(O);
if(!isObject(proto) && proto !== null)throw TypeError(proto + ": can't set as prototype!");
};
module.exports = {
set: Object.setPrototypeOf || ('__proto__' in {} // eslint-disable-line
? function(buggy, set){
try {
set = _dereq_(221)(Function.call, getDesc(Object.prototype, '__proto__').set, 2);
set({}, []);
} catch(e){ buggy = true; }
return function setPrototypeOf(O, proto){
check(O, proto);
if(buggy)O.__proto__ = proto;
else set(O, proto);
return O;
};
}()
: undefined),
check: check
};
},{"210":210,"221":221,"240":240,"247":247}],263:[function(_dereq_,module,exports){
var global = _dereq_(232)
, SHARED = '__core-js_shared__'
, store = global[SHARED] || (global[SHARED] = {});
module.exports = function(key){
return store[key] || (store[key] = {});
};
},{"232":232}],264:[function(_dereq_,module,exports){
// 20.2.2.28 Math.sign(x)
module.exports = Math.sign || function sign(x){
return (x = +x) == 0 || x != x ? x : x < 0 ? -1 : 1;
};
},{}],265:[function(_dereq_,module,exports){
'use strict';
var $ = _dereq_(247)
, SPECIES = _dereq_(282)('species');
module.exports = function(C){
if(_dereq_(272) && !(SPECIES in C))$.setDesc(C, SPECIES, {
configurable: true,
get: function(){ return this; }
});
};
},{"247":247,"272":272,"282":282}],266:[function(_dereq_,module,exports){
module.exports = function(it, Constructor, name){
if(!(it instanceof Constructor))throw TypeError(name + ": use the 'new' operator!");
return it;
};
},{}],267:[function(_dereq_,module,exports){
// true -> String#at
// false -> String#codePointAt
var toInteger = _dereq_(276)
, defined = _dereq_(223);
module.exports = function(TO_STRING){
return function(that, pos){
var s = String(defined(that))
, i = toInteger(pos)
, l = s.length
, a, b;
if(i < 0 || i >= l)return TO_STRING ? '' : undefined;
a = s.charCodeAt(i);
return a < 0xd800 || a > 0xdbff || i + 1 === l
|| (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
? TO_STRING ? s.charAt(i) : a
: TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
};
};
},{"223":223,"276":276}],268:[function(_dereq_,module,exports){
// helper for String#{startsWith, endsWith, includes}
var defined = _dereq_(223)
, cof = _dereq_(215);
module.exports = function(that, searchString, NAME){
if(cof(searchString) == 'RegExp')throw TypeError('String#' + NAME + " doesn't accept regex!");
return String(defined(that));
};
},{"215":215,"223":223}],269:[function(_dereq_,module,exports){
// https://github.com/ljharb/proposal-string-pad-left-right
var toLength = _dereq_(278)
, repeat = _dereq_(270)
, defined = _dereq_(223);
module.exports = function(that, maxLength, fillString, left){
var S = String(defined(that))
, stringLength = S.length
, fillStr = fillString === undefined ? ' ' : String(fillString)
, intMaxLength = toLength(maxLength);
if(intMaxLength <= stringLength)return S;
if(fillStr == '')fillStr = ' ';
var fillLen = intMaxLength - stringLength
, stringFiller = repeat.call(fillStr, Math.ceil(fillLen / fillStr.length));
if(stringFiller.length > fillLen)stringFiller = left
? stringFiller.slice(stringFiller.length - fillLen)
: stringFiller.slice(0, fillLen);
return left ? stringFiller + S : S + stringFiller;
};
},{"223":223,"270":270,"278":278}],270:[function(_dereq_,module,exports){
'use strict';
var toInteger = _dereq_(276)
, defined = _dereq_(223);
module.exports = function repeat(count){
var str = String(defined(this))
, res = ''
, n = toInteger(count);
if(n < 0 || n == Infinity)throw RangeError("Count can't be negative");
for(;n > 0; (n >>>= 1) && (str += str))if(n & 1)res += str;
return res;
};
},{"223":223,"276":276}],271:[function(_dereq_,module,exports){
// 1 -> String#trimLeft
// 2 -> String#trimRight
// 3 -> String#trim
var trim = function(string, TYPE){
string = String(defined(string));
if(TYPE & 1)string = string.replace(ltrim, '');
if(TYPE & 2)string = string.replace(rtrim, '');
return string;
};
var $def = _dereq_(222)
, defined = _dereq_(223)
, spaces = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' +
'\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF'
, space = '[' + spaces + ']'
, non = '\u200b\u0085'
, ltrim = RegExp('^' + space + space + '*')
, rtrim = RegExp(space + space + '*$');
module.exports = function(KEY, exec){
var exp = {};
exp[KEY] = exec(trim);
$def($def.P + $def.F * _dereq_(227)(function(){
return !!spaces[KEY]() || non[KEY]() != non;
}), 'String', exp);
};
},{"222":222,"223":223,"227":227}],272:[function(_dereq_,module,exports){
// Thank's IE8 for his funny defineProperty
module.exports = !_dereq_(227)(function(){
return Object.defineProperty({}, 'a', {get: function(){ return 7; }}).a != 7;
});
},{"227":227}],273:[function(_dereq_,module,exports){
var has = _dereq_(233)
, hide = _dereq_(234)
, TAG = _dereq_(282)('toStringTag');
module.exports = function(it, tag, stat){
if(it && !has(it = stat ? it : it.prototype, TAG))hide(it, TAG, tag);
};
},{"233":233,"234":234,"282":282}],274:[function(_dereq_,module,exports){
'use strict';
var ctx = _dereq_(221)
, invoke = _dereq_(236)
, html = _dereq_(235)
, cel = _dereq_(224)
, global = _dereq_(232)
, process = global.process
, setTask = global.setImmediate
, clearTask = global.clearImmediate
, MessageChannel = global.MessageChannel
, counter = 0
, queue = {}
, ONREADYSTATECHANGE = 'onreadystatechange'
, defer, channel, port;
var run = function(){
var id = +this;
if(queue.hasOwnProperty(id)){
var fn = queue[id];
delete queue[id];
fn();
}
};
var listner = function(event){
run.call(event.data);
};
// Node.js 0.9+ & IE10+ has setImmediate, otherwise:
if(!setTask || !clearTask){
setTask = function setImmediate(fn){
var args = [], i = 1;
while(arguments.length > i)args.push(arguments[i++]);
queue[++counter] = function(){
invoke(typeof fn == 'function' ? fn : Function(fn), args);
};
defer(counter);
return counter;
};
clearTask = function clearImmediate(id){
delete queue[id];
};
// Node.js 0.8-
if(_dereq_(215)(process) == 'process'){
defer = function(id){
process.nextTick(ctx(run, id, 1));
};
// Browsers with MessageChannel, includes WebWorkers
} else if(MessageChannel){
channel = new MessageChannel;
port = channel.port2;
channel.port1.onmessage = listner;
defer = ctx(port.postMessage, port, 1);
// Browsers with postMessage, skip WebWorkers
// IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
} else if(global.addEventListener && typeof postMessage == 'function' && !global.importScript){
defer = function(id){
global.postMessage(id + '', '*');
};
global.addEventListener('message', listner, false);
// IE8-
} else if(ONREADYSTATECHANGE in cel('script')){
defer = function(id){
html.appendChild(cel('script'))[ONREADYSTATECHANGE] = function(){
html.removeChild(this);
run.call(id);
};
};
// Rest old browsers
} else {
defer = function(id){
setTimeout(ctx(run, id, 1), 0);
};
}
}
module.exports = {
set: setTask,
clear: clearTask
};
},{"215":215,"221":221,"224":224,"232":232,"235":235,"236":236}],275:[function(_dereq_,module,exports){
var toInteger = _dereq_(276)
, max = Math.max
, min = Math.min;
module.exports = function(index, length){
index = toInteger(index);
return index < 0 ? max(index + length, 0) : min(index, length);
};
},{"276":276}],276:[function(_dereq_,module,exports){
// 7.1.4 ToInteger
var ceil = Math.ceil
, floor = Math.floor;
module.exports = function(it){
return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
};
},{}],277:[function(_dereq_,module,exports){
// to indexed object, toObject with fallback for non-array-like ES3 strings
var IObject = _dereq_(237)
, defined = _dereq_(223);
module.exports = function(it){
return IObject(defined(it));
};
},{"223":223,"237":237}],278:[function(_dereq_,module,exports){
// 7.1.15 ToLength
var toInteger = _dereq_(276)
, min = Math.min;
module.exports = function(it){
return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
};
},{"276":276}],279:[function(_dereq_,module,exports){
// 7.1.13 ToObject(argument)
var defined = _dereq_(223);
module.exports = function(it){
return Object(defined(it));
};
},{"223":223}],280:[function(_dereq_,module,exports){
var id = 0
, px = Math.random();
module.exports = function(key){
return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
};
},{}],281:[function(_dereq_,module,exports){
// 22.1.3.31 Array.prototype[@@unscopables]
var UNSCOPABLES = _dereq_(282)('unscopables');
if(!(UNSCOPABLES in []))_dereq_(234)(Array.prototype, UNSCOPABLES, {});
module.exports = function(key){
[][UNSCOPABLES][key] = true;
};
},{"234":234,"282":282}],282:[function(_dereq_,module,exports){
var store = _dereq_(263)('wks')
, Symbol = _dereq_(232).Symbol;
module.exports = function(name){
return store[name] || (store[name] =
Symbol && Symbol[name] || (Symbol || _dereq_(280))('Symbol.' + name));
};
},{"232":232,"263":263,"280":280}],283:[function(_dereq_,module,exports){
var classof = _dereq_(214)
, ITERATOR = _dereq_(282)('iterator')
, Iterators = _dereq_(246);
module.exports = _dereq_(220).getIteratorMethod = function(it){
if(it != undefined)return it[ITERATOR] || it['@@iterator'] || Iterators[classof(it)];
};
},{"214":214,"220":220,"246":246,"282":282}],284:[function(_dereq_,module,exports){
'use strict';
var $ = _dereq_(247)
, SUPPORT_DESC = _dereq_(272)
, createDesc = _dereq_(258)
, html = _dereq_(235)
, cel = _dereq_(224)
, has = _dereq_(233)
, cof = _dereq_(215)
, $def = _dereq_(222)
, invoke = _dereq_(236)
, arrayMethod = _dereq_(212)
, IE_PROTO = _dereq_(280)('__proto__')
, isObject = _dereq_(240)
, anObject = _dereq_(210)
, aFunction = _dereq_(209)
, toObject = _dereq_(279)
, toIObject = _dereq_(277)
, toInteger = _dereq_(276)
, toIndex = _dereq_(275)
, toLength = _dereq_(278)
, IObject = _dereq_(237)
, fails = _dereq_(227)
, ObjectProto = Object.prototype
, A = []
, _slice = A.slice
, _join = A.join
, defineProperty = $.setDesc
, getOwnDescriptor = $.getDesc
, defineProperties = $.setDescs
, $indexOf = _dereq_(211)(false)
, factories = {}
, IE8_DOM_DEFINE;
if(!SUPPORT_DESC){
IE8_DOM_DEFINE = !fails(function(){
return defineProperty(cel('div'), 'a', {get: function(){ return 7; }}).a != 7;
});
$.setDesc = function(O, P, Attributes){
if(IE8_DOM_DEFINE)try {
return defineProperty(O, P, Attributes);
} catch(e){ /* empty */ }
if('get' in Attributes || 'set' in Attributes)throw TypeError('Accessors not supported!');
if('value' in Attributes)anObject(O)[P] = Attributes.value;
return O;
};
$.getDesc = function(O, P){
if(IE8_DOM_DEFINE)try {
return getOwnDescriptor(O, P);
} catch(e){ /* empty */ }
if(has(O, P))return createDesc(!ObjectProto.propertyIsEnumerable.call(O, P), O[P]);
};
$.setDescs = defineProperties = function(O, Properties){
anObject(O);
var keys = $.getKeys(Properties)
, length = keys.length
, i = 0
, P;
while(length > i)$.setDesc(O, P = keys[i++], Properties[P]);
return O;
};
}
$def($def.S + $def.F * !SUPPORT_DESC, 'Object', {
// 19.1.2.6 / 15.2.3.3 Object.getOwnPropertyDescriptor(O, P)
getOwnPropertyDescriptor: $.getDesc,
// 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes)
defineProperty: $.setDesc,
// 19.1.2.3 / 15.2.3.7 Object.defineProperties(O, Properties)
defineProperties: defineProperties
});
// IE 8- don't enum bug keys
var keys1 = ('constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,' +
'toLocaleString,toString,valueOf').split(',')
// Additional keys for getOwnPropertyNames
, keys2 = keys1.concat('length', 'prototype')
, keysLen1 = keys1.length;
// Create object with `null` prototype: use iframe Object with cleared prototype
var createDict = function(){
// Thrash, waste and sodomy: IE GC bug
var iframe = cel('iframe')
, i = keysLen1
, gt = '>'
, iframeDocument;
iframe.style.display = 'none';
html.appendChild(iframe);
iframe.src = 'javascript:'; // eslint-disable-line no-script-url
// createDict = iframe.contentWindow.Object;
// html.removeChild(iframe);
iframeDocument = iframe.contentWindow.document;
iframeDocument.open();
iframeDocument.write('<script>document.F=Object</script' + gt);
iframeDocument.close();
createDict = iframeDocument.F;
while(i--)delete createDict.prototype[keys1[i]];
return createDict();
};
var createGetKeys = function(names, length){
return function(object){
var O = toIObject(object)
, i = 0
, result = []
, key;
for(key in O)if(key != IE_PROTO)has(O, key) && result.push(key);
// Don't enum bug & hidden keys
while(length > i)if(has(O, key = names[i++])){
~$indexOf(result, key) || result.push(key);
}
return result;
};
};
var Empty = function(){};
$def($def.S, 'Object', {
// 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)
getPrototypeOf: $.getProto = $.getProto || function(O){
O = toObject(O);
if(has(O, IE_PROTO))return O[IE_PROTO];
if(typeof O.constructor == 'function' && O instanceof O.constructor){
return O.constructor.prototype;
} return O instanceof Object ? ObjectProto : null;
},
// 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)
getOwnPropertyNames: $.getNames = $.getNames || createGetKeys(keys2, keys2.length, true),
// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
create: $.create = $.create || function(O, /*?*/Properties){
var result;
if(O !== null){
Empty.prototype = anObject(O);
result = new Empty();
Empty.prototype = null;
// add "__proto__" for Object.getPrototypeOf shim
result[IE_PROTO] = O;
} else result = createDict();
return Properties === undefined ? result : defineProperties(result, Properties);
},
// 19.1.2.14 / 15.2.3.14 Object.keys(O)
keys: $.getKeys = $.getKeys || createGetKeys(keys1, keysLen1, false)
});
var construct = function(F, len, args){
if(!(len in factories)){
for(var n = [], i = 0; i < len; i++)n[i] = 'a[' + i + ']';
factories[len] = Function('F,a', 'return new F(' + n.join(',') + ')');
}
return factories[len](F, args);
};
// 19.2.3.2 / 15.3.4.5 Function.prototype.bind(thisArg, args...)
$def($def.P, 'Function', {
bind: function bind(that /*, args... */){
var fn = aFunction(this)
, partArgs = _slice.call(arguments, 1);
var bound = function(/* args... */){
var args = partArgs.concat(_slice.call(arguments));
return this instanceof bound ? construct(fn, args.length, args) : invoke(fn, args, that);
};
if(isObject(fn.prototype))bound.prototype = fn.prototype;
return bound;
}
});
// fallback for not array-like ES3 strings and DOM objects
var buggySlice = fails(function(){
if(html)_slice.call(html);
});
$def($def.P + $def.F * buggySlice, 'Array', {
slice: function(begin, end){
var len = toLength(this.length)
, klass = cof(this);
end = end === undefined ? len : end;
if(klass == 'Array')return _slice.call(this, begin, end);
var start = toIndex(begin, len)
, upTo = toIndex(end, len)
, size = toLength(upTo - start)
, cloned = Array(size)
, i = 0;
for(; i < size; i++)cloned[i] = klass == 'String'
? this.charAt(start + i)
: this[start + i];
return cloned;
}
});
$def($def.P + $def.F * (IObject != Object), 'Array', {
join: function(){
return _join.apply(IObject(this), arguments);
}
});
// 22.1.2.2 / 15.4.3.2 Array.isArray(arg)
$def($def.S, 'Array', {isArray: function(arg){ return cof(arg) == 'Array'; }});
var createArrayReduce = function(isRight){
return function(callbackfn, memo){
aFunction(callbackfn);
var O = IObject(this)
, length = toLength(O.length)
, index = isRight ? length - 1 : 0
, i = isRight ? -1 : 1;
if(arguments.length < 2)for(;;){
if(index in O){
memo = O[index];
index += i;
break;
}
index += i;
if(isRight ? index < 0 : length <= index){
throw TypeError('Reduce of empty array with no initial value');
}
}
for(;isRight ? index >= 0 : length > index; index += i)if(index in O){
memo = callbackfn(memo, O[index], index, this);
}
return memo;
};
};
var methodize = function($fn){
return function(arg1/*, arg2 = undefined */){
return $fn(this, arg1, arguments[1]);
};
};
$def($def.P, 'Array', {
// 22.1.3.10 / 15.4.4.18 Array.prototype.forEach(callbackfn [, thisArg])
forEach: $.each = $.each || methodize(arrayMethod(0)),
// 22.1.3.15 / 15.4.4.19 Array.prototype.map(callbackfn [, thisArg])
map: methodize(arrayMethod(1)),
// 22.1.3.7 / 15.4.4.20 Array.prototype.filter(callbackfn [, thisArg])
filter: methodize(arrayMethod(2)),
// 22.1.3.23 / 15.4.4.17 Array.prototype.some(callbackfn [, thisArg])
some: methodize(arrayMethod(3)),
// 22.1.3.5 / 15.4.4.16 Array.prototype.every(callbackfn [, thisArg])
every: methodize(arrayMethod(4)),
// 22.1.3.18 / 15.4.4.21 Array.prototype.reduce(callbackfn [, initialValue])
reduce: createArrayReduce(false),
// 22.1.3.19 / 15.4.4.22 Array.prototype.reduceRight(callbackfn [, initialValue])
reduceRight: createArrayReduce(true),
// 22.1.3.11 / 15.4.4.14 Array.prototype.indexOf(searchElement [, fromIndex])
indexOf: methodize($indexOf),
// 22.1.3.14 / 15.4.4.15 Array.prototype.lastIndexOf(searchElement [, fromIndex])
lastIndexOf: function(el, fromIndex /* = @[*-1] */){
var O = toIObject(this)
, length = toLength(O.length)
, index = length - 1;
if(arguments.length > 1)index = Math.min(index, toInteger(fromIndex));
if(index < 0)index = toLength(length + index);
for(;index >= 0; index--)if(index in O)if(O[index] === el)return index;
return -1;
}
});
// 20.3.3.1 / 15.9.4.4 Date.now()
$def($def.S, 'Date', {now: function(){ return +new Date; }});
var lz = function(num){
return num > 9 ? num : '0' + num;
};
// 20.3.4.36 / 15.9.5.43 Date.prototype.toISOString()
// PhantomJS and old webkit had a broken Date implementation.
var date = new Date(-5e13 - 1)
, brokenDate = !(date.toISOString && date.toISOString() == '0385-07-25T07:06:39.999Z'
&& fails(function(){ new Date(NaN).toISOString(); }));
$def($def.P + $def.F * brokenDate, 'Date', {
toISOString: function toISOString(){
if(!isFinite(this))throw RangeError('Invalid time value');
var d = this
, y = d.getUTCFullYear()
, m = d.getUTCMilliseconds()
, s = y < 0 ? '-' : y > 9999 ? '+' : '';
return s + ('00000' + Math.abs(y)).slice(s ? -6 : -4) +
'-' + lz(d.getUTCMonth() + 1) + '-' + lz(d.getUTCDate()) +
'T' + lz(d.getUTCHours()) + ':' + lz(d.getUTCMinutes()) +
':' + lz(d.getUTCSeconds()) + '.' + (m > 99 ? m : '0' + lz(m)) + 'Z';
}
});
},{"209":209,"210":210,"211":211,"212":212,"215":215,"222":222,"224":224,"227":227,"233":233,"235":235,"236":236,"237":237,"240":240,"247":247,"258":258,"272":272,"275":275,"276":276,"277":277,"278":278,"279":279,"280":280}],285:[function(_dereq_,module,exports){
'use strict';
var $def = _dereq_(222)
, toObject = _dereq_(279)
, toIndex = _dereq_(275)
, toLength = _dereq_(278);
$def($def.P, 'Array', {
// 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length)
copyWithin: function copyWithin(target/* = 0 */, start /* = 0, end = @length */){
var O = toObject(this)
, len = toLength(O.length)
, to = toIndex(target, len)
, from = toIndex(start, len)
, end = arguments[2]
, fin = end === undefined ? len : toIndex(end, len)
, count = Math.min(fin - from, len - to)
, inc = 1;
if(from < to && to < from + count){
inc = -1;
from = from + count - 1;
to = to + count - 1;
}
while(count-- > 0){
if(from in O)O[to] = O[from];
else delete O[to];
to += inc;
from += inc;
} return O;
}
});
_dereq_(281)('copyWithin');
},{"222":222,"275":275,"278":278,"279":279,"281":281}],286:[function(_dereq_,module,exports){
'use strict';
var $def = _dereq_(222)
, toObject = _dereq_(279)
, toIndex = _dereq_(275)
, toLength = _dereq_(278);
$def($def.P, 'Array', {
// 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length)
fill: function fill(value /*, start = 0, end = @length */){
var O = toObject(this, true)
, length = toLength(O.length)
, index = toIndex(arguments[1], length)
, end = arguments[2]
, endPos = end === undefined ? length : toIndex(end, length);
while(endPos > index)O[index++] = value;
return O;
}
});
_dereq_(281)('fill');
},{"222":222,"275":275,"278":278,"279":279,"281":281}],287:[function(_dereq_,module,exports){
'use strict';
// 22.1.3.9 Array.prototype.findIndex(predicate, thisArg = undefined)
var KEY = 'findIndex'
, $def = _dereq_(222)
, forced = true
, $find = _dereq_(212)(6);
// Shouldn't skip holes
if(KEY in [])Array(1)[KEY](function(){ forced = false; });
$def($def.P + $def.F * forced, 'Array', {
findIndex: function findIndex(callbackfn/*, that = undefined */){
return $find(this, callbackfn, arguments[1]);
}
});
_dereq_(281)(KEY);
},{"212":212,"222":222,"281":281}],288:[function(_dereq_,module,exports){
'use strict';
// 22.1.3.8 Array.prototype.find(predicate, thisArg = undefined)
var KEY = 'find'
, $def = _dereq_(222)
, forced = true
, $find = _dereq_(212)(5);
// Shouldn't skip holes
if(KEY in [])Array(1)[KEY](function(){ forced = false; });
$def($def.P + $def.F * forced, 'Array', {
find: function find(callbackfn/*, that = undefined */){
return $find(this, callbackfn, arguments[1]);
}
});
_dereq_(281)(KEY);
},{"212":212,"222":222,"281":281}],289:[function(_dereq_,module,exports){
'use strict';
var ctx = _dereq_(221)
, $def = _dereq_(222)
, toObject = _dereq_(279)
, call = _dereq_(241)
, isArrayIter = _dereq_(238)
, toLength = _dereq_(278)
, getIterFn = _dereq_(283);
$def($def.S + $def.F * !_dereq_(244)(function(iter){ Array.from(iter); }), 'Array', {
// 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined)
from: function from(arrayLike/*, mapfn = undefined, thisArg = undefined*/){
var O = toObject(arrayLike)
, C = typeof this == 'function' ? this : Array
, mapfn = arguments[1]
, mapping = mapfn !== undefined
, index = 0
, iterFn = getIterFn(O)
, length, result, step, iterator;
if(mapping)mapfn = ctx(mapfn, arguments[2], 2);
// if object isn't iterable or it's array with default iterator - use simple case
if(iterFn != undefined && !(C == Array && isArrayIter(iterFn))){
for(iterator = iterFn.call(O), result = new C; !(step = iterator.next()).done; index++){
result[index] = mapping ? call(iterator, mapfn, [step.value, index], true) : step.value;
}
} else {
for(result = new C(length = toLength(O.length)); length > index; index++){
result[index] = mapping ? mapfn(O[index], index) : O[index];
}
}
result.length = index;
return result;
}
});
},{"221":221,"222":222,"238":238,"241":241,"244":244,"278":278,"279":279,"283":283}],290:[function(_dereq_,module,exports){
'use strict';
var setUnscope = _dereq_(281)
, step = _dereq_(245)
, Iterators = _dereq_(246)
, toIObject = _dereq_(277);
// 22.1.3.4 Array.prototype.entries()
// 22.1.3.13 Array.prototype.keys()
// 22.1.3.29 Array.prototype.values()
// 22.1.3.30 Array.prototype[@@iterator]()
_dereq_(243)(Array, 'Array', function(iterated, kind){
this._t = toIObject(iterated); // target
this._i = 0; // next index
this._k = kind; // kind
// 22.1.5.2.1 %ArrayIteratorPrototype%.next()
}, function(){
var O = this._t
, kind = this._k
, index = this._i++;
if(!O || index >= O.length){
this._t = undefined;
return step(1);
}
if(kind == 'keys' )return step(0, index);
if(kind == 'values')return step(0, O[index]);
return step(0, [index, O[index]]);
}, 'values');
// argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
Iterators.Arguments = Iterators.Array;
setUnscope('keys');
setUnscope('values');
setUnscope('entries');
},{"243":243,"245":245,"246":246,"277":277,"281":281}],291:[function(_dereq_,module,exports){
'use strict';
var $def = _dereq_(222);
// WebKit Array.of isn't generic
$def($def.S + $def.F * _dereq_(227)(function(){
function F(){}
return !(Array.of.call(F) instanceof F);
}), 'Array', {
// 22.1.2.3 Array.of( ...items)
of: function of(/* ...args */){
var index = 0
, length = arguments.length
, result = new (typeof this == 'function' ? this : Array)(length);
while(length > index)result[index] = arguments[index++];
result.length = length;
return result;
}
});
},{"222":222,"227":227}],292:[function(_dereq_,module,exports){
_dereq_(265)(Array);
},{"265":265}],293:[function(_dereq_,module,exports){
'use strict';
var $ = _dereq_(247)
, isObject = _dereq_(240)
, HAS_INSTANCE = _dereq_(282)('hasInstance')
, FunctionProto = Function.prototype;
// 19.2.3.6 Function.prototype[@@hasInstance](V)
if(!(HAS_INSTANCE in FunctionProto))$.setDesc(FunctionProto, HAS_INSTANCE, {value: function(O){
if(typeof this != 'function' || !isObject(O))return false;
if(!isObject(this.prototype))return O instanceof this;
// for environment w/o native `@@hasInstance` logic enough `instanceof`, but add this:
while(O = $.getProto(O))if(this.prototype === O)return true;
return false;
}});
},{"240":240,"247":247,"282":282}],294:[function(_dereq_,module,exports){
var setDesc = _dereq_(247).setDesc
, createDesc = _dereq_(258)
, has = _dereq_(233)
, FProto = Function.prototype
, nameRE = /^\s*function ([^ (]*)/
, NAME = 'name';
// 19.2.4.2 name
NAME in FProto || _dereq_(272) && setDesc(FProto, NAME, {
configurable: true,
get: function(){
var match = ('' + this).match(nameRE)
, name = match ? match[1] : '';
has(this, NAME) || setDesc(this, NAME, createDesc(5, name));
return name;
}
});
},{"233":233,"247":247,"258":258,"272":272}],295:[function(_dereq_,module,exports){
'use strict';
var strong = _dereq_(216);
// 23.1 Map Objects
_dereq_(219)('Map', function(get){
return function Map(){ return get(this, arguments[0]); };
}, {
// 23.1.3.6 Map.prototype.get(key)
get: function get(key){
var entry = strong.getEntry(this, key);
return entry && entry.v;
},
// 23.1.3.9 Map.prototype.set(key, value)
set: function set(key, value){
return strong.def(this, key === 0 ? 0 : key, value);
}
}, strong, true);
},{"216":216,"219":219}],296:[function(_dereq_,module,exports){
// 20.2.2.3 Math.acosh(x)
var $def = _dereq_(222)
, log1p = _dereq_(250)
, sqrt = Math.sqrt
, $acosh = Math.acosh;
// V8 bug https://code.google.com/p/v8/issues/detail?id=3509
$def($def.S + $def.F * !($acosh && Math.floor($acosh(Number.MAX_VALUE)) == 710), 'Math', {
acosh: function acosh(x){
return (x = +x) < 1 ? NaN : x > 94906265.62425156
? Math.log(x) + Math.LN2
: log1p(x - 1 + sqrt(x - 1) * sqrt(x + 1));
}
});
},{"222":222,"250":250}],297:[function(_dereq_,module,exports){
// 20.2.2.5 Math.asinh(x)
var $def = _dereq_(222);
function asinh(x){
return !isFinite(x = +x) || x == 0 ? x : x < 0 ? -asinh(-x) : Math.log(x + Math.sqrt(x * x + 1));
}
$def($def.S, 'Math', {asinh: asinh});
},{"222":222}],298:[function(_dereq_,module,exports){
// 20.2.2.7 Math.atanh(x)
var $def = _dereq_(222);
$def($def.S, 'Math', {
atanh: function atanh(x){
return (x = +x) == 0 ? x : Math.log((1 + x) / (1 - x)) / 2;
}
});
},{"222":222}],299:[function(_dereq_,module,exports){
// 20.2.2.9 Math.cbrt(x)
var $def = _dereq_(222)
, sign = _dereq_(264);
$def($def.S, 'Math', {
cbrt: function cbrt(x){
return sign(x = +x) * Math.pow(Math.abs(x), 1 / 3);
}
});
},{"222":222,"264":264}],300:[function(_dereq_,module,exports){
// 20.2.2.11 Math.clz32(x)
var $def = _dereq_(222);
$def($def.S, 'Math', {
clz32: function clz32(x){
return (x >>>= 0) ? 31 - Math.floor(Math.log(x + 0.5) * Math.LOG2E) : 32;
}
});
},{"222":222}],301:[function(_dereq_,module,exports){
// 20.2.2.12 Math.cosh(x)
var $def = _dereq_(222)
, exp = Math.exp;
$def($def.S, 'Math', {
cosh: function cosh(x){
return (exp(x = +x) + exp(-x)) / 2;
}
});
},{"222":222}],302:[function(_dereq_,module,exports){
// 20.2.2.14 Math.expm1(x)
var $def = _dereq_(222);
$def($def.S, 'Math', {expm1: _dereq_(226)});
},{"222":222,"226":226}],303:[function(_dereq_,module,exports){
// 20.2.2.16 Math.fround(x)
var $def = _dereq_(222)
, sign = _dereq_(264)
, pow = Math.pow
, EPSILON = pow(2, -52)
, EPSILON32 = pow(2, -23)
, MAX32 = pow(2, 127) * (2 - EPSILON32)
, MIN32 = pow(2, -126);
var roundTiesToEven = function(n){
return n + 1 / EPSILON - 1 / EPSILON;
};
$def($def.S, 'Math', {
fround: function fround(x){
var $abs = Math.abs(x)
, $sign = sign(x)
, a, result;
if($abs < MIN32)return $sign * roundTiesToEven($abs / MIN32 / EPSILON32) * MIN32 * EPSILON32;
a = (1 + EPSILON32 / EPSILON) * $abs;
result = a - (a - $abs);
if(result > MAX32 || result != result)return $sign * Infinity;
return $sign * result;
}
});
},{"222":222,"264":264}],304:[function(_dereq_,module,exports){
// 20.2.2.17 Math.hypot([value1[, value2[, … ]]])
var $def = _dereq_(222)
, abs = Math.abs;
$def($def.S, 'Math', {
hypot: function hypot(value1, value2){ // eslint-disable-line no-unused-vars
var sum = 0
, i = 0
, len = arguments.length
, larg = 0
, arg, div;
while(i < len){
arg = abs(arguments[i++]);
if(larg < arg){
div = larg / arg;
sum = sum * div * div + 1;
larg = arg;
} else if(arg > 0){
div = arg / larg;
sum += div * div;
} else sum += arg;
}
return larg === Infinity ? Infinity : larg * Math.sqrt(sum);
}
});
},{"222":222}],305:[function(_dereq_,module,exports){
// 20.2.2.18 Math.imul(x, y)
var $def = _dereq_(222);
// WebKit fails with big numbers
$def($def.S + $def.F * _dereq_(227)(function(){
return Math.imul(0xffffffff, 5) != -5;
}), 'Math', {
imul: function imul(x, y){
var UINT16 = 0xffff
, xn = +x
, yn = +y
, xl = UINT16 & xn
, yl = UINT16 & yn;
return 0 | xl * yl + ((UINT16 & xn >>> 16) * yl + xl * (UINT16 & yn >>> 16) << 16 >>> 0);
}
});
},{"222":222,"227":227}],306:[function(_dereq_,module,exports){
// 20.2.2.21 Math.log10(x)
var $def = _dereq_(222);
$def($def.S, 'Math', {
log10: function log10(x){
return Math.log(x) / Math.LN10;
}
});
},{"222":222}],307:[function(_dereq_,module,exports){
// 20.2.2.20 Math.log1p(x)
var $def = _dereq_(222);
$def($def.S, 'Math', {log1p: _dereq_(250)});
},{"222":222,"250":250}],308:[function(_dereq_,module,exports){
// 20.2.2.22 Math.log2(x)
var $def = _dereq_(222);
$def($def.S, 'Math', {
log2: function log2(x){
return Math.log(x) / Math.LN2;
}
});
},{"222":222}],309:[function(_dereq_,module,exports){
// 20.2.2.28 Math.sign(x)
var $def = _dereq_(222);
$def($def.S, 'Math', {sign: _dereq_(264)});
},{"222":222,"264":264}],310:[function(_dereq_,module,exports){
// 20.2.2.30 Math.sinh(x)
var $def = _dereq_(222)
, expm1 = _dereq_(226)
, exp = Math.exp;
$def($def.S, 'Math', {
sinh: function sinh(x){
return Math.abs(x = +x) < 1
? (expm1(x) - expm1(-x)) / 2
: (exp(x - 1) - exp(-x - 1)) * (Math.E / 2);
}
});
},{"222":222,"226":226}],311:[function(_dereq_,module,exports){
// 20.2.2.33 Math.tanh(x)
var $def = _dereq_(222)
, expm1 = _dereq_(226)
, exp = Math.exp;
$def($def.S, 'Math', {
tanh: function tanh(x){
var a = expm1(x = +x)
, b = expm1(-x);
return a == Infinity ? 1 : b == Infinity ? -1 : (a - b) / (exp(x) + exp(-x));
}
});
},{"222":222,"226":226}],312:[function(_dereq_,module,exports){
// 20.2.2.34 Math.trunc(x)
var $def = _dereq_(222);
$def($def.S, 'Math', {
trunc: function trunc(it){
return (it > 0 ? Math.floor : Math.ceil)(it);
}
});
},{"222":222}],313:[function(_dereq_,module,exports){
'use strict';
var $ = _dereq_(247)
, global = _dereq_(232)
, has = _dereq_(233)
, cof = _dereq_(215)
, isObject = _dereq_(240)
, fails = _dereq_(227)
, NUMBER = 'Number'
, $Number = global[NUMBER]
, Base = $Number
, proto = $Number.prototype
// Opera ~12 has broken Object#toString
, BROKEN_COF = cof($.create(proto)) == NUMBER;
var toPrimitive = function(it){
var fn, val;
if(typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it)))return val;
if(typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val;
throw TypeError("Can't convert object to number");
};
var toNumber = function(it){
if(isObject(it))it = toPrimitive(it);
if(typeof it == 'string' && it.length > 2 && it.charCodeAt(0) == 48){
var binary = false;
switch(it.charCodeAt(1)){
case 66 : case 98 : binary = true;
case 79 : case 111 : return parseInt(it.slice(2), binary ? 2 : 8);
}
} return +it;
};
if(!($Number('0o1') && $Number('0b1'))){
$Number = function Number(it){
var that = this;
return that instanceof $Number
// check on 1..constructor(foo) case
&& (BROKEN_COF ? fails(function(){ proto.valueOf.call(that); }) : cof(that) != NUMBER)
? new Base(toNumber(it)) : toNumber(it);
};
$.each.call(_dereq_(272) ? $.getNames(Base) : (
// ES3:
'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' +
// ES6 (in case, if modules with ES6 Number statics required before):
'EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,' +
'MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger'
).split(','), function(key){
if(has(Base, key) && !has($Number, key)){
$.setDesc($Number, key, $.getDesc(Base, key));
}
}
);
$Number.prototype = proto;
proto.constructor = $Number;
_dereq_(259)(global, NUMBER, $Number);
}
},{"215":215,"227":227,"232":232,"233":233,"240":240,"247":247,"259":259,"272":272}],314:[function(_dereq_,module,exports){
// 20.1.2.1 Number.EPSILON
var $def = _dereq_(222);
$def($def.S, 'Number', {EPSILON: Math.pow(2, -52)});
},{"222":222}],315:[function(_dereq_,module,exports){
// 20.1.2.2 Number.isFinite(number)
var $def = _dereq_(222)
, _isFinite = _dereq_(232).isFinite;
$def($def.S, 'Number', {
isFinite: function isFinite(it){
return typeof it == 'number' && _isFinite(it);
}
});
},{"222":222,"232":232}],316:[function(_dereq_,module,exports){
// 20.1.2.3 Number.isInteger(number)
var $def = _dereq_(222);
$def($def.S, 'Number', {isInteger: _dereq_(239)});
},{"222":222,"239":239}],317:[function(_dereq_,module,exports){
// 20.1.2.4 Number.isNaN(number)
var $def = _dereq_(222);
$def($def.S, 'Number', {
isNaN: function isNaN(number){
return number != number;
}
});
},{"222":222}],318:[function(_dereq_,module,exports){
// 20.1.2.5 Number.isSafeInteger(number)
var $def = _dereq_(222)
, isInteger = _dereq_(239)
, abs = Math.abs;
$def($def.S, 'Number', {
isSafeInteger: function isSafeInteger(number){
return isInteger(number) && abs(number) <= 0x1fffffffffffff;
}
});
},{"222":222,"239":239}],319:[function(_dereq_,module,exports){
// 20.1.2.6 Number.MAX_SAFE_INTEGER
var $def = _dereq_(222);
$def($def.S, 'Number', {MAX_SAFE_INTEGER: 0x1fffffffffffff});
},{"222":222}],320:[function(_dereq_,module,exports){
// 20.1.2.10 Number.MIN_SAFE_INTEGER
var $def = _dereq_(222);
$def($def.S, 'Number', {MIN_SAFE_INTEGER: -0x1fffffffffffff});
},{"222":222}],321:[function(_dereq_,module,exports){
// 20.1.2.12 Number.parseFloat(string)
var $def = _dereq_(222);
$def($def.S, 'Number', {parseFloat: parseFloat});
},{"222":222}],322:[function(_dereq_,module,exports){
// 20.1.2.13 Number.parseInt(string, radix)
var $def = _dereq_(222);
$def($def.S, 'Number', {parseInt: parseInt});
},{"222":222}],323:[function(_dereq_,module,exports){
// 19.1.3.1 Object.assign(target, source)
var $def = _dereq_(222);
$def($def.S + $def.F, 'Object', {assign: _dereq_(213)});
},{"213":213,"222":222}],324:[function(_dereq_,module,exports){
// 19.1.2.5 Object.freeze(O)
var isObject = _dereq_(240);
_dereq_(253)('freeze', function($freeze){
return function freeze(it){
return $freeze && isObject(it) ? $freeze(it) : it;
};
});
},{"240":240,"253":253}],325:[function(_dereq_,module,exports){
// 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)
var toIObject = _dereq_(277);
_dereq_(253)('getOwnPropertyDescriptor', function($getOwnPropertyDescriptor){
return function getOwnPropertyDescriptor(it, key){
return $getOwnPropertyDescriptor(toIObject(it), key);
};
});
},{"253":253,"277":277}],326:[function(_dereq_,module,exports){
// 19.1.2.7 Object.getOwnPropertyNames(O)
_dereq_(253)('getOwnPropertyNames', function(){
return _dereq_(231).get;
});
},{"231":231,"253":253}],327:[function(_dereq_,module,exports){
// 19.1.2.9 Object.getPrototypeOf(O)
var toObject = _dereq_(279);
_dereq_(253)('getPrototypeOf', function($getPrototypeOf){
return function getPrototypeOf(it){
return $getPrototypeOf(toObject(it));
};
});
},{"253":253,"279":279}],328:[function(_dereq_,module,exports){
// 19.1.2.11 Object.isExtensible(O)
var isObject = _dereq_(240);
_dereq_(253)('isExtensible', function($isExtensible){
return function isExtensible(it){
return isObject(it) ? $isExtensible ? $isExtensible(it) : true : false;
};
});
},{"240":240,"253":253}],329:[function(_dereq_,module,exports){
// 19.1.2.12 Object.isFrozen(O)
var isObject = _dereq_(240);
_dereq_(253)('isFrozen', function($isFrozen){
return function isFrozen(it){
return isObject(it) ? $isFrozen ? $isFrozen(it) : false : true;
};
});
},{"240":240,"253":253}],330:[function(_dereq_,module,exports){
// 19.1.2.13 Object.isSealed(O)
var isObject = _dereq_(240);
_dereq_(253)('isSealed', function($isSealed){
return function isSealed(it){
return isObject(it) ? $isSealed ? $isSealed(it) : false : true;
};
});
},{"240":240,"253":253}],331:[function(_dereq_,module,exports){
// 19.1.3.10 Object.is(value1, value2)
var $def = _dereq_(222);
$def($def.S, 'Object', {
is: _dereq_(261)
});
},{"222":222,"261":261}],332:[function(_dereq_,module,exports){
// 19.1.2.14 Object.keys(O)
var toObject = _dereq_(279);
_dereq_(253)('keys', function($keys){
return function keys(it){
return $keys(toObject(it));
};
});
},{"253":253,"279":279}],333:[function(_dereq_,module,exports){
// 19.1.2.15 Object.preventExtensions(O)
var isObject = _dereq_(240);
_dereq_(253)('preventExtensions', function($preventExtensions){
return function preventExtensions(it){
return $preventExtensions && isObject(it) ? $preventExtensions(it) : it;
};
});
},{"240":240,"253":253}],334:[function(_dereq_,module,exports){
// 19.1.2.17 Object.seal(O)
var isObject = _dereq_(240);
_dereq_(253)('seal', function($seal){
return function seal(it){
return $seal && isObject(it) ? $seal(it) : it;
};
});
},{"240":240,"253":253}],335:[function(_dereq_,module,exports){
// 19.1.3.19 Object.setPrototypeOf(O, proto)
var $def = _dereq_(222);
$def($def.S, 'Object', {setPrototypeOf: _dereq_(262).set});
},{"222":222,"262":262}],336:[function(_dereq_,module,exports){
'use strict';
// 19.1.3.6 Object.prototype.toString()
var classof = _dereq_(214)
, test = {};
test[_dereq_(282)('toStringTag')] = 'z';
if(test + '' != '[object z]'){
_dereq_(259)(Object.prototype, 'toString', function toString(){
return '[object ' + classof(this) + ']';
}, true);
}
},{"214":214,"259":259,"282":282}],337:[function(_dereq_,module,exports){
'use strict';
var $ = _dereq_(247)
, LIBRARY = _dereq_(249)
, global = _dereq_(232)
, ctx = _dereq_(221)
, classof = _dereq_(214)
, $def = _dereq_(222)
, isObject = _dereq_(240)
, anObject = _dereq_(210)
, aFunction = _dereq_(209)
, strictNew = _dereq_(266)
, forOf = _dereq_(230)
, setProto = _dereq_(262).set
, same = _dereq_(261)
, species = _dereq_(265)
, SPECIES = _dereq_(282)('species')
, RECORD = _dereq_(280)('record')
, asap = _dereq_(251)
, PROMISE = 'Promise'
, process = global.process
, isNode = classof(process) == 'process'
, P = global[PROMISE]
, Wrapper;
var testResolve = function(sub){
var test = new P(function(){});
if(sub)test.constructor = Object;
return P.resolve(test) === test;
};
var useNative = function(){
var works = false;
function P2(x){
var self = new P(x);
setProto(self, P2.prototype);
return self;
}
try {
works = P && P.resolve && testResolve();
setProto(P2, P);
P2.prototype = $.create(P.prototype, {constructor: {value: P2}});
// actual Firefox has broken subclass support, test that
if(!(P2.resolve(5).then(function(){}) instanceof P2)){
works = false;
}
// actual V8 bug, https://code.google.com/p/v8/issues/detail?id=4162
if(works && _dereq_(272)){
var thenableThenGotten = false;
P.resolve($.setDesc({}, 'then', {
get: function(){ thenableThenGotten = true; }
}));
works = thenableThenGotten;
}
} catch(e){ works = false; }
return works;
}();
// helpers
var isPromise = function(it){
return isObject(it) && (useNative ? classof(it) == 'Promise' : RECORD in it);
};
var sameConstructor = function(a, b){
// library wrapper special case
if(LIBRARY && a === P && b === Wrapper)return true;
return same(a, b);
};
var getConstructor = function(C){
var S = anObject(C)[SPECIES];
return S != undefined ? S : C;
};
var isThenable = function(it){
var then;
return isObject(it) && typeof (then = it.then) == 'function' ? then : false;
};
var notify = function(record, isReject){
if(record.n)return;
record.n = true;
var chain = record.c;
asap(function(){
var value = record.v
, ok = record.s == 1
, i = 0;
var run = function(react){
var cb = ok ? react.ok : react.fail
, ret, then;
try {
if(cb){
if(!ok)record.h = true;
ret = cb === true ? value : cb(value);
if(ret === react.P){
react.rej(TypeError('Promise-chain cycle'));
} else if(then = isThenable(ret)){
then.call(ret, react.res, react.rej);
} else react.res(ret);
} else react.rej(value);
} catch(err){
react.rej(err);
}
};
while(chain.length > i)run(chain[i++]); // variable length - can't use forEach
chain.length = 0;
record.n = false;
if(isReject)setTimeout(function(){
if(isUnhandled(record.p)){
if(isNode){
process.emit('unhandledRejection', value, record.p);
} else if(global.console && console.error){
console.error('Unhandled promise rejection', value);
}
} record.a = undefined;
}, 1);
});
};
var isUnhandled = function(promise){
var record = promise[RECORD]
, chain = record.a || record.c
, i = 0
, react;
if(record.h)return false;
while(chain.length > i){
react = chain[i++];
if(react.fail || !isUnhandled(react.P))return false;
} return true;
};
var $reject = function(value){
var record = this;
if(record.d)return;
record.d = true;
record = record.r || record; // unwrap
record.v = value;
record.s = 2;
record.a = record.c.slice();
notify(record, true);
};
var $resolve = function(value){
var record = this
, then;
if(record.d)return;
record.d = true;
record = record.r || record; // unwrap
try {
if(then = isThenable(value)){
asap(function(){
var wrapper = {r: record, d: false}; // wrap
try {
then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1));
} catch(e){
$reject.call(wrapper, e);
}
});
} else {
record.v = value;
record.s = 1;
notify(record, false);
}
} catch(e){
$reject.call({r: record, d: false}, e); // wrap
}
};
// constructor polyfill
if(!useNative){
// 25.4.3.1 Promise(executor)
P = function Promise(executor){
aFunction(executor);
var record = {
p: strictNew(this, P, PROMISE), // <- promise
c: [], // <- awaiting reactions
a: undefined, // <- checked in isUnhandled reactions
s: 0, // <- state
d: false, // <- done
v: undefined, // <- value
h: false, // <- handled rejection
n: false // <- notify
};
this[RECORD] = record;
try {
executor(ctx($resolve, record, 1), ctx($reject, record, 1));
} catch(err){
$reject.call(record, err);
}
};
_dereq_(252)(P.prototype, {
// 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected)
then: function then(onFulfilled, onRejected){
var S = anObject(anObject(this).constructor)[SPECIES];
var react = {
ok: typeof onFulfilled == 'function' ? onFulfilled : true,
fail: typeof onRejected == 'function' ? onRejected : false
};
var promise = react.P = new (S != undefined ? S : P)(function(res, rej){
react.res = aFunction(res);
react.rej = aFunction(rej);
});
var record = this[RECORD];
record.c.push(react);
if(record.a)record.a.push(react);
if(record.s)notify(record, false);
return promise;
},
// 25.4.5.1 Promise.prototype.catch(onRejected)
'catch': function(onRejected){
return this.then(undefined, onRejected);
}
});
}
// export
$def($def.G + $def.W + $def.F * !useNative, {Promise: P});
_dereq_(273)(P, PROMISE);
species(P);
species(Wrapper = _dereq_(220)[PROMISE]);
// statics
$def($def.S + $def.F * !useNative, PROMISE, {
// 25.4.4.5 Promise.reject(r)
reject: function reject(r){
return new this(function(res, rej){ rej(r); });
}
});
$def($def.S + $def.F * (!useNative || testResolve(true)), PROMISE, {
// 25.4.4.6 Promise.resolve(x)
resolve: function resolve(x){
return isPromise(x) && sameConstructor(x.constructor, this)
? x : new this(function(res){ res(x); });
}
});
$def($def.S + $def.F * !(useNative && _dereq_(244)(function(iter){
P.all(iter)['catch'](function(){});
})), PROMISE, {
// 25.4.4.1 Promise.all(iterable)
all: function all(iterable){
var C = getConstructor(this)
, values = [];
return new C(function(res, rej){
forOf(iterable, false, values.push, values);
var remaining = values.length
, results = Array(remaining);
if(remaining)$.each.call(values, function(promise, index){
C.resolve(promise).then(function(value){
results[index] = value;
--remaining || res(results);
}, rej);
});
else res(results);
});
},
// 25.4.4.4 Promise.race(iterable)
race: function race(iterable){
var C = getConstructor(this);
return new C(function(res, rej){
forOf(iterable, false, function(promise){
C.resolve(promise).then(res, rej);
});
});
}
});
},{"209":209,"210":210,"214":214,"220":220,"221":221,"222":222,"230":230,"232":232,"240":240,"244":244,"247":247,"249":249,"251":251,"252":252,"261":261,"262":262,"265":265,"266":266,"272":272,"273":273,"280":280,"282":282}],338:[function(_dereq_,module,exports){
// 26.1.1 Reflect.apply(target, thisArgument, argumentsList)
var $def = _dereq_(222)
, _apply = Function.apply;
$def($def.S, 'Reflect', {
apply: function apply(target, thisArgument, argumentsList){
return _apply.call(target, thisArgument, argumentsList);
}
});
},{"222":222}],339:[function(_dereq_,module,exports){
// 26.1.2 Reflect.construct(target, argumentsList [, newTarget])
var $ = _dereq_(247)
, $def = _dereq_(222)
, aFunction = _dereq_(209)
, anObject = _dereq_(210)
, isObject = _dereq_(240)
, bind = Function.bind || _dereq_(220).Function.prototype.bind;
// MS Edge supports only 2 arguments
// FF Nightly sets third argument as `new.target`, but does not create `this` from it
$def($def.S + $def.F * _dereq_(227)(function(){
function F(){}
return !(Reflect.construct(function(){}, [], F) instanceof F);
}), 'Reflect', {
construct: function construct(Target, args /*, newTarget*/){
aFunction(Target);
var newTarget = arguments.length < 3 ? Target : aFunction(arguments[2]);
if(Target == newTarget){
// w/o altered newTarget, optimization for 0-4 arguments
if(args != undefined)switch(anObject(args).length){
case 0: return new Target;
case 1: return new Target(args[0]);
case 2: return new Target(args[0], args[1]);
case 3: return new Target(args[0], args[1], args[2]);
case 4: return new Target(args[0], args[1], args[2], args[3]);
}
// w/o altered newTarget, lot of arguments case
var $args = [null];
$args.push.apply($args, args);
return new (bind.apply(Target, $args));
}
// with altered newTarget, not support built-in constructors
var proto = newTarget.prototype
, instance = $.create(isObject(proto) ? proto : Object.prototype)
, result = Function.apply.call(Target, instance, args);
return isObject(result) ? result : instance;
}
});
},{"209":209,"210":210,"220":220,"222":222,"227":227,"240":240,"247":247}],340:[function(_dereq_,module,exports){
// 26.1.3 Reflect.defineProperty(target, propertyKey, attributes)
var $ = _dereq_(247)
, $def = _dereq_(222)
, anObject = _dereq_(210);
// MS Edge has broken Reflect.defineProperty - throwing instead of returning false
$def($def.S + $def.F * _dereq_(227)(function(){
Reflect.defineProperty($.setDesc({}, 1, {value: 1}), 1, {value: 2});
}), 'Reflect', {
defineProperty: function defineProperty(target, propertyKey, attributes){
anObject(target);
try {
$.setDesc(target, propertyKey, attributes);
return true;
} catch(e){
return false;
}
}
});
},{"210":210,"222":222,"227":227,"247":247}],341:[function(_dereq_,module,exports){
// 26.1.4 Reflect.deleteProperty(target, propertyKey)
var $def = _dereq_(222)
, getDesc = _dereq_(247).getDesc
, anObject = _dereq_(210);
$def($def.S, 'Reflect', {
deleteProperty: function deleteProperty(target, propertyKey){
var desc = getDesc(anObject(target), propertyKey);
return desc && !desc.configurable ? false : delete target[propertyKey];
}
});
},{"210":210,"222":222,"247":247}],342:[function(_dereq_,module,exports){
'use strict';
// 26.1.5 Reflect.enumerate(target)
var $def = _dereq_(222)
, anObject = _dereq_(210);
var Enumerate = function(iterated){
this._t = anObject(iterated); // target
this._i = 0; // next index
var keys = this._k = [] // keys
, key;
for(key in iterated)keys.push(key);
};
_dereq_(242)(Enumerate, 'Object', function(){
var that = this
, keys = that._k
, key;
do {
if(that._i >= keys.length)return {value: undefined, done: true};
} while(!((key = keys[that._i++]) in that._t));
return {value: key, done: false};
});
$def($def.S, 'Reflect', {
enumerate: function enumerate(target){
return new Enumerate(target);
}
});
},{"210":210,"222":222,"242":242}],343:[function(_dereq_,module,exports){
// 26.1.7 Reflect.getOwnPropertyDescriptor(target, propertyKey)
var $ = _dereq_(247)
, $def = _dereq_(222)
, anObject = _dereq_(210);
$def($def.S, 'Reflect', {
getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, propertyKey){
return $.getDesc(anObject(target), propertyKey);
}
});
},{"210":210,"222":222,"247":247}],344:[function(_dereq_,module,exports){
// 26.1.8 Reflect.getPrototypeOf(target)
var $def = _dereq_(222)
, getProto = _dereq_(247).getProto
, anObject = _dereq_(210);
$def($def.S, 'Reflect', {
getPrototypeOf: function getPrototypeOf(target){
return getProto(anObject(target));
}
});
},{"210":210,"222":222,"247":247}],345:[function(_dereq_,module,exports){
// 26.1.6 Reflect.get(target, propertyKey [, receiver])
var $ = _dereq_(247)
, has = _dereq_(233)
, $def = _dereq_(222)
, isObject = _dereq_(240)
, anObject = _dereq_(210);
function get(target, propertyKey/*, receiver*/){
var receiver = arguments.length < 3 ? target : arguments[2]
, desc, proto;
if(anObject(target) === receiver)return target[propertyKey];
if(desc = $.getDesc(target, propertyKey))return has(desc, 'value')
? desc.value
: desc.get !== undefined
? desc.get.call(receiver)
: undefined;
if(isObject(proto = $.getProto(target)))return get(proto, propertyKey, receiver);
}
$def($def.S, 'Reflect', {get: get});
},{"210":210,"222":222,"233":233,"240":240,"247":247}],346:[function(_dereq_,module,exports){
// 26.1.9 Reflect.has(target, propertyKey)
var $def = _dereq_(222);
$def($def.S, 'Reflect', {
has: function has(target, propertyKey){
return propertyKey in target;
}
});
},{"222":222}],347:[function(_dereq_,module,exports){
// 26.1.10 Reflect.isExtensible(target)
var $def = _dereq_(222)
, anObject = _dereq_(210)
, $isExtensible = Object.isExtensible;
$def($def.S, 'Reflect', {
isExtensible: function isExtensible(target){
anObject(target);
return $isExtensible ? $isExtensible(target) : true;
}
});
},{"210":210,"222":222}],348:[function(_dereq_,module,exports){
// 26.1.11 Reflect.ownKeys(target)
var $def = _dereq_(222);
$def($def.S, 'Reflect', {ownKeys: _dereq_(255)});
},{"222":222,"255":255}],349:[function(_dereq_,module,exports){
// 26.1.12 Reflect.preventExtensions(target)
var $def = _dereq_(222)
, anObject = _dereq_(210)
, $preventExtensions = Object.preventExtensions;
$def($def.S, 'Reflect', {
preventExtensions: function preventExtensions(target){
anObject(target);
try {
if($preventExtensions)$preventExtensions(target);
return true;
} catch(e){
return false;
}
}
});
},{"210":210,"222":222}],350:[function(_dereq_,module,exports){
// 26.1.14 Reflect.setPrototypeOf(target, proto)
var $def = _dereq_(222)
, setProto = _dereq_(262);
if(setProto)$def($def.S, 'Reflect', {
setPrototypeOf: function setPrototypeOf(target, proto){
setProto.check(target, proto);
try {
setProto.set(target, proto);
return true;
} catch(e){
return false;
}
}
});
},{"222":222,"262":262}],351:[function(_dereq_,module,exports){
// 26.1.13 Reflect.set(target, propertyKey, V [, receiver])
var $ = _dereq_(247)
, has = _dereq_(233)
, $def = _dereq_(222)
, createDesc = _dereq_(258)
, anObject = _dereq_(210)
, isObject = _dereq_(240);
function set(target, propertyKey, V/*, receiver*/){
var receiver = arguments.length < 4 ? target : arguments[3]
, ownDesc = $.getDesc(anObject(target), propertyKey)
, existingDescriptor, proto;
if(!ownDesc){
if(isObject(proto = $.getProto(target))){
return set(proto, propertyKey, V, receiver);
}
ownDesc = createDesc(0);
}
if(has(ownDesc, 'value')){
if(ownDesc.writable === false || !isObject(receiver))return false;
existingDescriptor = $.getDesc(receiver, propertyKey) || createDesc(0);
existingDescriptor.value = V;
$.setDesc(receiver, propertyKey, existingDescriptor);
return true;
}
return ownDesc.set === undefined ? false : (ownDesc.set.call(receiver, V), true);
}
$def($def.S, 'Reflect', {set: set});
},{"210":210,"222":222,"233":233,"240":240,"247":247,"258":258}],352:[function(_dereq_,module,exports){
var $ = _dereq_(247)
, global = _dereq_(232)
, cof = _dereq_(215)
, $flags = _dereq_(229)
, $RegExp = global.RegExp
, Base = $RegExp
, proto = $RegExp.prototype
, re = /a/g
// "new" creates a new object
, CORRECT_NEW = new $RegExp(re) !== re
// RegExp allows a regex with flags as the pattern
, ALLOWS_RE_WITH_FLAGS = function(){
try {
return $RegExp(re, 'i') == '/a/i';
} catch(e){ /* empty */ }
}();
if(_dereq_(272)){
if(!CORRECT_NEW || !ALLOWS_RE_WITH_FLAGS){
$RegExp = function RegExp(pattern, flags){
var patternIsRegExp = cof(pattern) == 'RegExp'
, flagsIsUndefined = flags === undefined;
if(!(this instanceof $RegExp) && patternIsRegExp && flagsIsUndefined)return pattern;
return CORRECT_NEW
? new Base(patternIsRegExp && !flagsIsUndefined ? pattern.source : pattern, flags)
: new Base(patternIsRegExp ? pattern.source : pattern
, patternIsRegExp && flagsIsUndefined ? $flags.call(pattern) : flags);
};
$.each.call($.getNames(Base), function(key){
key in $RegExp || $.setDesc($RegExp, key, {
configurable: true,
get: function(){ return Base[key]; },
set: function(it){ Base[key] = it; }
});
});
proto.constructor = $RegExp;
$RegExp.prototype = proto;
_dereq_(259)(global, 'RegExp', $RegExp);
}
}
_dereq_(265)($RegExp);
},{"215":215,"229":229,"232":232,"247":247,"259":259,"265":265,"272":272}],353:[function(_dereq_,module,exports){
// 21.2.5.3 get RegExp.prototype.flags()
var $ = _dereq_(247);
if(_dereq_(272) && /./g.flags != 'g')$.setDesc(RegExp.prototype, 'flags', {
configurable: true,
get: _dereq_(229)
});
},{"229":229,"247":247,"272":272}],354:[function(_dereq_,module,exports){
// @@match logic
_dereq_(228)('match', 1, function(defined, MATCH){
// 21.1.3.11 String.prototype.match(regexp)
return function match(regexp){
'use strict';
var O = defined(this)
, fn = regexp == undefined ? undefined : regexp[MATCH];
return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[MATCH](String(O));
};
});
},{"228":228}],355:[function(_dereq_,module,exports){
// @@replace logic
_dereq_(228)('replace', 2, function(defined, REPLACE, $replace){
// 21.1.3.14 String.prototype.replace(searchValue, replaceValue)
return function replace(searchValue, replaceValue){
'use strict';
var O = defined(this)
, fn = searchValue == undefined ? undefined : searchValue[REPLACE];
return fn !== undefined
? fn.call(searchValue, O, replaceValue)
: $replace.call(String(O), searchValue, replaceValue);
};
});
},{"228":228}],356:[function(_dereq_,module,exports){
// @@search logic
_dereq_(228)('search', 1, function(defined, SEARCH){
// 21.1.3.15 String.prototype.search(regexp)
return function search(regexp){
'use strict';
var O = defined(this)
, fn = regexp == undefined ? undefined : regexp[SEARCH];
return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[SEARCH](String(O));
};
});
},{"228":228}],357:[function(_dereq_,module,exports){
// @@split logic
_dereq_(228)('split', 2, function(defined, SPLIT, $split){
// 21.1.3.17 String.prototype.split(separator, limit)
return function split(separator, limit){
'use strict';
var O = defined(this)
, fn = separator == undefined ? undefined : separator[SPLIT];
return fn !== undefined
? fn.call(separator, O, limit)
: $split.call(String(O), separator, limit);
};
});
},{"228":228}],358:[function(_dereq_,module,exports){
'use strict';
var strong = _dereq_(216);
// 23.2 Set Objects
_dereq_(219)('Set', function(get){
return function Set(){ return get(this, arguments[0]); };
}, {
// 23.2.3.1 Set.prototype.add(value)
add: function add(value){
return strong.def(this, value = value === 0 ? 0 : value, value);
}
}, strong);
},{"216":216,"219":219}],359:[function(_dereq_,module,exports){
'use strict';
var $def = _dereq_(222)
, $at = _dereq_(267)(false);
$def($def.P, 'String', {
// 21.1.3.3 String.prototype.codePointAt(pos)
codePointAt: function codePointAt(pos){
return $at(this, pos);
}
});
},{"222":222,"267":267}],360:[function(_dereq_,module,exports){
'use strict';
var $def = _dereq_(222)
, toLength = _dereq_(278)
, context = _dereq_(268);
// should throw error on regex
$def($def.P + $def.F * !_dereq_(227)(function(){ 'q'.endsWith(/./); }), 'String', {
// 21.1.3.6 String.prototype.endsWith(searchString [, endPosition])
endsWith: function endsWith(searchString /*, endPosition = @length */){
var that = context(this, searchString, 'endsWith')
, endPosition = arguments[1]
, len = toLength(that.length)
, end = endPosition === undefined ? len : Math.min(toLength(endPosition), len)
, search = String(searchString);
return that.slice(end - search.length, end) === search;
}
});
},{"222":222,"227":227,"268":268,"278":278}],361:[function(_dereq_,module,exports){
var $def = _dereq_(222)
, toIndex = _dereq_(275)
, fromCharCode = String.fromCharCode
, $fromCodePoint = String.fromCodePoint;
// length should be 1, old FF problem
$def($def.S + $def.F * (!!$fromCodePoint && $fromCodePoint.length != 1), 'String', {
// 21.1.2.2 String.fromCodePoint(...codePoints)
fromCodePoint: function fromCodePoint(x){ // eslint-disable-line no-unused-vars
var res = []
, len = arguments.length
, i = 0
, code;
while(len > i){
code = +arguments[i++];
if(toIndex(code, 0x10ffff) !== code)throw RangeError(code + ' is not a valid code point');
res.push(code < 0x10000
? fromCharCode(code)
: fromCharCode(((code -= 0x10000) >> 10) + 0xd800, code % 0x400 + 0xdc00)
);
} return res.join('');
}
});
},{"222":222,"275":275}],362:[function(_dereq_,module,exports){
'use strict';
var $def = _dereq_(222)
, context = _dereq_(268);
$def($def.P, 'String', {
// 21.1.3.7 String.prototype.includes(searchString, position = 0)
includes: function includes(searchString /*, position = 0 */){
return !!~context(this, searchString, 'includes').indexOf(searchString, arguments[1]);
}
});
},{"222":222,"268":268}],363:[function(_dereq_,module,exports){
'use strict';
var $at = _dereq_(267)(true);
// 21.1.3.27 String.prototype[@@iterator]()
_dereq_(243)(String, 'String', function(iterated){
this._t = String(iterated); // target
this._i = 0; // next index
// 21.1.5.2.1 %StringIteratorPrototype%.next()
}, function(){
var O = this._t
, index = this._i
, point;
if(index >= O.length)return {value: undefined, done: true};
point = $at(O, index);
this._i += point.length;
return {value: point, done: false};
});
},{"243":243,"267":267}],364:[function(_dereq_,module,exports){
var $def = _dereq_(222)
, toIObject = _dereq_(277)
, toLength = _dereq_(278);
$def($def.S, 'String', {
// 21.1.2.4 String.raw(callSite, ...substitutions)
raw: function raw(callSite){
var tpl = toIObject(callSite.raw)
, len = toLength(tpl.length)
, sln = arguments.length
, res = []
, i = 0;
while(len > i){
res.push(String(tpl[i++]));
if(i < sln)res.push(String(arguments[i]));
} return res.join('');
}
});
},{"222":222,"277":277,"278":278}],365:[function(_dereq_,module,exports){
var $def = _dereq_(222);
$def($def.P, 'String', {
// 21.1.3.13 String.prototype.repeat(count)
repeat: _dereq_(270)
});
},{"222":222,"270":270}],366:[function(_dereq_,module,exports){
'use strict';
var $def = _dereq_(222)
, toLength = _dereq_(278)
, context = _dereq_(268);
// should throw error on regex
$def($def.P + $def.F * !_dereq_(227)(function(){ 'q'.startsWith(/./); }), 'String', {
// 21.1.3.18 String.prototype.startsWith(searchString [, position ])
startsWith: function startsWith(searchString /*, position = 0 */){
var that = context(this, searchString, 'startsWith')
, index = toLength(Math.min(arguments[1], that.length))
, search = String(searchString);
return that.slice(index, index + search.length) === search;
}
});
},{"222":222,"227":227,"268":268,"278":278}],367:[function(_dereq_,module,exports){
'use strict';
// 21.1.3.25 String.prototype.trim()
_dereq_(271)('trim', function($trim){
return function trim(){
return $trim(this, 3);
};
});
},{"271":271}],368:[function(_dereq_,module,exports){
'use strict';
// ECMAScript 6 symbols shim
var $ = _dereq_(247)
, global = _dereq_(232)
, has = _dereq_(233)
, SUPPORT_DESC = _dereq_(272)
, $def = _dereq_(222)
, $redef = _dereq_(259)
, shared = _dereq_(263)
, setTag = _dereq_(273)
, uid = _dereq_(280)
, wks = _dereq_(282)
, keyOf = _dereq_(248)
, $names = _dereq_(231)
, enumKeys = _dereq_(225)
, isObject = _dereq_(240)
, anObject = _dereq_(210)
, toIObject = _dereq_(277)
, createDesc = _dereq_(258)
, getDesc = $.getDesc
, setDesc = $.setDesc
, _create = $.create
, getNames = $names.get
, $Symbol = global.Symbol
, setter = false
, HIDDEN = wks('_hidden')
, isEnum = $.isEnum
, SymbolRegistry = shared('symbol-registry')
, AllSymbols = shared('symbols')
, useNative = typeof $Symbol == 'function'
, ObjectProto = Object.prototype;
var setSymbolDesc = SUPPORT_DESC ? function(){ // fallback for old Android
try {
return _create(setDesc({}, HIDDEN, {
get: function(){
return setDesc(this, HIDDEN, {value: false})[HIDDEN];
}
}))[HIDDEN] || setDesc;
} catch(e){
return function(it, key, D){
var protoDesc = getDesc(ObjectProto, key);
if(protoDesc)delete ObjectProto[key];
setDesc(it, key, D);
if(protoDesc && it !== ObjectProto)setDesc(ObjectProto, key, protoDesc);
};
}
}() : setDesc;
var wrap = function(tag){
var sym = AllSymbols[tag] = _create($Symbol.prototype);
sym._k = tag;
SUPPORT_DESC && setter && setSymbolDesc(ObjectProto, tag, {
configurable: true,
set: function(value){
if(has(this, HIDDEN) && has(this[HIDDEN], tag))this[HIDDEN][tag] = false;
setSymbolDesc(this, tag, createDesc(1, value));
}
});
return sym;
};
var $defineProperty = function defineProperty(it, key, D){
if(D && has(AllSymbols, key)){
if(!D.enumerable){
if(!has(it, HIDDEN))setDesc(it, HIDDEN, createDesc(1, {}));
it[HIDDEN][key] = true;
} else {
if(has(it, HIDDEN) && it[HIDDEN][key])it[HIDDEN][key] = false;
D = _create(D, {enumerable: createDesc(0, false)});
} return setSymbolDesc(it, key, D);
} return setDesc(it, key, D);
};
var $defineProperties = function defineProperties(it, P){
anObject(it);
var keys = enumKeys(P = toIObject(P))
, i = 0
, l = keys.length
, key;
while(l > i)$defineProperty(it, key = keys[i++], P[key]);
return it;
};
var $create = function create(it, P){
return P === undefined ? _create(it) : $defineProperties(_create(it), P);
};
var $propertyIsEnumerable = function propertyIsEnumerable(key){
var E = isEnum.call(this, key);
return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key]
? E : true;
};
var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key){
var D = getDesc(it = toIObject(it), key);
if(D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key]))D.enumerable = true;
return D;
};
var $getOwnPropertyNames = function getOwnPropertyNames(it){
var names = getNames(toIObject(it))
, result = []
, i = 0
, key;
while(names.length > i)if(!has(AllSymbols, key = names[i++]) && key != HIDDEN)result.push(key);
return result;
};
var $getOwnPropertySymbols = function getOwnPropertySymbols(it){
var names = getNames(toIObject(it))
, result = []
, i = 0
, key;
while(names.length > i)if(has(AllSymbols, key = names[i++]))result.push(AllSymbols[key]);
return result;
};
// 19.4.1.1 Symbol([description])
if(!useNative){
$Symbol = function Symbol(){
if(this instanceof $Symbol)throw TypeError('Symbol is not a constructor');
return wrap(uid(arguments[0]));
};
$redef($Symbol.prototype, 'toString', function toString(){
return this._k;
});
$.create = $create;
$.isEnum = $propertyIsEnumerable;
$.getDesc = $getOwnPropertyDescriptor;
$.setDesc = $defineProperty;
$.setDescs = $defineProperties;
$.getNames = $names.get = $getOwnPropertyNames;
$.getSymbols = $getOwnPropertySymbols;
if(SUPPORT_DESC && !_dereq_(249)){
$redef(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true);
}
}
// MS Edge converts symbol values to JSON as {}
// WebKit converts symbol values in objects to JSON as null
if(!useNative || _dereq_(227)(function(){
return JSON.stringify([{a: $Symbol()}, [$Symbol()]]) != '[{},[null]]';
}))$redef($Symbol.prototype, 'toJSON', function toJSON(){
if(useNative && isObject(this))return this;
});
var symbolStatics = {
// 19.4.2.1 Symbol.for(key)
'for': function(key){
return has(SymbolRegistry, key += '')
? SymbolRegistry[key]
: SymbolRegistry[key] = $Symbol(key);
},
// 19.4.2.5 Symbol.keyFor(sym)
keyFor: function keyFor(key){
return keyOf(SymbolRegistry, key);
},
useSetter: function(){ setter = true; },
useSimple: function(){ setter = false; }
};
// 19.4.2.2 Symbol.hasInstance
// 19.4.2.3 Symbol.isConcatSpreadable
// 19.4.2.4 Symbol.iterator
// 19.4.2.6 Symbol.match
// 19.4.2.8 Symbol.replace
// 19.4.2.9 Symbol.search
// 19.4.2.10 Symbol.species
// 19.4.2.11 Symbol.split
// 19.4.2.12 Symbol.toPrimitive
// 19.4.2.13 Symbol.toStringTag
// 19.4.2.14 Symbol.unscopables
$.each.call((
'hasInstance,isConcatSpreadable,iterator,match,replace,search,' +
'species,split,toPrimitive,toStringTag,unscopables'
).split(','), function(it){
var sym = wks(it);
symbolStatics[it] = useNative ? sym : wrap(sym);
}
);
setter = true;
$def($def.G + $def.W, {Symbol: $Symbol});
$def($def.S, 'Symbol', symbolStatics);
$def($def.S + $def.F * !useNative, 'Object', {
// 19.1.2.2 Object.create(O [, Properties])
create: $create,
// 19.1.2.4 Object.defineProperty(O, P, Attributes)
defineProperty: $defineProperty,
// 19.1.2.3 Object.defineProperties(O, Properties)
defineProperties: $defineProperties,
// 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)
getOwnPropertyDescriptor: $getOwnPropertyDescriptor,
// 19.1.2.7 Object.getOwnPropertyNames(O)
getOwnPropertyNames: $getOwnPropertyNames,
// 19.1.2.8 Object.getOwnPropertySymbols(O)
getOwnPropertySymbols: $getOwnPropertySymbols
});
// 19.4.3.5 Symbol.prototype[@@toStringTag]
setTag($Symbol, 'Symbol');
// 20.2.1.9 Math[@@toStringTag]
setTag(Math, 'Math', true);
// 24.3.3 JSON[@@toStringTag]
setTag(global.JSON, 'JSON', true);
},{"210":210,"222":222,"225":225,"227":227,"231":231,"232":232,"233":233,"240":240,"247":247,"248":248,"249":249,"258":258,"259":259,"263":263,"272":272,"273":273,"277":277,"280":280,"282":282}],369:[function(_dereq_,module,exports){
'use strict';
var $ = _dereq_(247)
, weak = _dereq_(218)
, isObject = _dereq_(240)
, has = _dereq_(233)
, frozenStore = weak.frozenStore
, WEAK = weak.WEAK
, isExtensible = Object.isExtensible || isObject
, tmp = {};
// 23.3 WeakMap Objects
var $WeakMap = _dereq_(219)('WeakMap', function(get){
return function WeakMap(){ return get(this, arguments[0]); };
}, {
// 23.3.3.3 WeakMap.prototype.get(key)
get: function get(key){
if(isObject(key)){
if(!isExtensible(key))return frozenStore(this).get(key);
if(has(key, WEAK))return key[WEAK][this._i];
}
},
// 23.3.3.5 WeakMap.prototype.set(key, value)
set: function set(key, value){
return weak.def(this, key, value);
}
}, weak, true, true);
// IE11 WeakMap frozen keys fix
if(new $WeakMap().set((Object.freeze || Object)(tmp), 7).get(tmp) != 7){
$.each.call(['delete', 'has', 'get', 'set'], function(key){
var proto = $WeakMap.prototype
, method = proto[key];
_dereq_(259)(proto, key, function(a, b){
// store frozen objects on leaky map
if(isObject(a) && !isExtensible(a)){
var result = frozenStore(this)[key](a, b);
return key == 'set' ? this : result;
// store all the rest on native weakmap
} return method.call(this, a, b);
});
});
}
},{"218":218,"219":219,"233":233,"240":240,"247":247,"259":259}],370:[function(_dereq_,module,exports){
'use strict';
var weak = _dereq_(218);
// 23.4 WeakSet Objects
_dereq_(219)('WeakSet', function(get){
return function WeakSet(){ return get(this, arguments[0]); };
}, {
// 23.4.3.1 WeakSet.prototype.add(value)
add: function add(value){
return weak.def(this, value, true);
}
}, weak, false, true);
},{"218":218,"219":219}],371:[function(_dereq_,module,exports){
'use strict';
var $def = _dereq_(222)
, $includes = _dereq_(211)(true);
$def($def.P, 'Array', {
// https://github.com/domenic/Array.prototype.includes
includes: function includes(el /*, fromIndex = 0 */){
return $includes(this, el, arguments[1]);
}
});
_dereq_(281)('includes');
},{"211":211,"222":222,"281":281}],372:[function(_dereq_,module,exports){
// https://github.com/DavidBruant/Map-Set.prototype.toJSON
var $def = _dereq_(222);
$def($def.P, 'Map', {toJSON: _dereq_(217)('Map')});
},{"217":217,"222":222}],373:[function(_dereq_,module,exports){
// http://goo.gl/XkBrjD
var $def = _dereq_(222)
, $entries = _dereq_(254)(true);
$def($def.S, 'Object', {
entries: function entries(it){
return $entries(it);
}
});
},{"222":222,"254":254}],374:[function(_dereq_,module,exports){
// https://gist.github.com/WebReflection/9353781
var $ = _dereq_(247)
, $def = _dereq_(222)
, ownKeys = _dereq_(255)
, toIObject = _dereq_(277)
, createDesc = _dereq_(258);
$def($def.S, 'Object', {
getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object){
var O = toIObject(object)
, setDesc = $.setDesc
, getDesc = $.getDesc
, keys = ownKeys(O)
, result = {}
, i = 0
, key, D;
while(keys.length > i){
D = getDesc(O, key = keys[i++]);
if(key in result)setDesc(result, key, createDesc(0, D));
else result[key] = D;
} return result;
}
});
},{"222":222,"247":247,"255":255,"258":258,"277":277}],375:[function(_dereq_,module,exports){
// http://goo.gl/XkBrjD
var $def = _dereq_(222)
, $values = _dereq_(254)(false);
$def($def.S, 'Object', {
values: function values(it){
return $values(it);
}
});
},{"222":222,"254":254}],376:[function(_dereq_,module,exports){
// https://github.com/benjamingr/RexExp.escape
var $def = _dereq_(222)
, $re = _dereq_(260)(/[\\^$*+?.()|[\]{}]/g, '\\$&');
$def($def.S, 'RegExp', {escape: function escape(it){ return $re(it); }});
},{"222":222,"260":260}],377:[function(_dereq_,module,exports){
// https://github.com/DavidBruant/Map-Set.prototype.toJSON
var $def = _dereq_(222);
$def($def.P, 'Set', {toJSON: _dereq_(217)('Set')});
},{"217":217,"222":222}],378:[function(_dereq_,module,exports){
// https://github.com/mathiasbynens/String.prototype.at
'use strict';
var $def = _dereq_(222)
, $at = _dereq_(267)(true);
$def($def.P, 'String', {
at: function at(pos){
return $at(this, pos);
}
});
},{"222":222,"267":267}],379:[function(_dereq_,module,exports){
'use strict';
var $def = _dereq_(222)
, $pad = _dereq_(269);
$def($def.P, 'String', {
padLeft: function padLeft(maxLength /*, fillString = ' ' */){
return $pad(this, maxLength, arguments[1], true);
}
});
},{"222":222,"269":269}],380:[function(_dereq_,module,exports){
'use strict';
var $def = _dereq_(222)
, $pad = _dereq_(269);
$def($def.P, 'String', {
padRight: function padRight(maxLength /*, fillString = ' ' */){
return $pad(this, maxLength, arguments[1], false);
}
});
},{"222":222,"269":269}],381:[function(_dereq_,module,exports){
'use strict';
// https://github.com/sebmarkbage/ecmascript-string-left-right-trim
_dereq_(271)('trimLeft', function($trim){
return function trimLeft(){
return $trim(this, 1);
};
});
},{"271":271}],382:[function(_dereq_,module,exports){
'use strict';
// https://github.com/sebmarkbage/ecmascript-string-left-right-trim
_dereq_(271)('trimRight', function($trim){
return function trimRight(){
return $trim(this, 2);
};
});
},{"271":271}],383:[function(_dereq_,module,exports){
// JavaScript 1.6 / Strawman array statics shim
var $ = _dereq_(247)
, $def = _dereq_(222)
, $Array = _dereq_(220).Array || Array
, statics = {};
var setStatics = function(keys, length){
$.each.call(keys.split(','), function(key){
if(length == undefined && key in $Array)statics[key] = $Array[key];
else if(key in [])statics[key] = _dereq_(221)(Function.call, [][key], length);
});
};
setStatics('pop,reverse,shift,keys,values,entries', 1);
setStatics('indexOf,every,some,forEach,map,filter,find,findIndex,includes', 3);
setStatics('join,slice,concat,push,splice,unshift,sort,lastIndexOf,' +
'reduce,reduceRight,copyWithin,fill');
$def($def.S, 'Array', statics);
},{"220":220,"221":221,"222":222,"247":247}],384:[function(_dereq_,module,exports){
_dereq_(290);
var global = _dereq_(232)
, hide = _dereq_(234)
, Iterators = _dereq_(246)
, ITERATOR = _dereq_(282)('iterator')
, NL = global.NodeList
, HTC = global.HTMLCollection
, NLProto = NL && NL.prototype
, HTCProto = HTC && HTC.prototype
, ArrayValues = Iterators.NodeList = Iterators.HTMLCollection = Iterators.Array;
if(NL && !(ITERATOR in NLProto))hide(NLProto, ITERATOR, ArrayValues);
if(HTC && !(ITERATOR in HTCProto))hide(HTCProto, ITERATOR, ArrayValues);
},{"232":232,"234":234,"246":246,"282":282,"290":290}],385:[function(_dereq_,module,exports){
var $def = _dereq_(222)
, $task = _dereq_(274);
$def($def.G + $def.B, {
setImmediate: $task.set,
clearImmediate: $task.clear
});
},{"222":222,"274":274}],386:[function(_dereq_,module,exports){
// ie9- setTimeout & setInterval additional parameters fix
var global = _dereq_(232)
, $def = _dereq_(222)
, invoke = _dereq_(236)
, partial = _dereq_(256)
, navigator = global.navigator
, MSIE = !!navigator && /MSIE .\./.test(navigator.userAgent); // <- dirty ie9- check
var wrap = function(set){
return MSIE ? function(fn, time /*, ...args */){
return set(invoke(
partial,
[].slice.call(arguments, 2),
typeof fn == 'function' ? fn : Function(fn)
), time);
} : set;
};
$def($def.G + $def.B + $def.F * MSIE, {
setTimeout: wrap(global.setTimeout),
setInterval: wrap(global.setInterval)
});
},{"222":222,"232":232,"236":236,"256":256}],387:[function(_dereq_,module,exports){
_dereq_(284);
_dereq_(368);
_dereq_(323);
_dereq_(331);
_dereq_(335);
_dereq_(336);
_dereq_(324);
_dereq_(334);
_dereq_(333);
_dereq_(329);
_dereq_(330);
_dereq_(328);
_dereq_(325);
_dereq_(327);
_dereq_(332);
_dereq_(326);
_dereq_(294);
_dereq_(293);
_dereq_(313);
_dereq_(314);
_dereq_(315);
_dereq_(316);
_dereq_(317);
_dereq_(318);
_dereq_(319);
_dereq_(320);
_dereq_(321);
_dereq_(322);
_dereq_(296);
_dereq_(297);
_dereq_(298);
_dereq_(299);
_dereq_(300);
_dereq_(301);
_dereq_(302);
_dereq_(303);
_dereq_(304);
_dereq_(305);
_dereq_(306);
_dereq_(307);
_dereq_(308);
_dereq_(309);
_dereq_(310);
_dereq_(311);
_dereq_(312);
_dereq_(361);
_dereq_(364);
_dereq_(367);
_dereq_(363);
_dereq_(359);
_dereq_(360);
_dereq_(362);
_dereq_(365);
_dereq_(366);
_dereq_(289);
_dereq_(291);
_dereq_(290);
_dereq_(292);
_dereq_(285);
_dereq_(286);
_dereq_(288);
_dereq_(287);
_dereq_(352);
_dereq_(353);
_dereq_(354);
_dereq_(355);
_dereq_(356);
_dereq_(357);
_dereq_(337);
_dereq_(295);
_dereq_(358);
_dereq_(369);
_dereq_(370);
_dereq_(338);
_dereq_(339);
_dereq_(340);
_dereq_(341);
_dereq_(342);
_dereq_(345);
_dereq_(343);
_dereq_(344);
_dereq_(346);
_dereq_(347);
_dereq_(348);
_dereq_(349);
_dereq_(351);
_dereq_(350);
_dereq_(371);
_dereq_(378);
_dereq_(379);
_dereq_(380);
_dereq_(381);
_dereq_(382);
_dereq_(376);
_dereq_(374);
_dereq_(375);
_dereq_(373);
_dereq_(372);
_dereq_(377);
_dereq_(383);
_dereq_(386);
_dereq_(385);
_dereq_(384);
module.exports = _dereq_(220);
},{"220":220,"284":284,"285":285,"286":286,"287":287,"288":288,"289":289,"290":290,"291":291,"292":292,"293":293,"294":294,"295":295,"296":296,"297":297,"298":298,"299":299,"300":300,"301":301,"302":302,"303":303,"304":304,"305":305,"306":306,"307":307,"308":308,"309":309,"310":310,"311":311,"312":312,"313":313,"314":314,"315":315,"316":316,"317":317,"318":318,"319":319,"320":320,"321":321,"322":322,"323":323,"324":324,"325":325,"326":326,"327":327,"328":328,"329":329,"330":330,"331":331,"332":332,"333":333,"334":334,"335":335,"336":336,"337":337,"338":338,"339":339,"340":340,"341":341,"342":342,"343":343,"344":344,"345":345,"346":346,"347":347,"348":348,"349":349,"350":350,"351":351,"352":352,"353":353,"354":354,"355":355,"356":356,"357":357,"358":358,"359":359,"360":360,"361":361,"362":362,"363":363,"364":364,"365":365,"366":366,"367":367,"368":368,"369":369,"370":370,"371":371,"372":372,"373":373,"374":374,"375":375,"376":376,"377":377,"378":378,"379":379,"380":380,"381":381,"382":382,"383":383,"384":384,"385":385,"386":386}],388:[function(_dereq_,module,exports){
/**
* This is the common logic for both the Node.js and web browser
* implementations of `debug()`.
*
* Expose `debug()` as the module.
*/
exports = module.exports = debug;
exports.coerce = coerce;
exports.disable = disable;
exports.enable = enable;
exports.enabled = enabled;
exports.humanize = _dereq_(390);
/**
* The currently active debug mode names, and names to skip.
*/
exports.names = [];
exports.skips = [];
/**
* Map of special "%n" handling functions, for the debug "format" argument.
*
* Valid key names are a single, lowercased letter, i.e. "n".
*/
exports.formatters = {};
/**
* Previously assigned color.
*/
var prevColor = 0;
/**
* Previous log timestamp.
*/
var prevTime;
/**
* Select a color.
*
* @return {Number}
* @api private
*/
function selectColor() {
return exports.colors[prevColor++ % exports.colors.length];
}
/**
* Create a debugger with the given `namespace`.
*
* @param {String} namespace
* @return {Function}
* @api public
*/
function debug(namespace) {
// define the `disabled` version
function disabled() {
}
disabled.enabled = false;
// define the `enabled` version
function enabled() {
var self = enabled;
// set `diff` timestamp
var curr = +new Date();
var ms = curr - (prevTime || curr);
self.diff = ms;
self.prev = prevTime;
self.curr = curr;
prevTime = curr;
// add the `color` if not set
if (null == self.useColors) self.useColors = exports.useColors();
if (null == self.color && self.useColors) self.color = selectColor();
var args = Array.prototype.slice.call(arguments);
args[0] = exports.coerce(args[0]);
if ('string' !== typeof args[0]) {
// anything else let's inspect with %o
args = ['%o'].concat(args);
}
// apply any `formatters` transformations
var index = 0;
args[0] = args[0].replace(/%([a-z%])/g, function(match, format) {
// if we encounter an escaped % then don't increase the array index
if (match === '%%') return match;
index++;
var formatter = exports.formatters[format];
if ('function' === typeof formatter) {
var val = args[index];
match = formatter.call(self, val);
// now we need to remove `args[index]` since it's inlined in the `format`
args.splice(index, 1);
index--;
}
return match;
});
if ('function' === typeof exports.formatArgs) {
args = exports.formatArgs.apply(self, args);
}
var logFn = enabled.log || exports.log || console.log.bind(console);
logFn.apply(self, args);
}
enabled.enabled = true;
var fn = exports.enabled(namespace) ? enabled : disabled;
fn.namespace = namespace;
return fn;
}
/**
* Enables a debug mode by namespaces. This can include modes
* separated by a colon and wildcards.
*
* @param {String} namespaces
* @api public
*/
function enable(namespaces) {
exports.save(namespaces);
var split = (namespaces || '').split(/[\s,]+/);
var len = split.length;
for (var i = 0; i < len; i++) {
if (!split[i]) continue; // ignore empty strings
namespaces = split[i].replace(/\*/g, '.*?');
if (namespaces[0] === '-') {
exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
} else {
exports.names.push(new RegExp('^' + namespaces + '$'));
}
}
}
/**
* Disable debug output.
*
* @api public
*/
function disable() {
exports.enable('');
}
/**
* Returns true if the given mode name is enabled, false otherwise.
*
* @param {String} name
* @return {Boolean}
* @api public
*/
function enabled(name) {
var i, len;
for (i = 0, len = exports.skips.length; i < len; i++) {
if (exports.skips[i].test(name)) {
return false;
}
}
for (i = 0, len = exports.names.length; i < len; i++) {
if (exports.names[i].test(name)) {
return true;
}
}
return false;
}
/**
* Coerce `val`.
*
* @param {Mixed} val
* @return {Mixed}
* @api private
*/
function coerce(val) {
if (val instanceof Error) return val.stack || val.message;
return val;
}
},{"390":390}],389:[function(_dereq_,module,exports){
(function (process){
/**
* Module dependencies.
*/
var tty = _dereq_(11);
var util = _dereq_(13);
/**
* This is the Node.js implementation of `debug()`.
*
* Expose `debug()` as the module.
*/
exports = module.exports = _dereq_(388);
exports.log = log;
exports.formatArgs = formatArgs;
exports.save = save;
exports.load = load;
exports.useColors = useColors;
/**
* Colors.
*/
exports.colors = [6, 2, 3, 4, 5, 1];
/**
* The file descriptor to write the `debug()` calls to.
* Set the `DEBUG_FD` env variable to override with another value. i.e.:
*
* $ DEBUG_FD=3 node script.js 3>debug.log
*/
var fd = parseInt(process.env.DEBUG_FD, 10) || 2;
var stream = 1 === fd ? process.stdout :
2 === fd ? process.stderr :
createWritableStdioStream(fd);
/**
* Is stdout a TTY? Colored output is enabled when `true`.
*/
function useColors() {
var debugColors = (process.env.DEBUG_COLORS || '').trim().toLowerCase();
if (0 === debugColors.length) {
return tty.isatty(fd);
} else {
return '0' !== debugColors
&& 'no' !== debugColors
&& 'false' !== debugColors
&& 'disabled' !== debugColors;
}
}
/**
* Map %o to `util.inspect()`, since Node doesn't do that out of the box.
*/
var inspect = (4 === util.inspect.length ?
// node <= 0.8.x
function (v, colors) {
return util.inspect(v, void 0, void 0, colors);
} :
// node > 0.8.x
function (v, colors) {
return util.inspect(v, { colors: colors });
}
);
exports.formatters.o = function(v) {
return inspect(v, this.useColors)
.replace(/\s*\n\s*/g, ' ');
};
/**
* Adds ANSI color escape codes if enabled.
*
* @api public
*/
function formatArgs() {
var args = arguments;
var useColors = this.useColors;
var name = this.namespace;
if (useColors) {
var c = this.color;
args[0] = ' \u001b[3' + c + ';1m' + name + ' '
+ '\u001b[0m'
+ args[0] + '\u001b[3' + c + 'm'
+ ' +' + exports.humanize(this.diff) + '\u001b[0m';
} else {
args[0] = new Date().toUTCString()
+ ' ' + name + ' ' + args[0];
}
return args;
}
/**
* Invokes `console.error()` with the specified arguments.
*/
function log() {
return stream.write(util.format.apply(this, arguments) + '\n');
}
/**
* Save `namespaces`.
*
* @param {String} namespaces
* @api private
*/
function save(namespaces) {
if (null == namespaces) {
// If you set a process.env field to null or undefined, it gets cast to the
// string 'null' or 'undefined'. Just delete instead.
delete process.env.DEBUG;
} else {
process.env.DEBUG = namespaces;
}
}
/**
* Load `namespaces`.
*
* @return {String} returns the previously persisted debug modes
* @api private
*/
function load() {
return process.env.DEBUG;
}
/**
* Copied from `node/src/node.js`.
*
* XXX: It's lame that node doesn't expose this API out-of-the-box. It also
* relies on the undocumented `tty_wrap.guessHandleType()` which is also lame.
*/
function createWritableStdioStream (fd) {
var stream;
var tty_wrap = process.binding('tty_wrap');
// Note stream._type is used for test-module-load-list.js
switch (tty_wrap.guessHandleType(fd)) {
case 'TTY':
stream = new tty.WriteStream(fd);
stream._type = 'tty';
// Hack to have stream not keep the event loop alive.
// See https://github.com/joyent/node/issues/1726
if (stream._handle && stream._handle.unref) {
stream._handle.unref();
}
break;
case 'FILE':
var fs = _dereq_(1);
stream = new fs.SyncWriteStream(fd, { autoClose: false });
stream._type = 'fs';
break;
case 'PIPE':
case 'TCP':
var net = _dereq_(1);
stream = new net.Socket({
fd: fd,
readable: false,
writable: true
});
// FIXME Should probably have an option in net.Socket to create a
// stream from an existing fd which is writable only. But for now
// we'll just add this hack and set the `readable` member to false.
// Test: ./node test/fixtures/echo.js < /etc/passwd
stream.readable = false;
stream.read = null;
stream._type = 'pipe';
// FIXME Hack to have stream not keep the event loop alive.
// See https://github.com/joyent/node/issues/1726
if (stream._handle && stream._handle.unref) {
stream._handle.unref();
}
break;
default:
// Probably an error on in uv_guess_handle()
throw new Error('Implement me. Unknown stream file type!');
}
// For supporting legacy API we put the FD here.
stream.fd = fd;
stream._isStdio = true;
return stream;
}
/**
* Enable namespaces listed in `process.env.DEBUG` initially.
*/
exports.enable(load());
}).call(this,_dereq_(10))
},{"1":1,"10":10,"11":11,"13":13,"388":388}],390:[function(_dereq_,module,exports){
/**
* Helpers.
*/
var s = 1000;
var m = s * 60;
var h = m * 60;
var d = h * 24;
var y = d * 365.25;
/**
* Parse or format the given `val`.
*
* Options:
*
* - `long` verbose formatting [false]
*
* @param {String|Number} val
* @param {Object} options
* @return {String|Number}
* @api public
*/
module.exports = function(val, options){
options = options || {};
if ('string' == typeof val) return parse(val);
return options.long
? long(val)
: short(val);
};
/**
* Parse the given `str` and return milliseconds.
*
* @param {String} str
* @return {Number}
* @api private
*/
function parse(str) {
str = '' + str;
if (str.length > 10000) return;
var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str);
if (!match) return;
var n = parseFloat(match[1]);
var type = (match[2] || 'ms').toLowerCase();
switch (type) {
case 'years':
case 'year':
case 'yrs':
case 'yr':
case 'y':
return n * y;
case 'days':
case 'day':
case 'd':
return n * d;
case 'hours':
case 'hour':
case 'hrs':
case 'hr':
case 'h':
return n * h;
case 'minutes':
case 'minute':
case 'mins':
case 'min':
case 'm':
return n * m;
case 'seconds':
case 'second':
case 'secs':
case 'sec':
case 's':
return n * s;
case 'milliseconds':
case 'millisecond':
case 'msecs':
case 'msec':
case 'ms':
return n;
}
}
/**
* Short format for `ms`.
*
* @param {Number} ms
* @return {String}
* @api private
*/
function short(ms) {
if (ms >= d) return Math.round(ms / d) + 'd';
if (ms >= h) return Math.round(ms / h) + 'h';
if (ms >= m) return Math.round(ms / m) + 'm';
if (ms >= s) return Math.round(ms / s) + 's';
return ms + 'ms';
}
/**
* Long format for `ms`.
*
* @param {Number} ms
* @return {String}
* @api private
*/
function long(ms) {
return plural(ms, d, 'day')
|| plural(ms, h, 'hour')
|| plural(ms, m, 'minute')
|| plural(ms, s, 'second')
|| ms + ' ms';
}
/**
* Pluralization helper.
*/
function plural(ms, n, name) {
if (ms < n) return;
if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name;
return Math.ceil(ms / n) + ' ' + name + 's';
}
},{}],391:[function(_dereq_,module,exports){
'use strict';
var repeating = _dereq_(584);
// detect either spaces or tabs but not both to properly handle tabs
// for indentation and spaces for alignment
var INDENT_RE = /^(?:( )+|\t+)/;
function getMostUsed(indents) {
var result = 0;
var maxUsed = 0;
var maxWeight = 0;
for (var n in indents) {
var indent = indents[n];
var u = indent[0];
var w = indent[1];
if (u > maxUsed || u === maxUsed && w > maxWeight) {
maxUsed = u;
maxWeight = w;
result = +n;
}
}
return result;
}
module.exports = function (str) {
if (typeof str !== 'string') {
throw new TypeError('Expected a string');
}
// used to see if tabs or spaces are the most used
var tabs = 0;
var spaces = 0;
// remember the size of previous line's indentation
var prev = 0;
// remember how many indents/unindents as occurred for a given size
// and how much lines follow a given indentation
//
// indents = {
// 3: [1, 0],
// 4: [1, 5],
// 5: [1, 0],
// 12: [1, 0],
// }
var indents = {};
// pointer to the array of last used indent
var current;
// whether the last action was an indent (opposed to an unindent)
var isIndent;
str.split(/\n/g).forEach(function (line) {
if (!line) {
// ignore empty lines
return;
}
var indent;
var matches = line.match(INDENT_RE);
if (!matches) {
indent = 0;
} else {
indent = matches[0].length;
if (matches[1]) {
spaces++;
} else {
tabs++;
}
}
var diff = indent - prev;
prev = indent;
if (diff) {
// an indent or unindent has been detected
isIndent = diff > 0;
current = indents[isIndent ? diff : -diff];
if (current) {
current[0]++;
} else {
current = indents[diff] = [1, 0];
}
} else if (current) {
// if the last action was an indent, increment the weight
current[1] += +isIndent;
}
});
var amount = getMostUsed(indents);
var type;
var actual;
if (!amount) {
type = null;
actual = '';
} else if (spaces >= tabs) {
type = 'space';
actual = repeating(' ', amount);
} else {
type = 'tab';
actual = repeating('\t', amount);
}
return {
amount: amount,
type: type,
indent: actual
};
};
},{"584":584}],392:[function(_dereq_,module,exports){
/*
Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
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.
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 <COPYRIGHT HOLDER> 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.
*/
(function () {
'use strict';
function isExpression(node) {
if (node == null) { return false; }
switch (node.type) {
case 'ArrayExpression':
case 'AssignmentExpression':
case 'BinaryExpression':
case 'CallExpression':
case 'ConditionalExpression':
case 'FunctionExpression':
case 'Identifier':
case 'Literal':
case 'LogicalExpression':
case 'MemberExpression':
case 'NewExpression':
case 'ObjectExpression':
case 'SequenceExpression':
case 'ThisExpression':
case 'UnaryExpression':
case 'UpdateExpression':
return true;
}
return false;
}
function isIterationStatement(node) {
if (node == null) { return false; }
switch (node.type) {
case 'DoWhileStatement':
case 'ForInStatement':
case 'ForStatement':
case 'WhileStatement':
return true;
}
return false;
}
function isStatement(node) {
if (node == null) { return false; }
switch (node.type) {
case 'BlockStatement':
case 'BreakStatement':
case 'ContinueStatement':
case 'DebuggerStatement':
case 'DoWhileStatement':
case 'EmptyStatement':
case 'ExpressionStatement':
case 'ForInStatement':
case 'ForStatement':
case 'IfStatement':
case 'LabeledStatement':
case 'ReturnStatement':
case 'SwitchStatement':
case 'ThrowStatement':
case 'TryStatement':
case 'VariableDeclaration':
case 'WhileStatement':
case 'WithStatement':
return true;
}
return false;
}
function isSourceElement(node) {
return isStatement(node) || node != null && node.type === 'FunctionDeclaration';
}
function trailingStatement(node) {
switch (node.type) {
case 'IfStatement':
if (node.alternate != null) {
return node.alternate;
}
return node.consequent;
case 'LabeledStatement':
case 'ForStatement':
case 'ForInStatement':
case 'WhileStatement':
case 'WithStatement':
return node.body;
}
return null;
}
function isProblematicIfStatement(node) {
var current;
if (node.type !== 'IfStatement') {
return false;
}
if (node.alternate == null) {
return false;
}
current = node.consequent;
do {
if (current.type === 'IfStatement') {
if (current.alternate == null) {
return true;
}
}
current = trailingStatement(current);
} while (current);
return false;
}
module.exports = {
isExpression: isExpression,
isStatement: isStatement,
isIterationStatement: isIterationStatement,
isSourceElement: isSourceElement,
isProblematicIfStatement: isProblematicIfStatement,
trailingStatement: trailingStatement
};
}());
/* vim: set sw=4 ts=4 et tw=80 : */
},{}],393:[function(_dereq_,module,exports){
/*
Copyright (C) 2013-2014 Yusuke Suzuki <utatane.tea@gmail.com>
Copyright (C) 2014 Ivan Nikulin <ifaaan@gmail.com>
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.
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 <COPYRIGHT HOLDER> 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.
*/
(function () {
'use strict';
var ES6Regex, ES5Regex, NON_ASCII_WHITESPACES, IDENTIFIER_START, IDENTIFIER_PART, ch;
// See `tools/generate-identifier-regex.js`.
ES5Regex = {
// ECMAScript 5.1/Unicode v7.0.0 NonAsciiIdentifierStart:
NonAsciiIdentifierStart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B2\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\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\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\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-\uAB5F\uAB64\uAB65\uABC0-\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]/,
// ECMAScript 5.1/Unicode v7.0.0 NonAsciiIdentifierPart:
NonAsciiIdentifierPart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B2\u08E4-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D60-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA69D\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2D\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/
};
ES6Regex = {
// ECMAScript 6/Unicode v7.0.0 NonAsciiIdentifierStart:
NonAsciiIdentifierStart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B2\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\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\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-
View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment