3900 lines
106 KiB
JavaScript
3900 lines
106 KiB
JavaScript
(function (global, factory) {
|
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
|
|
typeof define === 'function' && define.amd ? define(factory) :
|
|
(factory());
|
|
}(this, (function () { 'use strict';
|
|
|
|
function unwrapExports (x) {
|
|
return x && x.__esModule ? x['default'] : x;
|
|
}
|
|
|
|
function createCommonjsModule(fn, module) {
|
|
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
}
|
|
|
|
// 7.2.1 RequireObjectCoercible(argument)
|
|
var _defined = function (it) {
|
|
if (it == undefined) throw TypeError("Can't call method on " + it);
|
|
return it;
|
|
};
|
|
|
|
// 7.1.13 ToObject(argument)
|
|
|
|
var _toObject = function (it) {
|
|
return Object(_defined(it));
|
|
};
|
|
|
|
var hasOwnProperty = {}.hasOwnProperty;
|
|
var _has = function (it, key) {
|
|
return hasOwnProperty.call(it, key);
|
|
};
|
|
|
|
var toString$2 = {}.toString;
|
|
|
|
var _cof = function (it) {
|
|
return toString$2.call(it).slice(8, -1);
|
|
};
|
|
|
|
// fallback for non-array-like ES3 and non-enumerable old V8 strings
|
|
|
|
// eslint-disable-next-line no-prototype-builtins
|
|
var _iobject = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
|
|
return _cof(it) == 'String' ? it.split('') : Object(it);
|
|
};
|
|
|
|
// to indexed object, toObject with fallback for non-array-like ES3 strings
|
|
|
|
|
|
var _toIobject = function (it) {
|
|
return _iobject(_defined(it));
|
|
};
|
|
|
|
// 7.1.4 ToInteger
|
|
var ceil = Math.ceil;
|
|
var floor = Math.floor;
|
|
var _toInteger = function (it) {
|
|
return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
|
|
};
|
|
|
|
// 7.1.15 ToLength
|
|
|
|
var min = Math.min;
|
|
var _toLength = function (it) {
|
|
return it > 0 ? min(_toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
|
|
};
|
|
|
|
var max = Math.max;
|
|
var min$1 = Math.min;
|
|
var _toAbsoluteIndex = function (index, length) {
|
|
index = _toInteger(index);
|
|
return index < 0 ? max(index + length, 0) : min$1(index, length);
|
|
};
|
|
|
|
// false -> Array#indexOf
|
|
// true -> Array#includes
|
|
|
|
|
|
|
|
var _arrayIncludes = function (IS_INCLUDES) {
|
|
return function ($this, el, fromIndex) {
|
|
var O = _toIobject($this);
|
|
var length = _toLength(O.length);
|
|
var index = _toAbsoluteIndex(fromIndex, length);
|
|
var value;
|
|
// Array#includes uses SameValueZero equality algorithm
|
|
// eslint-disable-next-line no-self-compare
|
|
if (IS_INCLUDES && el != el) while (length > index) {
|
|
value = O[index++];
|
|
// eslint-disable-next-line no-self-compare
|
|
if (value != value) return true;
|
|
// Array#indexOf ignores holes, Array#includes - not
|
|
} else for (;length > index; index++) if (IS_INCLUDES || index in O) {
|
|
if (O[index] === el) return IS_INCLUDES || index || 0;
|
|
} return !IS_INCLUDES && -1;
|
|
};
|
|
};
|
|
|
|
var _global = createCommonjsModule(function (module) {
|
|
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
|
|
var global = module.exports = typeof window != 'undefined' && window.Math == Math
|
|
? window : typeof self != 'undefined' && self.Math == Math ? self
|
|
// eslint-disable-next-line no-new-func
|
|
: Function('return this')();
|
|
if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef
|
|
});
|
|
|
|
var SHARED = '__core-js_shared__';
|
|
var store = _global[SHARED] || (_global[SHARED] = {});
|
|
var _shared = function (key) {
|
|
return store[key] || (store[key] = {});
|
|
};
|
|
|
|
var id = 0;
|
|
var px = Math.random();
|
|
var _uid = function (key) {
|
|
return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
|
|
};
|
|
|
|
var shared = _shared('keys');
|
|
|
|
var _sharedKey = function (key) {
|
|
return shared[key] || (shared[key] = _uid(key));
|
|
};
|
|
|
|
var arrayIndexOf = _arrayIncludes(false);
|
|
var IE_PROTO = _sharedKey('IE_PROTO');
|
|
|
|
var _objectKeysInternal = function (object, names) {
|
|
var O = _toIobject(object);
|
|
var i = 0;
|
|
var result = [];
|
|
var key;
|
|
for (key in O) if (key != IE_PROTO) _has(O, key) && result.push(key);
|
|
// Don't enum bug & hidden keys
|
|
while (names.length > i) if (_has(O, key = names[i++])) {
|
|
~arrayIndexOf(result, key) || result.push(key);
|
|
}
|
|
return result;
|
|
};
|
|
|
|
// IE 8- don't enum bug keys
|
|
var _enumBugKeys = (
|
|
'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
|
|
).split(',');
|
|
|
|
// 19.1.2.14 / 15.2.3.14 Object.keys(O)
|
|
|
|
|
|
|
|
var _objectKeys = Object.keys || function keys(O) {
|
|
return _objectKeysInternal(O, _enumBugKeys);
|
|
};
|
|
|
|
var _core = createCommonjsModule(function (module) {
|
|
var core = module.exports = { version: '2.5.1' };
|
|
if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef
|
|
});
|
|
|
|
var _aFunction = function (it) {
|
|
if (typeof it != 'function') throw TypeError(it + ' is not a function!');
|
|
return it;
|
|
};
|
|
|
|
// optional / simple context binding
|
|
|
|
var _ctx = 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);
|
|
};
|
|
};
|
|
|
|
var _isObject = function (it) {
|
|
return typeof it === 'object' ? it !== null : typeof it === 'function';
|
|
};
|
|
|
|
var _anObject = function (it) {
|
|
if (!_isObject(it)) throw TypeError(it + ' is not an object!');
|
|
return it;
|
|
};
|
|
|
|
var _fails = function (exec) {
|
|
try {
|
|
return !!exec();
|
|
} catch (e) {
|
|
return true;
|
|
}
|
|
};
|
|
|
|
// Thank's IE8 for his funny defineProperty
|
|
var _descriptors = !_fails(function () {
|
|
return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
|
|
});
|
|
|
|
var document = _global.document;
|
|
// typeof document.createElement is 'object' in old IE
|
|
var is = _isObject(document) && _isObject(document.createElement);
|
|
var _domCreate = function (it) {
|
|
return is ? document.createElement(it) : {};
|
|
};
|
|
|
|
var _ie8DomDefine = !_descriptors && !_fails(function () {
|
|
return Object.defineProperty(_domCreate('div'), 'a', { get: function () { return 7; } }).a != 7;
|
|
});
|
|
|
|
// 7.1.1 ToPrimitive(input [, PreferredType])
|
|
|
|
// instead of the ES6 spec version, we didn't implement @@toPrimitive case
|
|
// and the second argument - flag - preferred type is a string
|
|
var _toPrimitive = function (it, S) {
|
|
if (!_isObject(it)) return it;
|
|
var fn, val;
|
|
if (S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val;
|
|
if (typeof (fn = it.valueOf) == 'function' && !_isObject(val = fn.call(it))) return val;
|
|
if (!S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val;
|
|
throw TypeError("Can't convert object to primitive value");
|
|
};
|
|
|
|
var dP = Object.defineProperty;
|
|
|
|
var f = _descriptors ? Object.defineProperty : function defineProperty(O, P, Attributes) {
|
|
_anObject(O);
|
|
P = _toPrimitive(P, true);
|
|
_anObject(Attributes);
|
|
if (_ie8DomDefine) try {
|
|
return dP(O, P, Attributes);
|
|
} catch (e) { /* empty */ }
|
|
if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
|
|
if ('value' in Attributes) O[P] = Attributes.value;
|
|
return O;
|
|
};
|
|
|
|
var _objectDp = {
|
|
f: f
|
|
};
|
|
|
|
var _propertyDesc = function (bitmap, value) {
|
|
return {
|
|
enumerable: !(bitmap & 1),
|
|
configurable: !(bitmap & 2),
|
|
writable: !(bitmap & 4),
|
|
value: value
|
|
};
|
|
};
|
|
|
|
var _hide = _descriptors ? function (object, key, value) {
|
|
return _objectDp.f(object, key, _propertyDesc(1, value));
|
|
} : function (object, key, value) {
|
|
object[key] = value;
|
|
return object;
|
|
};
|
|
|
|
var PROTOTYPE = 'prototype';
|
|
|
|
var $export = function (type, name, source) {
|
|
var IS_FORCED = type & $export.F;
|
|
var IS_GLOBAL = type & $export.G;
|
|
var IS_STATIC = type & $export.S;
|
|
var IS_PROTO = type & $export.P;
|
|
var IS_BIND = type & $export.B;
|
|
var IS_WRAP = type & $export.W;
|
|
var exports = IS_GLOBAL ? _core : _core[name] || (_core[name] = {});
|
|
var expProto = exports[PROTOTYPE];
|
|
var target = IS_GLOBAL ? _global : IS_STATIC ? _global[name] : (_global[name] || {})[PROTOTYPE];
|
|
var key, own, out;
|
|
if (IS_GLOBAL) source = name;
|
|
for (key in source) {
|
|
// contains in native
|
|
own = !IS_FORCED && target && target[key] !== undefined;
|
|
if (own && key in exports) continue;
|
|
// export native or passed
|
|
out = own ? target[key] : source[key];
|
|
// prevent global pollution for namespaces
|
|
exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key]
|
|
// bind timers to global for call from export context
|
|
: IS_BIND && own ? _ctx(out, _global)
|
|
// wrap global constructors for prevent change them in library
|
|
: IS_WRAP && target[key] == out ? (function (C) {
|
|
var F = function (a, b, c) {
|
|
if (this instanceof C) {
|
|
switch (arguments.length) {
|
|
case 0: return new C();
|
|
case 1: return new C(a);
|
|
case 2: return new C(a, b);
|
|
} return new C(a, b, c);
|
|
} return C.apply(this, arguments);
|
|
};
|
|
F[PROTOTYPE] = C[PROTOTYPE];
|
|
return F;
|
|
// make static versions for prototype methods
|
|
})(out) : IS_PROTO && typeof out == 'function' ? _ctx(Function.call, out) : out;
|
|
// export proto methods to core.%CONSTRUCTOR%.methods.%NAME%
|
|
if (IS_PROTO) {
|
|
(exports.virtual || (exports.virtual = {}))[key] = out;
|
|
// export proto methods to core.%CONSTRUCTOR%.prototype.%NAME%
|
|
if (type & $export.R && expProto && !expProto[key]) _hide(expProto, key, out);
|
|
}
|
|
}
|
|
};
|
|
// type bitmap
|
|
$export.F = 1; // forced
|
|
$export.G = 2; // global
|
|
$export.S = 4; // static
|
|
$export.P = 8; // proto
|
|
$export.B = 16; // bind
|
|
$export.W = 32; // wrap
|
|
$export.U = 64; // safe
|
|
$export.R = 128; // real proto method for `library`
|
|
var _export = $export;
|
|
|
|
// most Object methods by ES6 should accept primitives
|
|
|
|
|
|
|
|
var _objectSap = function (KEY, exec) {
|
|
var fn = (_core.Object || {})[KEY] || Object[KEY];
|
|
var exp = {};
|
|
exp[KEY] = exec(fn);
|
|
_export(_export.S + _export.F * _fails(function () { fn(1); }), 'Object', exp);
|
|
};
|
|
|
|
// 19.1.2.14 Object.keys(O)
|
|
|
|
|
|
|
|
_objectSap('keys', function () {
|
|
return function keys(it) {
|
|
return _objectKeys(_toObject(it));
|
|
};
|
|
});
|
|
|
|
var keys$1 = _core.Object.keys;
|
|
|
|
var keys = createCommonjsModule(function (module) {
|
|
module.exports = { "default": keys$1, __esModule: true };
|
|
});
|
|
|
|
var _Object$keys = unwrapExports(keys);
|
|
|
|
// true -> String#at
|
|
// false -> String#codePointAt
|
|
var _stringAt = function (TO_STRING) {
|
|
return function (that, pos) {
|
|
var s = String(_defined(that));
|
|
var i = _toInteger(pos);
|
|
var l = s.length;
|
|
var 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;
|
|
};
|
|
};
|
|
|
|
var _library = true;
|
|
|
|
var _redefine = _hide;
|
|
|
|
var _iterators = {};
|
|
|
|
var _objectDps = _descriptors ? Object.defineProperties : function defineProperties(O, Properties) {
|
|
_anObject(O);
|
|
var keys = _objectKeys(Properties);
|
|
var length = keys.length;
|
|
var i = 0;
|
|
var P;
|
|
while (length > i) _objectDp.f(O, P = keys[i++], Properties[P]);
|
|
return O;
|
|
};
|
|
|
|
var document$1 = _global.document;
|
|
var _html = document$1 && document$1.documentElement;
|
|
|
|
// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
|
|
|
|
|
|
|
|
var IE_PROTO$1 = _sharedKey('IE_PROTO');
|
|
var Empty = function () { /* empty */ };
|
|
var PROTOTYPE$1 = 'prototype';
|
|
|
|
// Create object with fake `null` prototype: use iframe Object with cleared prototype
|
|
var createDict = function () {
|
|
// Thrash, waste and sodomy: IE GC bug
|
|
var iframe = _domCreate('iframe');
|
|
var i = _enumBugKeys.length;
|
|
var lt = '<';
|
|
var gt = '>';
|
|
var 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(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
|
|
iframeDocument.close();
|
|
createDict = iframeDocument.F;
|
|
while (i--) delete createDict[PROTOTYPE$1][_enumBugKeys[i]];
|
|
return createDict();
|
|
};
|
|
|
|
var _objectCreate = Object.create || function create(O, Properties) {
|
|
var result;
|
|
if (O !== null) {
|
|
Empty[PROTOTYPE$1] = _anObject(O);
|
|
result = new Empty();
|
|
Empty[PROTOTYPE$1] = null;
|
|
// add "__proto__" for Object.getPrototypeOf polyfill
|
|
result[IE_PROTO$1] = O;
|
|
} else result = createDict();
|
|
return Properties === undefined ? result : _objectDps(result, Properties);
|
|
};
|
|
|
|
var _wks = createCommonjsModule(function (module) {
|
|
var store = _shared('wks');
|
|
|
|
var Symbol = _global.Symbol;
|
|
var USE_SYMBOL = typeof Symbol == 'function';
|
|
|
|
var $exports = module.exports = function (name) {
|
|
return store[name] || (store[name] =
|
|
USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : _uid)('Symbol.' + name));
|
|
};
|
|
|
|
$exports.store = store;
|
|
});
|
|
|
|
var def = _objectDp.f;
|
|
|
|
var TAG = _wks('toStringTag');
|
|
|
|
var _setToStringTag = function (it, tag, stat) {
|
|
if (it && !_has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag });
|
|
};
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var IteratorPrototype = {};
|
|
|
|
// 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
|
|
_hide(IteratorPrototype, _wks('iterator'), function () { return this; });
|
|
|
|
var _iterCreate = function (Constructor, NAME, next) {
|
|
Constructor.prototype = _objectCreate(IteratorPrototype, { next: _propertyDesc(1, next) });
|
|
_setToStringTag(Constructor, NAME + ' Iterator');
|
|
};
|
|
|
|
// 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)
|
|
|
|
|
|
var IE_PROTO$2 = _sharedKey('IE_PROTO');
|
|
var ObjectProto = Object.prototype;
|
|
|
|
var _objectGpo = Object.getPrototypeOf || function (O) {
|
|
O = _toObject(O);
|
|
if (_has(O, IE_PROTO$2)) return O[IE_PROTO$2];
|
|
if (typeof O.constructor == 'function' && O instanceof O.constructor) {
|
|
return O.constructor.prototype;
|
|
} return O instanceof Object ? ObjectProto : null;
|
|
};
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var ITERATOR = _wks('iterator');
|
|
var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next`
|
|
var FF_ITERATOR = '@@iterator';
|
|
var KEYS = 'keys';
|
|
var VALUES = 'values';
|
|
|
|
var returnThis = function () { return this; };
|
|
|
|
var _iterDefine = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
|
|
_iterCreate(Constructor, NAME, next);
|
|
var getMethod = function (kind) {
|
|
if (!BUGGY && kind in proto) return proto[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';
|
|
var DEF_VALUES = DEFAULT == VALUES;
|
|
var VALUES_BUG = false;
|
|
var proto = Base.prototype;
|
|
var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
|
|
var $default = $native || getMethod(DEFAULT);
|
|
var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;
|
|
var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;
|
|
var methods, key, IteratorPrototype;
|
|
// Fix native
|
|
if ($anyNative) {
|
|
IteratorPrototype = _objectGpo($anyNative.call(new Base()));
|
|
if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
|
|
// Set @@toStringTag to native iterators
|
|
_setToStringTag(IteratorPrototype, TAG, true);
|
|
// fix for some old engines
|
|
if (!_library && !_has(IteratorPrototype, ITERATOR)) _hide(IteratorPrototype, ITERATOR, returnThis);
|
|
}
|
|
}
|
|
// fix Array#{values, @@iterator}.name in V8 / FF
|
|
if (DEF_VALUES && $native && $native.name !== VALUES) {
|
|
VALUES_BUG = true;
|
|
$default = function values() { return $native.call(this); };
|
|
}
|
|
// Define iterator
|
|
if ((!_library || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {
|
|
_hide(proto, ITERATOR, $default);
|
|
}
|
|
// Plug for library
|
|
_iterators[NAME] = $default;
|
|
_iterators[TAG] = returnThis;
|
|
if (DEFAULT) {
|
|
methods = {
|
|
values: DEF_VALUES ? $default : getMethod(VALUES),
|
|
keys: IS_SET ? $default : getMethod(KEYS),
|
|
entries: $entries
|
|
};
|
|
if (FORCED) for (key in methods) {
|
|
if (!(key in proto)) _redefine(proto, key, methods[key]);
|
|
} else _export(_export.P + _export.F * (BUGGY || VALUES_BUG), NAME, methods);
|
|
}
|
|
return methods;
|
|
};
|
|
|
|
'use strict';
|
|
var $at = _stringAt(true);
|
|
|
|
// 21.1.3.27 String.prototype[@@iterator]()
|
|
_iterDefine(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;
|
|
var index = this._i;
|
|
var point;
|
|
if (index >= O.length) return { value: undefined, done: true };
|
|
point = $at(O, index);
|
|
this._i += point.length;
|
|
return { value: point, done: false };
|
|
});
|
|
|
|
var _addToUnscopables = function () { /* empty */ };
|
|
|
|
var _iterStep = function (done, value) {
|
|
return { value: value, done: !!done };
|
|
};
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
|
|
// 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]()
|
|
var es6_array_iterator = _iterDefine(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;
|
|
var kind = this._k;
|
|
var index = this._i++;
|
|
if (!O || index >= O.length) {
|
|
this._t = undefined;
|
|
return _iterStep(1);
|
|
}
|
|
if (kind == 'keys') return _iterStep(0, index);
|
|
if (kind == 'values') return _iterStep(0, O[index]);
|
|
return _iterStep(0, [index, O[index]]);
|
|
}, 'values');
|
|
|
|
// argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
|
|
_iterators.Arguments = _iterators.Array;
|
|
|
|
_addToUnscopables('keys');
|
|
_addToUnscopables('values');
|
|
_addToUnscopables('entries');
|
|
|
|
var TO_STRING_TAG = _wks('toStringTag');
|
|
|
|
var DOMIterables = ('CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,' +
|
|
'DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,' +
|
|
'MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,' +
|
|
'SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,' +
|
|
'TextTrackList,TouchList').split(',');
|
|
|
|
for (var i = 0; i < DOMIterables.length; i++) {
|
|
var NAME = DOMIterables[i];
|
|
var Collection = _global[NAME];
|
|
var proto = Collection && Collection.prototype;
|
|
if (proto && !proto[TO_STRING_TAG]) _hide(proto, TO_STRING_TAG, NAME);
|
|
_iterators[NAME] = _iterators.Array;
|
|
}
|
|
|
|
var f$1 = _wks;
|
|
|
|
var _wksExt = {
|
|
f: f$1
|
|
};
|
|
|
|
var iterator$2 = _wksExt.f('iterator');
|
|
|
|
var iterator = createCommonjsModule(function (module) {
|
|
module.exports = { "default": iterator$2, __esModule: true };
|
|
});
|
|
|
|
unwrapExports(iterator);
|
|
|
|
var _meta = createCommonjsModule(function (module) {
|
|
var META = _uid('meta');
|
|
|
|
|
|
var setDesc = _objectDp.f;
|
|
var id = 0;
|
|
var isExtensible = Object.isExtensible || function () {
|
|
return true;
|
|
};
|
|
var FREEZE = !_fails(function () {
|
|
return isExtensible(Object.preventExtensions({}));
|
|
});
|
|
var setMeta = function (it) {
|
|
setDesc(it, META, { value: {
|
|
i: 'O' + ++id, // object ID
|
|
w: {} // weak collections IDs
|
|
} });
|
|
};
|
|
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, META)) {
|
|
// can't set metadata to uncaught frozen object
|
|
if (!isExtensible(it)) return 'F';
|
|
// not necessary to add metadata
|
|
if (!create) return 'E';
|
|
// add missing metadata
|
|
setMeta(it);
|
|
// return object ID
|
|
} return it[META].i;
|
|
};
|
|
var getWeak = function (it, create) {
|
|
if (!_has(it, META)) {
|
|
// can't set metadata to uncaught frozen object
|
|
if (!isExtensible(it)) return true;
|
|
// not necessary to add metadata
|
|
if (!create) return false;
|
|
// add missing metadata
|
|
setMeta(it);
|
|
// return hash weak collections IDs
|
|
} return it[META].w;
|
|
};
|
|
// add metadata on freeze-family methods calling
|
|
var onFreeze = function (it) {
|
|
if (FREEZE && meta.NEED && isExtensible(it) && !_has(it, META)) setMeta(it);
|
|
return it;
|
|
};
|
|
var meta = module.exports = {
|
|
KEY: META,
|
|
NEED: false,
|
|
fastKey: fastKey,
|
|
getWeak: getWeak,
|
|
onFreeze: onFreeze
|
|
};
|
|
});
|
|
|
|
var defineProperty = _objectDp.f;
|
|
var _wksDefine = function (name) {
|
|
var $Symbol = _core.Symbol || (_core.Symbol = _library ? {} : _global.Symbol || {});
|
|
if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty($Symbol, name, { value: _wksExt.f(name) });
|
|
};
|
|
|
|
var f$2 = Object.getOwnPropertySymbols;
|
|
|
|
var _objectGops = {
|
|
f: f$2
|
|
};
|
|
|
|
var f$3 = {}.propertyIsEnumerable;
|
|
|
|
var _objectPie = {
|
|
f: f$3
|
|
};
|
|
|
|
// all enumerable object keys, includes symbols
|
|
|
|
|
|
|
|
var _enumKeys = function (it) {
|
|
var result = _objectKeys(it);
|
|
var getSymbols = _objectGops.f;
|
|
if (getSymbols) {
|
|
var symbols = getSymbols(it);
|
|
var isEnum = _objectPie.f;
|
|
var i = 0;
|
|
var key;
|
|
while (symbols.length > i) if (isEnum.call(it, key = symbols[i++])) result.push(key);
|
|
} return result;
|
|
};
|
|
|
|
// 7.2.2 IsArray(argument)
|
|
|
|
var _isArray = Array.isArray || function isArray(arg) {
|
|
return _cof(arg) == 'Array';
|
|
};
|
|
|
|
// 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)
|
|
|
|
var hiddenKeys = _enumBugKeys.concat('length', 'prototype');
|
|
|
|
var f$5 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
|
|
return _objectKeysInternal(O, hiddenKeys);
|
|
};
|
|
|
|
var _objectGopn = {
|
|
f: f$5
|
|
};
|
|
|
|
// fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
|
|
|
|
var gOPN$1 = _objectGopn.f;
|
|
var toString$3 = {}.toString;
|
|
|
|
var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
|
|
? Object.getOwnPropertyNames(window) : [];
|
|
|
|
var getWindowNames = function (it) {
|
|
try {
|
|
return gOPN$1(it);
|
|
} catch (e) {
|
|
return windowNames.slice();
|
|
}
|
|
};
|
|
|
|
var f$4 = function getOwnPropertyNames(it) {
|
|
return windowNames && toString$3.call(it) == '[object Window]' ? getWindowNames(it) : gOPN$1(_toIobject(it));
|
|
};
|
|
|
|
var _objectGopnExt = {
|
|
f: f$4
|
|
};
|
|
|
|
var gOPD$1 = Object.getOwnPropertyDescriptor;
|
|
|
|
var f$6 = _descriptors ? gOPD$1 : function getOwnPropertyDescriptor(O, P) {
|
|
O = _toIobject(O);
|
|
P = _toPrimitive(P, true);
|
|
if (_ie8DomDefine) try {
|
|
return gOPD$1(O, P);
|
|
} catch (e) { /* empty */ }
|
|
if (_has(O, P)) return _propertyDesc(!_objectPie.f.call(O, P), O[P]);
|
|
};
|
|
|
|
var _objectGopd = {
|
|
f: f$6
|
|
};
|
|
|
|
'use strict';
|
|
// ECMAScript 6 symbols shim
|
|
|
|
|
|
|
|
|
|
|
|
var META = _meta.KEY;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var gOPD = _objectGopd.f;
|
|
var dP$1 = _objectDp.f;
|
|
var gOPN = _objectGopnExt.f;
|
|
var $Symbol = _global.Symbol;
|
|
var $JSON = _global.JSON;
|
|
var _stringify = $JSON && $JSON.stringify;
|
|
var PROTOTYPE$2 = 'prototype';
|
|
var HIDDEN = _wks('_hidden');
|
|
var TO_PRIMITIVE = _wks('toPrimitive');
|
|
var isEnum = {}.propertyIsEnumerable;
|
|
var SymbolRegistry = _shared('symbol-registry');
|
|
var AllSymbols = _shared('symbols');
|
|
var OPSymbols = _shared('op-symbols');
|
|
var ObjectProto$1 = Object[PROTOTYPE$2];
|
|
var USE_NATIVE = typeof $Symbol == 'function';
|
|
var QObject = _global.QObject;
|
|
// Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
|
|
var setter = !QObject || !QObject[PROTOTYPE$2] || !QObject[PROTOTYPE$2].findChild;
|
|
|
|
// fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
|
|
var setSymbolDesc = _descriptors && _fails(function () {
|
|
return _objectCreate(dP$1({}, 'a', {
|
|
get: function () { return dP$1(this, 'a', { value: 7 }).a; }
|
|
})).a != 7;
|
|
}) ? function (it, key, D) {
|
|
var protoDesc = gOPD(ObjectProto$1, key);
|
|
if (protoDesc) delete ObjectProto$1[key];
|
|
dP$1(it, key, D);
|
|
if (protoDesc && it !== ObjectProto$1) dP$1(ObjectProto$1, key, protoDesc);
|
|
} : dP$1;
|
|
|
|
var wrap = function (tag) {
|
|
var sym = AllSymbols[tag] = _objectCreate($Symbol[PROTOTYPE$2]);
|
|
sym._k = tag;
|
|
return sym;
|
|
};
|
|
|
|
var isSymbol = USE_NATIVE && typeof $Symbol.iterator == 'symbol' ? function (it) {
|
|
return typeof it == 'symbol';
|
|
} : function (it) {
|
|
return it instanceof $Symbol;
|
|
};
|
|
|
|
var $defineProperty = function defineProperty(it, key, D) {
|
|
if (it === ObjectProto$1) $defineProperty(OPSymbols, key, D);
|
|
_anObject(it);
|
|
key = _toPrimitive(key, true);
|
|
_anObject(D);
|
|
if (_has(AllSymbols, key)) {
|
|
if (!D.enumerable) {
|
|
if (!_has(it, HIDDEN)) dP$1(it, HIDDEN, _propertyDesc(1, {}));
|
|
it[HIDDEN][key] = true;
|
|
} else {
|
|
if (_has(it, HIDDEN) && it[HIDDEN][key]) it[HIDDEN][key] = false;
|
|
D = _objectCreate(D, { enumerable: _propertyDesc(0, false) });
|
|
} return setSymbolDesc(it, key, D);
|
|
} return dP$1(it, key, D);
|
|
};
|
|
var $defineProperties = function defineProperties(it, P) {
|
|
_anObject(it);
|
|
var keys = _enumKeys(P = _toIobject(P));
|
|
var i = 0;
|
|
var l = keys.length;
|
|
var key;
|
|
while (l > i) $defineProperty(it, key = keys[i++], P[key]);
|
|
return it;
|
|
};
|
|
var $create = function create(it, P) {
|
|
return P === undefined ? _objectCreate(it) : $defineProperties(_objectCreate(it), P);
|
|
};
|
|
var $propertyIsEnumerable = function propertyIsEnumerable(key) {
|
|
var E = isEnum.call(this, key = _toPrimitive(key, true));
|
|
if (this === ObjectProto$1 && _has(AllSymbols, key) && !_has(OPSymbols, key)) return false;
|
|
return E || !_has(this, key) || !_has(AllSymbols, key) || _has(this, HIDDEN) && this[HIDDEN][key] ? E : true;
|
|
};
|
|
var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key) {
|
|
it = _toIobject(it);
|
|
key = _toPrimitive(key, true);
|
|
if (it === ObjectProto$1 && _has(AllSymbols, key) && !_has(OPSymbols, key)) return;
|
|
var D = gOPD(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 = gOPN(_toIobject(it));
|
|
var result = [];
|
|
var i = 0;
|
|
var key;
|
|
while (names.length > i) {
|
|
if (!_has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META) result.push(key);
|
|
} return result;
|
|
};
|
|
var $getOwnPropertySymbols = function getOwnPropertySymbols(it) {
|
|
var IS_OP = it === ObjectProto$1;
|
|
var names = gOPN(IS_OP ? OPSymbols : _toIobject(it));
|
|
var result = [];
|
|
var i = 0;
|
|
var key;
|
|
while (names.length > i) {
|
|
if (_has(AllSymbols, key = names[i++]) && (IS_OP ? _has(ObjectProto$1, key) : true)) result.push(AllSymbols[key]);
|
|
} return result;
|
|
};
|
|
|
|
// 19.4.1.1 Symbol([description])
|
|
if (!USE_NATIVE) {
|
|
$Symbol = function Symbol() {
|
|
if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor!');
|
|
var tag = _uid(arguments.length > 0 ? arguments[0] : undefined);
|
|
var $set = function (value) {
|
|
if (this === ObjectProto$1) $set.call(OPSymbols, value);
|
|
if (_has(this, HIDDEN) && _has(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
|
|
setSymbolDesc(this, tag, _propertyDesc(1, value));
|
|
};
|
|
if (_descriptors && setter) setSymbolDesc(ObjectProto$1, tag, { configurable: true, set: $set });
|
|
return wrap(tag);
|
|
};
|
|
_redefine($Symbol[PROTOTYPE$2], 'toString', function toString() {
|
|
return this._k;
|
|
});
|
|
|
|
_objectGopd.f = $getOwnPropertyDescriptor;
|
|
_objectDp.f = $defineProperty;
|
|
_objectGopn.f = _objectGopnExt.f = $getOwnPropertyNames;
|
|
_objectPie.f = $propertyIsEnumerable;
|
|
_objectGops.f = $getOwnPropertySymbols;
|
|
|
|
if (_descriptors && !_library) {
|
|
_redefine(ObjectProto$1, 'propertyIsEnumerable', $propertyIsEnumerable, true);
|
|
}
|
|
|
|
_wksExt.f = function (name) {
|
|
return wrap(_wks(name));
|
|
};
|
|
}
|
|
|
|
_export(_export.G + _export.W + _export.F * !USE_NATIVE, { Symbol: $Symbol });
|
|
|
|
for (var es6Symbols = (
|
|
// 19.4.2.2, 19.4.2.3, 19.4.2.4, 19.4.2.6, 19.4.2.8, 19.4.2.9, 19.4.2.10, 19.4.2.11, 19.4.2.12, 19.4.2.13, 19.4.2.14
|
|
'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables'
|
|
).split(','), j = 0; es6Symbols.length > j;)_wks(es6Symbols[j++]);
|
|
|
|
for (var wellKnownSymbols = _objectKeys(_wks.store), k = 0; wellKnownSymbols.length > k;) _wksDefine(wellKnownSymbols[k++]);
|
|
|
|
_export(_export.S + _export.F * !USE_NATIVE, 'Symbol', {
|
|
// 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(sym) {
|
|
if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol!');
|
|
for (var key in SymbolRegistry) if (SymbolRegistry[key] === sym) return key;
|
|
},
|
|
useSetter: function () { setter = true; },
|
|
useSimple: function () { setter = false; }
|
|
});
|
|
|
|
_export(_export.S + _export.F * !USE_NATIVE, '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
|
|
});
|
|
|
|
// 24.3.2 JSON.stringify(value [, replacer [, space]])
|
|
$JSON && _export(_export.S + _export.F * (!USE_NATIVE || _fails(function () {
|
|
var S = $Symbol();
|
|
// MS Edge converts symbol values to JSON as {}
|
|
// WebKit converts symbol values to JSON as null
|
|
// V8 throws on boxed symbols
|
|
return _stringify([S]) != '[null]' || _stringify({ a: S }) != '{}' || _stringify(Object(S)) != '{}';
|
|
})), 'JSON', {
|
|
stringify: function stringify(it) {
|
|
if (it === undefined || isSymbol(it)) return; // IE8 returns string on undefined
|
|
var args = [it];
|
|
var i = 1;
|
|
var replacer, $replacer;
|
|
while (arguments.length > i) args.push(arguments[i++]);
|
|
replacer = args[1];
|
|
if (typeof replacer == 'function') $replacer = replacer;
|
|
if ($replacer || !_isArray(replacer)) replacer = function (key, value) {
|
|
if ($replacer) value = $replacer.call(this, key, value);
|
|
if (!isSymbol(value)) return value;
|
|
};
|
|
args[1] = replacer;
|
|
return _stringify.apply($JSON, args);
|
|
}
|
|
});
|
|
|
|
// 19.4.3.4 Symbol.prototype[@@toPrimitive](hint)
|
|
$Symbol[PROTOTYPE$2][TO_PRIMITIVE] || _hide($Symbol[PROTOTYPE$2], TO_PRIMITIVE, $Symbol[PROTOTYPE$2].valueOf);
|
|
// 19.4.3.5 Symbol.prototype[@@toStringTag]
|
|
_setToStringTag($Symbol, 'Symbol');
|
|
// 20.2.1.9 Math[@@toStringTag]
|
|
_setToStringTag(Math, 'Math', true);
|
|
// 24.3.3 JSON[@@toStringTag]
|
|
_setToStringTag(_global.JSON, 'JSON', true);
|
|
|
|
_wksDefine('asyncIterator');
|
|
|
|
_wksDefine('observable');
|
|
|
|
var symbol$1 = _core.Symbol;
|
|
|
|
var symbol = createCommonjsModule(function (module) {
|
|
module.exports = { "default": symbol$1, __esModule: true };
|
|
});
|
|
|
|
var _Symbol = unwrapExports(symbol);
|
|
|
|
var _typeof_1 = createCommonjsModule(function (module, exports) {
|
|
"use strict";
|
|
|
|
exports.__esModule = true;
|
|
|
|
|
|
|
|
var _iterator2 = _interopRequireDefault(iterator);
|
|
|
|
|
|
|
|
var _symbol2 = _interopRequireDefault(symbol);
|
|
|
|
var _typeof = typeof _symbol2.default === "function" && typeof _iterator2.default === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj; };
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
exports.default = typeof _symbol2.default === "function" && _typeof(_iterator2.default) === "symbol" ? function (obj) {
|
|
return typeof obj === "undefined" ? "undefined" : _typeof(obj);
|
|
} : function (obj) {
|
|
return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof(obj);
|
|
};
|
|
});
|
|
|
|
var _typeof = unwrapExports(_typeof_1);
|
|
|
|
// 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes)
|
|
_export(_export.S + _export.F * !_descriptors, 'Object', { defineProperty: _objectDp.f });
|
|
|
|
var $Object = _core.Object;
|
|
var defineProperty$2 = function defineProperty(it, key, desc) {
|
|
return $Object.defineProperty(it, key, desc);
|
|
};
|
|
|
|
var defineProperty$1 = createCommonjsModule(function (module) {
|
|
module.exports = { "default": defineProperty$2, __esModule: true };
|
|
});
|
|
|
|
var _Object$defineProperty = unwrapExports(defineProperty$1);
|
|
|
|
// getting tag from 19.1.3.6 Object.prototype.toString()
|
|
|
|
var TAG$1 = _wks('toStringTag');
|
|
// ES3 wrong here
|
|
var ARG = _cof(function () { return arguments; }()) == 'Arguments';
|
|
|
|
// fallback for IE11 Script Access Denied error
|
|
var tryGet = function (it, key) {
|
|
try {
|
|
return it[key];
|
|
} catch (e) { /* empty */ }
|
|
};
|
|
|
|
var _classof = function (it) {
|
|
var O, T, B;
|
|
return it === undefined ? 'Undefined' : it === null ? 'Null'
|
|
// @@toStringTag case
|
|
: typeof (T = tryGet(O = Object(it), TAG$1)) == 'string' ? T
|
|
// builtinTag case
|
|
: ARG ? _cof(O)
|
|
// ES3 arguments fallback
|
|
: (B = _cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
|
|
};
|
|
|
|
var ITERATOR$1 = _wks('iterator');
|
|
|
|
var core_getIteratorMethod = _core.getIteratorMethod = function (it) {
|
|
if (it != undefined) return it[ITERATOR$1]
|
|
|| it['@@iterator']
|
|
|| _iterators[_classof(it)];
|
|
};
|
|
|
|
var core_getIterator = _core.getIterator = function (it) {
|
|
var iterFn = core_getIteratorMethod(it);
|
|
if (typeof iterFn != 'function') throw TypeError(it + ' is not iterable!');
|
|
return _anObject(iterFn.call(it));
|
|
};
|
|
|
|
var getIterator$1 = core_getIterator;
|
|
|
|
var getIterator = createCommonjsModule(function (module) {
|
|
module.exports = { "default": getIterator$1, __esModule: true };
|
|
});
|
|
|
|
var _getIterator = unwrapExports(getIterator);
|
|
|
|
var _redefineAll = function (target, src, safe) {
|
|
for (var key in src) {
|
|
if (safe && target[key]) target[key] = src[key];
|
|
else _hide(target, key, src[key]);
|
|
} return target;
|
|
};
|
|
|
|
var _anInstance = function (it, Constructor, name, forbiddenField) {
|
|
if (!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)) {
|
|
throw TypeError(name + ': incorrect invocation!');
|
|
} return it;
|
|
};
|
|
|
|
// call something on iterator step with safe closing on error
|
|
|
|
var _iterCall = 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;
|
|
}
|
|
};
|
|
|
|
// check on default Array iterator
|
|
|
|
var ITERATOR$2 = _wks('iterator');
|
|
var ArrayProto = Array.prototype;
|
|
|
|
var _isArrayIter = function (it) {
|
|
return it !== undefined && (_iterators.Array === it || ArrayProto[ITERATOR$2] === it);
|
|
};
|
|
|
|
var _forOf = createCommonjsModule(function (module) {
|
|
var BREAK = {};
|
|
var RETURN = {};
|
|
var exports = module.exports = function (iterable, entries, fn, that, ITERATOR) {
|
|
var iterFn = ITERATOR ? function () { return iterable; } : core_getIteratorMethod(iterable);
|
|
var f = _ctx(fn, that, entries ? 2 : 1);
|
|
var index = 0;
|
|
var length, step, iterator, result;
|
|
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++) {
|
|
result = entries ? f(_anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
|
|
if (result === BREAK || result === RETURN) return result;
|
|
} else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) {
|
|
result = _iterCall(iterator, f, step.value, entries);
|
|
if (result === BREAK || result === RETURN) return result;
|
|
}
|
|
};
|
|
exports.BREAK = BREAK;
|
|
exports.RETURN = RETURN;
|
|
});
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
var SPECIES = _wks('species');
|
|
|
|
var _setSpecies = function (KEY) {
|
|
var C = typeof _core[KEY] == 'function' ? _core[KEY] : _global[KEY];
|
|
if (_descriptors && C && !C[SPECIES]) _objectDp.f(C, SPECIES, {
|
|
configurable: true,
|
|
get: function () { return this; }
|
|
});
|
|
};
|
|
|
|
var _validateCollection = function (it, TYPE) {
|
|
if (!_isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!');
|
|
return it;
|
|
};
|
|
|
|
'use strict';
|
|
var dP$2 = _objectDp.f;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var fastKey = _meta.fastKey;
|
|
|
|
var SIZE = _descriptors ? '_s' : 'size';
|
|
|
|
var getEntry = function (that, key) {
|
|
// fast case
|
|
var index = fastKey(key);
|
|
var 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;
|
|
}
|
|
};
|
|
|
|
var _collectionStrong = {
|
|
getConstructor: function (wrapper, NAME, IS_MAP, ADDER) {
|
|
var C = wrapper(function (that, iterable) {
|
|
_anInstance(that, C, NAME, '_i');
|
|
that._t = NAME; // collection type
|
|
that._i = _objectCreate(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);
|
|
});
|
|
_redefineAll(C.prototype, {
|
|
// 23.1.3.1 Map.prototype.clear()
|
|
// 23.2.3.2 Set.prototype.clear()
|
|
clear: function clear() {
|
|
for (var that = _validateCollection(this, NAME), 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 = _validateCollection(this, NAME);
|
|
var entry = getEntry(that, key);
|
|
if (entry) {
|
|
var next = entry.n;
|
|
var 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 */) {
|
|
_validateCollection(this, NAME);
|
|
var f = _ctx(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3);
|
|
var 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(_validateCollection(this, NAME), key);
|
|
}
|
|
});
|
|
if (_descriptors) dP$2(C.prototype, 'size', {
|
|
get: function () {
|
|
return _validateCollection(this, NAME)[SIZE];
|
|
}
|
|
});
|
|
return C;
|
|
},
|
|
def: function (that, key, value) {
|
|
var entry = getEntry(that, key);
|
|
var 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
|
|
_iterDefine(C, NAME, function (iterated, kind) {
|
|
this._t = _validateCollection(iterated, NAME); // target
|
|
this._k = kind; // kind
|
|
this._l = undefined; // previous
|
|
}, function () {
|
|
var that = this;
|
|
var kind = that._k;
|
|
var 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 _iterStep(1);
|
|
}
|
|
// return step by kind
|
|
if (kind == 'keys') return _iterStep(0, entry.k);
|
|
if (kind == 'values') return _iterStep(0, entry.v);
|
|
return _iterStep(0, [entry.k, entry.v]);
|
|
}, IS_MAP ? 'entries' : 'values', !IS_MAP, true);
|
|
|
|
// add [@@species], 23.1.2.2, 23.2.2.2
|
|
_setSpecies(NAME);
|
|
}
|
|
};
|
|
|
|
var SPECIES$1 = _wks('species');
|
|
|
|
var _arraySpeciesConstructor = function (original) {
|
|
var C;
|
|
if (_isArray(original)) {
|
|
C = original.constructor;
|
|
// cross-realm fallback
|
|
if (typeof C == 'function' && (C === Array || _isArray(C.prototype))) C = undefined;
|
|
if (_isObject(C)) {
|
|
C = C[SPECIES$1];
|
|
if (C === null) C = undefined;
|
|
}
|
|
} return C === undefined ? Array : C;
|
|
};
|
|
|
|
// 9.4.2.3 ArraySpeciesCreate(originalArray, length)
|
|
|
|
|
|
var _arraySpeciesCreate = function (original, length) {
|
|
return new (_arraySpeciesConstructor(original))(length);
|
|
};
|
|
|
|
// 0 -> Array#forEach
|
|
// 1 -> Array#map
|
|
// 2 -> Array#filter
|
|
// 3 -> Array#some
|
|
// 4 -> Array#every
|
|
// 5 -> Array#find
|
|
// 6 -> Array#findIndex
|
|
|
|
|
|
|
|
|
|
|
|
var _arrayMethods = function (TYPE, $create) {
|
|
var IS_MAP = TYPE == 1;
|
|
var IS_FILTER = TYPE == 2;
|
|
var IS_SOME = TYPE == 3;
|
|
var IS_EVERY = TYPE == 4;
|
|
var IS_FIND_INDEX = TYPE == 6;
|
|
var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
|
|
var create = $create || _arraySpeciesCreate;
|
|
return function ($this, callbackfn, that) {
|
|
var O = _toObject($this);
|
|
var self = _iobject(O);
|
|
var f = _ctx(callbackfn, that, 3);
|
|
var length = _toLength(self.length);
|
|
var index = 0;
|
|
var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
|
|
var 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;
|
|
};
|
|
};
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var dP$3 = _objectDp.f;
|
|
var each = _arrayMethods(0);
|
|
|
|
|
|
var _collection = function (NAME, wrapper, methods, common, IS_MAP, IS_WEAK) {
|
|
var Base = _global[NAME];
|
|
var C = Base;
|
|
var ADDER = IS_MAP ? 'set' : 'add';
|
|
var proto = C && C.prototype;
|
|
var O = {};
|
|
if (!_descriptors || typeof C != 'function' || !(IS_WEAK || proto.forEach && !_fails(function () {
|
|
new C().entries().next();
|
|
}))) {
|
|
// create collection constructor
|
|
C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER);
|
|
_redefineAll(C.prototype, methods);
|
|
_meta.NEED = true;
|
|
} else {
|
|
C = wrapper(function (target, iterable) {
|
|
_anInstance(target, C, NAME, '_c');
|
|
target._c = new Base();
|
|
if (iterable != undefined) _forOf(iterable, IS_MAP, target[ADDER], target);
|
|
});
|
|
each('add,clear,delete,forEach,get,has,set,keys,values,entries,toJSON'.split(','), function (KEY) {
|
|
var IS_ADDER = KEY == 'add' || KEY == 'set';
|
|
if (KEY in proto && !(IS_WEAK && KEY == 'clear')) _hide(C.prototype, KEY, function (a, b) {
|
|
_anInstance(this, C, KEY);
|
|
if (!IS_ADDER && IS_WEAK && !_isObject(a)) return KEY == 'get' ? undefined : false;
|
|
var result = this._c[KEY](a === 0 ? 0 : a, b);
|
|
return IS_ADDER ? this : result;
|
|
});
|
|
});
|
|
IS_WEAK || dP$3(C.prototype, 'size', {
|
|
get: function () {
|
|
return this._c.size;
|
|
}
|
|
});
|
|
}
|
|
|
|
_setToStringTag(C, NAME);
|
|
|
|
O[NAME] = C;
|
|
_export(_export.G + _export.W + _export.F, O);
|
|
|
|
if (!IS_WEAK) common.setStrong(C, NAME, IS_MAP);
|
|
|
|
return C;
|
|
};
|
|
|
|
'use strict';
|
|
|
|
|
|
var MAP = 'Map';
|
|
|
|
// 23.1 Map Objects
|
|
var es6_map = _collection(MAP, function (get) {
|
|
return function Map() { return get(this, arguments.length > 0 ? arguments[0] : undefined); };
|
|
}, {
|
|
// 23.1.3.6 Map.prototype.get(key)
|
|
get: function get(key) {
|
|
var entry = _collectionStrong.getEntry(_validateCollection(this, MAP), key);
|
|
return entry && entry.v;
|
|
},
|
|
// 23.1.3.9 Map.prototype.set(key, value)
|
|
set: function set(key, value) {
|
|
return _collectionStrong.def(_validateCollection(this, MAP), key === 0 ? 0 : key, value);
|
|
}
|
|
}, _collectionStrong, true);
|
|
|
|
var _arrayFromIterable = function (iter, ITERATOR) {
|
|
var result = [];
|
|
_forOf(iter, false, result.push, result, ITERATOR);
|
|
return result;
|
|
};
|
|
|
|
// https://github.com/DavidBruant/Map-Set.prototype.toJSON
|
|
|
|
|
|
var _collectionToJson = function (NAME) {
|
|
return function toJSON() {
|
|
if (_classof(this) != NAME) throw TypeError(NAME + "#toJSON isn't generic");
|
|
return _arrayFromIterable(this);
|
|
};
|
|
};
|
|
|
|
// https://github.com/DavidBruant/Map-Set.prototype.toJSON
|
|
|
|
|
|
_export(_export.P + _export.R, 'Map', { toJSON: _collectionToJson('Map') });
|
|
|
|
'use strict';
|
|
// https://tc39.github.io/proposal-setmap-offrom/
|
|
|
|
|
|
var _setCollectionOf = function (COLLECTION) {
|
|
_export(_export.S, COLLECTION, { of: function of() {
|
|
var length = arguments.length;
|
|
var A = Array(length);
|
|
while (length--) A[length] = arguments[length];
|
|
return new this(A);
|
|
} });
|
|
};
|
|
|
|
// https://tc39.github.io/proposal-setmap-offrom/#sec-map.of
|
|
_setCollectionOf('Map');
|
|
|
|
'use strict';
|
|
// https://tc39.github.io/proposal-setmap-offrom/
|
|
|
|
|
|
|
|
|
|
|
|
var _setCollectionFrom = function (COLLECTION) {
|
|
_export(_export.S, COLLECTION, { from: function from(source /* , mapFn, thisArg */) {
|
|
var mapFn = arguments[1];
|
|
var mapping, A, n, cb;
|
|
_aFunction(this);
|
|
mapping = mapFn !== undefined;
|
|
if (mapping) _aFunction(mapFn);
|
|
if (source == undefined) return new this();
|
|
A = [];
|
|
if (mapping) {
|
|
n = 0;
|
|
cb = _ctx(mapFn, arguments[2], 2);
|
|
_forOf(source, false, function (nextItem) {
|
|
A.push(cb(nextItem, n++));
|
|
});
|
|
} else {
|
|
_forOf(source, false, A.push, A);
|
|
}
|
|
return new this(A);
|
|
} });
|
|
};
|
|
|
|
// https://tc39.github.io/proposal-setmap-offrom/#sec-map.from
|
|
_setCollectionFrom('Map');
|
|
|
|
var map$1 = _core.Map;
|
|
|
|
var map = createCommonjsModule(function (module) {
|
|
module.exports = { "default": map$1, __esModule: true };
|
|
});
|
|
|
|
var _Map = unwrapExports(map);
|
|
|
|
'use strict';
|
|
|
|
var colorName = {
|
|
"aliceblue": [240, 248, 255],
|
|
"antiquewhite": [250, 235, 215],
|
|
"aqua": [0, 255, 255],
|
|
"aquamarine": [127, 255, 212],
|
|
"azure": [240, 255, 255],
|
|
"beige": [245, 245, 220],
|
|
"bisque": [255, 228, 196],
|
|
"black": [0, 0, 0],
|
|
"blanchedalmond": [255, 235, 205],
|
|
"blue": [0, 0, 255],
|
|
"blueviolet": [138, 43, 226],
|
|
"brown": [165, 42, 42],
|
|
"burlywood": [222, 184, 135],
|
|
"cadetblue": [95, 158, 160],
|
|
"chartreuse": [127, 255, 0],
|
|
"chocolate": [210, 105, 30],
|
|
"coral": [255, 127, 80],
|
|
"cornflowerblue": [100, 149, 237],
|
|
"cornsilk": [255, 248, 220],
|
|
"crimson": [220, 20, 60],
|
|
"cyan": [0, 255, 255],
|
|
"darkblue": [0, 0, 139],
|
|
"darkcyan": [0, 139, 139],
|
|
"darkgoldenrod": [184, 134, 11],
|
|
"darkgray": [169, 169, 169],
|
|
"darkgreen": [0, 100, 0],
|
|
"darkgrey": [169, 169, 169],
|
|
"darkkhaki": [189, 183, 107],
|
|
"darkmagenta": [139, 0, 139],
|
|
"darkolivegreen": [85, 107, 47],
|
|
"darkorange": [255, 140, 0],
|
|
"darkorchid": [153, 50, 204],
|
|
"darkred": [139, 0, 0],
|
|
"darksalmon": [233, 150, 122],
|
|
"darkseagreen": [143, 188, 143],
|
|
"darkslateblue": [72, 61, 139],
|
|
"darkslategray": [47, 79, 79],
|
|
"darkslategrey": [47, 79, 79],
|
|
"darkturquoise": [0, 206, 209],
|
|
"darkviolet": [148, 0, 211],
|
|
"deeppink": [255, 20, 147],
|
|
"deepskyblue": [0, 191, 255],
|
|
"dimgray": [105, 105, 105],
|
|
"dimgrey": [105, 105, 105],
|
|
"dodgerblue": [30, 144, 255],
|
|
"firebrick": [178, 34, 34],
|
|
"floralwhite": [255, 250, 240],
|
|
"forestgreen": [34, 139, 34],
|
|
"fuchsia": [255, 0, 255],
|
|
"gainsboro": [220, 220, 220],
|
|
"ghostwhite": [248, 248, 255],
|
|
"gold": [255, 215, 0],
|
|
"goldenrod": [218, 165, 32],
|
|
"gray": [128, 128, 128],
|
|
"green": [0, 128, 0],
|
|
"greenyellow": [173, 255, 47],
|
|
"grey": [128, 128, 128],
|
|
"honeydew": [240, 255, 240],
|
|
"hotpink": [255, 105, 180],
|
|
"indianred": [205, 92, 92],
|
|
"indigo": [75, 0, 130],
|
|
"ivory": [255, 255, 240],
|
|
"khaki": [240, 230, 140],
|
|
"lavender": [230, 230, 250],
|
|
"lavenderblush": [255, 240, 245],
|
|
"lawngreen": [124, 252, 0],
|
|
"lemonchiffon": [255, 250, 205],
|
|
"lightblue": [173, 216, 230],
|
|
"lightcoral": [240, 128, 128],
|
|
"lightcyan": [224, 255, 255],
|
|
"lightgoldenrodyellow": [250, 250, 210],
|
|
"lightgray": [211, 211, 211],
|
|
"lightgreen": [144, 238, 144],
|
|
"lightgrey": [211, 211, 211],
|
|
"lightpink": [255, 182, 193],
|
|
"lightsalmon": [255, 160, 122],
|
|
"lightseagreen": [32, 178, 170],
|
|
"lightskyblue": [135, 206, 250],
|
|
"lightslategray": [119, 136, 153],
|
|
"lightslategrey": [119, 136, 153],
|
|
"lightsteelblue": [176, 196, 222],
|
|
"lightyellow": [255, 255, 224],
|
|
"lime": [0, 255, 0],
|
|
"limegreen": [50, 205, 50],
|
|
"linen": [250, 240, 230],
|
|
"magenta": [255, 0, 255],
|
|
"maroon": [128, 0, 0],
|
|
"mediumaquamarine": [102, 205, 170],
|
|
"mediumblue": [0, 0, 205],
|
|
"mediumorchid": [186, 85, 211],
|
|
"mediumpurple": [147, 112, 219],
|
|
"mediumseagreen": [60, 179, 113],
|
|
"mediumslateblue": [123, 104, 238],
|
|
"mediumspringgreen": [0, 250, 154],
|
|
"mediumturquoise": [72, 209, 204],
|
|
"mediumvioletred": [199, 21, 133],
|
|
"midnightblue": [25, 25, 112],
|
|
"mintcream": [245, 255, 250],
|
|
"mistyrose": [255, 228, 225],
|
|
"moccasin": [255, 228, 181],
|
|
"navajowhite": [255, 222, 173],
|
|
"navy": [0, 0, 128],
|
|
"oldlace": [253, 245, 230],
|
|
"olive": [128, 128, 0],
|
|
"olivedrab": [107, 142, 35],
|
|
"orange": [255, 165, 0],
|
|
"orangered": [255, 69, 0],
|
|
"orchid": [218, 112, 214],
|
|
"palegoldenrod": [238, 232, 170],
|
|
"palegreen": [152, 251, 152],
|
|
"paleturquoise": [175, 238, 238],
|
|
"palevioletred": [219, 112, 147],
|
|
"papayawhip": [255, 239, 213],
|
|
"peachpuff": [255, 218, 185],
|
|
"peru": [205, 133, 63],
|
|
"pink": [255, 192, 203],
|
|
"plum": [221, 160, 221],
|
|
"powderblue": [176, 224, 230],
|
|
"purple": [128, 0, 128],
|
|
"rebeccapurple": [102, 51, 153],
|
|
"red": [255, 0, 0],
|
|
"rosybrown": [188, 143, 143],
|
|
"royalblue": [65, 105, 225],
|
|
"saddlebrown": [139, 69, 19],
|
|
"salmon": [250, 128, 114],
|
|
"sandybrown": [244, 164, 96],
|
|
"seagreen": [46, 139, 87],
|
|
"seashell": [255, 245, 238],
|
|
"sienna": [160, 82, 45],
|
|
"silver": [192, 192, 192],
|
|
"skyblue": [135, 206, 235],
|
|
"slateblue": [106, 90, 205],
|
|
"slategray": [112, 128, 144],
|
|
"slategrey": [112, 128, 144],
|
|
"snow": [255, 250, 250],
|
|
"springgreen": [0, 255, 127],
|
|
"steelblue": [70, 130, 180],
|
|
"tan": [210, 180, 140],
|
|
"teal": [0, 128, 128],
|
|
"thistle": [216, 191, 216],
|
|
"tomato": [255, 99, 71],
|
|
"turquoise": [64, 224, 208],
|
|
"violet": [238, 130, 238],
|
|
"wheat": [245, 222, 179],
|
|
"white": [255, 255, 255],
|
|
"whitesmoke": [245, 245, 245],
|
|
"yellow": [255, 255, 0],
|
|
"yellowgreen": [154, 205, 50]
|
|
};
|
|
|
|
var conversions = createCommonjsModule(function (module) {
|
|
/* MIT license */
|
|
|
|
|
|
// NOTE: conversions should only return primitive values (i.e. arrays, or
|
|
// values that give correct `typeof` results).
|
|
// do not use box values types (i.e. Number(), String(), etc.)
|
|
|
|
var reverseKeywords = {};
|
|
for (var key in colorName) {
|
|
if (colorName.hasOwnProperty(key)) {
|
|
reverseKeywords[colorName[key]] = key;
|
|
}
|
|
}
|
|
|
|
var convert = module.exports = {
|
|
rgb: {channels: 3, labels: 'rgb'},
|
|
hsl: {channels: 3, labels: 'hsl'},
|
|
hsv: {channels: 3, labels: 'hsv'},
|
|
hwb: {channels: 3, labels: 'hwb'},
|
|
cmyk: {channels: 4, labels: 'cmyk'},
|
|
xyz: {channels: 3, labels: 'xyz'},
|
|
lab: {channels: 3, labels: 'lab'},
|
|
lch: {channels: 3, labels: 'lch'},
|
|
hex: {channels: 1, labels: ['hex']},
|
|
keyword: {channels: 1, labels: ['keyword']},
|
|
ansi16: {channels: 1, labels: ['ansi16']},
|
|
ansi256: {channels: 1, labels: ['ansi256']},
|
|
hcg: {channels: 3, labels: ['h', 'c', 'g']},
|
|
apple: {channels: 3, labels: ['r16', 'g16', 'b16']},
|
|
gray: {channels: 1, labels: ['gray']}
|
|
};
|
|
|
|
// hide .channels and .labels properties
|
|
for (var model in convert) {
|
|
if (convert.hasOwnProperty(model)) {
|
|
if (!('channels' in convert[model])) {
|
|
throw new Error('missing channels property: ' + model);
|
|
}
|
|
|
|
if (!('labels' in convert[model])) {
|
|
throw new Error('missing channel labels property: ' + model);
|
|
}
|
|
|
|
if (convert[model].labels.length !== convert[model].channels) {
|
|
throw new Error('channel and label counts mismatch: ' + model);
|
|
}
|
|
|
|
var channels = convert[model].channels;
|
|
var labels = convert[model].labels;
|
|
delete convert[model].channels;
|
|
delete convert[model].labels;
|
|
Object.defineProperty(convert[model], 'channels', {value: channels});
|
|
Object.defineProperty(convert[model], 'labels', {value: labels});
|
|
}
|
|
}
|
|
|
|
convert.rgb.hsl = function (rgb) {
|
|
var r = rgb[0] / 255;
|
|
var g = rgb[1] / 255;
|
|
var b = rgb[2] / 255;
|
|
var min = Math.min(r, g, b);
|
|
var max = Math.max(r, g, b);
|
|
var delta = max - min;
|
|
var h;
|
|
var s;
|
|
var l;
|
|
|
|
if (max === min) {
|
|
h = 0;
|
|
} else if (r === max) {
|
|
h = (g - b) / delta;
|
|
} else if (g === max) {
|
|
h = 2 + (b - r) / delta;
|
|
} else if (b === max) {
|
|
h = 4 + (r - g) / delta;
|
|
}
|
|
|
|
h = Math.min(h * 60, 360);
|
|
|
|
if (h < 0) {
|
|
h += 360;
|
|
}
|
|
|
|
l = (min + max) / 2;
|
|
|
|
if (max === min) {
|
|
s = 0;
|
|
} else if (l <= 0.5) {
|
|
s = delta / (max + min);
|
|
} else {
|
|
s = delta / (2 - max - min);
|
|
}
|
|
|
|
return [h, s * 100, l * 100];
|
|
};
|
|
|
|
convert.rgb.hsv = function (rgb) {
|
|
var r = rgb[0];
|
|
var g = rgb[1];
|
|
var b = rgb[2];
|
|
var min = Math.min(r, g, b);
|
|
var max = Math.max(r, g, b);
|
|
var delta = max - min;
|
|
var h;
|
|
var s;
|
|
var v;
|
|
|
|
if (max === 0) {
|
|
s = 0;
|
|
} else {
|
|
s = (delta / max * 1000) / 10;
|
|
}
|
|
|
|
if (max === min) {
|
|
h = 0;
|
|
} else if (r === max) {
|
|
h = (g - b) / delta;
|
|
} else if (g === max) {
|
|
h = 2 + (b - r) / delta;
|
|
} else if (b === max) {
|
|
h = 4 + (r - g) / delta;
|
|
}
|
|
|
|
h = Math.min(h * 60, 360);
|
|
|
|
if (h < 0) {
|
|
h += 360;
|
|
}
|
|
|
|
v = ((max / 255) * 1000) / 10;
|
|
|
|
return [h, s, v];
|
|
};
|
|
|
|
convert.rgb.hwb = function (rgb) {
|
|
var r = rgb[0];
|
|
var g = rgb[1];
|
|
var b = rgb[2];
|
|
var h = convert.rgb.hsl(rgb)[0];
|
|
var w = 1 / 255 * Math.min(r, Math.min(g, b));
|
|
|
|
b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
|
|
|
|
return [h, w * 100, b * 100];
|
|
};
|
|
|
|
convert.rgb.cmyk = function (rgb) {
|
|
var r = rgb[0] / 255;
|
|
var g = rgb[1] / 255;
|
|
var b = rgb[2] / 255;
|
|
var c;
|
|
var m;
|
|
var y;
|
|
var k;
|
|
|
|
k = Math.min(1 - r, 1 - g, 1 - b);
|
|
c = (1 - r - k) / (1 - k) || 0;
|
|
m = (1 - g - k) / (1 - k) || 0;
|
|
y = (1 - b - k) / (1 - k) || 0;
|
|
|
|
return [c * 100, m * 100, y * 100, k * 100];
|
|
};
|
|
|
|
/**
|
|
* See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
|
* */
|
|
function comparativeDistance(x, y) {
|
|
return (
|
|
Math.pow(x[0] - y[0], 2) +
|
|
Math.pow(x[1] - y[1], 2) +
|
|
Math.pow(x[2] - y[2], 2)
|
|
);
|
|
}
|
|
|
|
convert.rgb.keyword = function (rgb) {
|
|
var reversed = reverseKeywords[rgb];
|
|
if (reversed) {
|
|
return reversed;
|
|
}
|
|
|
|
var currentClosestDistance = Infinity;
|
|
var currentClosestKeyword;
|
|
|
|
for (var keyword in colorName) {
|
|
if (colorName.hasOwnProperty(keyword)) {
|
|
var value = colorName[keyword];
|
|
|
|
// Compute comparative distance
|
|
var distance = comparativeDistance(rgb, value);
|
|
|
|
// Check if its less, if so set as closest
|
|
if (distance < currentClosestDistance) {
|
|
currentClosestDistance = distance;
|
|
currentClosestKeyword = keyword;
|
|
}
|
|
}
|
|
}
|
|
|
|
return currentClosestKeyword;
|
|
};
|
|
|
|
convert.keyword.rgb = function (keyword) {
|
|
return colorName[keyword];
|
|
};
|
|
|
|
convert.rgb.xyz = function (rgb) {
|
|
var r = rgb[0] / 255;
|
|
var g = rgb[1] / 255;
|
|
var b = rgb[2] / 255;
|
|
|
|
// assume sRGB
|
|
r = r > 0.04045 ? Math.pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92);
|
|
g = g > 0.04045 ? Math.pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92);
|
|
b = b > 0.04045 ? Math.pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92);
|
|
|
|
var x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);
|
|
var y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);
|
|
var z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);
|
|
|
|
return [x * 100, y * 100, z * 100];
|
|
};
|
|
|
|
convert.rgb.lab = function (rgb) {
|
|
var xyz = convert.rgb.xyz(rgb);
|
|
var x = xyz[0];
|
|
var y = xyz[1];
|
|
var z = xyz[2];
|
|
var l;
|
|
var a;
|
|
var b;
|
|
|
|
x /= 95.047;
|
|
y /= 100;
|
|
z /= 108.883;
|
|
|
|
x = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116);
|
|
y = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116);
|
|
z = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116);
|
|
|
|
l = (116 * y) - 16;
|
|
a = 500 * (x - y);
|
|
b = 200 * (y - z);
|
|
|
|
return [l, a, b];
|
|
};
|
|
|
|
convert.hsl.rgb = function (hsl) {
|
|
var h = hsl[0] / 360;
|
|
var s = hsl[1] / 100;
|
|
var l = hsl[2] / 100;
|
|
var t1;
|
|
var t2;
|
|
var t3;
|
|
var rgb;
|
|
var val;
|
|
|
|
if (s === 0) {
|
|
val = l * 255;
|
|
return [val, val, val];
|
|
}
|
|
|
|
if (l < 0.5) {
|
|
t2 = l * (1 + s);
|
|
} else {
|
|
t2 = l + s - l * s;
|
|
}
|
|
|
|
t1 = 2 * l - t2;
|
|
|
|
rgb = [0, 0, 0];
|
|
for (var i = 0; i < 3; i++) {
|
|
t3 = h + 1 / 3 * -(i - 1);
|
|
if (t3 < 0) {
|
|
t3++;
|
|
}
|
|
if (t3 > 1) {
|
|
t3--;
|
|
}
|
|
|
|
if (6 * t3 < 1) {
|
|
val = t1 + (t2 - t1) * 6 * t3;
|
|
} else if (2 * t3 < 1) {
|
|
val = t2;
|
|
} else if (3 * t3 < 2) {
|
|
val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
|
|
} else {
|
|
val = t1;
|
|
}
|
|
|
|
rgb[i] = val * 255;
|
|
}
|
|
|
|
return rgb;
|
|
};
|
|
|
|
convert.hsl.hsv = function (hsl) {
|
|
var h = hsl[0];
|
|
var s = hsl[1] / 100;
|
|
var l = hsl[2] / 100;
|
|
var smin = s;
|
|
var lmin = Math.max(l, 0.01);
|
|
var sv;
|
|
var v;
|
|
|
|
l *= 2;
|
|
s *= (l <= 1) ? l : 2 - l;
|
|
smin *= lmin <= 1 ? lmin : 2 - lmin;
|
|
v = (l + s) / 2;
|
|
sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s);
|
|
|
|
return [h, sv * 100, v * 100];
|
|
};
|
|
|
|
convert.hsv.rgb = function (hsv) {
|
|
var h = hsv[0] / 60;
|
|
var s = hsv[1] / 100;
|
|
var v = hsv[2] / 100;
|
|
var hi = Math.floor(h) % 6;
|
|
|
|
var f = h - Math.floor(h);
|
|
var p = 255 * v * (1 - s);
|
|
var q = 255 * v * (1 - (s * f));
|
|
var t = 255 * v * (1 - (s * (1 - f)));
|
|
v *= 255;
|
|
|
|
switch (hi) {
|
|
case 0:
|
|
return [v, t, p];
|
|
case 1:
|
|
return [q, v, p];
|
|
case 2:
|
|
return [p, v, t];
|
|
case 3:
|
|
return [p, q, v];
|
|
case 4:
|
|
return [t, p, v];
|
|
case 5:
|
|
return [v, p, q];
|
|
}
|
|
};
|
|
|
|
convert.hsv.hsl = function (hsv) {
|
|
var h = hsv[0];
|
|
var s = hsv[1] / 100;
|
|
var v = hsv[2] / 100;
|
|
var vmin = Math.max(v, 0.01);
|
|
var lmin;
|
|
var sl;
|
|
var l;
|
|
|
|
l = (2 - s) * v;
|
|
lmin = (2 - s) * vmin;
|
|
sl = s * vmin;
|
|
sl /= (lmin <= 1) ? lmin : 2 - lmin;
|
|
sl = sl || 0;
|
|
l /= 2;
|
|
|
|
return [h, sl * 100, l * 100];
|
|
};
|
|
|
|
// http://dev.w3.org/csswg/css-color/#hwb-to-rgb
|
|
convert.hwb.rgb = function (hwb) {
|
|
var h = hwb[0] / 360;
|
|
var wh = hwb[1] / 100;
|
|
var bl = hwb[2] / 100;
|
|
var ratio = wh + bl;
|
|
var i;
|
|
var v;
|
|
var f;
|
|
var n;
|
|
|
|
// wh + bl cant be > 1
|
|
if (ratio > 1) {
|
|
wh /= ratio;
|
|
bl /= ratio;
|
|
}
|
|
|
|
i = Math.floor(6 * h);
|
|
v = 1 - bl;
|
|
f = 6 * h - i;
|
|
|
|
if ((i & 0x01) !== 0) {
|
|
f = 1 - f;
|
|
}
|
|
|
|
n = wh + f * (v - wh); // linear interpolation
|
|
|
|
var r;
|
|
var g;
|
|
var b;
|
|
switch (i) {
|
|
default:
|
|
case 6:
|
|
case 0: r = v; g = n; b = wh; break;
|
|
case 1: r = n; g = v; b = wh; break;
|
|
case 2: r = wh; g = v; b = n; break;
|
|
case 3: r = wh; g = n; b = v; break;
|
|
case 4: r = n; g = wh; b = v; break;
|
|
case 5: r = v; g = wh; b = n; break;
|
|
}
|
|
|
|
return [r * 255, g * 255, b * 255];
|
|
};
|
|
|
|
convert.cmyk.rgb = function (cmyk) {
|
|
var c = cmyk[0] / 100;
|
|
var m = cmyk[1] / 100;
|
|
var y = cmyk[2] / 100;
|
|
var k = cmyk[3] / 100;
|
|
var r;
|
|
var g;
|
|
var b;
|
|
|
|
r = 1 - Math.min(1, c * (1 - k) + k);
|
|
g = 1 - Math.min(1, m * (1 - k) + k);
|
|
b = 1 - Math.min(1, y * (1 - k) + k);
|
|
|
|
return [r * 255, g * 255, b * 255];
|
|
};
|
|
|
|
convert.xyz.rgb = function (xyz) {
|
|
var x = xyz[0] / 100;
|
|
var y = xyz[1] / 100;
|
|
var z = xyz[2] / 100;
|
|
var r;
|
|
var g;
|
|
var b;
|
|
|
|
r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);
|
|
g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);
|
|
b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);
|
|
|
|
// assume sRGB
|
|
r = r > 0.0031308
|
|
? ((1.055 * Math.pow(r, 1.0 / 2.4)) - 0.055)
|
|
: r * 12.92;
|
|
|
|
g = g > 0.0031308
|
|
? ((1.055 * Math.pow(g, 1.0 / 2.4)) - 0.055)
|
|
: g * 12.92;
|
|
|
|
b = b > 0.0031308
|
|
? ((1.055 * Math.pow(b, 1.0 / 2.4)) - 0.055)
|
|
: b * 12.92;
|
|
|
|
r = Math.min(Math.max(0, r), 1);
|
|
g = Math.min(Math.max(0, g), 1);
|
|
b = Math.min(Math.max(0, b), 1);
|
|
|
|
return [r * 255, g * 255, b * 255];
|
|
};
|
|
|
|
convert.xyz.lab = function (xyz) {
|
|
var x = xyz[0];
|
|
var y = xyz[1];
|
|
var z = xyz[2];
|
|
var l;
|
|
var a;
|
|
var b;
|
|
|
|
x /= 95.047;
|
|
y /= 100;
|
|
z /= 108.883;
|
|
|
|
x = x > 0.008856 ? Math.pow(x, 1 / 3) : (7.787 * x) + (16 / 116);
|
|
y = y > 0.008856 ? Math.pow(y, 1 / 3) : (7.787 * y) + (16 / 116);
|
|
z = z > 0.008856 ? Math.pow(z, 1 / 3) : (7.787 * z) + (16 / 116);
|
|
|
|
l = (116 * y) - 16;
|
|
a = 500 * (x - y);
|
|
b = 200 * (y - z);
|
|
|
|
return [l, a, b];
|
|
};
|
|
|
|
convert.lab.xyz = function (lab) {
|
|
var l = lab[0];
|
|
var a = lab[1];
|
|
var b = lab[2];
|
|
var x;
|
|
var y;
|
|
var z;
|
|
|
|
y = (l + 16) / 116;
|
|
x = a / 500 + y;
|
|
z = y - b / 200;
|
|
|
|
var y2 = Math.pow(y, 3);
|
|
var x2 = Math.pow(x, 3);
|
|
var z2 = Math.pow(z, 3);
|
|
y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
|
|
x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
|
|
z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
|
|
|
|
x *= 95.047;
|
|
y *= 100;
|
|
z *= 108.883;
|
|
|
|
return [x, y, z];
|
|
};
|
|
|
|
convert.lab.lch = function (lab) {
|
|
var l = lab[0];
|
|
var a = lab[1];
|
|
var b = lab[2];
|
|
var hr;
|
|
var h;
|
|
var c;
|
|
|
|
hr = Math.atan2(b, a);
|
|
h = hr * 360 / 2 / Math.PI;
|
|
|
|
if (h < 0) {
|
|
h += 360;
|
|
}
|
|
|
|
c = Math.sqrt(a * a + b * b);
|
|
|
|
return [l, c, h];
|
|
};
|
|
|
|
convert.lch.lab = function (lch) {
|
|
var l = lch[0];
|
|
var c = lch[1];
|
|
var h = lch[2];
|
|
var a;
|
|
var b;
|
|
var hr;
|
|
|
|
hr = h / 360 * 2 * Math.PI;
|
|
a = c * Math.cos(hr);
|
|
b = c * Math.sin(hr);
|
|
|
|
return [l, a, b];
|
|
};
|
|
|
|
convert.rgb.ansi16 = function (args) {
|
|
var r = args[0];
|
|
var g = args[1];
|
|
var b = args[2];
|
|
var value = 1 in arguments ? arguments[1] : convert.rgb.hsv(args)[2]; // hsv -> ansi16 optimization
|
|
|
|
value = Math.round(value / 50);
|
|
|
|
if (value === 0) {
|
|
return 30;
|
|
}
|
|
|
|
var ansi = 30
|
|
+ ((Math.round(b / 255) << 2)
|
|
| (Math.round(g / 255) << 1)
|
|
| Math.round(r / 255));
|
|
|
|
if (value === 2) {
|
|
ansi += 60;
|
|
}
|
|
|
|
return ansi;
|
|
};
|
|
|
|
convert.hsv.ansi16 = function (args) {
|
|
// optimization here; we already know the value and don't need to get
|
|
// it converted for us.
|
|
return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
|
|
};
|
|
|
|
convert.rgb.ansi256 = function (args) {
|
|
var r = args[0];
|
|
var g = args[1];
|
|
var b = args[2];
|
|
|
|
// we use the extended greyscale palette here, with the exception of
|
|
// black and white. normal palette only has 4 greyscale shades.
|
|
if (r === g && g === b) {
|
|
if (r < 8) {
|
|
return 16;
|
|
}
|
|
|
|
if (r > 248) {
|
|
return 231;
|
|
}
|
|
|
|
return Math.round(((r - 8) / 247) * 24) + 232;
|
|
}
|
|
|
|
var ansi = 16
|
|
+ (36 * Math.round(r / 255 * 5))
|
|
+ (6 * Math.round(g / 255 * 5))
|
|
+ Math.round(b / 255 * 5);
|
|
|
|
return ansi;
|
|
};
|
|
|
|
convert.ansi16.rgb = function (args) {
|
|
var color = args % 10;
|
|
|
|
// handle greyscale
|
|
if (color === 0 || color === 7) {
|
|
if (args > 50) {
|
|
color += 3.5;
|
|
}
|
|
|
|
color = color / 10.5 * 255;
|
|
|
|
return [color, color, color];
|
|
}
|
|
|
|
var mult = (~~(args > 50) + 1) * 0.5;
|
|
var r = ((color & 1) * mult) * 255;
|
|
var g = (((color >> 1) & 1) * mult) * 255;
|
|
var b = (((color >> 2) & 1) * mult) * 255;
|
|
|
|
return [r, g, b];
|
|
};
|
|
|
|
convert.ansi256.rgb = function (args) {
|
|
// handle greyscale
|
|
if (args >= 232) {
|
|
var c = (args - 232) * 10 + 8;
|
|
return [c, c, c];
|
|
}
|
|
|
|
args -= 16;
|
|
|
|
var rem;
|
|
var r = Math.floor(args / 36) / 5 * 255;
|
|
var g = Math.floor((rem = args % 36) / 6) / 5 * 255;
|
|
var b = (rem % 6) / 5 * 255;
|
|
|
|
return [r, g, b];
|
|
};
|
|
|
|
convert.rgb.hex = function (args) {
|
|
var integer = ((Math.round(args[0]) & 0xFF) << 16)
|
|
+ ((Math.round(args[1]) & 0xFF) << 8)
|
|
+ (Math.round(args[2]) & 0xFF);
|
|
|
|
var string = integer.toString(16).toUpperCase();
|
|
return '000000'.substring(string.length) + string;
|
|
};
|
|
|
|
convert.hex.rgb = function (args) {
|
|
var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
|
|
if (!match) {
|
|
return [0, 0, 0];
|
|
}
|
|
|
|
var colorString = match[0];
|
|
|
|
if (match[0].length === 3) {
|
|
colorString = colorString.split('').map(function (char) {
|
|
return char + char;
|
|
}).join('');
|
|
}
|
|
|
|
var integer = parseInt(colorString, 16);
|
|
var r = (integer >> 16) & 0xFF;
|
|
var g = (integer >> 8) & 0xFF;
|
|
var b = integer & 0xFF;
|
|
|
|
return [r, g, b];
|
|
};
|
|
|
|
convert.rgb.hcg = function (rgb) {
|
|
var r = rgb[0] / 255;
|
|
var g = rgb[1] / 255;
|
|
var b = rgb[2] / 255;
|
|
var max = Math.max(Math.max(r, g), b);
|
|
var min = Math.min(Math.min(r, g), b);
|
|
var chroma = (max - min);
|
|
var grayscale;
|
|
var hue;
|
|
|
|
if (chroma < 1) {
|
|
grayscale = min / (1 - chroma);
|
|
} else {
|
|
grayscale = 0;
|
|
}
|
|
|
|
if (chroma <= 0) {
|
|
hue = 0;
|
|
} else
|
|
if (max === r) {
|
|
hue = ((g - b) / chroma) % 6;
|
|
} else
|
|
if (max === g) {
|
|
hue = 2 + (b - r) / chroma;
|
|
} else {
|
|
hue = 4 + (r - g) / chroma + 4;
|
|
}
|
|
|
|
hue /= 6;
|
|
hue %= 1;
|
|
|
|
return [hue * 360, chroma * 100, grayscale * 100];
|
|
};
|
|
|
|
convert.hsl.hcg = function (hsl) {
|
|
var s = hsl[1] / 100;
|
|
var l = hsl[2] / 100;
|
|
var c = 1;
|
|
var f = 0;
|
|
|
|
if (l < 0.5) {
|
|
c = 2.0 * s * l;
|
|
} else {
|
|
c = 2.0 * s * (1.0 - l);
|
|
}
|
|
|
|
if (c < 1.0) {
|
|
f = (l - 0.5 * c) / (1.0 - c);
|
|
}
|
|
|
|
return [hsl[0], c * 100, f * 100];
|
|
};
|
|
|
|
convert.hsv.hcg = function (hsv) {
|
|
var s = hsv[1] / 100;
|
|
var v = hsv[2] / 100;
|
|
|
|
var c = s * v;
|
|
var f = 0;
|
|
|
|
if (c < 1.0) {
|
|
f = (v - c) / (1 - c);
|
|
}
|
|
|
|
return [hsv[0], c * 100, f * 100];
|
|
};
|
|
|
|
convert.hcg.rgb = function (hcg) {
|
|
var h = hcg[0] / 360;
|
|
var c = hcg[1] / 100;
|
|
var g = hcg[2] / 100;
|
|
|
|
if (c === 0.0) {
|
|
return [g * 255, g * 255, g * 255];
|
|
}
|
|
|
|
var pure = [0, 0, 0];
|
|
var hi = (h % 1) * 6;
|
|
var v = hi % 1;
|
|
var w = 1 - v;
|
|
var mg = 0;
|
|
|
|
switch (Math.floor(hi)) {
|
|
case 0:
|
|
pure[0] = 1; pure[1] = v; pure[2] = 0; break;
|
|
case 1:
|
|
pure[0] = w; pure[1] = 1; pure[2] = 0; break;
|
|
case 2:
|
|
pure[0] = 0; pure[1] = 1; pure[2] = v; break;
|
|
case 3:
|
|
pure[0] = 0; pure[1] = w; pure[2] = 1; break;
|
|
case 4:
|
|
pure[0] = v; pure[1] = 0; pure[2] = 1; break;
|
|
default:
|
|
pure[0] = 1; pure[1] = 0; pure[2] = w;
|
|
}
|
|
|
|
mg = (1.0 - c) * g;
|
|
|
|
return [
|
|
(c * pure[0] + mg) * 255,
|
|
(c * pure[1] + mg) * 255,
|
|
(c * pure[2] + mg) * 255
|
|
];
|
|
};
|
|
|
|
convert.hcg.hsv = function (hcg) {
|
|
var c = hcg[1] / 100;
|
|
var g = hcg[2] / 100;
|
|
|
|
var v = c + g * (1.0 - c);
|
|
var f = 0;
|
|
|
|
if (v > 0.0) {
|
|
f = c / v;
|
|
}
|
|
|
|
return [hcg[0], f * 100, v * 100];
|
|
};
|
|
|
|
convert.hcg.hsl = function (hcg) {
|
|
var c = hcg[1] / 100;
|
|
var g = hcg[2] / 100;
|
|
|
|
var l = g * (1.0 - c) + 0.5 * c;
|
|
var s = 0;
|
|
|
|
if (l > 0.0 && l < 0.5) {
|
|
s = c / (2 * l);
|
|
} else
|
|
if (l >= 0.5 && l < 1.0) {
|
|
s = c / (2 * (1 - l));
|
|
}
|
|
|
|
return [hcg[0], s * 100, l * 100];
|
|
};
|
|
|
|
convert.hcg.hwb = function (hcg) {
|
|
var c = hcg[1] / 100;
|
|
var g = hcg[2] / 100;
|
|
var v = c + g * (1.0 - c);
|
|
return [hcg[0], (v - c) * 100, (1 - v) * 100];
|
|
};
|
|
|
|
convert.hwb.hcg = function (hwb) {
|
|
var w = hwb[1] / 100;
|
|
var b = hwb[2] / 100;
|
|
var v = 1 - b;
|
|
var c = v - w;
|
|
var g = 0;
|
|
|
|
if (c < 1) {
|
|
g = (v - c) / (1 - c);
|
|
}
|
|
|
|
return [hwb[0], c * 100, g * 100];
|
|
};
|
|
|
|
convert.apple.rgb = function (apple) {
|
|
return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255];
|
|
};
|
|
|
|
convert.rgb.apple = function (rgb) {
|
|
return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535];
|
|
};
|
|
|
|
convert.gray.rgb = function (args) {
|
|
return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
|
|
};
|
|
|
|
convert.gray.hsl = convert.gray.hsv = function (args) {
|
|
return [0, 0, args[0]];
|
|
};
|
|
|
|
convert.gray.hwb = function (gray) {
|
|
return [0, 100, gray[0]];
|
|
};
|
|
|
|
convert.gray.cmyk = function (gray) {
|
|
return [0, 0, 0, gray[0]];
|
|
};
|
|
|
|
convert.gray.lab = function (gray) {
|
|
return [gray[0], 0, 0];
|
|
};
|
|
|
|
convert.gray.hex = function (gray) {
|
|
var val = Math.round(gray[0] / 100 * 255) & 0xFF;
|
|
var integer = (val << 16) + (val << 8) + val;
|
|
|
|
var string = integer.toString(16).toUpperCase();
|
|
return '000000'.substring(string.length) + string;
|
|
};
|
|
|
|
convert.rgb.gray = function (rgb) {
|
|
var val = (rgb[0] + rgb[1] + rgb[2]) / 3;
|
|
return [val / 255 * 100];
|
|
};
|
|
});
|
|
|
|
/*
|
|
this function routes a model to all other models.
|
|
|
|
all functions that are routed have a property `.conversion` attached
|
|
to the returned synthetic function. This property is an array
|
|
of strings, each with the steps in between the 'from' and 'to'
|
|
color models (inclusive).
|
|
|
|
conversions that are not possible simply are not included.
|
|
*/
|
|
|
|
// https://jsperf.com/object-keys-vs-for-in-with-closure/3
|
|
var models$1 = Object.keys(conversions);
|
|
|
|
function buildGraph() {
|
|
var graph = {};
|
|
|
|
for (var len = models$1.length, i = 0; i < len; i++) {
|
|
graph[models$1[i]] = {
|
|
// http://jsperf.com/1-vs-infinity
|
|
// micro-opt, but this is simple.
|
|
distance: -1,
|
|
parent: null
|
|
};
|
|
}
|
|
|
|
return graph;
|
|
}
|
|
|
|
// https://en.wikipedia.org/wiki/Breadth-first_search
|
|
function deriveBFS(fromModel) {
|
|
var graph = buildGraph();
|
|
var queue = [fromModel]; // unshift -> queue -> pop
|
|
|
|
graph[fromModel].distance = 0;
|
|
|
|
while (queue.length) {
|
|
var current = queue.pop();
|
|
var adjacents = Object.keys(conversions[current]);
|
|
|
|
for (var len = adjacents.length, i = 0; i < len; i++) {
|
|
var adjacent = adjacents[i];
|
|
var node = graph[adjacent];
|
|
|
|
if (node.distance === -1) {
|
|
node.distance = graph[current].distance + 1;
|
|
node.parent = current;
|
|
queue.unshift(adjacent);
|
|
}
|
|
}
|
|
}
|
|
|
|
return graph;
|
|
}
|
|
|
|
function link(from, to) {
|
|
return function (args) {
|
|
return to(from(args));
|
|
};
|
|
}
|
|
|
|
function wrapConversion(toModel, graph) {
|
|
var path = [graph[toModel].parent, toModel];
|
|
var fn = conversions[graph[toModel].parent][toModel];
|
|
|
|
var cur = graph[toModel].parent;
|
|
while (graph[cur].parent) {
|
|
path.unshift(graph[cur].parent);
|
|
fn = link(conversions[graph[cur].parent][cur], fn);
|
|
cur = graph[cur].parent;
|
|
}
|
|
|
|
fn.conversion = path;
|
|
return fn;
|
|
}
|
|
|
|
var route = function (fromModel) {
|
|
var graph = deriveBFS(fromModel);
|
|
var conversion = {};
|
|
|
|
var models = Object.keys(graph);
|
|
for (var len = models.length, i = 0; i < len; i++) {
|
|
var toModel = models[i];
|
|
var node = graph[toModel];
|
|
|
|
if (node.parent === null) {
|
|
// no possible conversion, or this node is the source model.
|
|
continue;
|
|
}
|
|
|
|
conversion[toModel] = wrapConversion(toModel, graph);
|
|
}
|
|
|
|
return conversion;
|
|
};
|
|
|
|
var convert = {};
|
|
|
|
var models = Object.keys(conversions);
|
|
|
|
function wrapRaw(fn) {
|
|
var wrappedFn = function (args) {
|
|
if (args === undefined || args === null) {
|
|
return args;
|
|
}
|
|
|
|
if (arguments.length > 1) {
|
|
args = Array.prototype.slice.call(arguments);
|
|
}
|
|
|
|
return fn(args);
|
|
};
|
|
|
|
// preserve .conversion property if there is one
|
|
if ('conversion' in fn) {
|
|
wrappedFn.conversion = fn.conversion;
|
|
}
|
|
|
|
return wrappedFn;
|
|
}
|
|
|
|
function wrapRounded(fn) {
|
|
var wrappedFn = function (args) {
|
|
if (args === undefined || args === null) {
|
|
return args;
|
|
}
|
|
|
|
if (arguments.length > 1) {
|
|
args = Array.prototype.slice.call(arguments);
|
|
}
|
|
|
|
var result = fn(args);
|
|
|
|
// we're assuming the result is an array here.
|
|
// see notice in conversions.js; don't use box types
|
|
// in conversion functions.
|
|
if (typeof result === 'object') {
|
|
for (var len = result.length, i = 0; i < len; i++) {
|
|
result[i] = Math.round(result[i]);
|
|
}
|
|
}
|
|
|
|
return result;
|
|
};
|
|
|
|
// preserve .conversion property if there is one
|
|
if ('conversion' in fn) {
|
|
wrappedFn.conversion = fn.conversion;
|
|
}
|
|
|
|
return wrappedFn;
|
|
}
|
|
|
|
models.forEach(function (fromModel) {
|
|
convert[fromModel] = {};
|
|
|
|
Object.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels});
|
|
Object.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels});
|
|
|
|
var routes = route(fromModel);
|
|
var routeModels = Object.keys(routes);
|
|
|
|
routeModels.forEach(function (toModel) {
|
|
var fn = routes[toModel];
|
|
|
|
convert[fromModel][toModel] = wrapRounded(fn);
|
|
convert[fromModel][toModel].raw = wrapRaw(fn);
|
|
});
|
|
});
|
|
|
|
var colorConvert = convert;
|
|
|
|
'use strict';
|
|
|
|
var ansiStyles = createCommonjsModule(function (module) {
|
|
'use strict';
|
|
|
|
var wrapAnsi16 = function wrapAnsi16(fn, offset) {
|
|
return function () {
|
|
var code = fn.apply(colorConvert, arguments);
|
|
return '\x1B[' + (code + offset) + 'm';
|
|
};
|
|
};
|
|
|
|
var wrapAnsi256 = function wrapAnsi256(fn, offset) {
|
|
return function () {
|
|
var code = fn.apply(colorConvert, arguments);
|
|
return '\x1B[' + (38 + offset) + ';5;' + code + 'm';
|
|
};
|
|
};
|
|
|
|
var wrapAnsi16m = function wrapAnsi16m(fn, offset) {
|
|
return function () {
|
|
var rgb = fn.apply(colorConvert, arguments);
|
|
return '\x1B[' + (38 + offset) + ';2;' + rgb[0] + ';' + rgb[1] + ';' + rgb[2] + 'm';
|
|
};
|
|
};
|
|
|
|
function assembleStyles() {
|
|
var codes = new _Map();
|
|
var styles = {
|
|
modifier: {
|
|
reset: [0, 0],
|
|
// 21 isn't widely supported and 22 does the same thing
|
|
bold: [1, 22],
|
|
dim: [2, 22],
|
|
italic: [3, 23],
|
|
underline: [4, 24],
|
|
inverse: [7, 27],
|
|
hidden: [8, 28],
|
|
strikethrough: [9, 29]
|
|
},
|
|
color: {
|
|
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],
|
|
|
|
// Bright color
|
|
redBright: [91, 39],
|
|
greenBright: [92, 39],
|
|
yellowBright: [93, 39],
|
|
blueBright: [94, 39],
|
|
magentaBright: [95, 39],
|
|
cyanBright: [96, 39],
|
|
whiteBright: [97, 39]
|
|
},
|
|
bgColor: {
|
|
bgBlack: [40, 49],
|
|
bgRed: [41, 49],
|
|
bgGreen: [42, 49],
|
|
bgYellow: [43, 49],
|
|
bgBlue: [44, 49],
|
|
bgMagenta: [45, 49],
|
|
bgCyan: [46, 49],
|
|
bgWhite: [47, 49],
|
|
|
|
// Bright color
|
|
bgBlackBright: [100, 49],
|
|
bgRedBright: [101, 49],
|
|
bgGreenBright: [102, 49],
|
|
bgYellowBright: [103, 49],
|
|
bgBlueBright: [104, 49],
|
|
bgMagentaBright: [105, 49],
|
|
bgCyanBright: [106, 49],
|
|
bgWhiteBright: [107, 49]
|
|
}
|
|
};
|
|
|
|
// Fix humans
|
|
styles.color.grey = styles.color.gray;
|
|
|
|
var _iteratorNormalCompletion = true;
|
|
var _didIteratorError = false;
|
|
var _iteratorError = undefined;
|
|
|
|
try {
|
|
for (var _iterator = _getIterator(_Object$keys(styles)), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
var groupName = _step.value;
|
|
|
|
var group = styles[groupName];
|
|
|
|
var _iteratorNormalCompletion3 = true;
|
|
var _didIteratorError3 = false;
|
|
var _iteratorError3 = undefined;
|
|
|
|
try {
|
|
for (var _iterator3 = _getIterator(_Object$keys(group)), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
|
var styleName = _step3.value;
|
|
|
|
var style = group[styleName];
|
|
|
|
styles[styleName] = {
|
|
open: '\x1B[' + style[0] + 'm',
|
|
close: '\x1B[' + style[1] + 'm'
|
|
};
|
|
|
|
group[styleName] = styles[styleName];
|
|
|
|
codes.set(style[0], style[1]);
|
|
}
|
|
} catch (err) {
|
|
_didIteratorError3 = true;
|
|
_iteratorError3 = err;
|
|
} finally {
|
|
try {
|
|
if (!_iteratorNormalCompletion3 && _iterator3.return) {
|
|
_iterator3.return();
|
|
}
|
|
} finally {
|
|
if (_didIteratorError3) {
|
|
throw _iteratorError3;
|
|
}
|
|
}
|
|
}
|
|
|
|
_Object$defineProperty(styles, groupName, {
|
|
value: group,
|
|
enumerable: false
|
|
});
|
|
|
|
Object.defineProperty(styles, 'codes', {
|
|
value: codes,
|
|
enumerable: false
|
|
});
|
|
}
|
|
} catch (err) {
|
|
_didIteratorError = true;
|
|
_iteratorError = err;
|
|
} finally {
|
|
try {
|
|
if (!_iteratorNormalCompletion && _iterator.return) {
|
|
_iterator.return();
|
|
}
|
|
} finally {
|
|
if (_didIteratorError) {
|
|
throw _iteratorError;
|
|
}
|
|
}
|
|
}
|
|
|
|
var rgb2rgb = function rgb2rgb(r, g, b) {
|
|
return [r, g, b];
|
|
};
|
|
|
|
styles.color.close = '\x1B[39m';
|
|
styles.bgColor.close = '\x1B[49m';
|
|
|
|
styles.color.ansi = {};
|
|
styles.color.ansi256 = {};
|
|
styles.color.ansi16m = {
|
|
rgb: wrapAnsi16m(rgb2rgb, 0)
|
|
};
|
|
|
|
styles.bgColor.ansi = {};
|
|
styles.bgColor.ansi256 = {};
|
|
styles.bgColor.ansi16m = {
|
|
rgb: wrapAnsi16m(rgb2rgb, 10)
|
|
};
|
|
|
|
var _iteratorNormalCompletion2 = true;
|
|
var _didIteratorError2 = false;
|
|
var _iteratorError2 = undefined;
|
|
|
|
try {
|
|
for (var _iterator2 = _getIterator(_Object$keys(colorConvert)), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
var key = _step2.value;
|
|
|
|
if (_typeof(colorConvert[key]) !== 'object') {
|
|
continue;
|
|
}
|
|
|
|
var suite = colorConvert[key];
|
|
|
|
if ('ansi16' in suite) {
|
|
styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0);
|
|
styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10);
|
|
}
|
|
|
|
if ('ansi256' in suite) {
|
|
styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0);
|
|
styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10);
|
|
}
|
|
|
|
if ('rgb' in suite) {
|
|
styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0);
|
|
styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10);
|
|
}
|
|
}
|
|
} catch (err) {
|
|
_didIteratorError2 = true;
|
|
_iteratorError2 = err;
|
|
} finally {
|
|
try {
|
|
if (!_iteratorNormalCompletion2 && _iterator2.return) {
|
|
_iterator2.return();
|
|
}
|
|
} finally {
|
|
if (_didIteratorError2) {
|
|
throw _iteratorError2;
|
|
}
|
|
}
|
|
}
|
|
|
|
return styles;
|
|
}
|
|
|
|
// Make the export immutable
|
|
Object.defineProperty(module, 'exports', {
|
|
enumerable: true,
|
|
get: assembleStyles
|
|
});
|
|
});
|
|
|
|
var getOwnPropertySymbols$1 = _core.Object.getOwnPropertySymbols;
|
|
|
|
var getOwnPropertySymbols = createCommonjsModule(function (module) {
|
|
module.exports = { "default": getOwnPropertySymbols$1, __esModule: true };
|
|
});
|
|
|
|
var _Object$getOwnPropertySymbols = unwrapExports(getOwnPropertySymbols);
|
|
|
|
'use strict';
|
|
|
|
/**
|
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
*
|
|
*/
|
|
|
|
var getSymbols = _Object$getOwnPropertySymbols || function (obj) {
|
|
return [];
|
|
};
|
|
|
|
var isSymbol$1 = function isSymbol(key) {
|
|
return (
|
|
// $FlowFixMe string literal `symbol`. This value is not a valid `typeof` return value
|
|
(typeof key === 'undefined' ? 'undefined' : _typeof(key)) === 'symbol' || toString.call(key) === '[object Symbol]'
|
|
);
|
|
};
|
|
|
|
// Return entries (for example, of a map)
|
|
// with spacing, indentation, and comma
|
|
// without surrounding punctuation (for example, braces)
|
|
function printIteratorEntries(
|
|
// Flow 0.51.0: property `@@iterator` of $Iterator not found in Object
|
|
// To allow simplistic getRecordIterator in immutable.js
|
|
iterator, config, indentation, depth, refs, printer) {
|
|
var separator = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : ': ';
|
|
|
|
var result = '';
|
|
var current = iterator.next();
|
|
|
|
if (!current.done) {
|
|
result += config.spacingOuter;
|
|
|
|
var indentationNext = indentation + config.indent;
|
|
|
|
while (!current.done) {
|
|
var name = printer(current.value[0], config, indentationNext, depth, refs);
|
|
var value = printer(current.value[1], config, indentationNext, depth, refs);
|
|
|
|
result += indentationNext + name + separator + value;
|
|
|
|
current = iterator.next();
|
|
|
|
if (!current.done) {
|
|
result += ',' + config.spacingInner;
|
|
} else if (!config.min) {
|
|
result += ',';
|
|
}
|
|
}
|
|
|
|
result += config.spacingOuter + indentation;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
// Return values (for example, of a set)
|
|
// with spacing, indentation, and comma
|
|
// without surrounding punctuation (braces or brackets)
|
|
function printIteratorValues(iterator, config, indentation, depth, refs, printer) {
|
|
var result = '';
|
|
var current = iterator.next();
|
|
|
|
if (!current.done) {
|
|
result += config.spacingOuter;
|
|
|
|
var indentationNext = indentation + config.indent;
|
|
|
|
while (!current.done) {
|
|
result += indentationNext + printer(current.value, config, indentationNext, depth, refs);
|
|
|
|
current = iterator.next();
|
|
|
|
if (!current.done) {
|
|
result += ',' + config.spacingInner;
|
|
} else if (!config.min) {
|
|
result += ',';
|
|
}
|
|
}
|
|
|
|
result += config.spacingOuter + indentation;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
// Return items (for example, of an array)
|
|
// with spacing, indentation, and comma
|
|
// without surrounding punctuation (for example, brackets)
|
|
function printListItems(list, config, indentation, depth, refs, printer) {
|
|
var result = '';
|
|
|
|
if (list.length) {
|
|
result += config.spacingOuter;
|
|
|
|
var indentationNext = indentation + config.indent;
|
|
|
|
for (var i = 0; i < list.length; i++) {
|
|
result += indentationNext + printer(list[i], config, indentationNext, depth, refs);
|
|
|
|
if (i < list.length - 1) {
|
|
result += ',' + config.spacingInner;
|
|
} else if (!config.min) {
|
|
result += ',';
|
|
}
|
|
}
|
|
|
|
result += config.spacingOuter + indentation;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
// Return properties of an object
|
|
// with spacing, indentation, and comma
|
|
// without surrounding punctuation (for example, braces)
|
|
function printObjectProperties(val, config, indentation, depth, refs, printer) {
|
|
var result = '';
|
|
var keys$$1 = _Object$keys(val).sort();
|
|
var symbols = getSymbols(val);
|
|
|
|
if (symbols.length) {
|
|
keys$$1 = keys$$1.filter(function (key) {
|
|
return !isSymbol$1(key);
|
|
}).concat(symbols);
|
|
}
|
|
|
|
if (keys$$1.length) {
|
|
result += config.spacingOuter;
|
|
|
|
var indentationNext = indentation + config.indent;
|
|
|
|
for (var i = 0; i < keys$$1.length; i++) {
|
|
var key = keys$$1[i];
|
|
var name = printer(key, config, indentationNext, depth, refs);
|
|
var value = printer(val[key], config, indentationNext, depth, refs);
|
|
|
|
result += indentationNext + name + ': ' + value;
|
|
|
|
if (i < keys$$1.length - 1) {
|
|
result += ',' + config.spacingInner;
|
|
} else if (!config.min) {
|
|
result += ',';
|
|
}
|
|
}
|
|
|
|
result += config.spacingOuter + indentation;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
var _for$1 = _core.Symbol['for'];
|
|
|
|
var _for = createCommonjsModule(function (module) {
|
|
module.exports = { "default": _for$1, __esModule: true };
|
|
});
|
|
|
|
var _Symbol$for = unwrapExports(_for);
|
|
|
|
'use strict';
|
|
|
|
/**
|
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
*
|
|
*/
|
|
|
|
var asymmetricMatcher = _Symbol$for('jest.asymmetricMatcher');
|
|
var SPACE = ' ';
|
|
|
|
var serialize = function serialize(val, config, indentation, depth, refs, printer) {
|
|
var stringedValue = val.toString();
|
|
|
|
if (stringedValue === 'ArrayContaining') {
|
|
if (++depth > config.maxDepth) {
|
|
return '[' + stringedValue + ']';
|
|
}
|
|
return stringedValue + SPACE + '[' + printListItems(val.sample, config, indentation, depth, refs, printer) + ']';
|
|
}
|
|
|
|
if (stringedValue === 'ObjectContaining') {
|
|
if (++depth > config.maxDepth) {
|
|
return '[' + stringedValue + ']';
|
|
}
|
|
return stringedValue + SPACE + '{' + printObjectProperties(val.sample, config, indentation, depth, refs, printer) + '}';
|
|
}
|
|
|
|
if (stringedValue === 'StringMatching') {
|
|
return stringedValue + SPACE + printer(val.sample, config, indentation, depth, refs);
|
|
}
|
|
|
|
if (stringedValue === 'StringContaining') {
|
|
return stringedValue + SPACE + printer(val.sample, config, indentation, depth, refs);
|
|
}
|
|
|
|
return val.toAsymmetricMatcher();
|
|
};
|
|
|
|
var test = function test(val) {
|
|
return val && val.$$typeof === asymmetricMatcher;
|
|
};
|
|
|
|
var AsymmetricMatcher = { serialize: serialize, test: test };
|
|
|
|
'use strict';
|
|
|
|
var ansiRegex = createCommonjsModule(function (module) {
|
|
'use strict';
|
|
|
|
module.exports = function () {
|
|
var pattern = ['[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)', '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))'].join('|');
|
|
|
|
return new RegExp(pattern, 'g');
|
|
};
|
|
});
|
|
|
|
'use strict';
|
|
|
|
/**
|
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
*
|
|
*/
|
|
|
|
var toHumanReadableAnsi = function toHumanReadableAnsi(text) {
|
|
return text.replace(ansiRegex(), function (match, offset, string) {
|
|
switch (match) {
|
|
case ansiStyles.red.close:
|
|
case ansiStyles.green.close:
|
|
case ansiStyles.cyan.close:
|
|
case ansiStyles.gray.close:
|
|
case ansiStyles.white.close:
|
|
case ansiStyles.yellow.close:
|
|
case ansiStyles.bgRed.close:
|
|
case ansiStyles.bgGreen.close:
|
|
case ansiStyles.bgCyan.close:
|
|
case ansiStyles.inverse.close:
|
|
case ansiStyles.dim.close:
|
|
case ansiStyles.bold.close:
|
|
case ansiStyles.reset.open:
|
|
case ansiStyles.reset.close:
|
|
return '</>';
|
|
case ansiStyles.red.open:
|
|
return '<red>';
|
|
case ansiStyles.green.open:
|
|
return '<green>';
|
|
case ansiStyles.cyan.open:
|
|
return '<cyan>';
|
|
case ansiStyles.gray.open:
|
|
return '<gray>';
|
|
case ansiStyles.white.open:
|
|
return '<white>';
|
|
case ansiStyles.yellow.open:
|
|
return '<yellow>';
|
|
case ansiStyles.bgRed.open:
|
|
return '<bgRed>';
|
|
case ansiStyles.bgGreen.open:
|
|
return '<bgGreen>';
|
|
case ansiStyles.bgCyan.open:
|
|
return '<bgCyan>';
|
|
case ansiStyles.inverse.open:
|
|
return '<inverse>';
|
|
case ansiStyles.dim.open:
|
|
return '<dim>';
|
|
case ansiStyles.bold.open:
|
|
return '<bold>';
|
|
default:
|
|
return '';
|
|
}
|
|
});
|
|
};
|
|
|
|
var test$1 = function test(val) {
|
|
return typeof val === 'string' && val.match(ansiRegex());
|
|
};
|
|
|
|
var serialize$1 = function serialize(val, config, indentation, depth, refs, printer) {
|
|
return printer(toHumanReadableAnsi(val), config, indentation, depth, refs);
|
|
};
|
|
|
|
var ConvertAnsi = { serialize: serialize$1, test: test$1 };
|
|
|
|
'use strict';
|
|
|
|
/**
|
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
*
|
|
*/
|
|
|
|
function escapeHTML(str) {
|
|
return str.replace(/</g, '<').replace(/>/g, '>');
|
|
}
|
|
|
|
'use strict';
|
|
|
|
/**
|
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
*
|
|
*/
|
|
|
|
// Return empty string if keys is empty.
|
|
var printProps = function printProps(keys, props, config, indentation, depth, refs, printer) {
|
|
var indentationNext = indentation + config.indent;
|
|
var colors = config.colors;
|
|
return keys.map(function (key) {
|
|
var value = props[key];
|
|
var printed = printer(value, config, indentationNext, depth, refs);
|
|
|
|
if (typeof value !== 'string') {
|
|
if (printed.indexOf('\n') !== -1) {
|
|
printed = config.spacingOuter + indentationNext + printed + config.spacingOuter + indentation;
|
|
}
|
|
printed = '{' + printed + '}';
|
|
}
|
|
|
|
return config.spacingInner + indentation + colors.prop.open + key + colors.prop.close + '=' + colors.value.open + printed + colors.value.close;
|
|
}).join('');
|
|
};
|
|
|
|
// Return empty string if children is empty.
|
|
var printChildren = function printChildren(children, config, indentation, depth, refs, printer) {
|
|
return children.map(function (child) {
|
|
return config.spacingOuter + indentation + (typeof child === 'string' ? printText(child, config) : printer(child, config, indentation, depth, refs));
|
|
}).join('');
|
|
};
|
|
|
|
var printText = function printText(text, config) {
|
|
var contentColor = config.colors.content;
|
|
return contentColor.open + escapeHTML(text) + contentColor.close;
|
|
};
|
|
|
|
var printComment = function printComment(comment, config) {
|
|
var commentColor = config.colors.comment;
|
|
return commentColor.open + '<!--' + escapeHTML(comment) + '-->' + commentColor.close;
|
|
};
|
|
|
|
// Separate the functions to format props, children, and element,
|
|
// so a plugin could override a particular function, if needed.
|
|
// Too bad, so sad: the traditional (but unnecessary) space
|
|
// in a self-closing tagColor requires a second test of printedProps.
|
|
var printElement = function printElement(type, printedProps, printedChildren, config, indentation) {
|
|
var tagColor = config.colors.tag;
|
|
return tagColor.open + '<' + type + (printedProps && tagColor.close + printedProps + config.spacingOuter + indentation + tagColor.open) + (printedChildren ? '>' + tagColor.close + printedChildren + config.spacingOuter + indentation + tagColor.open + '</' + type : (printedProps && !config.min ? '' : ' ') + '/') + '>' + tagColor.close;
|
|
};
|
|
|
|
var printElementAsLeaf = function printElementAsLeaf(type, config) {
|
|
var tagColor = config.colors.tag;
|
|
return tagColor.open + '<' + type + tagColor.close + ' …' + tagColor.open + ' />' + tagColor.close;
|
|
};
|
|
|
|
'use strict';
|
|
|
|
/**
|
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
*
|
|
*/
|
|
|
|
var ELEMENT_NODE = 1;
|
|
var TEXT_NODE = 3;
|
|
var COMMENT_NODE = 8;
|
|
|
|
var ELEMENT_REGEXP = /^(HTML|SVG)\w*?Element$/;
|
|
|
|
var testNode = function testNode(nodeType, name) {
|
|
return nodeType === ELEMENT_NODE && ELEMENT_REGEXP.test(name) || nodeType === TEXT_NODE && name === 'Text' || nodeType === COMMENT_NODE && name === 'Comment';
|
|
};
|
|
|
|
var test$2 = function test(val) {
|
|
return val && val.constructor && val.constructor.name && testNode(val.nodeType, val.constructor.name);
|
|
};
|
|
|
|
// Convert array of attribute objects to keys array and props object.
|
|
var keysMapper = function keysMapper(attribute) {
|
|
return attribute.name;
|
|
};
|
|
var propsReducer = function propsReducer(props, attribute) {
|
|
props[attribute.name] = attribute.value;
|
|
return props;
|
|
};
|
|
|
|
var serialize$2 = function serialize(node, config, indentation, depth, refs, printer) {
|
|
if (node.nodeType === TEXT_NODE) {
|
|
return printText(node.data, config);
|
|
}
|
|
|
|
if (node.nodeType === COMMENT_NODE) {
|
|
return printComment(node.data, config);
|
|
}
|
|
|
|
var type = node.tagName.toLowerCase();
|
|
if (++depth > config.maxDepth) {
|
|
return printElementAsLeaf(type, config);
|
|
}
|
|
|
|
return printElement(type, printProps(Array.prototype.map.call(node.attributes, keysMapper).sort(), Array.prototype.reduce.call(node.attributes, propsReducer, {}), config, indentation + config.indent, depth, refs, printer), printChildren(Array.prototype.slice.call(node.childNodes), config, indentation + config.indent, depth, refs, printer), config, indentation);
|
|
};
|
|
|
|
var DOMElement = { serialize: serialize$2, test: test$2 };
|
|
|
|
'use strict';
|
|
|
|
/**
|
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
*
|
|
*/
|
|
|
|
// SENTINEL constants are from https://github.com/facebook/immutable-js
|
|
var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
|
|
var IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
|
|
var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
|
|
var IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@';
|
|
var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
|
|
var IS_RECORD_SENTINEL = '@@__IMMUTABLE_RECORD__@@'; // immutable v4
|
|
var IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@';
|
|
var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
|
|
var IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@';
|
|
|
|
var getImmutableName = function getImmutableName(name) {
|
|
return 'Immutable.' + name;
|
|
};
|
|
var printAsLeaf = function printAsLeaf(name) {
|
|
return '[' + name + ']';
|
|
};
|
|
var SPACE$1 = ' ';
|
|
var LAZY = '…'; // Seq is lazy if it calls a method like filter
|
|
|
|
var printImmutableEntries = function printImmutableEntries(val, config, indentation, depth, refs, printer, type) {
|
|
return ++depth > config.maxDepth ? printAsLeaf(getImmutableName(type)) : getImmutableName(type) + SPACE$1 + '{' + printIteratorEntries(val.entries(), config, indentation, depth, refs, printer) + '}';
|
|
};
|
|
|
|
// Return an iterator for Immutable Record in v4 or later.
|
|
var getRecordEntries = function getRecordEntries(val) {
|
|
var i = 0;
|
|
return {
|
|
next: function next() {
|
|
if (i < val._keys.length) {
|
|
var key = val._keys[i++];
|
|
return { done: false, value: [key, val.get(key)] };
|
|
}
|
|
return { done: true };
|
|
}
|
|
};
|
|
};
|
|
|
|
var printImmutableRecord = function printImmutableRecord(val, config, indentation, depth, refs, printer) {
|
|
// _name property is defined only for an Immutable Record instance
|
|
// which was constructed with a second optional descriptive name arg
|
|
var name = getImmutableName(val._name || 'Record');
|
|
var entries = _typeof(Array.isArray(val._keys)) ? getRecordEntries(val) // immutable v4
|
|
: val.entries(); // Record is a collection in immutable v3
|
|
return ++depth > config.maxDepth ? printAsLeaf(name) : name + SPACE$1 + '{' + printIteratorEntries(entries, config, indentation, depth, refs, printer) + '}';
|
|
};
|
|
|
|
var printImmutableSeq = function printImmutableSeq(val, config, indentation, depth, refs, printer) {
|
|
var name = getImmutableName('Seq');
|
|
|
|
if (++depth > config.maxDepth) {
|
|
return printAsLeaf(name);
|
|
}
|
|
|
|
if (val[IS_KEYED_SENTINEL]) {
|
|
return name + SPACE$1 + '{' + (
|
|
// from Immutable collection of entries or from ECMAScript object
|
|
val._iter || val._object ? printIteratorEntries(val.entries(), config, indentation, depth, refs, printer) : LAZY) + '}';
|
|
}
|
|
|
|
return name + SPACE$1 + '[' + (val._iter || // from Immutable collection of values
|
|
val._array || // from ECMAScript array
|
|
val._collection || // from ECMAScript collection in immutable v4
|
|
val._iterable // from ECMAScript collection in immutable v3
|
|
? printIteratorValues(val.values(), config, indentation, depth, refs, printer) : LAZY) + ']';
|
|
};
|
|
|
|
var printImmutableValues = function printImmutableValues(val, config, indentation, depth, refs, printer, type) {
|
|
return ++depth > config.maxDepth ? printAsLeaf(getImmutableName(type)) : getImmutableName(type) + SPACE$1 + '[' + printIteratorValues(val.values(), config, indentation, depth, refs, printer) + ']';
|
|
};
|
|
|
|
var serialize$3 = function serialize(val, config, indentation, depth, refs, printer) {
|
|
if (val[IS_MAP_SENTINEL]) {
|
|
return printImmutableEntries(val, config, indentation, depth, refs, printer, val[IS_ORDERED_SENTINEL] ? 'OrderedMap' : 'Map');
|
|
}
|
|
|
|
if (val[IS_LIST_SENTINEL]) {
|
|
return printImmutableValues(val, config, indentation, depth, refs, printer, 'List');
|
|
}
|
|
if (val[IS_SET_SENTINEL]) {
|
|
return printImmutableValues(val, config, indentation, depth, refs, printer, val[IS_ORDERED_SENTINEL] ? 'OrderedSet' : 'Set');
|
|
}
|
|
if (val[IS_STACK_SENTINEL]) {
|
|
return printImmutableValues(val, config, indentation, depth, refs, printer, 'Stack');
|
|
}
|
|
|
|
if (val[IS_SEQ_SENTINEL]) {
|
|
return printImmutableSeq(val, config, indentation, depth, refs, printer);
|
|
}
|
|
|
|
// For compatibility with immutable v3 and v4, let record be the default.
|
|
return printImmutableRecord(val, config, indentation, depth, refs, printer);
|
|
};
|
|
|
|
var test$3 = function test(val) {
|
|
return val && (val[IS_ITERABLE_SENTINEL] || val[IS_RECORD_SENTINEL]);
|
|
};
|
|
|
|
var Immutable = { serialize: serialize$3, test: test$3 };
|
|
|
|
'use strict';
|
|
|
|
/**
|
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
*
|
|
*/
|
|
|
|
var elementSymbol = _Symbol$for('react.element');
|
|
|
|
// Given element.props.children, or subtree during recursive traversal,
|
|
// return flattened array of children.
|
|
var getChildren = function getChildren(arg) {
|
|
var children = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
|
|
if (Array.isArray(arg)) {
|
|
arg.forEach(function (item) {
|
|
getChildren(item, children);
|
|
});
|
|
} else if (arg != null && arg !== false) {
|
|
children.push(arg);
|
|
}
|
|
return children;
|
|
};
|
|
|
|
var getType = function getType(element) {
|
|
if (typeof element.type === 'string') {
|
|
return element.type;
|
|
}
|
|
if (typeof element.type === 'function') {
|
|
return element.type.displayName || element.type.name || 'Unknown';
|
|
}
|
|
return 'UNDEFINED';
|
|
};
|
|
|
|
var serialize$4 = function serialize(element, config, indentation, depth, refs, printer) {
|
|
return ++depth > config.maxDepth ? printElementAsLeaf(getType(element), config) : printElement(getType(element), printProps(_Object$keys(element.props).filter(function (key) {
|
|
return key !== 'children';
|
|
}).sort(), element.props, config, indentation + config.indent, depth, refs, printer), printChildren(getChildren(element.props.children), config, indentation + config.indent, depth, refs, printer), config, indentation);
|
|
};
|
|
|
|
var test$4 = function test(val) {
|
|
return val && val.$$typeof === elementSymbol;
|
|
};
|
|
|
|
var ReactElement = { serialize: serialize$4, test: test$4 };
|
|
|
|
'use strict';
|
|
|
|
/**
|
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
*
|
|
*/
|
|
|
|
var testSymbol = _Symbol$for('react.test.json');
|
|
|
|
var serialize$5 = function serialize(object, config, indentation, depth, refs, printer) {
|
|
return ++depth > config.maxDepth ? printElementAsLeaf(object.type, config) : printElement(object.type, object.props ? printProps(_Object$keys(object.props).sort(),
|
|
// Despite ternary expression, Flow 0.51.0 found incorrect error:
|
|
// undefined is incompatible with the expected param type of Object
|
|
// $FlowFixMe
|
|
object.props, config, indentation + config.indent, depth, refs, printer) : '', object.children ? printChildren(object.children, config, indentation + config.indent, depth, refs, printer) : '', config, indentation);
|
|
};
|
|
|
|
var test$5 = function test(val) {
|
|
return val && val.$$typeof === testSymbol;
|
|
};
|
|
|
|
var ReactTestComponent = { serialize: serialize$5, test: test$5 };
|
|
|
|
'use strict';
|
|
|
|
/**
|
|
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
*
|
|
*/
|
|
|
|
var toString$1 = Object.prototype.toString;
|
|
var toISOString = Date.prototype.toISOString;
|
|
var errorToString = Error.prototype.toString;
|
|
var regExpToString = RegExp.prototype.toString;
|
|
var symbolToString = _Symbol.prototype.toString;
|
|
|
|
var SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/;
|
|
var NEWLINE_REGEXP = /\n/gi;
|
|
|
|
function isToStringedArrayType(toStringed) {
|
|
return toStringed === '[object Array]' || toStringed === '[object ArrayBuffer]' || toStringed === '[object DataView]' || toStringed === '[object Float32Array]' || toStringed === '[object Float64Array]' || toStringed === '[object Int8Array]' || toStringed === '[object Int16Array]' || toStringed === '[object Int32Array]' || toStringed === '[object Uint8Array]' || toStringed === '[object Uint8ClampedArray]' || toStringed === '[object Uint16Array]' || toStringed === '[object Uint32Array]';
|
|
}
|
|
|
|
function printNumber(val) {
|
|
if (val != +val) {
|
|
return 'NaN';
|
|
}
|
|
var isNegativeZero = val === 0 && 1 / val < 0;
|
|
return isNegativeZero ? '-0' : '' + val;
|
|
}
|
|
|
|
function printFunction(val, printFunctionName) {
|
|
if (!printFunctionName) {
|
|
return '[Function]';
|
|
}
|
|
return '[Function ' + (val.name || 'anonymous') + ']';
|
|
}
|
|
|
|
function printSymbol(val) {
|
|
return symbolToString.call(val).replace(SYMBOL_REGEXP, 'Symbol($1)');
|
|
}
|
|
|
|
function printError(val) {
|
|
return '[' + errorToString.call(val) + ']';
|
|
}
|
|
|
|
function printBasicValue(val, printFunctionName, escapeRegex) {
|
|
if (val === true || val === false) {
|
|
return '' + val;
|
|
}
|
|
if (val === undefined) {
|
|
return 'undefined';
|
|
}
|
|
if (val === null) {
|
|
return 'null';
|
|
}
|
|
|
|
var typeOf = typeof val === 'undefined' ? 'undefined' : _typeof(val);
|
|
|
|
if (typeOf === 'number') {
|
|
return printNumber(val);
|
|
}
|
|
if (typeOf === 'string') {
|
|
return '"' + val.replace(/"|\\/g, '\\$&') + '"';
|
|
}
|
|
if (typeOf === 'function') {
|
|
return printFunction(val, printFunctionName);
|
|
}
|
|
if (typeOf === 'symbol') {
|
|
return printSymbol(val);
|
|
}
|
|
|
|
var toStringed = toString$1.call(val);
|
|
|
|
if (toStringed === '[object WeakMap]') {
|
|
return 'WeakMap {}';
|
|
}
|
|
if (toStringed === '[object WeakSet]') {
|
|
return 'WeakSet {}';
|
|
}
|
|
if (toStringed === '[object Function]' || toStringed === '[object GeneratorFunction]') {
|
|
return printFunction(val, printFunctionName);
|
|
}
|
|
if (toStringed === '[object Symbol]') {
|
|
return printSymbol(val);
|
|
}
|
|
if (toStringed === '[object Date]') {
|
|
return toISOString.call(val);
|
|
}
|
|
if (toStringed === '[object Error]') {
|
|
return printError(val);
|
|
}
|
|
if (toStringed === '[object RegExp]') {
|
|
if (escapeRegex) {
|
|
// https://github.com/benjamingr/RegExp.escape/blob/master/polyfill.js
|
|
return regExpToString.call(val).replace(/[\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
}
|
|
return regExpToString.call(val);
|
|
}
|
|
|
|
if (val instanceof Error) {
|
|
return printError(val);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
function printComplexValue(val, config, indentation, depth, refs) {
|
|
if (refs.indexOf(val) !== -1) {
|
|
return '[Circular]';
|
|
}
|
|
refs = refs.slice();
|
|
refs.push(val);
|
|
|
|
var hitMaxDepth = ++depth > config.maxDepth;
|
|
var min = config.min;
|
|
|
|
if (config.callToJSON && !hitMaxDepth && val.toJSON && typeof val.toJSON === 'function') {
|
|
return printer(val.toJSON(), config, indentation, depth, refs);
|
|
}
|
|
|
|
var toStringed = toString$1.call(val);
|
|
if (toStringed === '[object Arguments]') {
|
|
return hitMaxDepth ? '[Arguments]' : (min ? '' : 'Arguments ') + '[' + printListItems(val, config, indentation, depth, refs, printer) + ']';
|
|
}
|
|
if (isToStringedArrayType(toStringed)) {
|
|
return hitMaxDepth ? '[' + val.constructor.name + ']' : (min ? '' : val.constructor.name + ' ') + '[' + printListItems(val, config, indentation, depth, refs, printer) + ']';
|
|
}
|
|
if (toStringed === '[object Map]') {
|
|
return hitMaxDepth ? '[Map]' : 'Map {' + printIteratorEntries(val.entries(), config, indentation, depth, refs, printer, ' => ') + '}';
|
|
}
|
|
if (toStringed === '[object Set]') {
|
|
return hitMaxDepth ? '[Set]' : 'Set {' + printIteratorValues(val.values(), config, indentation, depth, refs, printer) + '}';
|
|
}
|
|
|
|
return hitMaxDepth ? '[' + (val.constructor ? val.constructor.name : 'Object') + ']' : (min ? '' : (val.constructor ? val.constructor.name : 'Object') + ' ') + '{' + printObjectProperties(val, config, indentation, depth, refs, printer) + '}';
|
|
}
|
|
|
|
function printPlugin(plugin, val, config, indentation, depth, refs) {
|
|
var printed = plugin.serialize ? plugin.serialize(val, config, indentation, depth, refs, printer) : plugin.print(val, function (valChild) {
|
|
return printer(valChild, config, indentation, depth, refs);
|
|
}, function (str) {
|
|
var indentationNext = indentation + config.indent;
|
|
return indentationNext + str.replace(NEWLINE_REGEXP, '\n' + indentationNext);
|
|
}, {
|
|
edgeSpacing: config.spacingOuter,
|
|
min: config.min,
|
|
spacing: config.spacingInner
|
|
}, config.colors);
|
|
if (typeof printed !== 'string') {
|
|
throw new Error('pretty-format: Plugin must return type "string" but instead returned "' + (typeof printed === 'undefined' ? 'undefined' : _typeof(printed)) + '".');
|
|
}
|
|
return printed;
|
|
}
|
|
|
|
function findPlugin(plugins, val) {
|
|
for (var p = 0; p < plugins.length; p++) {
|
|
if (plugins[p].test(val)) {
|
|
return plugins[p];
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
function printer(val, config, indentation, depth, refs) {
|
|
var plugin = findPlugin(config.plugins, val);
|
|
if (plugin !== null) {
|
|
return printPlugin(plugin, val, config, indentation, depth, refs);
|
|
}
|
|
|
|
var basicResult = printBasicValue(val, config.printFunctionName, config.escapeRegex);
|
|
if (basicResult !== null) {
|
|
return basicResult;
|
|
}
|
|
|
|
return printComplexValue(val, config, indentation, depth, refs);
|
|
}
|
|
|
|
var DEFAULT_THEME = {
|
|
comment: 'gray',
|
|
content: 'reset',
|
|
prop: 'yellow',
|
|
tag: 'cyan',
|
|
value: 'green'
|
|
};
|
|
|
|
var DEFAULT_THEME_KEYS = _Object$keys(DEFAULT_THEME);
|
|
|
|
var DEFAULT_OPTIONS = {
|
|
callToJSON: true,
|
|
escapeRegex: false,
|
|
highlight: false,
|
|
indent: 2,
|
|
maxDepth: Infinity,
|
|
min: false,
|
|
plugins: [],
|
|
printFunctionName: true,
|
|
theme: DEFAULT_THEME
|
|
};
|
|
|
|
function validateOptions(options) {
|
|
_Object$keys(options).forEach(function (key) {
|
|
if (!DEFAULT_OPTIONS.hasOwnProperty(key)) {
|
|
throw new Error('pretty-format: Unknown option "' + key + '".');
|
|
}
|
|
});
|
|
|
|
if (options.min && options.indent !== undefined && options.indent !== 0) {
|
|
throw new Error('pretty-format: Options "min" and "indent" cannot be used together.');
|
|
}
|
|
|
|
if (options.theme !== undefined) {
|
|
if (options.theme === null) {
|
|
throw new Error('pretty-format: Option "theme" must not be null.');
|
|
}
|
|
|
|
if (_typeof(options.theme) !== 'object') {
|
|
throw new Error('pretty-format: Option "theme" must be of type "object" but instead received "' + _typeof(options.theme) + '".');
|
|
}
|
|
}
|
|
}
|
|
|
|
var getColorsHighlight = function getColorsHighlight(options) {
|
|
return DEFAULT_THEME_KEYS.reduce(function (colors, key) {
|
|
var value = options.theme && options.theme[key] !== undefined ? options.theme[key] : DEFAULT_THEME[key];
|
|
var color = ansiStyles[value];
|
|
if (color && typeof color.close === 'string' && typeof color.open === 'string') {
|
|
colors[key] = color;
|
|
} else {
|
|
throw new Error('pretty-format: Option "theme" has a key "' + key + '" whose value "' + value + '" is undefined in ansi-styles.');
|
|
}
|
|
return colors;
|
|
}, {});
|
|
};
|
|
|
|
var getColorsEmpty = function getColorsEmpty() {
|
|
return DEFAULT_THEME_KEYS.reduce(function (colors, key) {
|
|
colors[key] = { close: '', open: '' };
|
|
return colors;
|
|
}, {});
|
|
};
|
|
|
|
var getPrintFunctionName = function getPrintFunctionName(options) {
|
|
return options && options.printFunctionName !== undefined ? options.printFunctionName : DEFAULT_OPTIONS.printFunctionName;
|
|
};
|
|
|
|
var getEscapeRegex = function getEscapeRegex(options) {
|
|
return options && options.escapeRegex !== undefined ? options.escapeRegex : DEFAULT_OPTIONS.escapeRegex;
|
|
};
|
|
|
|
var getConfig = function getConfig(options) {
|
|
return {
|
|
callToJSON: options && options.callToJSON !== undefined ? options.callToJSON : DEFAULT_OPTIONS.callToJSON,
|
|
colors: options && options.highlight ? getColorsHighlight(options) : getColorsEmpty(),
|
|
escapeRegex: getEscapeRegex(options),
|
|
indent: options && options.min ? '' : createIndent(options && options.indent !== undefined ? options.indent : DEFAULT_OPTIONS.indent),
|
|
maxDepth: options && options.maxDepth !== undefined ? options.maxDepth : DEFAULT_OPTIONS.maxDepth,
|
|
min: options && options.min !== undefined ? options.min : DEFAULT_OPTIONS.min,
|
|
plugins: options && options.plugins !== undefined ? options.plugins : DEFAULT_OPTIONS.plugins,
|
|
printFunctionName: getPrintFunctionName(options),
|
|
spacingInner: options && options.min ? ' ' : '\n',
|
|
spacingOuter: options && options.min ? '' : '\n'
|
|
};
|
|
};
|
|
|
|
function createIndent(indent) {
|
|
return new Array(indent + 1).join(' ');
|
|
}
|
|
|
|
function prettyFormat(val, options) {
|
|
if (options) {
|
|
validateOptions(options);
|
|
if (options.plugins) {
|
|
var plugin = findPlugin(options.plugins, val);
|
|
if (plugin !== null) {
|
|
return printPlugin(plugin, val, getConfig(options), '', 0, []);
|
|
}
|
|
}
|
|
}
|
|
|
|
var basicResult = printBasicValue(val, getPrintFunctionName(options), getEscapeRegex(options));
|
|
if (basicResult !== null) {
|
|
return basicResult;
|
|
}
|
|
|
|
return printComplexValue(val, getConfig(options), '', 0, []);
|
|
}
|
|
|
|
prettyFormat.plugins = {
|
|
AsymmetricMatcher: AsymmetricMatcher,
|
|
ConvertAnsi: ConvertAnsi,
|
|
DOMElement: DOMElement,
|
|
Immutable: Immutable,
|
|
ReactElement: ReactElement,
|
|
ReactTestComponent: ReactTestComponent
|
|
};
|
|
|
|
module.exports = prettyFormat;
|
|
|
|
})));
|