From e3a528c76486d712e1f71fd34ab214cc8b4bd80c Mon Sep 17 00:00:00 2001 From: Brett Camper Date: Wed, 17 Aug 2016 18:05:06 -0400 Subject: [PATCH] v0.9.1 --- dist/tangram.debug.js | 14777 ++++++++++++++++++++++------------------ dist/tangram.min.js | 38 +- package.json | 2 +- 3 files changed, 8188 insertions(+), 6629 deletions(-) diff --git a/dist/tangram.debug.js b/dist/tangram.debug.js index ad2286fc0..51f4c13ff 100644 --- a/dist/tangram.debug.js +++ b/dist/tangram.debug.js @@ -290,70 +290,72 @@ rawAsap.makeRequestCallFromTimer = makeRequestCallFromTimer; // https://github.com/tildeio/rsvp.js/blob/cddf7232546a9cf858524b75cde6f9edf72620a7/lib/rsvp/asap.js }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -//# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9hc2FwL2Jyb3dzZXItcmF3LmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0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IG1hZGUgZnVydGhlclxuLy8gYW1lbmRtZW50cy4gVGhlc2UgZGVjaXNpb25zLCBwYXJ0aWN1bGFybHkgdG8gbWFyZ2luYWxpemUgTWVzc2FnZUNoYW5uZWwgYW5kXG4vLyB0byBjYXB0dXJlIHRoZSBNdXRhdGlvbk9ic2VydmVyIGltcGxlbWVudGF0aW9uIGluIGEgY2xvc3VyZSwgd2VyZSBpbnRlZ3JhdGVkXG4vLyBiYWNrIGludG8gQVNBUCBwcm9wZXIuXG4vLyBodHRwczovL2dpdGh1Yi5jb20vdGlsZGVpby9yc3ZwLmpzL2Jsb2IvY2RkZjcyMzI1NDZhOWNmODU4NTI0Yjc1Y2RlNmY5ZWRmNzI2MjBhNy9saWIvcnN2cC9hc2FwLmpzXG4iXX0= + },{}],3:[function(_dereq_,module,exports){ module.exports = { "default": _dereq_("core-js/library/fn/array/from"), __esModule: true }; -},{"core-js/library/fn/array/from":43}],4:[function(_dereq_,module,exports){ +},{"core-js/library/fn/array/from":42}],4:[function(_dereq_,module,exports){ module.exports = { "default": _dereq_("core-js/library/fn/get-iterator"), __esModule: true }; -},{"core-js/library/fn/get-iterator":44}],5:[function(_dereq_,module,exports){ +},{"core-js/library/fn/get-iterator":43}],5:[function(_dereq_,module,exports){ module.exports = { "default": _dereq_("core-js/library/fn/is-iterable"), __esModule: true }; -},{"core-js/library/fn/is-iterable":45}],6:[function(_dereq_,module,exports){ +},{"core-js/library/fn/is-iterable":44}],6:[function(_dereq_,module,exports){ +module.exports = { "default": _dereq_("core-js/library/fn/json/stringify"), __esModule: true }; +},{"core-js/library/fn/json/stringify":45}],7:[function(_dereq_,module,exports){ module.exports = { "default": _dereq_("core-js/library/fn/map"), __esModule: true }; -},{"core-js/library/fn/map":46}],7:[function(_dereq_,module,exports){ +},{"core-js/library/fn/map":46}],8:[function(_dereq_,module,exports){ module.exports = { "default": _dereq_("core-js/library/fn/math/log2"), __esModule: true }; -},{"core-js/library/fn/math/log2":47}],8:[function(_dereq_,module,exports){ +},{"core-js/library/fn/math/log2":47}],9:[function(_dereq_,module,exports){ module.exports = { "default": _dereq_("core-js/library/fn/object/assign"), __esModule: true }; -},{"core-js/library/fn/object/assign":48}],9:[function(_dereq_,module,exports){ +},{"core-js/library/fn/object/assign":48}],10:[function(_dereq_,module,exports){ module.exports = { "default": _dereq_("core-js/library/fn/object/create"), __esModule: true }; -},{"core-js/library/fn/object/create":49}],10:[function(_dereq_,module,exports){ -module.exports = { "default": _dereq_("core-js/library/fn/object/define-properties"), __esModule: true }; -},{"core-js/library/fn/object/define-properties":50}],11:[function(_dereq_,module,exports){ +},{"core-js/library/fn/object/create":49}],11:[function(_dereq_,module,exports){ module.exports = { "default": _dereq_("core-js/library/fn/object/define-property"), __esModule: true }; -},{"core-js/library/fn/object/define-property":51}],12:[function(_dereq_,module,exports){ +},{"core-js/library/fn/object/define-property":50}],12:[function(_dereq_,module,exports){ module.exports = { "default": _dereq_("core-js/library/fn/object/freeze"), __esModule: true }; -},{"core-js/library/fn/object/freeze":52}],13:[function(_dereq_,module,exports){ +},{"core-js/library/fn/object/freeze":51}],13:[function(_dereq_,module,exports){ module.exports = { "default": _dereq_("core-js/library/fn/object/get-own-property-descriptor"), __esModule: true }; -},{"core-js/library/fn/object/get-own-property-descriptor":53}],14:[function(_dereq_,module,exports){ +},{"core-js/library/fn/object/get-own-property-descriptor":52}],14:[function(_dereq_,module,exports){ +module.exports = { "default": _dereq_("core-js/library/fn/object/get-prototype-of"), __esModule: true }; +},{"core-js/library/fn/object/get-prototype-of":53}],15:[function(_dereq_,module,exports){ module.exports = { "default": _dereq_("core-js/library/fn/object/keys"), __esModule: true }; -},{"core-js/library/fn/object/keys":54}],15:[function(_dereq_,module,exports){ +},{"core-js/library/fn/object/keys":54}],16:[function(_dereq_,module,exports){ module.exports = { "default": _dereq_("core-js/library/fn/object/set-prototype-of"), __esModule: true }; -},{"core-js/library/fn/object/set-prototype-of":55}],16:[function(_dereq_,module,exports){ +},{"core-js/library/fn/object/set-prototype-of":55}],17:[function(_dereq_,module,exports){ module.exports = { "default": _dereq_("core-js/library/fn/promise"), __esModule: true }; -},{"core-js/library/fn/promise":56}],17:[function(_dereq_,module,exports){ +},{"core-js/library/fn/promise":56}],18:[function(_dereq_,module,exports){ module.exports = { "default": _dereq_("core-js/library/fn/set"), __esModule: true }; -},{"core-js/library/fn/set":57}],18:[function(_dereq_,module,exports){ +},{"core-js/library/fn/set":57}],19:[function(_dereq_,module,exports){ module.exports = { "default": _dereq_("core-js/library/fn/symbol"), __esModule: true }; -},{"core-js/library/fn/symbol":58}],19:[function(_dereq_,module,exports){ +},{"core-js/library/fn/symbol":58}],20:[function(_dereq_,module,exports){ module.exports = { "default": _dereq_("core-js/library/fn/symbol/iterator"), __esModule: true }; -},{"core-js/library/fn/symbol/iterator":59}],20:[function(_dereq_,module,exports){ +},{"core-js/library/fn/symbol/iterator":59}],21:[function(_dereq_,module,exports){ "use strict"; -exports["default"] = Function.prototype.bind; exports.__esModule = true; -},{}],21:[function(_dereq_,module,exports){ -"use strict"; -exports["default"] = function (instance, Constructor) { +exports.default = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; - -exports.__esModule = true; },{}],22:[function(_dereq_,module,exports){ "use strict"; -var _Object$defineProperty = _dereq_("babel-runtime/core-js/object/define-property")["default"]; +exports.__esModule = true; + +var _defineProperty = _dereq_("../core-js/object/define-property"); + +var _defineProperty2 = _interopRequireDefault(_defineProperty); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -exports["default"] = (function () { +exports.default = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; - - _Object$defineProperty(target, descriptor.key, descriptor); + (0, _defineProperty2.default)(target, descriptor.key, descriptor); } } @@ -362,17 +364,21 @@ exports["default"] = (function () { if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; -})(); +}(); +},{"../core-js/object/define-property":11}],23:[function(_dereq_,module,exports){ +"use strict"; exports.__esModule = true; -},{"babel-runtime/core-js/object/define-property":11}],23:[function(_dereq_,module,exports){ -"use strict"; -var _Object$defineProperty = _dereq_("babel-runtime/core-js/object/define-property")["default"]; +var _defineProperty = _dereq_("../core-js/object/define-property"); + +var _defineProperty2 = _interopRequireDefault(_defineProperty); -exports["default"] = function (obj, key, value) { +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.default = function (obj, key, value) { if (key in obj) { - _Object$defineProperty(obj, key, { + (0, _defineProperty2.default)(obj, key, { value: value, enumerable: true, configurable: true, @@ -384,66 +390,70 @@ exports["default"] = function (obj, key, value) { return obj; }; +},{"../core-js/object/define-property":11}],24:[function(_dereq_,module,exports){ +"use strict"; exports.__esModule = true; -},{"babel-runtime/core-js/object/define-property":11}],24:[function(_dereq_,module,exports){ -"use strict"; -var _Object$getOwnPropertyDescriptor = _dereq_("babel-runtime/core-js/object/get-own-property-descriptor")["default"]; +var _getPrototypeOf = _dereq_("../core-js/object/get-prototype-of"); -exports["default"] = function get(_x, _x2, _x3) { - var _again = true; +var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf); - _function: while (_again) { - var object = _x, - property = _x2, - receiver = _x3; - _again = false; - if (object === null) object = Function.prototype; +var _getOwnPropertyDescriptor = _dereq_("../core-js/object/get-own-property-descriptor"); - var desc = _Object$getOwnPropertyDescriptor(object, property); +var _getOwnPropertyDescriptor2 = _interopRequireDefault(_getOwnPropertyDescriptor); - if (desc === undefined) { - var parent = Object.getPrototypeOf(object); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - if (parent === null) { - return undefined; - } else { - _x = parent; - _x2 = property; - _x3 = receiver; - _again = true; - desc = parent = undefined; - continue _function; - } - } else if ("value" in desc) { - return desc.value; - } else { - var getter = desc.get; +exports.default = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = (0, _getOwnPropertyDescriptor2.default)(object, property); - if (getter === undefined) { - return undefined; - } + if (desc === undefined) { + var parent = (0, _getPrototypeOf2.default)(object); + + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; - return getter.call(receiver); + if (getter === undefined) { + return undefined; } + + return getter.call(receiver); } }; +},{"../core-js/object/get-own-property-descriptor":13,"../core-js/object/get-prototype-of":14}],25:[function(_dereq_,module,exports){ +"use strict"; exports.__esModule = true; -},{"babel-runtime/core-js/object/get-own-property-descriptor":13}],25:[function(_dereq_,module,exports){ -"use strict"; -var _Object$create = _dereq_("babel-runtime/core-js/object/create")["default"]; +var _setPrototypeOf = _dereq_("../core-js/object/set-prototype-of"); + +var _setPrototypeOf2 = _interopRequireDefault(_setPrototypeOf); + +var _create = _dereq_("../core-js/object/create"); + +var _create2 = _interopRequireDefault(_create); + +var _typeof2 = _dereq_("../helpers/typeof"); -var _Object$setPrototypeOf = _dereq_("babel-runtime/core-js/object/set-prototype-of")["default"]; +var _typeof3 = _interopRequireDefault(_typeof2); -exports["default"] = function (subClass, superClass) { +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.default = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { - throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); + throw new TypeError("Super expression must either be null or a function, not " + (typeof superClass === "undefined" ? "undefined" : (0, _typeof3.default)(superClass))); } - subClass.prototype = _Object$create(superClass && superClass.prototype, { + subClass.prototype = (0, _create2.default)(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, @@ -451,28 +461,42 @@ exports["default"] = function (subClass, superClass) { configurable: true } }); - if (superClass) _Object$setPrototypeOf ? _Object$setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; + if (superClass) _setPrototypeOf2.default ? (0, _setPrototypeOf2.default)(subClass, superClass) : subClass.__proto__ = superClass; }; +},{"../core-js/object/create":10,"../core-js/object/set-prototype-of":16,"../helpers/typeof":29}],26:[function(_dereq_,module,exports){ +"use strict"; exports.__esModule = true; -},{"babel-runtime/core-js/object/create":9,"babel-runtime/core-js/object/set-prototype-of":15}],26:[function(_dereq_,module,exports){ -"use strict"; -exports["default"] = function (obj) { - return obj && obj.__esModule ? obj : { - "default": obj - }; +var _typeof2 = _dereq_("../helpers/typeof"); + +var _typeof3 = _interopRequireDefault(_typeof2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.default = function (self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return call && ((typeof call === "undefined" ? "undefined" : (0, _typeof3.default)(call)) === "object" || typeof call === "function") ? call : self; }; +},{"../helpers/typeof":29}],27:[function(_dereq_,module,exports){ +"use strict"; exports.__esModule = true; -},{}],27:[function(_dereq_,module,exports){ -"use strict"; -var _getIterator = _dereq_("babel-runtime/core-js/get-iterator")["default"]; +var _isIterable2 = _dereq_("../core-js/is-iterable"); + +var _isIterable3 = _interopRequireDefault(_isIterable2); -var _isIterable = _dereq_("babel-runtime/core-js/is-iterable")["default"]; +var _getIterator2 = _dereq_("../core-js/get-iterator"); -exports["default"] = (function () { +var _getIterator3 = _interopRequireDefault(_getIterator2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.default = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; @@ -480,7 +504,7 @@ exports["default"] = (function () { var _e = undefined; try { - for (var _i = _getIterator(arr), _s; !(_n = (_s = _i.next()).done); _n = true) { + for (var _i = (0, _getIterator3.default)(arr), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; @@ -502,1044 +526,390 @@ exports["default"] = (function () { return function (arr, i) { if (Array.isArray(arr)) { return arr; - } else if (_isIterable(Object(arr))) { + } else if ((0, _isIterable3.default)(Object(arr))) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; -})(); +}(); +},{"../core-js/get-iterator":4,"../core-js/is-iterable":5}],28:[function(_dereq_,module,exports){ +"use strict"; exports.__esModule = true; -},{"babel-runtime/core-js/get-iterator":4,"babel-runtime/core-js/is-iterable":5}],28:[function(_dereq_,module,exports){ -"use strict"; -var _Array$from = _dereq_("babel-runtime/core-js/array/from")["default"]; +var _from = _dereq_("../core-js/array/from"); + +var _from2 = _interopRequireDefault(_from); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -exports["default"] = function (arr) { +exports.default = function (arr) { if (Array.isArray(arr)) { - for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; + for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { + arr2[i] = arr[i]; + } return arr2; } else { - return _Array$from(arr); + return (0, _from2.default)(arr); } }; +},{"../core-js/array/from":3}],29:[function(_dereq_,module,exports){ +"use strict"; exports.__esModule = true; -},{"babel-runtime/core-js/array/from":3}],29:[function(_dereq_,module,exports){ -(function (global){ -// This method of obtaining a reference to the global object needs to be -// kept identical to the way it is obtained in runtime.js -var g = - typeof global === "object" ? global : - typeof window === "object" ? window : - typeof self === "object" ? self : this; -// Use `getOwnPropertyNames` because not all browsers support calling -// `hasOwnProperty` on the global `self` object in a worker. See #183. -var hadRuntime = g.regeneratorRuntime && - Object.getOwnPropertyNames(g).indexOf("regeneratorRuntime") >= 0; +var _iterator = _dereq_("../core-js/symbol/iterator"); -// Save the old regeneratorRuntime in case it needs to be restored later. -var oldRuntime = hadRuntime && g.regeneratorRuntime; +var _iterator2 = _interopRequireDefault(_iterator); -// Force reevalutation of runtime.js. -g.regeneratorRuntime = undefined; +var _symbol = _dereq_("../core-js/symbol"); -module.exports = _dereq_("./runtime"); +var _symbol2 = _interopRequireDefault(_symbol); -if (hadRuntime) { - // Restore the original runtime. - g.regeneratorRuntime = oldRuntime; -} else { - // Remove the global property added by runtime.js. - try { - delete g.regeneratorRuntime; - } catch(e) { - g.regeneratorRuntime = undefined; - } -} +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 ? "symbol" : typeof obj; }; -module.exports = { "default": module.exports, __esModule: true }; +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -//# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9iYWJlbC1ydW50aW1lL3JlZ2VuZXJhdG9yL2luZGV4LmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsImZpbGUiOiJnZW5lcmF0ZWQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlc0NvbnRlbnQiOlsiLy8gVGhpcyBtZXRob2Qgb2Ygb2J0YWluaW5nIGEgcmVmZXJlbmNlIHRvIHRoZSBnbG9iYWwgb2JqZWN0IG5lZWRzIHRvIGJlXG4vLyBrZXB0IGlkZW50aWNhbCB0byB0aGUgd2F5IGl0IGlzIG9idGFpbmVkIGluIHJ1bnRpbWUuanNcbnZhciBnID1cbiAgdHlwZW9mIGdsb2JhbCA9PT0gXCJvYmplY3RcIiA/IGdsb2JhbCA6XG4gIHR5cGVvZiB3aW5kb3cgPT09IFwib2JqZWN0XCIgPyB3aW5kb3cgOlxuICB0eXBlb2Ygc2VsZiA9PT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xuXG5tb2R1bGUuZXhwb3J0cyA9IHsgXCJkZWZhdWx0XCI6IG1vZHVsZS5leHBvcnRzLCBfX2VzTW9kdWxlOiB0cnVlIH07XG4iXX0= -},{"./runtime":30}],30:[function(_dereq_,module,exports){ -(function (process,global){ -/** - * Copyright (c) 2014, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * https://raw.github.com/facebook/regenerator/master/LICENSE file. An - * additional grant of patent rights can be found in the PATENTS file in - * the same directory. - */ +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 ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof(obj); +}; +},{"../core-js/symbol":19,"../core-js/symbol/iterator":20}],30:[function(_dereq_,module,exports){ +module.exports = _dereq_("regenerator-runtime"); -"use strict"; +},{"regenerator-runtime":279}],31:[function(_dereq_,module,exports){ +'use strict' -var _Symbol = _dereq_("babel-runtime/core-js/symbol")["default"]; +exports.toByteArray = toByteArray +exports.fromByteArray = fromByteArray -var _Symbol$iterator = _dereq_("babel-runtime/core-js/symbol/iterator")["default"]; +var lookup = [] +var revLookup = [] +var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array -var _Object$create = _dereq_("babel-runtime/core-js/object/create")["default"]; +function init () { + var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' + for (var i = 0, len = code.length; i < len; ++i) { + lookup[i] = code[i] + revLookup[code.charCodeAt(i)] = i + } -var _Promise = _dereq_("babel-runtime/core-js/promise")["default"]; + revLookup['-'.charCodeAt(0)] = 62 + revLookup['_'.charCodeAt(0)] = 63 +} -!(function (global) { - "use strict"; +init() - var hasOwn = Object.prototype.hasOwnProperty; - var undefined; // More compressible than void 0. - var iteratorSymbol = typeof _Symbol === "function" && _Symbol$iterator || "@@iterator"; +function toByteArray (b64) { + var i, j, l, tmp, placeHolders, arr + var len = b64.length - var inModule = typeof module === "object"; - var runtime = global.regeneratorRuntime; - if (runtime) { - if (inModule) { - // If regeneratorRuntime is defined globally and we're in a module, - // make the exports object identical to regeneratorRuntime. - module.exports = runtime; - } - // Don't bother evaluating the rest of this file if the runtime was - // already defined globally. - return; + if (len % 4 > 0) { + throw new Error('Invalid string. Length must be a multiple of 4') } - // Define the runtime globally (as expected by generated code) as either - // module.exports (if we're in a module) or a new, empty object. - runtime = global.regeneratorRuntime = inModule ? module.exports : {}; + // the number of equal signs (place holders) + // if there are two placeholders, than the two characters before it + // represent one byte + // if there is only one, then the three characters before it represent 2 bytes + // this is just a cheap hack to not do indexOf twice + placeHolders = b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0 - function wrap(innerFn, outerFn, self, tryLocsList) { - // If outerFn provided, then outerFn.prototype instanceof Generator. - var generator = _Object$create((outerFn || Generator).prototype); + // base64 is 4/3 + up to two characters of the original data + arr = new Arr(len * 3 / 4 - placeHolders) - generator._invoke = makeInvokeMethod(innerFn, self || null, new Context(tryLocsList || [])); + // if there are placeholders, only get up to the last complete 4 chars + l = placeHolders > 0 ? len - 4 : len - return generator; - } - runtime.wrap = wrap; + var L = 0 - // Try/catch helper to minimize deoptimizations. Returns a completion - // record like context.tryEntries[i].completion. This interface could - // have been (and was previously) designed to take a closure to be - // invoked without arguments, but in all the cases we care about we - // already have an existing method we want to call, so there's no need - // to create a new function object. We can even get away with assuming - // the method takes exactly one argument, since that happens to be true - // in every case, so we don't have to touch the arguments object. The - // only additional allocation required is the completion record, which - // has a stable shape and so hopefully should be cheap to allocate. - function tryCatch(fn, obj, arg) { - try { - return { type: "normal", arg: fn.call(obj, arg) }; - } catch (err) { - return { type: "throw", arg: err }; - } + for (i = 0, j = 0; i < l; i += 4, j += 3) { + tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)] + arr[L++] = (tmp >> 16) & 0xFF + arr[L++] = (tmp >> 8) & 0xFF + arr[L++] = tmp & 0xFF } - var GenStateSuspendedStart = "suspendedStart"; - var GenStateSuspendedYield = "suspendedYield"; - var GenStateExecuting = "executing"; - var GenStateCompleted = "completed"; - - // Returning this object from the innerFn has the same effect as - // breaking out of the dispatch switch statement. - var ContinueSentinel = {}; + if (placeHolders === 2) { + tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4) + arr[L++] = tmp & 0xFF + } else if (placeHolders === 1) { + tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2) + arr[L++] = (tmp >> 8) & 0xFF + arr[L++] = tmp & 0xFF + } - // Dummy constructor functions that we use as the .constructor and - // .constructor.prototype properties for functions that return Generator - // objects. For full spec compliance, you may wish to configure your - // minifier not to mangle the names of these two functions. - function Generator() {} - function GeneratorFunction() {} - function GeneratorFunctionPrototype() {} + return arr +} - var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype; - GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; - GeneratorFunctionPrototype.constructor = GeneratorFunction; - GeneratorFunction.displayName = "GeneratorFunction"; +function tripletToBase64 (num) { + return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] +} - // Helper for defining the .next, .throw, and .return methods of the - // Iterator interface in terms of a single ._invoke method. - function defineIteratorMethods(prototype) { - ["next", "throw", "return"].forEach(function (method) { - prototype[method] = function (arg) { - return this._invoke(method, arg); - }; - }); +function encodeChunk (uint8, start, end) { + var tmp + var output = [] + for (var i = start; i < end; i += 3) { + tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]) + output.push(tripletToBase64(tmp)) } + return output.join('') +} - runtime.isGeneratorFunction = function (genFun) { - var ctor = typeof genFun === "function" && genFun.constructor; - return ctor ? ctor === GeneratorFunction || - // For the native GeneratorFunction constructor, the best we can - // do is to check its .name property. - (ctor.displayName || ctor.name) === "GeneratorFunction" : false; - }; - - runtime.mark = function (genFun) { - genFun.__proto__ = GeneratorFunctionPrototype; - genFun.prototype = _Object$create(Gp); - return genFun; - }; +function fromByteArray (uint8) { + var tmp + var len = uint8.length + var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes + var output = '' + var parts = [] + var maxChunkLength = 16383 // must be multiple of 3 - // Within the body of any async function, `await x` is transformed to - // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test - // `value instanceof AwaitArgument` to determine if the yielded value is - // meant to be awaited. Some may consider the name of this method too - // cutesy, but they are curmudgeons. - runtime.awrap = function (arg) { - return new AwaitArgument(arg); - }; + // go through the array every three bytes, we'll deal with trailing stuff later + for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { + parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) + } - function AwaitArgument(arg) { - this.arg = arg; + // pad the end with zeros, but make sure to not forget the extra bytes + if (extraBytes === 1) { + tmp = uint8[len - 1] + output += lookup[tmp >> 2] + output += lookup[(tmp << 4) & 0x3F] + output += '==' + } else if (extraBytes === 2) { + tmp = (uint8[len - 2] << 8) + (uint8[len - 1]) + output += lookup[tmp >> 10] + output += lookup[(tmp >> 4) & 0x3F] + output += lookup[(tmp << 2) & 0x3F] + output += '=' } - function AsyncIterator(generator) { - // This invoke function is written in a style that assumes some - // calling function (or Promise) will handle exceptions. - function invoke(method, arg) { - var result = generator[method](arg); - var value = result.value; - return value instanceof AwaitArgument ? _Promise.resolve(value.arg).then(invokeNext, invokeThrow) : _Promise.resolve(value).then(function (unwrapped) { - // When a yielded Promise is resolved, its final value becomes - // the .value of the Promise<{value,done}> result for the - // current iteration. If the Promise is rejected, however, the - // result for this iteration will be rejected with the same - // reason. Note that rejections of yielded Promises are not - // thrown back into the generator function, as is the case - // when an awaited Promise is rejected. This difference in - // behavior between yield and await is important, because it - // allows the consumer to decide what to do with the yielded - // rejection (swallow it and continue, manually .throw it back - // into the generator, abandon iteration, whatever). With - // await, by contrast, there is no opportunity to examine the - // rejection reason outside the generator function, so the - // only option is to throw it from the await expression, and - // let the generator function handle the exception. - result.value = unwrapped; - return result; - }); - } + parts.push(output) - if (typeof process === "object" && process.domain) { - invoke = process.domain.bind(invoke); - } + return parts.join('') +} - var invokeNext = invoke.bind(generator, "next"); - var invokeThrow = invoke.bind(generator, "throw"); - var invokeReturn = invoke.bind(generator, "return"); - var previousPromise; +},{}],32:[function(_dereq_,module,exports){ +/** + * Bit twiddling hacks for JavaScript. + * + * Author: Mikola Lysenko + * + * Ported from Stanford bit twiddling hack library: + * http://graphics.stanford.edu/~seander/bithacks.html + */ - function enqueue(method, arg) { - var enqueueResult = - // If enqueue has been called before, then we want to wait until - // all previous Promises have been resolved before calling invoke, - // so that results are always delivered in the correct order. If - // enqueue has not been called before, then it is important to - // call invoke immediately, without waiting on a callback to fire, - // so that the async generator function has the opportunity to do - // any necessary setup in a predictable way. This predictability - // is why the Promise constructor synchronously invokes its - // executor callback, and why async functions synchronously - // execute code before the first await. Since we implement simple - // async functions in terms of async generators, it is especially - // important to get this right, even though it requires care. - previousPromise ? previousPromise.then(function () { - return invoke(method, arg); - }) : new _Promise(function (resolve) { - resolve(invoke(method, arg)); - }); +"use strict"; "use restrict"; - // Avoid propagating enqueueResult failures to Promises returned by - // later invocations of the iterator. - previousPromise = enqueueResult["catch"](function (ignored) {}); +//Number of bits in an integer +var INT_BITS = 32; - return enqueueResult; - } +//Constants +exports.INT_BITS = INT_BITS; +exports.INT_MAX = 0x7fffffff; +exports.INT_MIN = -1<<(INT_BITS-1); - // Define the unified helper method that is used to implement .next, - // .throw, and .return (see defineIteratorMethods). - this._invoke = enqueue; - } +//Returns -1, 0, +1 depending on sign of x +exports.sign = function(v) { + return (v > 0) - (v < 0); +} - defineIteratorMethods(AsyncIterator.prototype); +//Computes absolute value of integer +exports.abs = function(v) { + var mask = v >> (INT_BITS-1); + return (v ^ mask) - mask; +} - // Note that simple async functions are implemented on top of - // AsyncIterator objects; they just return a Promise for the value of - // the final result produced by the iterator. - runtime.async = function (innerFn, outerFn, self, tryLocsList) { - var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList)); +//Computes minimum of integers x and y +exports.min = function(x, y) { + return y ^ ((x ^ y) & -(x < y)); +} - return runtime.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator. - : iter.next().then(function (result) { - return result.done ? result.value : iter.next(); - }); - }; +//Computes maximum of integers x and y +exports.max = function(x, y) { + return x ^ ((x ^ y) & -(x < y)); +} - function makeInvokeMethod(innerFn, self, context) { - var state = GenStateSuspendedStart; +//Checks if a number is a power of two +exports.isPow2 = function(v) { + return !(v & (v-1)) && (!!v); +} - return function invoke(method, arg) { - if (state === GenStateExecuting) { - throw new Error("Generator is already running"); - } +//Computes log base 2 of v +exports.log2 = function(v) { + var r, shift; + r = (v > 0xFFFF) << 4; v >>>= r; + shift = (v > 0xFF ) << 3; v >>>= shift; r |= shift; + shift = (v > 0xF ) << 2; v >>>= shift; r |= shift; + shift = (v > 0x3 ) << 1; v >>>= shift; r |= shift; + return r | (v >> 1); +} - if (state === GenStateCompleted) { - if (method === "throw") { - throw arg; - } +//Computes log base 10 of v +exports.log10 = function(v) { + return (v >= 1000000000) ? 9 : (v >= 100000000) ? 8 : (v >= 10000000) ? 7 : + (v >= 1000000) ? 6 : (v >= 100000) ? 5 : (v >= 10000) ? 4 : + (v >= 1000) ? 3 : (v >= 100) ? 2 : (v >= 10) ? 1 : 0; +} - // Be forgiving, per 25.3.3.3.3 of the spec: - // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume - return doneResult(); - } +//Counts number of bits +exports.popCount = function(v) { + v = v - ((v >>> 1) & 0x55555555); + v = (v & 0x33333333) + ((v >>> 2) & 0x33333333); + return ((v + (v >>> 4) & 0xF0F0F0F) * 0x1010101) >>> 24; +} - while (true) { - var delegate = context.delegate; - if (delegate) { - if (method === "return" || method === "throw" && delegate.iterator[method] === undefined) { - // A return or throw (when the delegate iterator has no throw - // method) always terminates the yield* loop. - context.delegate = null; +//Counts number of trailing zeros +function countTrailingZeros(v) { + var c = 32; + v &= -v; + if (v) c--; + if (v & 0x0000FFFF) c -= 16; + if (v & 0x00FF00FF) c -= 8; + if (v & 0x0F0F0F0F) c -= 4; + if (v & 0x33333333) c -= 2; + if (v & 0x55555555) c -= 1; + return c; +} +exports.countTrailingZeros = countTrailingZeros; - // If the delegate iterator has a return method, give it a - // chance to clean up. - var returnMethod = delegate.iterator["return"]; - if (returnMethod) { - var record = tryCatch(returnMethod, delegate.iterator, arg); - if (record.type === "throw") { - // If the return method threw an exception, let that - // exception prevail over the original return or throw. - method = "throw"; - arg = record.arg; - continue; - } - } +//Rounds to next power of 2 +exports.nextPow2 = function(v) { + v += v === 0; + --v; + v |= v >>> 1; + v |= v >>> 2; + v |= v >>> 4; + v |= v >>> 8; + v |= v >>> 16; + return v + 1; +} - if (method === "return") { - // Continue with the outer return, now that the delegate - // iterator has been terminated. - continue; - } - } +//Rounds down to previous power of 2 +exports.prevPow2 = function(v) { + v |= v >>> 1; + v |= v >>> 2; + v |= v >>> 4; + v |= v >>> 8; + v |= v >>> 16; + return v - (v>>>1); +} - var record = tryCatch(delegate.iterator[method], delegate.iterator, arg); +//Computes parity of word +exports.parity = function(v) { + v ^= v >>> 16; + v ^= v >>> 8; + v ^= v >>> 4; + v &= 0xf; + return (0x6996 >>> v) & 1; +} - if (record.type === "throw") { - context.delegate = null; +var REVERSE_TABLE = new Array(256); - // Like returning generator.throw(uncaught), but without the - // overhead of an extra function call. - method = "throw"; - arg = record.arg; - continue; - } +(function(tab) { + for(var i=0; i<256; ++i) { + var v = i, r = i, s = 7; + for (v >>>= 1; v; v >>>= 1) { + r <<= 1; + r |= v & 1; + --s; + } + tab[i] = (r << s) & 0xff; + } +})(REVERSE_TABLE); - // Delegate generator ran and handled its own exceptions so - // regardless of what the method was, we continue as if it is - // "next" with an undefined arg. - method = "next"; - arg = undefined; +//Reverse bits in a 32 bit word +exports.reverse = function(v) { + return (REVERSE_TABLE[ v & 0xff] << 24) | + (REVERSE_TABLE[(v >>> 8) & 0xff] << 16) | + (REVERSE_TABLE[(v >>> 16) & 0xff] << 8) | + REVERSE_TABLE[(v >>> 24) & 0xff]; +} - var info = record.arg; - if (info.done) { - context[delegate.resultName] = info.value; - context.next = delegate.nextLoc; - } else { - state = GenStateSuspendedYield; - return info; - } +//Interleave bits of 2 coordinates with 16 bits. Useful for fast quadtree codes +exports.interleave2 = function(x, y) { + x &= 0xFFFF; + x = (x | (x << 8)) & 0x00FF00FF; + x = (x | (x << 4)) & 0x0F0F0F0F; + x = (x | (x << 2)) & 0x33333333; + x = (x | (x << 1)) & 0x55555555; - context.delegate = null; - } + y &= 0xFFFF; + y = (y | (y << 8)) & 0x00FF00FF; + y = (y | (y << 4)) & 0x0F0F0F0F; + y = (y | (y << 2)) & 0x33333333; + y = (y | (y << 1)) & 0x55555555; - if (method === "next") { - if (state === GenStateSuspendedYield) { - context.sent = arg; - } else { - context.sent = undefined; - } - } else if (method === "throw") { - if (state === GenStateSuspendedStart) { - state = GenStateCompleted; - throw arg; - } + return x | (y << 1); +} - if (context.dispatchException(arg)) { - // If the dispatched exception was caught by a catch block, - // then let that catch block handle the exception normally. - method = "next"; - arg = undefined; - } - } else if (method === "return") { - context.abrupt("return", arg); - } +//Extracts the nth interleaved component +exports.deinterleave2 = function(v, n) { + v = (v >>> n) & 0x55555555; + v = (v | (v >>> 1)) & 0x33333333; + v = (v | (v >>> 2)) & 0x0F0F0F0F; + v = (v | (v >>> 4)) & 0x00FF00FF; + v = (v | (v >>> 16)) & 0x000FFFF; + return (v << 16) >> 16; +} - state = GenStateExecuting; - var record = tryCatch(innerFn, self, context); - if (record.type === "normal") { - // If an exception is thrown from innerFn, we leave state === - // GenStateExecuting and loop back for another invocation. - state = context.done ? GenStateCompleted : GenStateSuspendedYield; +//Interleave bits of 3 coordinates, each with 10 bits. Useful for fast octree codes +exports.interleave3 = function(x, y, z) { + x &= 0x3FF; + x = (x | (x<<16)) & 4278190335; + x = (x | (x<<8)) & 251719695; + x = (x | (x<<4)) & 3272356035; + x = (x | (x<<2)) & 1227133513; - var info = { - value: record.arg, - done: context.done - }; + y &= 0x3FF; + y = (y | (y<<16)) & 4278190335; + y = (y | (y<<8)) & 251719695; + y = (y | (y<<4)) & 3272356035; + y = (y | (y<<2)) & 1227133513; + x |= (y << 1); + + z &= 0x3FF; + z = (z | (z<<16)) & 4278190335; + z = (z | (z<<8)) & 251719695; + z = (z | (z<<4)) & 3272356035; + z = (z | (z<<2)) & 1227133513; + + return x | (z << 2); +} - if (record.arg === ContinueSentinel) { - if (context.delegate && method === "next") { - // Deliberately forget the last sent value so that we don't - // accidentally pass it on to the delegate. - arg = undefined; - } - } else { - return info; - } - } else if (record.type === "throw") { - state = GenStateCompleted; - // Dispatch the exception by looping back around to the - // context.dispatchException(arg) call above. - method = "throw"; - arg = record.arg; - } - } - }; - } +//Extracts nth interleaved component of a 3-tuple +exports.deinterleave3 = function(v, n) { + v = (v >>> n) & 1227133513; + v = (v | (v>>>2)) & 3272356035; + v = (v | (v>>>4)) & 251719695; + v = (v | (v>>>8)) & 4278190335; + v = (v | (v>>>16)) & 0x3FF; + return (v<<22)>>22; +} - // Define Generator.prototype.{next,throw,return} in terms of the - // unified ._invoke helper method. - defineIteratorMethods(Gp); +//Computes next combination in colexicographic order (this is mistakenly called nextPermutation on the bit twiddling hacks page) +exports.nextCombination = function(v) { + var t = v | (v - 1); + return (t + 1) | (((~t & -~t) - 1) >>> (countTrailingZeros(v) + 1)); +} - Gp[iteratorSymbol] = function () { - return this; - }; - Gp.toString = function () { - return "[object Generator]"; - }; +},{}],33:[function(_dereq_,module,exports){ +'use strict' - function pushTryEntry(locs) { - var entry = { tryLoc: locs[0] }; +module.exports = boxIntersectWrapper - if (1 in locs) { - entry.catchLoc = locs[1]; - } +var pool = _dereq_('typedarray-pool') +var sweep = _dereq_('./lib/sweep') +var boxIntersectIter = _dereq_('./lib/intersect') - if (2 in locs) { - entry.finallyLoc = locs[2]; - entry.afterLoc = locs[3]; - } - - this.tryEntries.push(entry); - } - - function resetTryEntry(entry) { - var record = entry.completion || {}; - record.type = "normal"; - delete record.arg; - entry.completion = record; - } - - function Context(tryLocsList) { - // The root entry object (effectively a try statement without a catch - // or a finally block) gives us a place to store values thrown from - // locations where there is no enclosing try statement. - this.tryEntries = [{ tryLoc: "root" }]; - tryLocsList.forEach(pushTryEntry, this); - this.reset(true); - } - - runtime.keys = function (object) { - var keys = []; - for (var key in object) { - keys.push(key); - } - keys.reverse(); - - // Rather than returning an object with a next method, we keep - // things simple and return the next function itself. - return function next() { - while (keys.length) { - var key = keys.pop(); - if (key in object) { - next.value = key; - next.done = false; - return next; - } - } - - // To avoid creating an additional object, we just hang the .value - // and .done properties off the next function object itself. This - // also ensures that the minifier will not anonymize the function. - next.done = true; - return next; - }; - }; - - function values(iterable) { - if (iterable) { - var iteratorMethod = iterable[iteratorSymbol]; - if (iteratorMethod) { - return iteratorMethod.call(iterable); - } - - if (typeof iterable.next === "function") { - return iterable; - } - - if (!isNaN(iterable.length)) { - var i = -1, - next = function next() { - while (++i < iterable.length) { - if (hasOwn.call(iterable, i)) { - next.value = iterable[i]; - next.done = false; - return next; - } - } - - next.value = undefined; - next.done = true; - - return next; - }; - - return next.next = next; - } - } - - // Return an iterator with no values. - return { next: doneResult }; - } - runtime.values = values; - - function doneResult() { - return { value: undefined, done: true }; - } - - Context.prototype = { - constructor: Context, - - reset: function reset(skipTempReset) { - this.prev = 0; - this.next = 0; - this.sent = undefined; - this.done = false; - this.delegate = null; - - this.tryEntries.forEach(resetTryEntry); - - if (!skipTempReset) { - for (var name in this) { - // Not sure about the optimal order of these conditions: - if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) { - this[name] = undefined; - } - } - } - }, - - stop: function stop() { - this.done = true; - - var rootEntry = this.tryEntries[0]; - var rootRecord = rootEntry.completion; - if (rootRecord.type === "throw") { - throw rootRecord.arg; - } - - return this.rval; - }, - - dispatchException: function dispatchException(exception) { - if (this.done) { - throw exception; - } - - var context = this; - function handle(loc, caught) { - record.type = "throw"; - record.arg = exception; - context.next = loc; - return !!caught; - } - - for (var i = this.tryEntries.length - 1; i >= 0; --i) { - var entry = this.tryEntries[i]; - var record = entry.completion; - - if (entry.tryLoc === "root") { - // Exception thrown outside of any try block that could handle - // it, so set the completion value of the entire function to - // throw the exception. - return handle("end"); - } - - if (entry.tryLoc <= this.prev) { - var hasCatch = hasOwn.call(entry, "catchLoc"); - var hasFinally = hasOwn.call(entry, "finallyLoc"); - - if (hasCatch && hasFinally) { - if (this.prev < entry.catchLoc) { - return handle(entry.catchLoc, true); - } else if (this.prev < entry.finallyLoc) { - return handle(entry.finallyLoc); - } - } else if (hasCatch) { - if (this.prev < entry.catchLoc) { - return handle(entry.catchLoc, true); - } - } else if (hasFinally) { - if (this.prev < entry.finallyLoc) { - return handle(entry.finallyLoc); - } - } else { - throw new Error("try statement without catch or finally"); - } - } - } - }, - - abrupt: function abrupt(type, arg) { - for (var i = this.tryEntries.length - 1; i >= 0; --i) { - var entry = this.tryEntries[i]; - if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { - var finallyEntry = entry; - break; - } - } - - if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) { - // Ignore the finally entry if control is not jumping to a - // location outside the try/catch block. - finallyEntry = null; - } - - var record = finallyEntry ? finallyEntry.completion : {}; - record.type = type; - record.arg = arg; - - if (finallyEntry) { - this.next = finallyEntry.finallyLoc; - } else { - this.complete(record); - } - - return ContinueSentinel; - }, - - complete: function complete(record, afterLoc) { - if (record.type === "throw") { - throw record.arg; - } - - if (record.type === "break" || record.type === "continue") { - this.next = record.arg; - } else if (record.type === "return") { - this.rval = record.arg; - this.next = "end"; - } else if (record.type === "normal" && afterLoc) { - this.next = afterLoc; - } - }, - - finish: function finish(finallyLoc) { - for (var i = this.tryEntries.length - 1; i >= 0; --i) { - var entry = this.tryEntries[i]; - if (entry.finallyLoc === finallyLoc) { - this.complete(entry.completion, entry.afterLoc); - resetTryEntry(entry); - return ContinueSentinel; - } - } - }, - - "catch": function _catch(tryLoc) { - for (var i = this.tryEntries.length - 1; i >= 0; --i) { - var entry = this.tryEntries[i]; - if (entry.tryLoc === tryLoc) { - var record = entry.completion; - if (record.type === "throw") { - var thrown = record.arg; - resetTryEntry(entry); - } - return thrown; - } - } - - // The context.catch method must only be called with a location - // argument that corresponds to a known catch block. - throw new Error("illegal catch attempt"); - }, - - delegateYield: function delegateYield(iterable, resultName, nextLoc) { - this.delegate = { - iterator: values(iterable), - resultName: resultName, - nextLoc: nextLoc - }; - - return ContinueSentinel; - } - }; -})( -// Among the various tricks for obtaining a reference to the global -// object, this seems to be the most reliable technique that does not -// use indirect eval (which violates Content Security Policy). -typeof global === "object" ? global : typeof window === "object" ? window : typeof self === "object" ? self : undefined); -}).call(this,_dereq_('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -//# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9iYWJlbC1ydW50aW1lL3JlZ2VuZXJhdG9yL3J1bnRpbWUuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ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sIGRlbGVnYXRlLml0ZXJhdG9yLCBhcmcpO1xuICAgICAgICAgICAgICBpZiAocmVjb3JkLnR5cGUgPT09IFwidGhyb3dcIikge1xuICAgICAgICAgICAgICAgIC8vIElmIHRoZSByZXR1cm4gbWV0aG9kIHRocmV3IGFuIGV4Y2VwdGlvbiwgbGV0IHRoYXRcbiAgICAgICAgICAgICAgICAvLyBleGNlcHRpb24gcHJldmFpbCBvdmVyIHRoZSBvcmlnaW5hbCByZXR1cm4gb3IgdGhyb3cuXG4gICAgICAgICAgICAgICAgbWV0aG9kID0gXCJ0aHJvd1wiO1xuICAgICAgICAgICAgICAgIGFyZyA9IHJlY29yZC5hcmc7XG4gICAgICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgaWYgKG1ldGhvZCA9PT0gXCJyZXR1cm5cIikge1xuICAgICAgICAgICAgICAvLyBDb250aW51ZSB3aXRoIHRoZSBvdXRlciByZXR1cm4sIG5vdyB0aGF0IHRoZSBkZWxlZ2F0ZVxuICAgICAgICAgICAgICAvLyBpdGVyYXRvciBoYXMgYmVlbiB0ZXJtaW5hdGVkLlxuICAgICAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG5cbiAgICAgICAgICB2YXIgcmVjb3JkID0gdHJ5Q2F0Y2goZGVsZWdhdGUuaXRlcmF0b3JbbWV0aG9kXSwgZGVsZWdhdGUuaXRlcmF0b3IsIGFyZyk7XG5cbiAgICAgICAgICBpZiAocmVjb3JkLnR5cGUgPT09IFwidGhyb3dcIikge1xuICAgICAgICAgICAgY29udGV4dC5kZWxlZ2F0ZSA9IG51bGw7XG5cbiAgICAgICAgICAgIC8vIExpa2UgcmV0dXJuaW5nIGdlbmVyYXRvci50aHJvdyh1bmNhdWdodCksIGJ1dCB3aXRob3V0IHRoZVxuICAgICAgICAgICAgLy8gb3ZlcmhlYWQgb2YgYW4gZXh0cmEgZnVuY3Rpb24gY2FsbC5cbiAgICAgICAgICAgIG1ldGhvZCA9IFwidGhyb3dcIjtcbiAgICAgICAgICAgIGFyZyA9IHJlY29yZC5hcmc7XG4gICAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgICB9XG5cbiAgICAgICAgICAvLyBEZWxlZ2F0ZSBnZW5lcmF0b3IgcmFuIGFuZCBoYW5kbGVkIGl0cyBvd24gZXhjZXB0aW9ucyBzb1xuICAgICAgICAgIC8vIHJlZ2FyZGxlc3Mgb2Ygd2hhdCB0aGUgbWV0aG9kIHdhcywgd2UgY29udGludWUgYXMgaWYgaXQgaXNcbiAgICAgICAgICAvLyBcIm5leHRcIiB3aXRoIGFuIHVuZGVmaW5lZCBhcmcuXG4gICAgICAgICAgbWV0aG9kID0gXCJuZXh0XCI7XG4gICAgICAgICAgYXJnID0gdW5kZWZpbmVkO1xuXG4gICAgICAgICAgdmFyIGluZm8gPSByZWNvcmQuYXJnO1xuICAgICAgICAgIGlmIChpbmZvLmRvbmUpIHtcbiAgICAgICAgICAgIGNvbnRleHRbZGVsZWdhdGUucmVzdWx0TmFtZV0gPSBpbmZvLnZhbHVlO1xuICAgICAgICAgICAgY29udGV4dC5uZXh0ID0gZGVsZWdhdGUubmV4dExvYztcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgc3RhdGUgPSBHZW5TdGF0ZVN1c3BlbmRlZFlpZWxkO1xuICAgICAgICAgICAgcmV0dXJuIGluZm87XG4gICAgICAgICAgfVxuXG4gICAgICAgICAgY29udGV4dC5kZWxlZ2F0ZSA9IG51bGw7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAobWV0aG9kID09PSBcIm5leHRcIikge1xuICAgICAgICAgIGlmIChzdGF0ZSA9PT0gR2VuU3RhdGVTdXNwZW5kZWRZaWVsZCkge1xuICAgICAgICAgICAgY29udGV4dC5zZW50ID0gYXJnO1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBjb250ZXh0LnNlbnQ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IGFcbiAgICAgICAgLy8gbG9jYXRpb24gb3V0c2lkZSB0aGUgdHJ5L2NhdGNoIGJsb2NrLlxuICAgICAgICBmaW5hbGx5RW50cnkgPSBudWxsO1xuICAgICAgfVxuXG4gICAgICB2YXIgcmVjb3JkID0gZmluYWxseUVudHJ5ID8gZmluYWxseUVudHJ5LmNvbXBsZXRpb24gOiB7fTtcbiAgICAgIHJlY29yZC50eXBlID0gdHlwZTtcbiAgICAgIHJlY29yZC5hcmcgPSBhcmc7XG5cbiAgICAgIGlmIChmaW5hbGx5RW50cnkpIHtcbiAgICAgICAgdGhpcy5uZXh0ID0gZmluYWxseUVudHJ5LmZpbmFsbHlMb2M7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICB0aGlzLmNvbXBsZXRlKHJlY29yZCk7XG4gICAgICB9XG5cbiAgICAgIHJldHVybiBDb250aW51ZVNlbnRpbmVsO1xuICAgIH0sXG5cbiAgICBjb21wbGV0ZTogZnVuY3Rpb24gY29tcGxldGUocmVjb3JkLCBhZnRlckxvYykge1xuICAgICAgaWYgKHJlY29yZC50eXBlID09PSBcInRocm93XCIpIHtcbiAgICAgICAgdGhyb3cgcmVjb3JkLmFyZztcbiAgICAgIH1cblxuICAgICAgaWYgKHJlY29yZC50eXBlID09PSBcImJyZWFrXCIgfHwgcmVjb3JkLnR5cGUgPT09IFwiY29udGludWVcIikge1xuICAgICAgICB0aGlzLm5leHQgPSByZWNvcmQuYXJnO1xuICAgICAgfSBlbHNlIGlmIChyZWNvcmQudHlwZSA9PT0gXCJyZXR1cm5cIikge1xuICAgICAgICB0aGlzLnJ2YWwgPSByZWNvcmQuYXJnO1xuICAgICAgICB0aGlzLm5leHQgPSBcImVuZFwiO1xuICAgICAgfSBlbHNlIGlmIChyZWNvcmQudHlwZSA9PT0gXCJub3JtYWxcIiAmJiBhZnRlckxvYykge1xuICAgICAgICB0aGlzLm5leHQgPSBhZnRlckxvYztcbiAgICAgIH1cbiAgICB9LFxuXG4gICAgZmluaXNoOiBmdW5jdGlvbiBmaW5pc2goZmluYWxseUxvYykge1xuICAgICAgZm9yICh2YXIgaSA9IHRoaXMudHJ5RW50cmllcy5sZW5ndGggLSAxOyBpID49IDA7IC0taSkge1xuICAgICAgICB2YXIgZW50cnkgPSB0aGlzLnRyeUVudHJpZXNbaV07XG4gICAgICAgIGlmIChlbnRyeS5maW5hbGx5TG9jID09PSBmaW5hbGx5TG9jKSB7XG4gICAgICAgICAgdGhpcy5jb21wbGV0ZShlbnRyeS5jb21wbGV0aW9uLCBlbnRyeS5hZnRlckxvYyk7XG4gICAgICAgICAgcmVzZXRUcnlFbnRyeShlbnRyeSk7XG4gICAgICAgICAgcmV0dXJuIENvbnRpbnVlU2VudGluZWw7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9LFxuXG4gICAgXCJjYXRjaFwiOiBmdW5jdGlvbiBfY2F0Y2godHJ5TG9jKSB7XG4gICAgICBmb3IgKHZhciBpID0gdGhpcy50cnlFbnRyaWVzLmxlbmd0aCAtIDE7IGkgPj0gMDsgLS1pKSB7XG4gICAgICAgIHZhciBlbnRyeSA9IHRoaXMudHJ5RW50cmllc1tpXTtcbiAgICAgICAgaWYgKGVudHJ5LnRyeUxvYyA9PT0gdHJ5TG9jKSB7XG4gICAgICAgICAgdmFyIHJlY29yZCA9IGVudHJ5LmNvbXBsZXRpb247XG4gICAgICAgICAgaWYgKHJlY29yZC50eXBlID09PSBcInRocm93XCIpIHtcbiAgICAgICAgICAgIHZhciB0aHJvd24gPSByZWNvcmQuYXJnO1xuICAgICAgICAgICAgcmVzZXRUcnlFbnRyeShlbnRyeSk7XG4gICAgICAgICAgfVxuICAgICAgICAgIHJldHVybiB0aHJvd247XG4gICAgICAgIH1cbiAgICAgIH1cblxuICAgICAgLy8gVGhlIGNvbnRleHQuY2F0Y2ggbWV0aG9kIG11c3Qgb25seSBiZSBjYWxsZWQgd2l0aCBhIGxvY2F0aW9uXG4gICAgICAvLyBhcmd1bWVudCB0aGF0IGNvcnJlc3BvbmRzIHRvIGEga25vd24gY2F0Y2ggYmxvY2suXG4gICAgICB0aHJvdyBuZXcgRXJyb3IoXCJpbGxlZ2FsIGNhdGNoIGF0dGVtcHRcIik7XG4gICAgfSxcblxuICAgIGRlbGVnYXRlWWllbGQ6IGZ1bmN0aW9uIGRlbGVnYXRlWWllbGQoaXRlcmFibGUsIHJlc3VsdE5hbWUsIG5leHRMb2MpIHtcbiAgICAgIHRoaXMuZGVsZWdhdGUgPSB7XG4gICAgICAgIGl0ZXJhdG9yOiB2YWx1ZXMoaXRlcmFibGUpLFxuICAgICAgICByZXN1bHROYW1lOiByZXN1bHROYW1lLFxuICAgICAgICBuZXh0TG9jOiBuZXh0TG9jXG4gICAgICB9O1xuXG4gICAgICByZXR1cm4gQ29udGludWVTZW50aW5lbDtcbiAgICB9XG4gIH07XG59KShcbi8vIEFtb25nIHRoZSB2YXJpb3VzIHRyaWNrcyBmb3Igb2J0YWluaW5nIGEgcmVmZXJlbmNlIHRvIHRoZSBnbG9iYWxcbi8vIG9iamVjdCwgdGhpcyBzZWVtcyB0byBiZSB0aGUgbW9zdCByZWxpYWJsZSB0ZWNobmlxdWUgdGhhdCBkb2VzIG5vdFxuLy8gdXNlIGluZGlyZWN0IGV2YWwgKHdoaWNoIHZpb2xhdGVzIENvbnRlbnQgU2VjdXJpdHkgUG9saWN5KS5cbnR5cGVvZiBnbG9iYWwgPT09IFwib2JqZWN0XCIgPyBnbG9iYWwgOiB0eXBlb2Ygd2luZG93ID09PSBcIm9iamVjdFwiID8gd2luZG93IDogdHlwZW9mIHNlbGYgPT09IFwib2JqZWN0XCIgPyBzZWxmIDogdW5kZWZpbmVkKTsiXX0= -},{"_process":251,"babel-runtime/core-js/object/create":9,"babel-runtime/core-js/promise":16,"babel-runtime/core-js/symbol":18,"babel-runtime/core-js/symbol/iterator":19}],31:[function(_dereq_,module,exports){ -var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; - -;(function (exports) { - 'use strict'; - - var Arr = (typeof Uint8Array !== 'undefined') - ? Uint8Array - : Array - - var PLUS = '+'.charCodeAt(0) - var SLASH = '/'.charCodeAt(0) - var NUMBER = '0'.charCodeAt(0) - var LOWER = 'a'.charCodeAt(0) - var UPPER = 'A'.charCodeAt(0) - var PLUS_URL_SAFE = '-'.charCodeAt(0) - var SLASH_URL_SAFE = '_'.charCodeAt(0) - - function decode (elt) { - var code = elt.charCodeAt(0) - if (code === PLUS || - code === PLUS_URL_SAFE) - return 62 // '+' - if (code === SLASH || - code === SLASH_URL_SAFE) - return 63 // '/' - if (code < NUMBER) - return -1 //no match - if (code < NUMBER + 10) - return code - NUMBER + 26 + 26 - if (code < UPPER + 26) - return code - UPPER - if (code < LOWER + 26) - return code - LOWER + 26 - } - - function b64ToByteArray (b64) { - var i, j, l, tmp, placeHolders, arr - - if (b64.length % 4 > 0) { - throw new Error('Invalid string. Length must be a multiple of 4') - } - - // the number of equal signs (place holders) - // if there are two placeholders, than the two characters before it - // represent one byte - // if there is only one, then the three characters before it represent 2 bytes - // this is just a cheap hack to not do indexOf twice - var len = b64.length - placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0 - - // base64 is 4/3 + up to two characters of the original data - arr = new Arr(b64.length * 3 / 4 - placeHolders) - - // if there are placeholders, only get up to the last complete 4 chars - l = placeHolders > 0 ? b64.length - 4 : b64.length - - var L = 0 - - function push (v) { - arr[L++] = v - } - - for (i = 0, j = 0; i < l; i += 4, j += 3) { - tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3)) - push((tmp & 0xFF0000) >> 16) - push((tmp & 0xFF00) >> 8) - push(tmp & 0xFF) - } - - if (placeHolders === 2) { - tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4) - push(tmp & 0xFF) - } else if (placeHolders === 1) { - tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2) - push((tmp >> 8) & 0xFF) - push(tmp & 0xFF) - } - - return arr - } - - function uint8ToBase64 (uint8) { - var i, - extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes - output = "", - temp, length - - function encode (num) { - return lookup.charAt(num) - } - - function tripletToBase64 (num) { - return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F) - } - - // go through the array every three bytes, we'll deal with trailing stuff later - for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) { - temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]) - output += tripletToBase64(temp) - } - - // pad the end with zeros, but make sure to not forget the extra bytes - switch (extraBytes) { - case 1: - temp = uint8[uint8.length - 1] - output += encode(temp >> 2) - output += encode((temp << 4) & 0x3F) - output += '==' - break - case 2: - temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1]) - output += encode(temp >> 10) - output += encode((temp >> 4) & 0x3F) - output += encode((temp << 2) & 0x3F) - output += '=' - break - } - - return output - } - - exports.toByteArray = b64ToByteArray - exports.fromByteArray = uint8ToBase64 -}(typeof exports === 'undefined' ? (this.base64js = {}) : exports)) - -},{}],32:[function(_dereq_,module,exports){ -/** - * Bit twiddling hacks for JavaScript. - * - * Author: Mikola Lysenko - * - * Ported from Stanford bit twiddling hack library: - * http://graphics.stanford.edu/~seander/bithacks.html - */ - -"use strict"; "use restrict"; - -//Number of bits in an integer -var INT_BITS = 32; - -//Constants -exports.INT_BITS = INT_BITS; -exports.INT_MAX = 0x7fffffff; -exports.INT_MIN = -1<<(INT_BITS-1); - -//Returns -1, 0, +1 depending on sign of x -exports.sign = function(v) { - return (v > 0) - (v < 0); -} - -//Computes absolute value of integer -exports.abs = function(v) { - var mask = v >> (INT_BITS-1); - return (v ^ mask) - mask; -} - -//Computes minimum of integers x and y -exports.min = function(x, y) { - return y ^ ((x ^ y) & -(x < y)); -} - -//Computes maximum of integers x and y -exports.max = function(x, y) { - return x ^ ((x ^ y) & -(x < y)); -} - -//Checks if a number is a power of two -exports.isPow2 = function(v) { - return !(v & (v-1)) && (!!v); -} - -//Computes log base 2 of v -exports.log2 = function(v) { - var r, shift; - r = (v > 0xFFFF) << 4; v >>>= r; - shift = (v > 0xFF ) << 3; v >>>= shift; r |= shift; - shift = (v > 0xF ) << 2; v >>>= shift; r |= shift; - shift = (v > 0x3 ) << 1; v >>>= shift; r |= shift; - return r | (v >> 1); -} - -//Computes log base 10 of v -exports.log10 = function(v) { - return (v >= 1000000000) ? 9 : (v >= 100000000) ? 8 : (v >= 10000000) ? 7 : - (v >= 1000000) ? 6 : (v >= 100000) ? 5 : (v >= 10000) ? 4 : - (v >= 1000) ? 3 : (v >= 100) ? 2 : (v >= 10) ? 1 : 0; -} - -//Counts number of bits -exports.popCount = function(v) { - v = v - ((v >>> 1) & 0x55555555); - v = (v & 0x33333333) + ((v >>> 2) & 0x33333333); - return ((v + (v >>> 4) & 0xF0F0F0F) * 0x1010101) >>> 24; -} - -//Counts number of trailing zeros -function countTrailingZeros(v) { - var c = 32; - v &= -v; - if (v) c--; - if (v & 0x0000FFFF) c -= 16; - if (v & 0x00FF00FF) c -= 8; - if (v & 0x0F0F0F0F) c -= 4; - if (v & 0x33333333) c -= 2; - if (v & 0x55555555) c -= 1; - return c; -} -exports.countTrailingZeros = countTrailingZeros; - -//Rounds to next power of 2 -exports.nextPow2 = function(v) { - v += v === 0; - --v; - v |= v >>> 1; - v |= v >>> 2; - v |= v >>> 4; - v |= v >>> 8; - v |= v >>> 16; - return v + 1; -} - -//Rounds down to previous power of 2 -exports.prevPow2 = function(v) { - v |= v >>> 1; - v |= v >>> 2; - v |= v >>> 4; - v |= v >>> 8; - v |= v >>> 16; - return v - (v>>>1); -} - -//Computes parity of word -exports.parity = function(v) { - v ^= v >>> 16; - v ^= v >>> 8; - v ^= v >>> 4; - v &= 0xf; - return (0x6996 >>> v) & 1; -} - -var REVERSE_TABLE = new Array(256); - -(function(tab) { - for(var i=0; i<256; ++i) { - var v = i, r = i, s = 7; - for (v >>>= 1; v; v >>>= 1) { - r <<= 1; - r |= v & 1; - --s; - } - tab[i] = (r << s) & 0xff; - } -})(REVERSE_TABLE); - -//Reverse bits in a 32 bit word -exports.reverse = function(v) { - return (REVERSE_TABLE[ v & 0xff] << 24) | - (REVERSE_TABLE[(v >>> 8) & 0xff] << 16) | - (REVERSE_TABLE[(v >>> 16) & 0xff] << 8) | - REVERSE_TABLE[(v >>> 24) & 0xff]; -} - -//Interleave bits of 2 coordinates with 16 bits. Useful for fast quadtree codes -exports.interleave2 = function(x, y) { - x &= 0xFFFF; - x = (x | (x << 8)) & 0x00FF00FF; - x = (x | (x << 4)) & 0x0F0F0F0F; - x = (x | (x << 2)) & 0x33333333; - x = (x | (x << 1)) & 0x55555555; - - y &= 0xFFFF; - y = (y | (y << 8)) & 0x00FF00FF; - y = (y | (y << 4)) & 0x0F0F0F0F; - y = (y | (y << 2)) & 0x33333333; - y = (y | (y << 1)) & 0x55555555; - - return x | (y << 1); -} - -//Extracts the nth interleaved component -exports.deinterleave2 = function(v, n) { - v = (v >>> n) & 0x55555555; - v = (v | (v >>> 1)) & 0x33333333; - v = (v | (v >>> 2)) & 0x0F0F0F0F; - v = (v | (v >>> 4)) & 0x00FF00FF; - v = (v | (v >>> 16)) & 0x000FFFF; - return (v << 16) >> 16; -} - - -//Interleave bits of 3 coordinates, each with 10 bits. Useful for fast octree codes -exports.interleave3 = function(x, y, z) { - x &= 0x3FF; - x = (x | (x<<16)) & 4278190335; - x = (x | (x<<8)) & 251719695; - x = (x | (x<<4)) & 3272356035; - x = (x | (x<<2)) & 1227133513; - - y &= 0x3FF; - y = (y | (y<<16)) & 4278190335; - y = (y | (y<<8)) & 251719695; - y = (y | (y<<4)) & 3272356035; - y = (y | (y<<2)) & 1227133513; - x |= (y << 1); - - z &= 0x3FF; - z = (z | (z<<16)) & 4278190335; - z = (z | (z<<8)) & 251719695; - z = (z | (z<<4)) & 3272356035; - z = (z | (z<<2)) & 1227133513; - - return x | (z << 2); -} - -//Extracts nth interleaved component of a 3-tuple -exports.deinterleave3 = function(v, n) { - v = (v >>> n) & 1227133513; - v = (v | (v>>>2)) & 3272356035; - v = (v | (v>>>4)) & 251719695; - v = (v | (v>>>8)) & 4278190335; - v = (v | (v>>>16)) & 0x3FF; - return (v<<22)>>22; -} - -//Computes next combination in colexicographic order (this is mistakenly called nextPermutation on the bit twiddling hacks page) -exports.nextCombination = function(v) { - var t = v | (v - 1); - return (t + 1) | (((~t & -~t) - 1) >>> (countTrailingZeros(v) + 1)); -} - - -},{}],33:[function(_dereq_,module,exports){ -'use strict' - -module.exports = boxIntersectWrapper - -var pool = _dereq_('typedarray-pool') -var sweep = _dereq_('./lib/sweep') -var boxIntersectIter = _dereq_('./lib/intersect') - -function boxEmpty(d, box) { - for(var j=0; j 1) return new Buffer(arg, arguments[1]) - return new Buffer(arg) - } - if (!Buffer.TYPED_ARRAY_SUPPORT) { - this.length = 0 - this.parent = undefined +function Buffer (arg, encodingOrOffset, length) { + if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) { + return new Buffer(arg, encodingOrOffset, length) } // Common case. if (typeof arg === 'number') { - return fromNumber(this, arg) + if (typeof encodingOrOffset === 'string') { + throw new Error( + 'If encoding is specified then the first argument must be a string' + ) + } + return allocUnsafe(this, arg) } + return from(this, arg, encodingOrOffset, length) +} - // Slightly less common case. - if (typeof arg === 'string') { - return fromString(this, arg, arguments.length > 1 ? arguments[1] : 'utf8') - } +Buffer.poolSize = 8192 // not used by this implementation - // Unusual. - return fromObject(this, arg) +// TODO: Legacy, not needed anymore. Remove in next major version. +Buffer._augment = function (arr) { + arr.__proto__ = Buffer.prototype + return arr } -function fromNumber (that, length) { - that = allocate(that, length < 0 ? 0 : checked(length) | 0) - if (!Buffer.TYPED_ARRAY_SUPPORT) { - for (var i = 0; i < length; i++) { - that[i] = 0 - } +function from (that, value, encodingOrOffset, length) { + if (typeof value === 'number') { + throw new TypeError('"value" argument must not be a number') } - return that -} -function fromString (that, string, encoding) { - if (typeof encoding !== 'string' || encoding === '') encoding = 'utf8' + if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) { + return fromArrayBuffer(that, value, encodingOrOffset, length) + } - // Assumption: byteLength() return value is always < kMaxLength. - var length = byteLength(string, encoding) | 0 - that = allocate(that, length) + if (typeof value === 'string') { + return fromString(that, value, encodingOrOffset) + } - that.write(string, encoding) - return that + return fromObject(that, value) } -function fromObject (that, object) { - if (Buffer.isBuffer(object)) return fromBuffer(that, object) - - if (isArray(object)) return fromArray(that, object) +/** + * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError + * if value is a number. + * Buffer.from(str[, encoding]) + * Buffer.from(array) + * Buffer.from(buffer) + * Buffer.from(arrayBuffer[, byteOffset[, length]]) + **/ +Buffer.from = function (value, encodingOrOffset, length) { + return from(null, value, encodingOrOffset, length) +} - if (object == null) { - throw new TypeError('must start with number, buffer, array or string') +if (Buffer.TYPED_ARRAY_SUPPORT) { + Buffer.prototype.__proto__ = Uint8Array.prototype + Buffer.__proto__ = Uint8Array + if (typeof Symbol !== 'undefined' && Symbol.species && + Buffer[Symbol.species] === Buffer) { + // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 + Object.defineProperty(Buffer, Symbol.species, { + value: null, + configurable: true + }) } +} - if (typeof ArrayBuffer !== 'undefined') { - if (object.buffer instanceof ArrayBuffer) { - return fromTypedArray(that, object) - } - if (object instanceof ArrayBuffer) { - return fromArrayBuffer(that, object) - } +function assertSize (size) { + if (typeof size !== 'number') { + throw new TypeError('"size" argument must be a number') } +} - if (object.length) return fromArrayLike(that, object) - - return fromJsonObject(that, object) +function alloc (that, size, fill, encoding) { + assertSize(size) + if (size <= 0) { + return createBuffer(that, size) + } + if (fill !== undefined) { + // Only pay attention to encoding if it's a string. This + // prevents accidentally sending in a number that would + // be interpretted as a start offset. + return typeof encoding === 'string' + ? createBuffer(that, size).fill(fill, encoding) + : createBuffer(that, size).fill(fill) + } + return createBuffer(that, size) } -function fromBuffer (that, buffer) { - var length = checked(buffer.length) | 0 - that = allocate(that, length) - buffer.copy(that, 0, 0, length) - return that +/** + * Creates a new filled Buffer instance. + * alloc(size[, fill[, encoding]]) + **/ +Buffer.alloc = function (size, fill, encoding) { + return alloc(null, size, fill, encoding) } -function fromArray (that, array) { - var length = checked(array.length) | 0 - that = allocate(that, length) - for (var i = 0; i < length; i += 1) { - that[i] = array[i] & 255 +function allocUnsafe (that, size) { + assertSize(size) + that = createBuffer(that, size < 0 ? 0 : checked(size) | 0) + if (!Buffer.TYPED_ARRAY_SUPPORT) { + for (var i = 0; i < size; ++i) { + that[i] = 0 + } } return that } -// Duplicate of fromArray() to keep fromArray() monomorphic. -function fromTypedArray (that, array) { - var length = checked(array.length) | 0 - that = allocate(that, length) - // Truncating the elements is probably not what people expect from typed - // arrays with BYTES_PER_ELEMENT > 1 but it's compatible with the behavior - // of the old Buffer constructor. - for (var i = 0; i < length; i += 1) { - that[i] = array[i] & 255 - } - return that +/** + * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. + * */ +Buffer.allocUnsafe = function (size) { + return allocUnsafe(null, size) +} +/** + * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. + */ +Buffer.allocUnsafeSlow = function (size) { + return allocUnsafe(null, size) } -function fromArrayBuffer (that, array) { - if (Buffer.TYPED_ARRAY_SUPPORT) { - // Return an augmented `Uint8Array` instance, for best performance - array.byteLength - that = Buffer._augment(new Uint8Array(array)) - } else { - // Fallback: Return an object instance of the Buffer class - that = fromTypedArray(that, new Uint8Array(array)) +function fromString (that, string, encoding) { + if (typeof encoding !== 'string' || encoding === '') { + encoding = 'utf8' + } + + if (!Buffer.isEncoding(encoding)) { + throw new TypeError('"encoding" must be a valid string encoding') } + + var length = byteLength(string, encoding) | 0 + that = createBuffer(that, length) + + var actual = that.write(string, encoding) + + if (actual !== length) { + // Writing a hex string, for example, that contains invalid characters will + // cause everything after the first invalid character to be ignored. (e.g. + // 'abxxcd' will be treated as 'ab') + that = that.slice(0, actual) + } + return that } function fromArrayLike (that, array) { var length = checked(array.length) | 0 - that = allocate(that, length) + that = createBuffer(that, length) for (var i = 0; i < length; i += 1) { that[i] = array[i] & 255 } return that } -// Deserialize { type: 'Buffer', data: [1,2,3,...] } into a Buffer object. -// Returns a zero-length buffer for inputs that don't conform to the spec. -function fromJsonObject (that, object) { - var array - var length = 0 +function fromArrayBuffer (that, array, byteOffset, length) { + array.byteLength // this throws if `array` is not a valid ArrayBuffer - if (object.type === 'Buffer' && isArray(object.data)) { - array = object.data - length = checked(array.length) | 0 + if (byteOffset < 0 || array.byteLength < byteOffset) { + throw new RangeError('\'offset\' is out of bounds') } - that = allocate(that, length) - for (var i = 0; i < length; i += 1) { - that[i] = array[i] & 255 + if (array.byteLength < byteOffset + (length || 0)) { + throw new RangeError('\'length\' is out of bounds') } - return that -} -if (Buffer.TYPED_ARRAY_SUPPORT) { - Buffer.prototype.__proto__ = Uint8Array.prototype - Buffer.__proto__ = Uint8Array -} else { - // pre-set for values that may exist in the future - Buffer.prototype.length = undefined - Buffer.prototype.parent = undefined -} + if (byteOffset === undefined && length === undefined) { + array = new Uint8Array(array) + } else if (length === undefined) { + array = new Uint8Array(array, byteOffset) + } else { + array = new Uint8Array(array, byteOffset, length) + } -function allocate (that, length) { if (Buffer.TYPED_ARRAY_SUPPORT) { // Return an augmented `Uint8Array` instance, for best performance - that = Buffer._augment(new Uint8Array(length)) + that = array that.__proto__ = Buffer.prototype } else { // Fallback: Return an object instance of the Buffer class - that.length = length - that._isBuffer = true + that = fromArrayLike(that, array) } + return that +} - var fromPool = length !== 0 && length <= Buffer.poolSize >>> 1 - if (fromPool) that.parent = rootParent +function fromObject (that, obj) { + if (Buffer.isBuffer(obj)) { + var len = checked(obj.length) | 0 + that = createBuffer(that, len) - return that + if (that.length === 0) { + return that + } + + obj.copy(that, 0, 0, len) + return that + } + + if (obj) { + if ((typeof ArrayBuffer !== 'undefined' && + obj.buffer instanceof ArrayBuffer) || 'length' in obj) { + if (typeof obj.length !== 'number' || isnan(obj.length)) { + return createBuffer(that, 0) + } + return fromArrayLike(that, obj) + } + + if (obj.type === 'Buffer' && isArray(obj.data)) { + return fromArrayLike(that, obj.data) + } + } + + throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.') } function checked (length) { @@ -3395,12 +2827,11 @@ function checked (length) { return length | 0 } -function SlowBuffer (subject, encoding) { - if (!(this instanceof SlowBuffer)) return new SlowBuffer(subject, encoding) - - var buf = new Buffer(subject, encoding) - delete buf.parent - return buf +function SlowBuffer (length) { + if (+length != length) { // eslint-disable-line eqeqeq + length = 0 + } + return Buffer.alloc(+length) } Buffer.isBuffer = function isBuffer (b) { @@ -3417,17 +2848,12 @@ Buffer.compare = function compare (a, b) { var x = a.length var y = b.length - var i = 0 - var len = Math.min(x, y) - while (i < len) { - if (a[i] !== b[i]) break - - ++i - } - - if (i !== len) { - x = a[i] - y = b[i] + for (var i = 0, len = Math.min(x, y); i < len; ++i) { + if (a[i] !== b[i]) { + x = a[i] + y = b[i] + break + } } if (x < y) return -1 @@ -3441,9 +2867,9 @@ Buffer.isEncoding = function isEncoding (encoding) { case 'utf8': case 'utf-8': case 'ascii': + case 'latin1': case 'binary': case 'base64': - case 'raw': case 'ucs2': case 'ucs-2': case 'utf16le': @@ -3455,32 +2881,46 @@ Buffer.isEncoding = function isEncoding (encoding) { } Buffer.concat = function concat (list, length) { - if (!isArray(list)) throw new TypeError('list argument must be an Array of Buffers.') + if (!isArray(list)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } if (list.length === 0) { - return new Buffer(0) + return Buffer.alloc(0) } var i if (length === undefined) { length = 0 - for (i = 0; i < list.length; i++) { + for (i = 0; i < list.length; ++i) { length += list[i].length } } - var buf = new Buffer(length) + var buffer = Buffer.allocUnsafe(length) var pos = 0 - for (i = 0; i < list.length; i++) { - var item = list[i] - item.copy(buf, pos) - pos += item.length + for (i = 0; i < list.length; ++i) { + var buf = list[i] + if (!Buffer.isBuffer(buf)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + buf.copy(buffer, pos) + pos += buf.length } - return buf + return buffer } function byteLength (string, encoding) { - if (typeof string !== 'string') string = '' + string + if (Buffer.isBuffer(string)) { + return string.length + } + if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' && + (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) { + return string.byteLength + } + if (typeof string !== 'string') { + string = '' + string + } var len = string.length if (len === 0) return 0 @@ -3490,13 +2930,12 @@ function byteLength (string, encoding) { for (;;) { switch (encoding) { case 'ascii': + case 'latin1': case 'binary': - // Deprecated - case 'raw': - case 'raws': return len case 'utf8': case 'utf-8': + case undefined: return utf8ToBytes(string).length case 'ucs2': case 'ucs-2': @@ -3519,13 +2958,39 @@ Buffer.byteLength = byteLength function slowToString (encoding, start, end) { var loweredCase = false - start = start | 0 - end = end === undefined || end === Infinity ? this.length : end | 0 + // No need to verify that "this.length <= MAX_UINT32" since it's a read-only + // property of a typed array. + + // This behaves neither like String nor Uint8Array in that we set start/end + // to their upper/lower bounds if the value passed is out of range. + // undefined is handled specially as per ECMA-262 6th Edition, + // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. + if (start === undefined || start < 0) { + start = 0 + } + // Return early if start > this.length. Done here to prevent potential uint32 + // coercion fail below. + if (start > this.length) { + return '' + } + + if (end === undefined || end > this.length) { + end = this.length + } + + if (end <= 0) { + return '' + } + + // Force coersion to uint32. This will also coerce falsey/NaN values to 0. + end >>>= 0 + start >>>= 0 + + if (end <= start) { + return '' + } if (!encoding) encoding = 'utf8' - if (start < 0) start = 0 - if (end > this.length) end = this.length - if (end <= start) return '' while (true) { switch (encoding) { @@ -3539,8 +3004,9 @@ function slowToString (encoding, start, end) { case 'ascii': return asciiSlice(this, start, end) + case 'latin1': case 'binary': - return binarySlice(this, start, end) + return latin1Slice(this, start, end) case 'base64': return base64Slice(this, start, end) @@ -3559,6 +3025,53 @@ function slowToString (encoding, start, end) { } } +// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect +// Buffer instances. +Buffer.prototype._isBuffer = true + +function swap (b, n, m) { + var i = b[n] + b[n] = b[m] + b[m] = i +} + +Buffer.prototype.swap16 = function swap16 () { + var len = this.length + if (len % 2 !== 0) { + throw new RangeError('Buffer size must be a multiple of 16-bits') + } + for (var i = 0; i < len; i += 2) { + swap(this, i, i + 1) + } + return this +} + +Buffer.prototype.swap32 = function swap32 () { + var len = this.length + if (len % 4 !== 0) { + throw new RangeError('Buffer size must be a multiple of 32-bits') + } + for (var i = 0; i < len; i += 4) { + swap(this, i, i + 3) + swap(this, i + 1, i + 2) + } + return this +} + +Buffer.prototype.swap64 = function swap64 () { + var len = this.length + if (len % 8 !== 0) { + throw new RangeError('Buffer size must be a multiple of 64-bits') + } + for (var i = 0; i < len; i += 8) { + swap(this, i, i + 7) + swap(this, i + 1, i + 6) + swap(this, i + 2, i + 5) + swap(this, i + 3, i + 4) + } + return this +} + Buffer.prototype.toString = function toString () { var length = this.length | 0 if (length === 0) return '' @@ -3582,63 +3095,197 @@ Buffer.prototype.inspect = function inspect () { return '' } -Buffer.prototype.compare = function compare (b) { - if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') - if (this === b) return 0 - return Buffer.compare(this, b) -} +Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { + if (!Buffer.isBuffer(target)) { + throw new TypeError('Argument must be a Buffer') + } -Buffer.prototype.indexOf = function indexOf (val, byteOffset) { - if (byteOffset > 0x7fffffff) byteOffset = 0x7fffffff - else if (byteOffset < -0x80000000) byteOffset = -0x80000000 - byteOffset >>= 0 + if (start === undefined) { + start = 0 + } + if (end === undefined) { + end = target ? target.length : 0 + } + if (thisStart === undefined) { + thisStart = 0 + } + if (thisEnd === undefined) { + thisEnd = this.length + } + + if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { + throw new RangeError('out of range index') + } + + if (thisStart >= thisEnd && start >= end) { + return 0 + } + if (thisStart >= thisEnd) { + return -1 + } + if (start >= end) { + return 1 + } + + start >>>= 0 + end >>>= 0 + thisStart >>>= 0 + thisEnd >>>= 0 + + if (this === target) return 0 + + var x = thisEnd - thisStart + var y = end - start + var len = Math.min(x, y) + + var thisCopy = this.slice(thisStart, thisEnd) + var targetCopy = target.slice(start, end) - if (this.length === 0) return -1 - if (byteOffset >= this.length) return -1 + for (var i = 0; i < len; ++i) { + if (thisCopy[i] !== targetCopy[i]) { + x = thisCopy[i] + y = targetCopy[i] + break + } + } - // Negative offsets start from the end of the buffer - if (byteOffset < 0) byteOffset = Math.max(this.length + byteOffset, 0) + if (x < y) return -1 + if (y < x) return 1 + return 0 +} +// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, +// OR the last index of `val` in `buffer` at offset <= `byteOffset`. +// +// Arguments: +// - buffer - a Buffer to search +// - val - a string, Buffer, or number +// - byteOffset - an index into `buffer`; will be clamped to an int32 +// - encoding - an optional encoding, relevant is val is a string +// - dir - true for indexOf, false for lastIndexOf +function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { + // Empty buffer means no match + if (buffer.length === 0) return -1 + + // Normalize byteOffset + if (typeof byteOffset === 'string') { + encoding = byteOffset + byteOffset = 0 + } else if (byteOffset > 0x7fffffff) { + byteOffset = 0x7fffffff + } else if (byteOffset < -0x80000000) { + byteOffset = -0x80000000 + } + byteOffset = +byteOffset // Coerce to Number. + if (isNaN(byteOffset)) { + // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer + byteOffset = dir ? 0 : (buffer.length - 1) + } + + // Normalize byteOffset: negative offsets start from the end of the buffer + if (byteOffset < 0) byteOffset = buffer.length + byteOffset + if (byteOffset >= buffer.length) { + if (dir) return -1 + else byteOffset = buffer.length - 1 + } else if (byteOffset < 0) { + if (dir) byteOffset = 0 + else return -1 + } + + // Normalize val if (typeof val === 'string') { - if (val.length === 0) return -1 // special case: looking for empty string always fails - return String.prototype.indexOf.call(this, val, byteOffset) + val = Buffer.from(val, encoding) } + + // Finally, search either indexOf (if dir is true) or lastIndexOf if (Buffer.isBuffer(val)) { - return arrayIndexOf(this, val, byteOffset) + // Special case: looking for empty string/buffer always fails + if (val.length === 0) { + return -1 + } + return arrayIndexOf(buffer, val, byteOffset, encoding, dir) + } else if (typeof val === 'number') { + val = val & 0xFF // Search for a byte value [0-255] + if (Buffer.TYPED_ARRAY_SUPPORT && + typeof Uint8Array.prototype.indexOf === 'function') { + if (dir) { + return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) + } else { + return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) + } + } + return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) } - if (typeof val === 'number') { - if (Buffer.TYPED_ARRAY_SUPPORT && Uint8Array.prototype.indexOf === 'function') { - return Uint8Array.prototype.indexOf.call(this, val, byteOffset) + + throw new TypeError('val must be string, number or Buffer') +} + +function arrayIndexOf (arr, val, byteOffset, encoding, dir) { + var indexSize = 1 + var arrLength = arr.length + var valLength = val.length + + if (encoding !== undefined) { + encoding = String(encoding).toLowerCase() + if (encoding === 'ucs2' || encoding === 'ucs-2' || + encoding === 'utf16le' || encoding === 'utf-16le') { + if (arr.length < 2 || val.length < 2) { + return -1 + } + indexSize = 2 + arrLength /= 2 + valLength /= 2 + byteOffset /= 2 + } + } + + function read (buf, i) { + if (indexSize === 1) { + return buf[i] + } else { + return buf.readUInt16BE(i * indexSize) } - return arrayIndexOf(this, [ val ], byteOffset) } - function arrayIndexOf (arr, val, byteOffset) { + var i + if (dir) { var foundIndex = -1 - for (var i = 0; byteOffset + i < arr.length; i++) { - if (arr[byteOffset + i] === val[foundIndex === -1 ? 0 : i - foundIndex]) { + for (i = byteOffset; i < arrLength; i++) { + if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { if (foundIndex === -1) foundIndex = i - if (i - foundIndex + 1 === val.length) return byteOffset + foundIndex + if (i - foundIndex + 1 === valLength) return foundIndex * indexSize } else { + if (foundIndex !== -1) i -= i - foundIndex foundIndex = -1 } } - return -1 + } else { + if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength + for (i = byteOffset; i >= 0; i--) { + var found = true + for (var j = 0; j < valLength; j++) { + if (read(arr, i + j) !== read(val, j)) { + found = false + break + } + } + if (found) return i + } } - throw new TypeError('val must be string, number or Buffer') + return -1 +} + +Buffer.prototype.includes = function includes (val, byteOffset, encoding) { + return this.indexOf(val, byteOffset, encoding) !== -1 } -// `get` is deprecated -Buffer.prototype.get = function get (offset) { - console.log('.get() is deprecated. Access using array indexes instead.') - return this.readUInt8(offset) +Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, true) } -// `set` is deprecated -Buffer.prototype.set = function set (v, offset) { - console.log('.set() is deprecated. Access using array indexes instead.') - return this.writeUInt8(v, offset) +Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, false) } function hexWrite (buf, string, offset, length) { @@ -3655,14 +3302,14 @@ function hexWrite (buf, string, offset, length) { // must be an even number of digits var strLen = string.length - if (strLen % 2 !== 0) throw new Error('Invalid hex string') + if (strLen % 2 !== 0) throw new TypeError('Invalid hex string') if (length > strLen / 2) { length = strLen / 2 } - for (var i = 0; i < length; i++) { + for (var i = 0; i < length; ++i) { var parsed = parseInt(string.substr(i * 2, 2), 16) - if (isNaN(parsed)) throw new Error('Invalid hex string') + if (isNaN(parsed)) return i buf[offset + i] = parsed } return i @@ -3676,7 +3323,7 @@ function asciiWrite (buf, string, offset, length) { return blitBuffer(asciiToBytes(string), buf, offset, length) } -function binaryWrite (buf, string, offset, length) { +function latin1Write (buf, string, offset, length) { return asciiWrite(buf, string, offset, length) } @@ -3711,17 +3358,16 @@ Buffer.prototype.write = function write (string, offset, length, encoding) { } // legacy write(string, encoding, offset, length) - remove in v0.13 } else { - var swap = encoding - encoding = offset - offset = length | 0 - length = swap + throw new Error( + 'Buffer.write(string, encoding, offset[, length]) is no longer supported' + ) } var remaining = this.length - offset if (length === undefined || length > remaining) length = remaining if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { - throw new RangeError('attempt to write outside buffer bounds') + throw new RangeError('Attempt to write outside buffer bounds') } if (!encoding) encoding = 'utf8' @@ -3739,8 +3385,9 @@ Buffer.prototype.write = function write (string, offset, length, encoding) { case 'ascii': return asciiWrite(this, string, offset, length) + case 'latin1': case 'binary': - return binaryWrite(this, string, offset, length) + return latin1Write(this, string, offset, length) case 'base64': // Warning: maxLength not taken into account in base64Write @@ -3875,17 +3522,17 @@ function asciiSlice (buf, start, end) { var ret = '' end = Math.min(buf.length, end) - for (var i = start; i < end; i++) { + for (var i = start; i < end; ++i) { ret += String.fromCharCode(buf[i] & 0x7F) } return ret } -function binarySlice (buf, start, end) { +function latin1Slice (buf, start, end) { var ret = '' end = Math.min(buf.length, end) - for (var i = start; i < end; i++) { + for (var i = start; i < end; ++i) { ret += String.fromCharCode(buf[i]) } return ret @@ -3898,7 +3545,7 @@ function hexSlice (buf, start, end) { if (!end || end < 0 || end > len) end = len var out = '' - for (var i = start; i < end; i++) { + for (var i = start; i < end; ++i) { out += toHex(buf[i]) } return out @@ -3936,17 +3583,16 @@ Buffer.prototype.slice = function slice (start, end) { var newBuf if (Buffer.TYPED_ARRAY_SUPPORT) { - newBuf = Buffer._augment(this.subarray(start, end)) + newBuf = this.subarray(start, end) + newBuf.__proto__ = Buffer.prototype } else { var sliceLen = end - start newBuf = new Buffer(sliceLen, undefined) - for (var i = 0; i < sliceLen; i++) { + for (var i = 0; i < sliceLen; ++i) { newBuf[i] = this[i + start] } } - if (newBuf.length) newBuf.parent = this.parent || this - return newBuf } @@ -4115,16 +3761,19 @@ Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { } function checkInt (buf, value, offset, ext, max, min) { - if (!Buffer.isBuffer(buf)) throw new TypeError('buffer must be a Buffer instance') - if (value > max || value < min) throw new RangeError('value is out of bounds') - if (offset + ext > buf.length) throw new RangeError('index out of range') + if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') + if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') + if (offset + ext > buf.length) throw new RangeError('Index out of range') } Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { value = +value offset = offset | 0 byteLength = byteLength | 0 - if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0) + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } var mul = 1 var i = 0 @@ -4140,7 +3789,10 @@ Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, value = +value offset = offset | 0 byteLength = byteLength | 0 - if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0) + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } var i = byteLength - 1 var mul = 1 @@ -4163,7 +3815,7 @@ Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { function objectWriteUInt16 (buf, value, offset, littleEndian) { if (value < 0) value = 0xffff + value + 1 - for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) { + for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) { buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> (littleEndian ? i : 1 - i) * 8 } @@ -4197,7 +3849,7 @@ Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert function objectWriteUInt32 (buf, value, offset, littleEndian) { if (value < 0) value = 0xffffffff + value + 1 - for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) { + for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) { buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff } } @@ -4243,9 +3895,12 @@ Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, no var i = 0 var mul = 1 - var sub = value < 0 ? 1 : 0 + var sub = 0 this[offset] = value & 0xFF while (++i < byteLength && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { + sub = 1 + } this[offset + i] = ((value / mul) >> 0) - sub & 0xFF } @@ -4263,9 +3918,12 @@ Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, no var i = byteLength - 1 var mul = 1 - var sub = value < 0 ? 1 : 0 + var sub = 0 this[offset + i] = value & 0xFF while (--i >= 0 && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { + sub = 1 + } this[offset + i] = ((value / mul) >> 0) - sub & 0xFF } @@ -4340,9 +3998,8 @@ Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) } function checkIEEE754 (buf, value, offset, ext, max, min) { - if (value > max || value < min) throw new RangeError('value is out of bounds') - if (offset + ext > buf.length) throw new RangeError('index out of range') - if (offset < 0) throw new RangeError('index out of range') + if (offset + ext > buf.length) throw new RangeError('Index out of range') + if (offset < 0) throw new RangeError('Index out of range') } function writeFloat (buf, value, offset, littleEndian, noAssert) { @@ -4407,143 +4064,91 @@ Buffer.prototype.copy = function copy (target, targetStart, start, end) { if (this === target && start < targetStart && targetStart < end) { // descending copy from end - for (i = len - 1; i >= 0; i--) { + for (i = len - 1; i >= 0; --i) { target[i + targetStart] = this[i + start] } } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { // ascending copy from start - for (i = 0; i < len; i++) { + for (i = 0; i < len; ++i) { target[i + targetStart] = this[i + start] } } else { - target._set(this.subarray(start, start + len), targetStart) + Uint8Array.prototype.set.call( + target, + this.subarray(start, start + len), + targetStart + ) } return len } -// fill(value, start=0, end=buffer.length) -Buffer.prototype.fill = function fill (value, start, end) { - if (!value) value = 0 - if (!start) start = 0 - if (!end) end = this.length +// Usage: +// buffer.fill(number[, offset[, end]]) +// buffer.fill(buffer[, offset[, end]]) +// buffer.fill(string[, offset[, end]][, encoding]) +Buffer.prototype.fill = function fill (val, start, end, encoding) { + // Handle string cases: + if (typeof val === 'string') { + if (typeof start === 'string') { + encoding = start + start = 0 + end = this.length + } else if (typeof end === 'string') { + encoding = end + end = this.length + } + if (val.length === 1) { + var code = val.charCodeAt(0) + if (code < 256) { + val = code + } + } + if (encoding !== undefined && typeof encoding !== 'string') { + throw new TypeError('encoding must be a string') + } + if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } + } else if (typeof val === 'number') { + val = val & 255 + } + + // Invalid ranges are not set to a default, so can range check early. + if (start < 0 || this.length < start || this.length < end) { + throw new RangeError('Out of range index') + } - if (end < start) throw new RangeError('end < start') + if (end <= start) { + return this + } - // Fill 0 bytes; we're done - if (end === start) return - if (this.length === 0) return + start = start >>> 0 + end = end === undefined ? this.length : end >>> 0 - if (start < 0 || start >= this.length) throw new RangeError('start out of bounds') - if (end < 0 || end > this.length) throw new RangeError('end out of bounds') + if (!val) val = 0 var i - if (typeof value === 'number') { - for (i = start; i < end; i++) { - this[i] = value + if (typeof val === 'number') { + for (i = start; i < end; ++i) { + this[i] = val } } else { - var bytes = utf8ToBytes(value.toString()) + var bytes = Buffer.isBuffer(val) + ? val + : utf8ToBytes(new Buffer(val, encoding).toString()) var len = bytes.length - for (i = start; i < end; i++) { - this[i] = bytes[i % len] + for (i = 0; i < end - start; ++i) { + this[i + start] = bytes[i % len] } } return this } -/** - * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance. - * Added in Node 0.12. Only available in browsers that support ArrayBuffer. - */ -Buffer.prototype.toArrayBuffer = function toArrayBuffer () { - if (typeof Uint8Array !== 'undefined') { - if (Buffer.TYPED_ARRAY_SUPPORT) { - return (new Buffer(this)).buffer - } else { - var buf = new Uint8Array(this.length) - for (var i = 0, len = buf.length; i < len; i += 1) { - buf[i] = this[i] - } - return buf.buffer - } - } else { - throw new TypeError('Buffer.toArrayBuffer not supported in this browser') - } -} - // HELPER FUNCTIONS // ================ -var BP = Buffer.prototype - -/** - * Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods - */ -Buffer._augment = function _augment (arr) { - arr.constructor = Buffer - arr._isBuffer = true - - // save reference to original Uint8Array set method before overwriting - arr._set = arr.set - - // deprecated - arr.get = BP.get - arr.set = BP.set - - arr.write = BP.write - arr.toString = BP.toString - arr.toLocaleString = BP.toString - arr.toJSON = BP.toJSON - arr.equals = BP.equals - arr.compare = BP.compare - arr.indexOf = BP.indexOf - arr.copy = BP.copy - arr.slice = BP.slice - arr.readUIntLE = BP.readUIntLE - arr.readUIntBE = BP.readUIntBE - arr.readUInt8 = BP.readUInt8 - arr.readUInt16LE = BP.readUInt16LE - arr.readUInt16BE = BP.readUInt16BE - arr.readUInt32LE = BP.readUInt32LE - arr.readUInt32BE = BP.readUInt32BE - arr.readIntLE = BP.readIntLE - arr.readIntBE = BP.readIntBE - arr.readInt8 = BP.readInt8 - arr.readInt16LE = BP.readInt16LE - arr.readInt16BE = BP.readInt16BE - arr.readInt32LE = BP.readInt32LE - arr.readInt32BE = BP.readInt32BE - arr.readFloatLE = BP.readFloatLE - arr.readFloatBE = BP.readFloatBE - arr.readDoubleLE = BP.readDoubleLE - arr.readDoubleBE = BP.readDoubleBE - arr.writeUInt8 = BP.writeUInt8 - arr.writeUIntLE = BP.writeUIntLE - arr.writeUIntBE = BP.writeUIntBE - arr.writeUInt16LE = BP.writeUInt16LE - arr.writeUInt16BE = BP.writeUInt16BE - arr.writeUInt32LE = BP.writeUInt32LE - arr.writeUInt32BE = BP.writeUInt32BE - arr.writeIntLE = BP.writeIntLE - arr.writeIntBE = BP.writeIntBE - arr.writeInt8 = BP.writeInt8 - arr.writeInt16LE = BP.writeInt16LE - arr.writeInt16BE = BP.writeInt16BE - arr.writeInt32LE = BP.writeInt32LE - arr.writeInt32BE = BP.writeInt32BE - arr.writeFloatLE = BP.writeFloatLE - arr.writeFloatBE = BP.writeFloatBE - arr.writeDoubleLE = BP.writeDoubleLE - arr.writeDoubleBE = BP.writeDoubleBE - arr.fill = BP.fill - arr.inspect = BP.inspect - arr.toArrayBuffer = BP.toArrayBuffer - - return arr -} - var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g function base64clean (str) { @@ -4575,7 +4180,7 @@ function utf8ToBytes (string, units) { var leadSurrogate = null var bytes = [] - for (var i = 0; i < length; i++) { + for (var i = 0; i < length; ++i) { codePoint = string.charCodeAt(i) // is surrogate component @@ -4650,7 +4255,7 @@ function utf8ToBytes (string, units) { function asciiToBytes (str) { var byteArray = [] - for (var i = 0; i < str.length; i++) { + for (var i = 0; i < str.length; ++i) { // Node's code seems to be doing this and not & 0x7F.. byteArray.push(str.charCodeAt(i) & 0xFF) } @@ -4660,7 +4265,7 @@ function asciiToBytes (str) { function utf16leToBytes (str, units) { var c, hi, lo var byteArray = [] - for (var i = 0; i < str.length; i++) { + for (var i = 0; i < str.length; ++i) { if ((units -= 2) < 0) break c = str.charCodeAt(i) @@ -4678,99 +4283,104 @@ function base64ToBytes (str) { } function blitBuffer (src, dst, offset, length) { - for (var i = 0; i < length; i++) { + for (var i = 0; i < length; ++i) { if ((i + offset >= dst.length) || (i >= src.length)) break dst[i + offset] = src[i] } return i } -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -//# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9idWZmZXIvaW5kZXguanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQ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pbnQgPSBmaXJzdEJ5dGVcbiAgICAgICAgICB9XG4gICAgICAgICAgYnJlYWtcbiAgICAgICAgY2FzZSAyOlxuICAgICAgICAgIHNlY29uZEJ5dGUgPSBidWZbaSArIDFdXG4gICAgICAgICAgaWYgKChzZWNvbmRCeXRlICYgMHhDMCkgPT09IDB4ODApIHtcbiAgICAgICAgICAgIHRlbXBDb2RlUG9pbnQgPSAoZmlyc3RCeXRlICYgMHgxRikgPDwgMHg2IHwgKHNlY29uZEJ5dGUgJiAweDNGKVxuICAgICAgICAgICAgaWYgKHRlbXBDb2RlUG9pbnQgPiAweDdGKSB7XG4gICAgICAgICAgICAgIGNvZGVQb2ludCA9IHRlbXBDb2RlUG9pbnRcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgICAgYnJlYWtcbiAgICAgICAgY2FzZSAzOlxuICAgICAgICAgIHNlY29uZEJ5dGUgPSBidWZbaSArIDFdXG4gICAgICAgICAgdGhpcmRCeXRlID0gYnVmW2kgKyAyXVxuICAgICAgICAgIGlmICgoc2Vjb25kQnl0ZSAmIDB4QzApID09PSAweDgwICYmICh0aGlyZEJ5dGUgJiAweEMwKSA9PT0gMHg4MCkge1xuICAgICAgICAgICAgdGVtcENvZGVQb2ludCA9IChmaXJzdEJ5dGUgJiAweEYpIDw8IDB4QyB8IChzZWNvbmRCeXRlICYgMHgzRikgPDwgMHg2IHwgKHRoaXJkQnl0ZSAmIDB4M0YpXG4gICAgICAgICAgICBpZiAodGVtcENvZGVQb2ludCA+IDB4N0ZGICYmICh0ZW1wQ29kZVBvaW50IDwgMHhEODAwIHx8IHRlbXBDb2RlUG9pbnQgPiAweERGRkYpKSB7XG4gICAgICAgICAgICAgIGNvZGVQb2ludCA9IHRlbXBDb2RlUG9pbnRcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgICAgYnJlYWtcbiAgICAgICAgY2FzZSA0OlxuICAgICAgICAgIHNlY29uZEJ5dGUgPSBidWZbaSArI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WFkRG91YmxlQkVcbiAgYXJyLndyaXRlVUludDggPSBCUC53cml0ZVVJbnQ4XG4gIGFyci53cml0ZVVJbnRMRSA9IEJQLndyaXRlVUludExFXG4gIGFyci53cml0ZVVJbnRCRSA9IEJQLndyaXRlVUludEJFXG4gIGFyci53cml0ZVVJbnQxNkxFID0gQlAud3JpdGVVSW50MTZMRVxuICBhcnIud3JpdGVVSW50MTZCRSA9IEJQLndyaXRlVUludDE2QkVcbiAgYXJyLndyaXRlVUludDMyTEUgPSBCUC53cml0ZVVJbnQzMkxFXG4gIGFyci53cml0ZVVJbnQzMkJFID0gQlAud3JpdGVVSW50MzJCRVxuICBhcnIud3JpdGVJbnRMRSA9IEJQLndyaXRlSW50TEVcbiAgYXJyLndyaXRlSW50QkUgPSBCUC53cml0ZUludEJFXG4gIGFyci53cml0ZUludDggPSBCUC53cml0ZUludDhcbiAgYXJyLndyaXRlSW50MTZMRSA9IEJQLndyaXRlSW50MTZMRVxuICBhcnIud3JpdGVJbnQxNkJFID0gQlAud3JpdGVJbnQxNkJFXG4gIGFyci53cml0ZUludDMyTEUgPSBCUC53cml0ZUludDMyTEVcbiAgYXJyLndyaXRlSW50MzJCRSA9IEJQLndyaXRlSW50MzJCRVxuICBhcnIud3JpdGVGbG9hdExFID0gQlAud3JpdGVGbG9hdExFXG4gIGFyci53cml0ZUZsb2F0QkUgPSBCUC53cml0ZUZsb2F0QkVcbiAgYXJyLndyaXRlRG91YmxlTEUgPSBCUC53cml0ZURvdWJsZUxFXG4gIGFyci53cml0ZURvdWJsZUJFID0gQlAud3JpdGVEb3VibGVCRVxuICBhcnIuZmlsbCA9IEJQLmZpbGxcbiAgYXJyLmluc3BlY3QgPSBCUC5pbnNwZWN0XG4gIGFyci50b0FycmF5QnVmZmVyID0gQlAudG9BcnJheUJ1ZmZlclxuXG4gIHJldHVybiBhcnJcbn1cblxudmFyIElOVkFMSURfQkFTRTY0X1JFID0gL1teK1xcLzAtOUEtWmEtei1fXS9nXG5cbmZ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pID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7XG4gICAgY29kZVBvaW50ID0gc3RyaW5nLmNoYXJDb2RlQXQoaSlcblxuICAgIC8vIGlzIHN1cnJvZ2F0ZSBjb21wb25lbnRcbiAgICBpZiAoY29kZVBvaW50ID4gMHhEN0ZGICYmIGNvZGVQb2ludCA8IDB4RTAwMCkge1xuICAgICAgLy8gbGFzdCBjaGFyIHdhcyBhIGxlYWRcbiAgICAgIGlmICghbGVhZFN1cnJvZ2F0ZSkge1xuICAgICAgICAvLyBubyBsZWFkIHlldFxuICAgICAgICBpZiAoY29kZVBvaW50ID4gMHhEQkZGKSB7XG4gICAgICAgICAgLy8gdW5leHBlY3RlZCB0cmFpbFxuICAgICAgICAgIGlmICgodW5pdHMgLT0gMykgPiAtMSkgYnl0ZXMucHVzaCgweEVGLCAweEJGLCAweEJEKVxuICAgICAgICAgIGNvbnRpbnVlXG4gICAgICAgIH0gZWxzZSBpZiAoaSArIDEgPT09IGxlbmd0aCkge1xuICAgICAgICAgIC8vIHVucGFpcmVkIGxlYWRcbiAgICAgICAgICBpZiAoKHVuaXRzIC09IDMpID4gLTEpIGJ5dGVzLnB1c2goMHhFRiwgMHhCRiwgMHhCRClcbiAgICAgICAgICBjb250aW51ZVxuICAgICAgICB9XG5cbiAgICAgICAgLy8gdmFsaWQgbGVhZFxuICAgICAgICBsZWFkU3Vycm9nYXRlID0gY29kZVBvaW50XG5cbiAgICAgICAgY29udGludWVcbiAgICAgIH1cblxuICAgICAgLy8gMiBsZWFkcyBpbiBhIHJvd1xuICAgICAgaWYgKGNvZGVQb2ludCA8IDB4REMwMCkge1xuICAgICAgICBpZiAoKHVuaXRzIC09IDMpID4gLTEpIGJ5dGVzLnB1c2goMHhFRiwgMHhCRiwgMHhCRClcbiAgICAgICAgbGVhZFN1cnJvZ2F0ZSA9IGNvZGVQb2ludFxuICAgICAgICBjb250aW51ZVxuICAgICAgfVxuXG4gICAgICAvLyB2YWxpZCBzdXJyb2dhdG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2U2NFRvQnl0ZXMgKHN0cikge1xuICByZXR1cm4gYmFzZTY0LnRvQnl0ZUFycmF5KGJhc2U2NGNsZWFuKHN0cikpXG59XG5cbmZ1bmN0aW9uIGJsaXRCdWZmZXIgKHNyYywgZHN0LCBvZmZzZXQsIGxlbmd0aCkge1xuICBmb3IgKHZhciBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKSB7XG4gICAgaWYgKChpICsgb2Zmc2V0ID49IGRzdC5sZW5ndGgpIHx8IChpID49IHNyYy5sZW5ndGgpKSBicmVha1xuICAgIGRzdFtpICsgb2Zmc2V0XSA9IHNyY1tpXVxuICB9XG4gIHJldHVybiBpXG59XG4iXX0= -},{"base64-js":31,"ieee754":159,"isarray":42}],42:[function(_dereq_,module,exports){ -var toString = {}.toString; +function isnan (val) { + return val !== val // eslint-disable-line no-self-compare +} -module.exports = Array.isArray || function (arr) { - return toString.call(arr) == '[object Array]'; -}; +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],43:[function(_dereq_,module,exports){ +},{"base64-js":31,"ieee754":186,"isarray":189}],42:[function(_dereq_,module,exports){ _dereq_('../../modules/es6.string.iterator'); _dereq_('../../modules/es6.array.from'); -module.exports = _dereq_('../../modules/$.core').Array.from; -},{"../../modules/$.core":68,"../../modules/es6.array.from":120,"../../modules/es6.string.iterator":132}],44:[function(_dereq_,module,exports){ +module.exports = _dereq_('../../modules/_core').Array.from; +},{"../../modules/_core":74,"../../modules/es6.array.from":142,"../../modules/es6.string.iterator":157}],43:[function(_dereq_,module,exports){ _dereq_('../modules/web.dom.iterable'); _dereq_('../modules/es6.string.iterator'); module.exports = _dereq_('../modules/core.get-iterator'); -},{"../modules/core.get-iterator":118,"../modules/es6.string.iterator":132,"../modules/web.dom.iterable":136}],45:[function(_dereq_,module,exports){ +},{"../modules/core.get-iterator":140,"../modules/es6.string.iterator":157,"../modules/web.dom.iterable":163}],44:[function(_dereq_,module,exports){ _dereq_('../modules/web.dom.iterable'); _dereq_('../modules/es6.string.iterator'); module.exports = _dereq_('../modules/core.is-iterable'); -},{"../modules/core.is-iterable":119,"../modules/es6.string.iterator":132,"../modules/web.dom.iterable":136}],46:[function(_dereq_,module,exports){ +},{"../modules/core.is-iterable":141,"../modules/es6.string.iterator":157,"../modules/web.dom.iterable":163}],45:[function(_dereq_,module,exports){ +var core = _dereq_('../../modules/_core') + , $JSON = core.JSON || (core.JSON = {stringify: JSON.stringify}); +module.exports = function stringify(it){ // eslint-disable-line no-unused-vars + return $JSON.stringify.apply($JSON, arguments); +}; +},{"../../modules/_core":74}],46:[function(_dereq_,module,exports){ _dereq_('../modules/es6.object.to-string'); _dereq_('../modules/es6.string.iterator'); _dereq_('../modules/web.dom.iterable'); _dereq_('../modules/es6.map'); _dereq_('../modules/es7.map.to-json'); -module.exports = _dereq_('../modules/$.core').Map; -},{"../modules/$.core":68,"../modules/es6.map":122,"../modules/es6.object.to-string":129,"../modules/es6.string.iterator":132,"../modules/es7.map.to-json":134,"../modules/web.dom.iterable":136}],47:[function(_dereq_,module,exports){ +module.exports = _dereq_('../modules/_core').Map; +},{"../modules/_core":74,"../modules/es6.map":144,"../modules/es6.object.to-string":154,"../modules/es6.string.iterator":157,"../modules/es7.map.to-json":159,"../modules/web.dom.iterable":163}],47:[function(_dereq_,module,exports){ _dereq_('../../modules/es6.math.log2'); -module.exports = _dereq_('../../modules/$.core').Math.log2; -},{"../../modules/$.core":68,"../../modules/es6.math.log2":123}],48:[function(_dereq_,module,exports){ +module.exports = _dereq_('../../modules/_core').Math.log2; +},{"../../modules/_core":74,"../../modules/es6.math.log2":145}],48:[function(_dereq_,module,exports){ _dereq_('../../modules/es6.object.assign'); -module.exports = _dereq_('../../modules/$.core').Object.assign; -},{"../../modules/$.core":68,"../../modules/es6.object.assign":124}],49:[function(_dereq_,module,exports){ -var $ = _dereq_('../../modules/$'); +module.exports = _dereq_('../../modules/_core').Object.assign; +},{"../../modules/_core":74,"../../modules/es6.object.assign":146}],49:[function(_dereq_,module,exports){ +_dereq_('../../modules/es6.object.create'); +var $Object = _dereq_('../../modules/_core').Object; module.exports = function create(P, D){ - return $.create(P, D); -}; -},{"../../modules/$":93}],50:[function(_dereq_,module,exports){ -var $ = _dereq_('../../modules/$'); -module.exports = function defineProperties(T, D){ - return $.setDescs(T, D); + return $Object.create(P, D); }; -},{"../../modules/$":93}],51:[function(_dereq_,module,exports){ -var $ = _dereq_('../../modules/$'); +},{"../../modules/_core":74,"../../modules/es6.object.create":147}],50:[function(_dereq_,module,exports){ +_dereq_('../../modules/es6.object.define-property'); +var $Object = _dereq_('../../modules/_core').Object; module.exports = function defineProperty(it, key, desc){ - return $.setDesc(it, key, desc); + return $Object.defineProperty(it, key, desc); }; -},{"../../modules/$":93}],52:[function(_dereq_,module,exports){ +},{"../../modules/_core":74,"../../modules/es6.object.define-property":148}],51:[function(_dereq_,module,exports){ _dereq_('../../modules/es6.object.freeze'); -module.exports = _dereq_('../../modules/$.core').Object.freeze; -},{"../../modules/$.core":68,"../../modules/es6.object.freeze":125}],53:[function(_dereq_,module,exports){ -var $ = _dereq_('../../modules/$'); +module.exports = _dereq_('../../modules/_core').Object.freeze; +},{"../../modules/_core":74,"../../modules/es6.object.freeze":149}],52:[function(_dereq_,module,exports){ _dereq_('../../modules/es6.object.get-own-property-descriptor'); +var $Object = _dereq_('../../modules/_core').Object; module.exports = function getOwnPropertyDescriptor(it, key){ - return $.getDesc(it, key); + return $Object.getOwnPropertyDescriptor(it, key); }; -},{"../../modules/$":93,"../../modules/es6.object.get-own-property-descriptor":126}],54:[function(_dereq_,module,exports){ +},{"../../modules/_core":74,"../../modules/es6.object.get-own-property-descriptor":150}],53:[function(_dereq_,module,exports){ +_dereq_('../../modules/es6.object.get-prototype-of'); +module.exports = _dereq_('../../modules/_core').Object.getPrototypeOf; +},{"../../modules/_core":74,"../../modules/es6.object.get-prototype-of":151}],54:[function(_dereq_,module,exports){ _dereq_('../../modules/es6.object.keys'); -module.exports = _dereq_('../../modules/$.core').Object.keys; -},{"../../modules/$.core":68,"../../modules/es6.object.keys":127}],55:[function(_dereq_,module,exports){ +module.exports = _dereq_('../../modules/_core').Object.keys; +},{"../../modules/_core":74,"../../modules/es6.object.keys":152}],55:[function(_dereq_,module,exports){ _dereq_('../../modules/es6.object.set-prototype-of'); -module.exports = _dereq_('../../modules/$.core').Object.setPrototypeOf; -},{"../../modules/$.core":68,"../../modules/es6.object.set-prototype-of":128}],56:[function(_dereq_,module,exports){ +module.exports = _dereq_('../../modules/_core').Object.setPrototypeOf; +},{"../../modules/_core":74,"../../modules/es6.object.set-prototype-of":153}],56:[function(_dereq_,module,exports){ _dereq_('../modules/es6.object.to-string'); _dereq_('../modules/es6.string.iterator'); _dereq_('../modules/web.dom.iterable'); _dereq_('../modules/es6.promise'); -module.exports = _dereq_('../modules/$.core').Promise; -},{"../modules/$.core":68,"../modules/es6.object.to-string":129,"../modules/es6.promise":130,"../modules/es6.string.iterator":132,"../modules/web.dom.iterable":136}],57:[function(_dereq_,module,exports){ +module.exports = _dereq_('../modules/_core').Promise; +},{"../modules/_core":74,"../modules/es6.object.to-string":154,"../modules/es6.promise":155,"../modules/es6.string.iterator":157,"../modules/web.dom.iterable":163}],57:[function(_dereq_,module,exports){ _dereq_('../modules/es6.object.to-string'); _dereq_('../modules/es6.string.iterator'); _dereq_('../modules/web.dom.iterable'); _dereq_('../modules/es6.set'); _dereq_('../modules/es7.set.to-json'); -module.exports = _dereq_('../modules/$.core').Set; -},{"../modules/$.core":68,"../modules/es6.object.to-string":129,"../modules/es6.set":131,"../modules/es6.string.iterator":132,"../modules/es7.set.to-json":135,"../modules/web.dom.iterable":136}],58:[function(_dereq_,module,exports){ +module.exports = _dereq_('../modules/_core').Set; +},{"../modules/_core":74,"../modules/es6.object.to-string":154,"../modules/es6.set":156,"../modules/es6.string.iterator":157,"../modules/es7.set.to-json":160,"../modules/web.dom.iterable":163}],58:[function(_dereq_,module,exports){ _dereq_('../../modules/es6.symbol'); _dereq_('../../modules/es6.object.to-string'); -module.exports = _dereq_('../../modules/$.core').Symbol; -},{"../../modules/$.core":68,"../../modules/es6.object.to-string":129,"../../modules/es6.symbol":133}],59:[function(_dereq_,module,exports){ +_dereq_('../../modules/es7.symbol.async-iterator'); +_dereq_('../../modules/es7.symbol.observable'); +module.exports = _dereq_('../../modules/_core').Symbol; +},{"../../modules/_core":74,"../../modules/es6.object.to-string":154,"../../modules/es6.symbol":158,"../../modules/es7.symbol.async-iterator":161,"../../modules/es7.symbol.observable":162}],59:[function(_dereq_,module,exports){ _dereq_('../../modules/es6.string.iterator'); _dereq_('../../modules/web.dom.iterable'); -module.exports = _dereq_('../../modules/$.wks')('iterator'); -},{"../../modules/$.wks":116,"../../modules/es6.string.iterator":132,"../../modules/web.dom.iterable":136}],60:[function(_dereq_,module,exports){ +module.exports = _dereq_('../../modules/_wks-ext').f('iterator'); +},{"../../modules/_wks-ext":137,"../../modules/es6.string.iterator":157,"../../modules/web.dom.iterable":163}],60:[function(_dereq_,module,exports){ module.exports = function(it){ if(typeof it != 'function')throw TypeError(it + ' is not a function!'); return it; @@ -4778,67 +4388,162 @@ module.exports = function(it){ },{}],61:[function(_dereq_,module,exports){ module.exports = function(){ /* empty */ }; },{}],62:[function(_dereq_,module,exports){ -var isObject = _dereq_('./$.is-object'); +module.exports = function(it, Constructor, name, forbiddenField){ + if(!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)){ + throw TypeError(name + ': incorrect invocation!'); + } return it; +}; +},{}],63:[function(_dereq_,module,exports){ +var isObject = _dereq_('./_is-object'); module.exports = function(it){ if(!isObject(it))throw TypeError(it + ' is not an object!'); return it; }; -},{"./$.is-object":86}],63:[function(_dereq_,module,exports){ +},{"./_is-object":94}],64:[function(_dereq_,module,exports){ +var forOf = _dereq_('./_for-of'); + +module.exports = function(iter, ITERATOR){ + var result = []; + forOf(iter, false, result.push, result, ITERATOR); + return result; +}; + +},{"./_for-of":84}],65:[function(_dereq_,module,exports){ +// false -> Array#indexOf +// true -> Array#includes +var toIObject = _dereq_('./_to-iobject') + , toLength = _dereq_('./_to-length') + , toIndex = _dereq_('./_to-index'); +module.exports = function(IS_INCLUDES){ + return function($this, el, fromIndex){ + var O = toIObject($this) + , length = toLength(O.length) + , index = toIndex(fromIndex, length) + , value; + // Array#includes uses SameValueZero equality algorithm + if(IS_INCLUDES && el != el)while(length > index){ + value = O[index++]; + if(value != value)return true; + // Array#toIndex ignores holes, Array#includes - not + } else for(;length > index; index++)if(IS_INCLUDES || index in O){ + if(O[index] === el)return IS_INCLUDES || index || 0; + } return !IS_INCLUDES && -1; + }; +}; +},{"./_to-index":129,"./_to-iobject":131,"./_to-length":132}],66:[function(_dereq_,module,exports){ +// 0 -> Array#forEach +// 1 -> Array#map +// 2 -> Array#filter +// 3 -> Array#some +// 4 -> Array#every +// 5 -> Array#find +// 6 -> Array#findIndex +var ctx = _dereq_('./_ctx') + , IObject = _dereq_('./_iobject') + , toObject = _dereq_('./_to-object') + , toLength = _dereq_('./_to-length') + , asc = _dereq_('./_array-species-create'); +module.exports = function(TYPE, $create){ + var IS_MAP = TYPE == 1 + , IS_FILTER = TYPE == 2 + , IS_SOME = TYPE == 3 + , IS_EVERY = TYPE == 4 + , IS_FIND_INDEX = TYPE == 6 + , NO_HOLES = TYPE == 5 || IS_FIND_INDEX + , create = $create || asc; + return function($this, callbackfn, that){ + var O = toObject($this) + , self = IObject(O) + , f = ctx(callbackfn, that, 3) + , length = toLength(self.length) + , index = 0 + , result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined + , val, res; + for(;length > index; index++)if(NO_HOLES || index in self){ + val = self[index]; + res = f(val, index, O); + if(TYPE){ + if(IS_MAP)result[index] = res; // map + else if(res)switch(TYPE){ + case 3: return true; // some + case 5: return val; // find + case 6: return index; // findIndex + case 2: result.push(val); // filter + } else if(IS_EVERY)return false; // every + } + } + return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result; + }; +}; +},{"./_array-species-create":68,"./_ctx":76,"./_iobject":91,"./_to-length":132,"./_to-object":133}],67:[function(_dereq_,module,exports){ +var isObject = _dereq_('./_is-object') + , isArray = _dereq_('./_is-array') + , SPECIES = _dereq_('./_wks')('species'); + +module.exports = 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]; + if(C === null)C = undefined; + } + } return C === undefined ? Array : C; +}; +},{"./_is-array":93,"./_is-object":94,"./_wks":138}],68:[function(_dereq_,module,exports){ +// 9.4.2.3 ArraySpeciesCreate(originalArray, length) +var speciesConstructor = _dereq_('./_array-species-constructor'); + +module.exports = function(original, length){ + return new (speciesConstructor(original))(length); +}; +},{"./_array-species-constructor":67}],69:[function(_dereq_,module,exports){ // getting tag from 19.1.3.6 Object.prototype.toString() -var cof = _dereq_('./$.cof') - , TAG = _dereq_('./$.wks')('toStringTag') +var cof = _dereq_('./_cof') + , TAG = _dereq_('./_wks')('toStringTag') // ES3 wrong here , 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 */ } +}; + module.exports = function(it){ var O, T, B; return it === undefined ? 'Undefined' : it === null ? 'Null' // @@toStringTag case - : typeof (T = (O = Object(it))[TAG]) == 'string' ? T + : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T // builtinTag case : ARG ? cof(O) // ES3 arguments fallback : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B; }; -},{"./$.cof":64,"./$.wks":116}],64:[function(_dereq_,module,exports){ +},{"./_cof":70,"./_wks":138}],70:[function(_dereq_,module,exports){ var toString = {}.toString; module.exports = function(it){ return toString.call(it).slice(8, -1); }; -},{}],65:[function(_dereq_,module,exports){ +},{}],71:[function(_dereq_,module,exports){ 'use strict'; -var $ = _dereq_('./$') - , hide = _dereq_('./$.hide') - , redefineAll = _dereq_('./$.redefine-all') - , ctx = _dereq_('./$.ctx') - , strictNew = _dereq_('./$.strict-new') - , defined = _dereq_('./$.defined') - , forOf = _dereq_('./$.for-of') - , $iterDefine = _dereq_('./$.iter-define') - , step = _dereq_('./$.iter-step') - , ID = _dereq_('./$.uid')('id') - , $has = _dereq_('./$.has') - , isObject = _dereq_('./$.is-object') - , setSpecies = _dereq_('./$.set-species') - , DESCRIPTORS = _dereq_('./$.descriptors') - , isExtensible = Object.isExtensible || isObject - , SIZE = DESCRIPTORS ? '_s' : 'size' - , id = 0; - -var fastKey = function(it, create){ - // return primitive with prefix - if(!isObject(it))return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it; - if(!$has(it, ID)){ - // can't set id to frozen object - if(!isExtensible(it))return 'F'; - // not necessary to add id - if(!create)return 'E'; - // add missing object id - hide(it, ID, ++id); - // return object id with prefix - } return 'O' + it[ID]; -}; +var dP = _dereq_('./_object-dp').f + , create = _dereq_('./_object-create') + , redefineAll = _dereq_('./_redefine-all') + , ctx = _dereq_('./_ctx') + , anInstance = _dereq_('./_an-instance') + , defined = _dereq_('./_defined') + , forOf = _dereq_('./_for-of') + , $iterDefine = _dereq_('./_iter-define') + , step = _dereq_('./_iter-step') + , setSpecies = _dereq_('./_set-species') + , DESCRIPTORS = _dereq_('./_descriptors') + , fastKey = _dereq_('./_meta').fastKey + , SIZE = DESCRIPTORS ? '_s' : 'size'; var getEntry = function(that, key){ // fast case @@ -4853,11 +4558,11 @@ var getEntry = function(that, key){ module.exports = { getConstructor: function(wrapper, NAME, IS_MAP, ADDER){ var C = wrapper(function(that, iterable){ - strictNew(that, C, NAME); - that._i = $.create(null); // index - that._f = undefined; // first entry - that._l = undefined; // last entry - that[SIZE] = 0; // size + anInstance(that, C, NAME, '_i'); + that._i = create(null); // index + that._f = undefined; // first entry + that._l = undefined; // last entry + that[SIZE] = 0; // size if(iterable != undefined)forOf(iterable, IS_MAP, that[ADDER], that); }); redefineAll(C.prototype, { @@ -4892,6 +4597,7 @@ module.exports = { // 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 */){ + anInstance(this, C, 'forEach'); var f = ctx(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3) , entry; while(entry = entry ? entry.n : this._f){ @@ -4906,7 +4612,7 @@ module.exports = { return !!getEntry(this, key); } }); - if(DESCRIPTORS)$.setDesc(C.prototype, 'size', { + if(DESCRIPTORS)dP(C.prototype, 'size', { get: function(){ return defined(this[SIZE]); } @@ -4966,31 +4672,31 @@ module.exports = { setSpecies(NAME); } }; -},{"./$":93,"./$.ctx":69,"./$.defined":70,"./$.descriptors":71,"./$.for-of":76,"./$.has":79,"./$.hide":80,"./$.is-object":86,"./$.iter-define":89,"./$.iter-step":91,"./$.redefine-all":100,"./$.set-species":104,"./$.strict-new":108,"./$.uid":115}],66:[function(_dereq_,module,exports){ +},{"./_an-instance":62,"./_ctx":76,"./_defined":77,"./_descriptors":78,"./_for-of":84,"./_iter-define":97,"./_iter-step":99,"./_meta":103,"./_object-create":106,"./_object-dp":107,"./_redefine-all":119,"./_set-species":122}],72:[function(_dereq_,module,exports){ // https://github.com/DavidBruant/Map-Set.prototype.toJSON -var forOf = _dereq_('./$.for-of') - , classof = _dereq_('./$.classof'); +var classof = _dereq_('./_classof') + , from = _dereq_('./_array-from-iterable'); module.exports = function(NAME){ return function toJSON(){ if(classof(this) != NAME)throw TypeError(NAME + "#toJSON isn't generic"); - var arr = []; - forOf(this, false, arr.push, arr); - return arr; + return from(this); }; }; -},{"./$.classof":63,"./$.for-of":76}],67:[function(_dereq_,module,exports){ +},{"./_array-from-iterable":64,"./_classof":69}],73:[function(_dereq_,module,exports){ 'use strict'; -var $ = _dereq_('./$') - , global = _dereq_('./$.global') - , $export = _dereq_('./$.export') - , fails = _dereq_('./$.fails') - , hide = _dereq_('./$.hide') - , redefineAll = _dereq_('./$.redefine-all') - , forOf = _dereq_('./$.for-of') - , strictNew = _dereq_('./$.strict-new') - , isObject = _dereq_('./$.is-object') - , setToStringTag = _dereq_('./$.set-to-string-tag') - , DESCRIPTORS = _dereq_('./$.descriptors'); +var global = _dereq_('./_global') + , $export = _dereq_('./_export') + , meta = _dereq_('./_meta') + , fails = _dereq_('./_fails') + , hide = _dereq_('./_hide') + , redefineAll = _dereq_('./_redefine-all') + , forOf = _dereq_('./_for-of') + , anInstance = _dereq_('./_an-instance') + , isObject = _dereq_('./_is-object') + , setToStringTag = _dereq_('./_set-to-string-tag') + , dP = _dereq_('./_object-dp').f + , each = _dereq_('./_array-methods')(0) + , DESCRIPTORS = _dereq_('./_descriptors'); module.exports = function(NAME, wrapper, methods, common, IS_MAP, IS_WEAK){ var Base = global[NAME] @@ -5004,21 +4710,23 @@ module.exports = function(NAME, wrapper, methods, common, IS_MAP, IS_WEAK){ // create collection constructor C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER); redefineAll(C.prototype, methods); + meta.NEED = true; } else { C = wrapper(function(target, iterable){ - strictNew(target, C, NAME); + anInstance(target, C, NAME, '_c'); target._c = new Base; if(iterable != undefined)forOf(iterable, IS_MAP, target[ADDER], target); }); - $.each.call('add,clear,delete,forEach,get,has,set,keys,values,entries'.split(','),function(KEY){ + 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; }); }); - if('size' in proto)$.setDesc(C.prototype, 'size', { + if('size' in proto)dP(C.prototype, 'size', { get: function(){ return this._c.size; } @@ -5034,12 +4742,21 @@ module.exports = function(NAME, wrapper, methods, common, IS_MAP, IS_WEAK){ return C; }; -},{"./$":93,"./$.descriptors":71,"./$.export":74,"./$.fails":75,"./$.for-of":76,"./$.global":78,"./$.hide":80,"./$.is-object":86,"./$.redefine-all":100,"./$.set-to-string-tag":105,"./$.strict-new":108}],68:[function(_dereq_,module,exports){ -var core = module.exports = {version: '1.2.6'}; +},{"./_an-instance":62,"./_array-methods":66,"./_descriptors":78,"./_export":82,"./_fails":83,"./_for-of":84,"./_global":85,"./_hide":87,"./_is-object":94,"./_meta":103,"./_object-dp":107,"./_redefine-all":119,"./_set-to-string-tag":123}],74:[function(_dereq_,module,exports){ +var core = module.exports = {version: '2.4.0'}; if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef -},{}],69:[function(_dereq_,module,exports){ +},{}],75:[function(_dereq_,module,exports){ +'use strict'; +var $defineProperty = _dereq_('./_object-dp') + , createDesc = _dereq_('./_property-desc'); + +module.exports = function(object, index, value){ + if(index in object)$defineProperty.f(object, index, createDesc(0, value)); + else object[index] = value; +}; +},{"./_object-dp":107,"./_property-desc":118}],76:[function(_dereq_,module,exports){ // optional / simple context binding -var aFunction = _dereq_('./$.a-function'); +var aFunction = _dereq_('./_a-function'); module.exports = function(fn, that, length){ aFunction(fn); if(that === undefined)return fn; @@ -5058,44 +4775,51 @@ module.exports = function(fn, that, length){ return fn.apply(that, arguments); }; }; -},{"./$.a-function":60}],70:[function(_dereq_,module,exports){ +},{"./_a-function":60}],77:[function(_dereq_,module,exports){ // 7.2.1 RequireObjectCoercible(argument) module.exports = function(it){ if(it == undefined)throw TypeError("Can't call method on " + it); return it; }; -},{}],71:[function(_dereq_,module,exports){ +},{}],78:[function(_dereq_,module,exports){ // Thank's IE8 for his funny defineProperty -module.exports = !_dereq_('./$.fails')(function(){ +module.exports = !_dereq_('./_fails')(function(){ return Object.defineProperty({}, 'a', {get: function(){ return 7; }}).a != 7; }); -},{"./$.fails":75}],72:[function(_dereq_,module,exports){ -var isObject = _dereq_('./$.is-object') - , document = _dereq_('./$.global').document +},{"./_fails":83}],79:[function(_dereq_,module,exports){ +var isObject = _dereq_('./_is-object') + , document = _dereq_('./_global').document // in old IE typeof document.createElement is 'object' , is = isObject(document) && isObject(document.createElement); module.exports = function(it){ return is ? document.createElement(it) : {}; }; -},{"./$.global":78,"./$.is-object":86}],73:[function(_dereq_,module,exports){ +},{"./_global":85,"./_is-object":94}],80:[function(_dereq_,module,exports){ +// IE 8- don't enum bug keys +module.exports = ( + 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf' +).split(','); +},{}],81:[function(_dereq_,module,exports){ // all enumerable object keys, includes symbols -var $ = _dereq_('./$'); +var getKeys = _dereq_('./_object-keys') + , gOPS = _dereq_('./_object-gops') + , pIE = _dereq_('./_object-pie'); module.exports = function(it){ - var keys = $.getKeys(it) - , getSymbols = $.getSymbols; + var result = getKeys(it) + , getSymbols = gOPS.f; if(getSymbols){ var symbols = getSymbols(it) - , isEnum = $.isEnum + , isEnum = pIE.f , i = 0 , key; - while(symbols.length > i)if(isEnum.call(it, key = symbols[i++]))keys.push(key); - } - return keys; -}; -},{"./$":93}],74:[function(_dereq_,module,exports){ -var global = _dereq_('./$.global') - , core = _dereq_('./$.core') - , ctx = _dereq_('./$.ctx') + while(symbols.length > i)if(isEnum.call(it, key = symbols[i++]))result.push(key); + } return result; +}; +},{"./_object-gops":112,"./_object-keys":115,"./_object-pie":116}],82:[function(_dereq_,module,exports){ +var global = _dereq_('./_global') + , core = _dereq_('./_core') + , ctx = _dereq_('./_ctx') + , hide = _dereq_('./_hide') , PROTOTYPE = 'prototype'; var $export = function(type, name, source){ @@ -5106,12 +4830,13 @@ var $export = function(type, name, source){ , IS_BIND = type & $export.B , IS_WRAP = type & $export.W , exports = IS_GLOBAL ? core : core[name] || (core[name] = {}) + , expProto = exports[PROTOTYPE] , target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE] , key, own, out; if(IS_GLOBAL)source = name; for(key in source){ // contains in native - own = !IS_FORCED && target && key in target; + own = !IS_FORCED && target && target[key] !== undefined; if(own && key in exports)continue; // export native or passed out = own ? target[key] : source[key]; @@ -5121,25 +4846,38 @@ var $export = function(type, name, source){ : 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(param){ - return this instanceof C ? new C(param) : C(param); + 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; - if(IS_PROTO)(exports[PROTOTYPE] || (exports[PROTOTYPE] = {}))[key] = 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.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` module.exports = $export; -},{"./$.core":68,"./$.ctx":69,"./$.global":78}],75:[function(_dereq_,module,exports){ +},{"./_core":74,"./_ctx":76,"./_global":85,"./_hide":87}],83:[function(_dereq_,module,exports){ module.exports = function(exec){ try { return !!exec(); @@ -5147,69 +4885,58 @@ module.exports = function(exec){ return true; } }; -},{}],76:[function(_dereq_,module,exports){ -var ctx = _dereq_('./$.ctx') - , call = _dereq_('./$.iter-call') - , isArrayIter = _dereq_('./$.is-array-iter') - , anObject = _dereq_('./$.an-object') - , toLength = _dereq_('./$.to-length') - , getIterFn = _dereq_('./core.get-iterator-method'); -module.exports = function(iterable, entries, fn, that){ - var iterFn = getIterFn(iterable) +},{}],84:[function(_dereq_,module,exports){ +var ctx = _dereq_('./_ctx') + , call = _dereq_('./_iter-call') + , isArrayIter = _dereq_('./_is-array-iter') + , anObject = _dereq_('./_an-object') + , toLength = _dereq_('./_to-length') + , getIterFn = _dereq_('./core.get-iterator-method') + , BREAK = {} + , RETURN = {}; +var exports = module.exports = function(iterable, entries, fn, that, ITERATOR){ + var iterFn = ITERATOR ? function(){ return iterable; } : getIterFn(iterable) , f = ctx(fn, that, entries ? 2 : 1) , index = 0 - , length, step, iterator; + , 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++){ - entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[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; ){ - call(iterator, f, step.value, entries); + result = call(iterator, f, step.value, entries); + if(result === BREAK || result === RETURN)return result; } }; -},{"./$.an-object":62,"./$.ctx":69,"./$.is-array-iter":84,"./$.iter-call":87,"./$.to-length":113,"./core.get-iterator-method":117}],77:[function(_dereq_,module,exports){ -// fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window -var toIObject = _dereq_('./$.to-iobject') - , getNames = _dereq_('./$').getNames - , toString = {}.toString; - -var windowNames = typeof window == 'object' && Object.getOwnPropertyNames - ? Object.getOwnPropertyNames(window) : []; - -var getWindowNames = function(it){ - try { - return getNames(it); - } catch(e){ - return windowNames.slice(); - } -}; - -module.exports.get = function getOwnPropertyNames(it){ - if(windowNames && toString.call(it) == '[object Window]')return getWindowNames(it); - return getNames(toIObject(it)); -}; -},{"./$":93,"./$.to-iobject":112}],78:[function(_dereq_,module,exports){ +exports.BREAK = BREAK; +exports.RETURN = RETURN; +},{"./_an-object":63,"./_ctx":76,"./_is-array-iter":92,"./_iter-call":95,"./_to-length":132,"./core.get-iterator-method":139}],85:[function(_dereq_,module,exports){ // 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 : Function('return this')(); if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef -},{}],79:[function(_dereq_,module,exports){ +},{}],86:[function(_dereq_,module,exports){ var hasOwnProperty = {}.hasOwnProperty; module.exports = function(it, key){ return hasOwnProperty.call(it, key); }; -},{}],80:[function(_dereq_,module,exports){ -var $ = _dereq_('./$') - , createDesc = _dereq_('./$.property-desc'); -module.exports = _dereq_('./$.descriptors') ? function(object, key, value){ - return $.setDesc(object, key, createDesc(1, value)); +},{}],87:[function(_dereq_,module,exports){ +var dP = _dereq_('./_object-dp') + , createDesc = _dereq_('./_property-desc'); +module.exports = _dereq_('./_descriptors') ? function(object, key, value){ + return dP.f(object, key, createDesc(1, value)); } : function(object, key, value){ object[key] = value; return object; }; -},{"./$":93,"./$.descriptors":71,"./$.property-desc":99}],81:[function(_dereq_,module,exports){ -module.exports = _dereq_('./$.global').document && document.documentElement; -},{"./$.global":78}],82:[function(_dereq_,module,exports){ +},{"./_descriptors":78,"./_object-dp":107,"./_property-desc":118}],88:[function(_dereq_,module,exports){ +module.exports = _dereq_('./_global').document && document.documentElement; +},{"./_global":85}],89:[function(_dereq_,module,exports){ +module.exports = !_dereq_('./_descriptors') && !_dereq_('./_fails')(function(){ + return Object.defineProperty(_dereq_('./_dom-create')('div'), 'a', {get: function(){ return 7; }}).a != 7; +}); +},{"./_descriptors":78,"./_dom-create":79,"./_fails":83}],90:[function(_dereq_,module,exports){ // fast apply, http://jsperf.lnkit.com/fast-apply/5 module.exports = function(fn, args, that){ var un = that === undefined; @@ -5226,34 +4953,34 @@ module.exports = function(fn, args, that){ : fn.call(that, args[0], args[1], args[2], args[3]); } return fn.apply(that, args); }; -},{}],83:[function(_dereq_,module,exports){ +},{}],91:[function(_dereq_,module,exports){ // fallback for non-array-like ES3 and non-enumerable old V8 strings -var cof = _dereq_('./$.cof'); +var cof = _dereq_('./_cof'); module.exports = Object('z').propertyIsEnumerable(0) ? Object : function(it){ return cof(it) == 'String' ? it.split('') : Object(it); }; -},{"./$.cof":64}],84:[function(_dereq_,module,exports){ +},{"./_cof":70}],92:[function(_dereq_,module,exports){ // check on default Array iterator -var Iterators = _dereq_('./$.iterators') - , ITERATOR = _dereq_('./$.wks')('iterator') +var Iterators = _dereq_('./_iterators') + , ITERATOR = _dereq_('./_wks')('iterator') , ArrayProto = Array.prototype; module.exports = function(it){ return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it); }; -},{"./$.iterators":92,"./$.wks":116}],85:[function(_dereq_,module,exports){ +},{"./_iterators":100,"./_wks":138}],93:[function(_dereq_,module,exports){ // 7.2.2 IsArray(argument) -var cof = _dereq_('./$.cof'); -module.exports = Array.isArray || function(arg){ +var cof = _dereq_('./_cof'); +module.exports = Array.isArray || function isArray(arg){ return cof(arg) == 'Array'; }; -},{"./$.cof":64}],86:[function(_dereq_,module,exports){ +},{"./_cof":70}],94:[function(_dereq_,module,exports){ module.exports = function(it){ return typeof it === 'object' ? it !== null : typeof it === 'function'; }; -},{}],87:[function(_dereq_,module,exports){ +},{}],95:[function(_dereq_,module,exports){ // call something on iterator step with safe closing on error -var anObject = _dereq_('./$.an-object'); +var anObject = _dereq_('./_an-object'); module.exports = function(iterator, fn, value, entries){ try { return entries ? fn(anObject(value)[0], value[1]) : fn(value); @@ -5264,32 +4991,32 @@ module.exports = function(iterator, fn, value, entries){ throw e; } }; -},{"./$.an-object":62}],88:[function(_dereq_,module,exports){ +},{"./_an-object":63}],96:[function(_dereq_,module,exports){ 'use strict'; -var $ = _dereq_('./$') - , descriptor = _dereq_('./$.property-desc') - , setToStringTag = _dereq_('./$.set-to-string-tag') +var create = _dereq_('./_object-create') + , descriptor = _dereq_('./_property-desc') + , setToStringTag = _dereq_('./_set-to-string-tag') , IteratorPrototype = {}; // 25.1.2.1.1 %IteratorPrototype%[@@iterator]() -_dereq_('./$.hide')(IteratorPrototype, _dereq_('./$.wks')('iterator'), function(){ return this; }); +_dereq_('./_hide')(IteratorPrototype, _dereq_('./_wks')('iterator'), function(){ return this; }); module.exports = function(Constructor, NAME, next){ - Constructor.prototype = $.create(IteratorPrototype, {next: descriptor(1, next)}); + Constructor.prototype = create(IteratorPrototype, {next: descriptor(1, next)}); setToStringTag(Constructor, NAME + ' Iterator'); }; -},{"./$":93,"./$.hide":80,"./$.property-desc":99,"./$.set-to-string-tag":105,"./$.wks":116}],89:[function(_dereq_,module,exports){ +},{"./_hide":87,"./_object-create":106,"./_property-desc":118,"./_set-to-string-tag":123,"./_wks":138}],97:[function(_dereq_,module,exports){ 'use strict'; -var LIBRARY = _dereq_('./$.library') - , $export = _dereq_('./$.export') - , redefine = _dereq_('./$.redefine') - , hide = _dereq_('./$.hide') - , has = _dereq_('./$.has') - , Iterators = _dereq_('./$.iterators') - , $iterCreate = _dereq_('./$.iter-create') - , setToStringTag = _dereq_('./$.set-to-string-tag') - , getProto = _dereq_('./$').getProto - , ITERATOR = _dereq_('./$.wks')('iterator') +var LIBRARY = _dereq_('./_library') + , $export = _dereq_('./_export') + , redefine = _dereq_('./_redefine') + , hide = _dereq_('./_hide') + , has = _dereq_('./_has') + , Iterators = _dereq_('./_iterators') + , $iterCreate = _dereq_('./_iter-create') + , setToStringTag = _dereq_('./_set-to-string-tag') + , getPrototypeOf = _dereq_('./_object-gpo') + , ITERATOR = _dereq_('./_wks')('iterator') , BUGGY = !([].keys && 'next' in [].keys()) // Safari has buggy iterators w/o `next` , FF_ITERATOR = '@@iterator' , KEYS = 'keys' @@ -5312,20 +5039,24 @@ module.exports = function(Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED , proto = Base.prototype , $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT] , $default = $native || getMethod(DEFAULT) - , methods, key; + , $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined + , $anyNative = NAME == 'Array' ? proto.entries || $native : $native + , methods, key, IteratorPrototype; // Fix native - if($native){ - var IteratorPrototype = getProto($default.call(new Base)); - // Set @@toStringTag to native iterators - setToStringTag(IteratorPrototype, TAG, true); - // FF fix - if(!LIBRARY && has(proto, FF_ITERATOR))hide(IteratorPrototype, ITERATOR, returnThis); - // fix Array#{values, @@iterator}.name in V8 / FF - if(DEF_VALUES && $native.name !== VALUES){ - VALUES_BUG = true; - $default = function values(){ return $native.call(this); }; + if($anyNative){ + IteratorPrototype = getPrototypeOf($anyNative.call(new Base)); + if(IteratorPrototype !== Object.prototype){ + // 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); @@ -5335,9 +5066,9 @@ module.exports = function(Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED Iterators[TAG] = returnThis; if(DEFAULT){ methods = { - values: DEF_VALUES ? $default : getMethod(VALUES), - keys: IS_SET ? $default : getMethod(KEYS), - entries: !DEF_VALUES ? $default : getMethod('entries') + 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]); @@ -5345,8 +5076,8 @@ module.exports = function(Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED } return methods; }; -},{"./$":93,"./$.export":74,"./$.has":79,"./$.hide":80,"./$.iter-create":88,"./$.iterators":92,"./$.library":95,"./$.redefine":101,"./$.set-to-string-tag":105,"./$.wks":116}],90:[function(_dereq_,module,exports){ -var ITERATOR = _dereq_('./$.wks')('iterator') +},{"./_export":82,"./_has":86,"./_hide":87,"./_iter-create":96,"./_iterators":100,"./_library":102,"./_object-gpo":113,"./_redefine":120,"./_set-to-string-tag":123,"./_wks":138}],98:[function(_dereq_,module,exports){ +var ITERATOR = _dereq_('./_wks')('iterator') , SAFE_CLOSING = false; try { @@ -5361,156 +5092,364 @@ module.exports = function(exec, skipClosing){ try { var arr = [7] , iter = arr[ITERATOR](); - iter.next = function(){ safe = true; }; + iter.next = function(){ return {done: safe = true}; }; arr[ITERATOR] = function(){ return iter; }; exec(arr); } catch(e){ /* empty */ } return safe; }; -},{"./$.wks":116}],91:[function(_dereq_,module,exports){ +},{"./_wks":138}],99:[function(_dereq_,module,exports){ module.exports = function(done, value){ return {value: value, done: !!done}; }; -},{}],92:[function(_dereq_,module,exports){ +},{}],100:[function(_dereq_,module,exports){ module.exports = {}; -},{}],93:[function(_dereq_,module,exports){ -var $Object = Object; -module.exports = { - create: $Object.create, - getProto: $Object.getPrototypeOf, - isEnum: {}.propertyIsEnumerable, - getDesc: $Object.getOwnPropertyDescriptor, - setDesc: $Object.defineProperty, - setDescs: $Object.defineProperties, - getKeys: $Object.keys, - getNames: $Object.getOwnPropertyNames, - getSymbols: $Object.getOwnPropertySymbols, - each: [].forEach -}; -},{}],94:[function(_dereq_,module,exports){ -var $ = _dereq_('./$') - , toIObject = _dereq_('./$.to-iobject'); +},{}],101:[function(_dereq_,module,exports){ +var getKeys = _dereq_('./_object-keys') + , toIObject = _dereq_('./_to-iobject'); module.exports = function(object, el){ var O = toIObject(object) - , keys = $.getKeys(O) + , keys = getKeys(O) , length = keys.length , index = 0 , key; while(length > index)if(O[key = keys[index++]] === el)return key; }; -},{"./$":93,"./$.to-iobject":112}],95:[function(_dereq_,module,exports){ +},{"./_object-keys":115,"./_to-iobject":131}],102:[function(_dereq_,module,exports){ module.exports = true; -},{}],96:[function(_dereq_,module,exports){ -var global = _dereq_('./$.global') - , macrotask = _dereq_('./$.task').set +},{}],103:[function(_dereq_,module,exports){ +var META = _dereq_('./_uid')('meta') + , isObject = _dereq_('./_is-object') + , has = _dereq_('./_has') + , setDesc = _dereq_('./_object-dp').f + , id = 0; +var isExtensible = Object.isExtensible || function(){ + return true; +}; +var FREEZE = !_dereq_('./_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 +}; +},{"./_fails":83,"./_has":86,"./_is-object":94,"./_object-dp":107,"./_uid":135}],104:[function(_dereq_,module,exports){ +var global = _dereq_('./_global') + , macrotask = _dereq_('./_task').set , Observer = global.MutationObserver || global.WebKitMutationObserver , process = global.process , Promise = global.Promise - , isNode = _dereq_('./$.cof')(process) == 'process' - , head, last, notify; - -var flush = function(){ - var parent, domain, fn; - if(isNode && (parent = process.domain)){ - process.domain = null; - parent.exit(); - } - while(head){ - domain = head.domain; - fn = head.fn; - if(domain)domain.enter(); - fn(); // <- currently we use it only for Promise - try / catch not required - if(domain)domain.exit(); - head = head.next; - } last = undefined; - if(parent)parent.enter(); -}; - -// Node.js -if(isNode){ - notify = function(){ - process.nextTick(flush); - }; -// browsers with MutationObserver -} else if(Observer){ - var toggle = 1 - , node = document.createTextNode(''); - new Observer(flush).observe(node, {characterData: true}); // eslint-disable-line no-new - notify = function(){ - node.data = toggle = -toggle; - }; -// environments with maybe non-completely correct, but existent Promise -} else if(Promise && Promise.resolve){ - notify = function(){ - Promise.resolve().then(flush); - }; -// for other environments - macrotask based on: -// - setImmediate -// - MessageChannel -// - window.postMessag -// - onreadystatechange -// - setTimeout -} else { - notify = function(){ - // strange IE + webpack dev server bug - use .call(global) - macrotask.call(global, flush); + , isNode = _dereq_('./_cof')(process) == 'process'; + +module.exports = function(){ + var head, last, notify; + + var flush = function(){ + var parent, fn; + if(isNode && (parent = process.domain))parent.exit(); + while(head){ + fn = head.fn; + head = head.next; + try { + fn(); + } catch(e){ + if(head)notify(); + else last = undefined; + throw e; + } + } last = undefined; + if(parent)parent.enter(); }; -} -module.exports = function asap(fn){ - var task = {fn: fn, next: undefined, domain: isNode && process.domain}; - if(last)last.next = task; - if(!head){ - head = task; - notify(); - } last = task; + // Node.js + if(isNode){ + notify = function(){ + process.nextTick(flush); + }; + // browsers with MutationObserver + } else if(Observer){ + var toggle = true + , node = document.createTextNode(''); + new Observer(flush).observe(node, {characterData: true}); // eslint-disable-line no-new + notify = function(){ + node.data = toggle = !toggle; + }; + // environments with maybe non-completely correct, but existent Promise + } else if(Promise && Promise.resolve){ + var promise = Promise.resolve(); + notify = function(){ + promise.then(flush); + }; + // for other environments - macrotask based on: + // - setImmediate + // - MessageChannel + // - window.postMessag + // - onreadystatechange + // - setTimeout + } else { + notify = function(){ + // strange IE + webpack dev server bug - use .call(global) + macrotask.call(global, flush); + }; + } + + return function(fn){ + var task = {fn: fn, next: undefined}; + if(last)last.next = task; + if(!head){ + head = task; + notify(); + } last = task; + }; }; -},{"./$.cof":64,"./$.global":78,"./$.task":110}],97:[function(_dereq_,module,exports){ +},{"./_cof":70,"./_global":85,"./_task":128}],105:[function(_dereq_,module,exports){ +'use strict'; // 19.1.2.1 Object.assign(target, source, ...) -var $ = _dereq_('./$') - , toObject = _dereq_('./$.to-object') - , IObject = _dereq_('./$.iobject'); +var getKeys = _dereq_('./_object-keys') + , gOPS = _dereq_('./_object-gops') + , pIE = _dereq_('./_object-pie') + , toObject = _dereq_('./_to-object') + , IObject = _dereq_('./_iobject') + , $assign = Object.assign; // should work with symbols and should have deterministic property order (V8 bug) -module.exports = _dereq_('./$.fails')(function(){ - var a = Object.assign - , A = {} +module.exports = !$assign || _dereq_('./_fails')(function(){ + var A = {} , B = {} , S = Symbol() , K = 'abcdefghijklmnopqrst'; A[S] = 7; K.split('').forEach(function(k){ B[k] = k; }); - return a({}, A)[S] != 7 || Object.keys(a({}, B)).join('') != K; + return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K; }) ? function assign(target, source){ // eslint-disable-line no-unused-vars var T = toObject(target) - , $$ = arguments - , $$len = $$.length + , aLen = arguments.length , index = 1 - , getKeys = $.getKeys - , getSymbols = $.getSymbols - , isEnum = $.isEnum; - while($$len > index){ - var S = IObject($$[index++]) + , getSymbols = gOPS.f + , isEnum = pIE.f; + while(aLen > index){ + var S = IObject(arguments[index++]) , keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S) , length = keys.length , j = 0 , key; while(length > j)if(isEnum.call(S, key = keys[j++]))T[key] = S[key]; + } return T; +} : $assign; +},{"./_fails":83,"./_iobject":91,"./_object-gops":112,"./_object-keys":115,"./_object-pie":116,"./_to-object":133}],106:[function(_dereq_,module,exports){ +// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) +var anObject = _dereq_('./_an-object') + , dPs = _dereq_('./_object-dps') + , enumBugKeys = _dereq_('./_enum-bug-keys') + , IE_PROTO = _dereq_('./_shared-key')('IE_PROTO') + , Empty = function(){ /* empty */ } + , PROTOTYPE = '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 = _dereq_('./_dom-create')('iframe') + , i = enumBugKeys.length + , lt = '<' + , gt = '>' + , iframeDocument; + iframe.style.display = 'none'; + _dereq_('./_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][enumBugKeys[i]]; + return createDict(); +}; + +module.exports = Object.create || function create(O, Properties){ + var result; + if(O !== null){ + Empty[PROTOTYPE] = anObject(O); + result = new Empty; + Empty[PROTOTYPE] = null; + // add "__proto__" for Object.getPrototypeOf polyfill + result[IE_PROTO] = O; + } else result = createDict(); + return Properties === undefined ? result : dPs(result, Properties); +}; + +},{"./_an-object":63,"./_dom-create":79,"./_enum-bug-keys":80,"./_html":88,"./_object-dps":108,"./_shared-key":124}],107:[function(_dereq_,module,exports){ +var anObject = _dereq_('./_an-object') + , IE8_DOM_DEFINE = _dereq_('./_ie8-dom-define') + , toPrimitive = _dereq_('./_to-primitive') + , dP = Object.defineProperty; + +exports.f = _dereq_('./_descriptors') ? Object.defineProperty : function defineProperty(O, P, Attributes){ + anObject(O); + P = toPrimitive(P, true); + anObject(Attributes); + if(IE8_DOM_DEFINE)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; +}; +},{"./_an-object":63,"./_descriptors":78,"./_ie8-dom-define":89,"./_to-primitive":134}],108:[function(_dereq_,module,exports){ +var dP = _dereq_('./_object-dp') + , anObject = _dereq_('./_an-object') + , getKeys = _dereq_('./_object-keys'); + +module.exports = _dereq_('./_descriptors') ? Object.defineProperties : function defineProperties(O, Properties){ + anObject(O); + var keys = getKeys(Properties) + , length = keys.length + , i = 0 + , P; + while(length > i)dP.f(O, P = keys[i++], Properties[P]); + return O; +}; +},{"./_an-object":63,"./_descriptors":78,"./_object-dp":107,"./_object-keys":115}],109:[function(_dereq_,module,exports){ +var pIE = _dereq_('./_object-pie') + , createDesc = _dereq_('./_property-desc') + , toIObject = _dereq_('./_to-iobject') + , toPrimitive = _dereq_('./_to-primitive') + , has = _dereq_('./_has') + , IE8_DOM_DEFINE = _dereq_('./_ie8-dom-define') + , gOPD = Object.getOwnPropertyDescriptor; + +exports.f = _dereq_('./_descriptors') ? gOPD : function getOwnPropertyDescriptor(O, P){ + O = toIObject(O); + P = toPrimitive(P, true); + if(IE8_DOM_DEFINE)try { + return gOPD(O, P); + } catch(e){ /* empty */ } + if(has(O, P))return createDesc(!pIE.f.call(O, P), O[P]); +}; +},{"./_descriptors":78,"./_has":86,"./_ie8-dom-define":89,"./_object-pie":116,"./_property-desc":118,"./_to-iobject":131,"./_to-primitive":134}],110:[function(_dereq_,module,exports){ +// fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window +var toIObject = _dereq_('./_to-iobject') + , gOPN = _dereq_('./_object-gopn').f + , toString = {}.toString; + +var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames + ? Object.getOwnPropertyNames(window) : []; + +var getWindowNames = function(it){ + try { + return gOPN(it); + } catch(e){ + return windowNames.slice(); + } +}; + +module.exports.f = function getOwnPropertyNames(it){ + return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(toIObject(it)); +}; + +},{"./_object-gopn":111,"./_to-iobject":131}],111:[function(_dereq_,module,exports){ +// 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O) +var $keys = _dereq_('./_object-keys-internal') + , hiddenKeys = _dereq_('./_enum-bug-keys').concat('length', 'prototype'); + +exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O){ + return $keys(O, hiddenKeys); +}; +},{"./_enum-bug-keys":80,"./_object-keys-internal":114}],112:[function(_dereq_,module,exports){ +exports.f = Object.getOwnPropertySymbols; +},{}],113:[function(_dereq_,module,exports){ +// 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O) +var has = _dereq_('./_has') + , toObject = _dereq_('./_to-object') + , IE_PROTO = _dereq_('./_shared-key')('IE_PROTO') + , ObjectProto = Object.prototype; + +module.exports = Object.getPrototypeOf || function(O){ + O = toObject(O); + if(has(O, IE_PROTO))return O[IE_PROTO]; + if(typeof O.constructor == 'function' && O instanceof O.constructor){ + return O.constructor.prototype; + } return O instanceof Object ? ObjectProto : null; +}; +},{"./_has":86,"./_shared-key":124,"./_to-object":133}],114:[function(_dereq_,module,exports){ +var has = _dereq_('./_has') + , toIObject = _dereq_('./_to-iobject') + , arrayIndexOf = _dereq_('./_array-includes')(false) + , IE_PROTO = _dereq_('./_shared-key')('IE_PROTO'); + +module.exports = function(object, names){ + var O = toIObject(object) + , i = 0 + , result = [] + , key; + for(key in O)if(key != IE_PROTO)has(O, key) && result.push(key); + // Don't enum bug & hidden keys + while(names.length > i)if(has(O, key = names[i++])){ + ~arrayIndexOf(result, key) || result.push(key); } - return T; -} : Object.assign; -},{"./$":93,"./$.fails":75,"./$.iobject":83,"./$.to-object":114}],98:[function(_dereq_,module,exports){ + return result; +}; +},{"./_array-includes":65,"./_has":86,"./_shared-key":124,"./_to-iobject":131}],115:[function(_dereq_,module,exports){ +// 19.1.2.14 / 15.2.3.14 Object.keys(O) +var $keys = _dereq_('./_object-keys-internal') + , enumBugKeys = _dereq_('./_enum-bug-keys'); + +module.exports = Object.keys || function keys(O){ + return $keys(O, enumBugKeys); +}; +},{"./_enum-bug-keys":80,"./_object-keys-internal":114}],116:[function(_dereq_,module,exports){ +exports.f = {}.propertyIsEnumerable; +},{}],117:[function(_dereq_,module,exports){ // most Object methods by ES6 should accept primitives -var $export = _dereq_('./$.export') - , core = _dereq_('./$.core') - , fails = _dereq_('./$.fails'); +var $export = _dereq_('./_export') + , core = _dereq_('./_core') + , fails = _dereq_('./_fails'); module.exports = function(KEY, exec){ var fn = (core.Object || {})[KEY] || Object[KEY] , exp = {}; exp[KEY] = exec(fn); $export($export.S + $export.F * fails(function(){ fn(1); }), 'Object', exp); }; -},{"./$.core":68,"./$.export":74,"./$.fails":75}],99:[function(_dereq_,module,exports){ +},{"./_core":74,"./_export":82,"./_fails":83}],118:[function(_dereq_,module,exports){ module.exports = function(bitmap, value){ return { enumerable : !(bitmap & 1), @@ -5519,25 +5458,21 @@ module.exports = function(bitmap, value){ value : value }; }; -},{}],100:[function(_dereq_,module,exports){ -var redefine = _dereq_('./$.redefine'); -module.exports = function(target, src){ - for(var key in src)redefine(target, key, src[key]); - return target; -}; -},{"./$.redefine":101}],101:[function(_dereq_,module,exports){ -module.exports = _dereq_('./$.hide'); -},{"./$.hide":80}],102:[function(_dereq_,module,exports){ -// 7.2.9 SameValue(x, y) -module.exports = Object.is || function is(x, y){ - return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y; -}; -},{}],103:[function(_dereq_,module,exports){ +},{}],119:[function(_dereq_,module,exports){ +var hide = _dereq_('./_hide'); +module.exports = 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; +}; +},{"./_hide":87}],120:[function(_dereq_,module,exports){ +module.exports = _dereq_('./_hide'); +},{"./_hide":87}],121:[function(_dereq_,module,exports){ // Works with __proto__ only. Old v8 can't work with null proto objects. /* eslint-disable no-proto */ -var getDesc = _dereq_('./$').getDesc - , isObject = _dereq_('./$.is-object') - , anObject = _dereq_('./$.an-object'); +var isObject = _dereq_('./_is-object') + , anObject = _dereq_('./_an-object'); var check = function(O, proto){ anObject(O); if(!isObject(proto) && proto !== null)throw TypeError(proto + ": can't set as prototype!"); @@ -5546,7 +5481,7 @@ module.exports = { set: Object.setPrototypeOf || ('__proto__' in {} ? // eslint-disable-line function(test, buggy, set){ try { - set = _dereq_('./$.ctx')(Function.call, getDesc(Object.prototype, '__proto__').set, 2); + set = _dereq_('./_ctx')(Function.call, _dereq_('./_object-gopd').f(Object.prototype, '__proto__').set, 2); set(test, []); buggy = !(test instanceof Array); } catch(e){ buggy = true; } @@ -5559,52 +5494,54 @@ module.exports = { }({}, false) : undefined), check: check }; -},{"./$":93,"./$.an-object":62,"./$.ctx":69,"./$.is-object":86}],104:[function(_dereq_,module,exports){ +},{"./_an-object":63,"./_ctx":76,"./_is-object":94,"./_object-gopd":109}],122:[function(_dereq_,module,exports){ 'use strict'; -var core = _dereq_('./$.core') - , $ = _dereq_('./$') - , DESCRIPTORS = _dereq_('./$.descriptors') - , SPECIES = _dereq_('./$.wks')('species'); +var global = _dereq_('./_global') + , core = _dereq_('./_core') + , dP = _dereq_('./_object-dp') + , DESCRIPTORS = _dereq_('./_descriptors') + , SPECIES = _dereq_('./_wks')('species'); module.exports = function(KEY){ - var C = core[KEY]; - if(DESCRIPTORS && C && !C[SPECIES])$.setDesc(C, SPECIES, { + var C = typeof core[KEY] == 'function' ? core[KEY] : global[KEY]; + if(DESCRIPTORS && C && !C[SPECIES])dP.f(C, SPECIES, { configurable: true, get: function(){ return this; } }); }; -},{"./$":93,"./$.core":68,"./$.descriptors":71,"./$.wks":116}],105:[function(_dereq_,module,exports){ -var def = _dereq_('./$').setDesc - , has = _dereq_('./$.has') - , TAG = _dereq_('./$.wks')('toStringTag'); +},{"./_core":74,"./_descriptors":78,"./_global":85,"./_object-dp":107,"./_wks":138}],123:[function(_dereq_,module,exports){ +var def = _dereq_('./_object-dp').f + , has = _dereq_('./_has') + , TAG = _dereq_('./_wks')('toStringTag'); module.exports = function(it, tag, stat){ if(it && !has(it = stat ? it : it.prototype, TAG))def(it, TAG, {configurable: true, value: tag}); }; -},{"./$":93,"./$.has":79,"./$.wks":116}],106:[function(_dereq_,module,exports){ -var global = _dereq_('./$.global') +},{"./_has":86,"./_object-dp":107,"./_wks":138}],124:[function(_dereq_,module,exports){ +var shared = _dereq_('./_shared')('keys') + , uid = _dereq_('./_uid'); +module.exports = function(key){ + return shared[key] || (shared[key] = uid(key)); +}; +},{"./_shared":125,"./_uid":135}],125:[function(_dereq_,module,exports){ +var global = _dereq_('./_global') , SHARED = '__core-js_shared__' , store = global[SHARED] || (global[SHARED] = {}); module.exports = function(key){ return store[key] || (store[key] = {}); }; -},{"./$.global":78}],107:[function(_dereq_,module,exports){ +},{"./_global":85}],126:[function(_dereq_,module,exports){ // 7.3.20 SpeciesConstructor(O, defaultConstructor) -var anObject = _dereq_('./$.an-object') - , aFunction = _dereq_('./$.a-function') - , SPECIES = _dereq_('./$.wks')('species'); +var anObject = _dereq_('./_an-object') + , aFunction = _dereq_('./_a-function') + , SPECIES = _dereq_('./_wks')('species'); module.exports = function(O, D){ var C = anObject(O).constructor, S; return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S); }; -},{"./$.a-function":60,"./$.an-object":62,"./$.wks":116}],108:[function(_dereq_,module,exports){ -module.exports = function(it, Constructor, name){ - if(!(it instanceof Constructor))throw TypeError(name + ": use the 'new' operator!"); - return it; -}; -},{}],109:[function(_dereq_,module,exports){ -var toInteger = _dereq_('./$.to-integer') - , defined = _dereq_('./$.defined'); +},{"./_a-function":60,"./_an-object":63,"./_wks":138}],127:[function(_dereq_,module,exports){ +var toInteger = _dereq_('./_to-integer') + , defined = _dereq_('./_defined'); // true -> String#at // false -> String#codePointAt module.exports = function(TO_STRING){ @@ -5620,12 +5557,12 @@ module.exports = function(TO_STRING){ : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000; }; }; -},{"./$.defined":70,"./$.to-integer":111}],110:[function(_dereq_,module,exports){ -var ctx = _dereq_('./$.ctx') - , invoke = _dereq_('./$.invoke') - , html = _dereq_('./$.html') - , cel = _dereq_('./$.dom-create') - , global = _dereq_('./$.global') +},{"./_defined":77,"./_to-integer":130}],128:[function(_dereq_,module,exports){ +var ctx = _dereq_('./_ctx') + , invoke = _dereq_('./_invoke') + , html = _dereq_('./_html') + , cel = _dereq_('./_dom-create') + , global = _dereq_('./_global') , process = global.process , setTask = global.setImmediate , clearTask = global.clearImmediate @@ -5642,7 +5579,7 @@ var run = function(){ fn(); } }; -var listner = function(event){ +var listener = function(event){ run.call(event.data); }; // Node.js 0.9+ & IE10+ has setImmediate, otherwise: @@ -5660,7 +5597,7 @@ if(!setTask || !clearTask){ delete queue[id]; }; // Node.js 0.8- - if(_dereq_('./$.cof')(process) == 'process'){ + if(_dereq_('./_cof')(process) == 'process'){ defer = function(id){ process.nextTick(ctx(run, id, 1)); }; @@ -5668,7 +5605,7 @@ if(!setTask || !clearTask){ } else if(MessageChannel){ channel = new MessageChannel; port = channel.port2; - channel.port1.onmessage = listner; + channel.port1.onmessage = listener; defer = ctx(port.postMessage, port, 1); // Browsers with postMessage, skip WebWorkers // IE8 has postMessage, but it's sync & typeof its postMessage is 'object' @@ -5676,7 +5613,7 @@ if(!setTask || !clearTask){ defer = function(id){ global.postMessage(id + '', '*'); }; - global.addEventListener('message', listner, false); + global.addEventListener('message', listener, false); // IE8- } else if(ONREADYSTATECHANGE in cel('script')){ defer = function(id){ @@ -5696,105 +5633,143 @@ module.exports = { set: setTask, clear: clearTask }; -},{"./$.cof":64,"./$.ctx":69,"./$.dom-create":72,"./$.global":78,"./$.html":81,"./$.invoke":82}],111:[function(_dereq_,module,exports){ +},{"./_cof":70,"./_ctx":76,"./_dom-create":79,"./_global":85,"./_html":88,"./_invoke":90}],129:[function(_dereq_,module,exports){ +var toInteger = _dereq_('./_to-integer') + , max = Math.max + , min = Math.min; +module.exports = function(index, length){ + index = toInteger(index); + return index < 0 ? max(index + length, 0) : min(index, length); +}; +},{"./_to-integer":130}],130:[function(_dereq_,module,exports){ // 7.1.4 ToInteger var ceil = Math.ceil , floor = Math.floor; module.exports = function(it){ return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it); }; -},{}],112:[function(_dereq_,module,exports){ +},{}],131:[function(_dereq_,module,exports){ // to indexed object, toObject with fallback for non-array-like ES3 strings -var IObject = _dereq_('./$.iobject') - , defined = _dereq_('./$.defined'); +var IObject = _dereq_('./_iobject') + , defined = _dereq_('./_defined'); module.exports = function(it){ return IObject(defined(it)); }; -},{"./$.defined":70,"./$.iobject":83}],113:[function(_dereq_,module,exports){ +},{"./_defined":77,"./_iobject":91}],132:[function(_dereq_,module,exports){ // 7.1.15 ToLength -var toInteger = _dereq_('./$.to-integer') +var toInteger = _dereq_('./_to-integer') , min = Math.min; module.exports = function(it){ return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 }; -},{"./$.to-integer":111}],114:[function(_dereq_,module,exports){ +},{"./_to-integer":130}],133:[function(_dereq_,module,exports){ // 7.1.13 ToObject(argument) -var defined = _dereq_('./$.defined'); +var defined = _dereq_('./_defined'); module.exports = function(it){ return Object(defined(it)); }; -},{"./$.defined":70}],115:[function(_dereq_,module,exports){ +},{"./_defined":77}],134:[function(_dereq_,module,exports){ +// 7.1.1 ToPrimitive(input [, PreferredType]) +var isObject = _dereq_('./_is-object'); +// instead of the ES6 spec version, we didn't implement @@toPrimitive case +// and the second argument - flag - preferred type is a string +module.exports = 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"); +}; +},{"./_is-object":94}],135:[function(_dereq_,module,exports){ var id = 0 , px = Math.random(); module.exports = function(key){ return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36)); }; -},{}],116:[function(_dereq_,module,exports){ -var store = _dereq_('./$.shared')('wks') - , uid = _dereq_('./$.uid') - , Symbol = _dereq_('./$.global').Symbol; +},{}],136:[function(_dereq_,module,exports){ +var global = _dereq_('./_global') + , core = _dereq_('./_core') + , LIBRARY = _dereq_('./_library') + , wksExt = _dereq_('./_wks-ext') + , defineProperty = _dereq_('./_object-dp').f; module.exports = 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)}); +}; +},{"./_core":74,"./_global":85,"./_library":102,"./_object-dp":107,"./_wks-ext":137}],137:[function(_dereq_,module,exports){ +exports.f = _dereq_('./_wks'); +},{"./_wks":138}],138:[function(_dereq_,module,exports){ +var store = _dereq_('./_shared')('wks') + , uid = _dereq_('./_uid') + , Symbol = _dereq_('./_global').Symbol + , USE_SYMBOL = typeof Symbol == 'function'; + +var $exports = module.exports = function(name){ return store[name] || (store[name] = - Symbol && Symbol[name] || (Symbol || uid)('Symbol.' + name)); + USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name)); }; -},{"./$.global":78,"./$.shared":106,"./$.uid":115}],117:[function(_dereq_,module,exports){ -var classof = _dereq_('./$.classof') - , ITERATOR = _dereq_('./$.wks')('iterator') - , Iterators = _dereq_('./$.iterators'); -module.exports = _dereq_('./$.core').getIteratorMethod = function(it){ + +$exports.store = store; +},{"./_global":85,"./_shared":125,"./_uid":135}],139:[function(_dereq_,module,exports){ +var classof = _dereq_('./_classof') + , ITERATOR = _dereq_('./_wks')('iterator') + , Iterators = _dereq_('./_iterators'); +module.exports = _dereq_('./_core').getIteratorMethod = function(it){ if(it != undefined)return it[ITERATOR] || it['@@iterator'] || Iterators[classof(it)]; }; -},{"./$.classof":63,"./$.core":68,"./$.iterators":92,"./$.wks":116}],118:[function(_dereq_,module,exports){ -var anObject = _dereq_('./$.an-object') +},{"./_classof":69,"./_core":74,"./_iterators":100,"./_wks":138}],140:[function(_dereq_,module,exports){ +var anObject = _dereq_('./_an-object') , get = _dereq_('./core.get-iterator-method'); -module.exports = _dereq_('./$.core').getIterator = function(it){ +module.exports = _dereq_('./_core').getIterator = function(it){ var iterFn = get(it); if(typeof iterFn != 'function')throw TypeError(it + ' is not iterable!'); return anObject(iterFn.call(it)); }; -},{"./$.an-object":62,"./$.core":68,"./core.get-iterator-method":117}],119:[function(_dereq_,module,exports){ -var classof = _dereq_('./$.classof') - , ITERATOR = _dereq_('./$.wks')('iterator') - , Iterators = _dereq_('./$.iterators'); -module.exports = _dereq_('./$.core').isIterable = function(it){ +},{"./_an-object":63,"./_core":74,"./core.get-iterator-method":139}],141:[function(_dereq_,module,exports){ +var classof = _dereq_('./_classof') + , ITERATOR = _dereq_('./_wks')('iterator') + , Iterators = _dereq_('./_iterators'); +module.exports = _dereq_('./_core').isIterable = function(it){ var O = Object(it); return O[ITERATOR] !== undefined || '@@iterator' in O || Iterators.hasOwnProperty(classof(O)); }; -},{"./$.classof":63,"./$.core":68,"./$.iterators":92,"./$.wks":116}],120:[function(_dereq_,module,exports){ +},{"./_classof":69,"./_core":74,"./_iterators":100,"./_wks":138}],142:[function(_dereq_,module,exports){ 'use strict'; -var ctx = _dereq_('./$.ctx') - , $export = _dereq_('./$.export') - , toObject = _dereq_('./$.to-object') - , call = _dereq_('./$.iter-call') - , isArrayIter = _dereq_('./$.is-array-iter') - , toLength = _dereq_('./$.to-length') - , getIterFn = _dereq_('./core.get-iterator-method'); -$export($export.S + $export.F * !_dereq_('./$.iter-detect')(function(iter){ Array.from(iter); }), 'Array', { +var ctx = _dereq_('./_ctx') + , $export = _dereq_('./_export') + , toObject = _dereq_('./_to-object') + , call = _dereq_('./_iter-call') + , isArrayIter = _dereq_('./_is-array-iter') + , toLength = _dereq_('./_to-length') + , createProperty = _dereq_('./_create-property') + , getIterFn = _dereq_('./core.get-iterator-method'); + +$export($export.S + $export.F * !_dereq_('./_iter-detect')(function(iter){ Array.from(iter); }), 'Array', { // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined) from: function from(arrayLike/*, mapfn = undefined, thisArg = undefined*/){ var O = toObject(arrayLike) , C = typeof this == 'function' ? this : Array - , $$ = arguments - , $$len = $$.length - , mapfn = $$len > 1 ? $$[1] : undefined + , aLen = arguments.length + , mapfn = aLen > 1 ? arguments[1] : undefined , mapping = mapfn !== undefined , index = 0 , iterFn = getIterFn(O) , length, result, step, iterator; - if(mapping)mapfn = ctx(mapfn, $$len > 2 ? $$[2] : undefined, 2); + if(mapping)mapfn = ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2); // if object isn't iterable or it's array with default iterator - use simple case if(iterFn != undefined && !(C == Array && isArrayIter(iterFn))){ for(iterator = iterFn.call(O), result = new C; !(step = iterator.next()).done; index++){ - result[index] = mapping ? call(iterator, mapfn, [step.value, index], true) : step.value; + createProperty(result, index, mapping ? call(iterator, mapfn, [step.value, index], true) : step.value); } } else { length = toLength(O.length); for(result = new C(length); length > index; index++){ - result[index] = mapping ? mapfn(O[index], index) : O[index]; + createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]); } } result.length = index; @@ -5802,18 +5777,18 @@ $export($export.S + $export.F * !_dereq_('./$.iter-detect')(function(iter){ Arra } }); -},{"./$.ctx":69,"./$.export":74,"./$.is-array-iter":84,"./$.iter-call":87,"./$.iter-detect":90,"./$.to-length":113,"./$.to-object":114,"./core.get-iterator-method":117}],121:[function(_dereq_,module,exports){ +},{"./_create-property":75,"./_ctx":76,"./_export":82,"./_is-array-iter":92,"./_iter-call":95,"./_iter-detect":98,"./_to-length":132,"./_to-object":133,"./core.get-iterator-method":139}],143:[function(_dereq_,module,exports){ 'use strict'; -var addToUnscopables = _dereq_('./$.add-to-unscopables') - , step = _dereq_('./$.iter-step') - , Iterators = _dereq_('./$.iterators') - , toIObject = _dereq_('./$.to-iobject'); +var addToUnscopables = _dereq_('./_add-to-unscopables') + , step = _dereq_('./_iter-step') + , Iterators = _dereq_('./_iterators') + , toIObject = _dereq_('./_to-iobject'); // 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]() -module.exports = _dereq_('./$.iter-define')(Array, 'Array', function(iterated, kind){ +module.exports = _dereq_('./_iter-define')(Array, 'Array', function(iterated, kind){ this._t = toIObject(iterated); // target this._i = 0; // next index this._k = kind; // kind @@ -5837,12 +5812,12 @@ Iterators.Arguments = Iterators.Array; addToUnscopables('keys'); addToUnscopables('values'); addToUnscopables('entries'); -},{"./$.add-to-unscopables":61,"./$.iter-define":89,"./$.iter-step":91,"./$.iterators":92,"./$.to-iobject":112}],122:[function(_dereq_,module,exports){ +},{"./_add-to-unscopables":61,"./_iter-define":97,"./_iter-step":99,"./_iterators":100,"./_to-iobject":131}],144:[function(_dereq_,module,exports){ 'use strict'; -var strong = _dereq_('./$.collection-strong'); +var strong = _dereq_('./_collection-strong'); // 23.1 Map Objects -_dereq_('./$.collection')('Map', function(get){ +module.exports = _dereq_('./_collection')('Map', function(get){ return function Map(){ return get(this, arguments.length > 0 ? arguments[0] : undefined); }; }, { // 23.1.3.6 Map.prototype.get(key) @@ -5855,133 +5830,130 @@ _dereq_('./$.collection')('Map', function(get){ return strong.def(this, key === 0 ? 0 : key, value); } }, strong, true); -},{"./$.collection":67,"./$.collection-strong":65}],123:[function(_dereq_,module,exports){ +},{"./_collection":73,"./_collection-strong":71}],145:[function(_dereq_,module,exports){ // 20.2.2.22 Math.log2(x) -var $export = _dereq_('./$.export'); +var $export = _dereq_('./_export'); $export($export.S, 'Math', { log2: function log2(x){ return Math.log(x) / Math.LN2; } }); -},{"./$.export":74}],124:[function(_dereq_,module,exports){ +},{"./_export":82}],146:[function(_dereq_,module,exports){ // 19.1.3.1 Object.assign(target, source) -var $export = _dereq_('./$.export'); - -$export($export.S + $export.F, 'Object', {assign: _dereq_('./$.object-assign')}); -},{"./$.export":74,"./$.object-assign":97}],125:[function(_dereq_,module,exports){ +var $export = _dereq_('./_export'); + +$export($export.S + $export.F, 'Object', {assign: _dereq_('./_object-assign')}); +},{"./_export":82,"./_object-assign":105}],147:[function(_dereq_,module,exports){ +var $export = _dereq_('./_export') +// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) +$export($export.S, 'Object', {create: _dereq_('./_object-create')}); +},{"./_export":82,"./_object-create":106}],148:[function(_dereq_,module,exports){ +var $export = _dereq_('./_export'); +// 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes) +$export($export.S + $export.F * !_dereq_('./_descriptors'), 'Object', {defineProperty: _dereq_('./_object-dp').f}); +},{"./_descriptors":78,"./_export":82,"./_object-dp":107}],149:[function(_dereq_,module,exports){ // 19.1.2.5 Object.freeze(O) -var isObject = _dereq_('./$.is-object'); +var isObject = _dereq_('./_is-object') + , meta = _dereq_('./_meta').onFreeze; -_dereq_('./$.object-sap')('freeze', function($freeze){ +_dereq_('./_object-sap')('freeze', function($freeze){ return function freeze(it){ - return $freeze && isObject(it) ? $freeze(it) : it; + return $freeze && isObject(it) ? $freeze(meta(it)) : it; }; }); -},{"./$.is-object":86,"./$.object-sap":98}],126:[function(_dereq_,module,exports){ +},{"./_is-object":94,"./_meta":103,"./_object-sap":117}],150:[function(_dereq_,module,exports){ // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P) -var toIObject = _dereq_('./$.to-iobject'); +var toIObject = _dereq_('./_to-iobject') + , $getOwnPropertyDescriptor = _dereq_('./_object-gopd').f; -_dereq_('./$.object-sap')('getOwnPropertyDescriptor', function($getOwnPropertyDescriptor){ +_dereq_('./_object-sap')('getOwnPropertyDescriptor', function(){ return function getOwnPropertyDescriptor(it, key){ return $getOwnPropertyDescriptor(toIObject(it), key); }; }); -},{"./$.object-sap":98,"./$.to-iobject":112}],127:[function(_dereq_,module,exports){ +},{"./_object-gopd":109,"./_object-sap":117,"./_to-iobject":131}],151:[function(_dereq_,module,exports){ +// 19.1.2.9 Object.getPrototypeOf(O) +var toObject = _dereq_('./_to-object') + , $getPrototypeOf = _dereq_('./_object-gpo'); + +_dereq_('./_object-sap')('getPrototypeOf', function(){ + return function getPrototypeOf(it){ + return $getPrototypeOf(toObject(it)); + }; +}); +},{"./_object-gpo":113,"./_object-sap":117,"./_to-object":133}],152:[function(_dereq_,module,exports){ // 19.1.2.14 Object.keys(O) -var toObject = _dereq_('./$.to-object'); +var toObject = _dereq_('./_to-object') + , $keys = _dereq_('./_object-keys'); -_dereq_('./$.object-sap')('keys', function($keys){ +_dereq_('./_object-sap')('keys', function(){ return function keys(it){ return $keys(toObject(it)); }; }); -},{"./$.object-sap":98,"./$.to-object":114}],128:[function(_dereq_,module,exports){ +},{"./_object-keys":115,"./_object-sap":117,"./_to-object":133}],153:[function(_dereq_,module,exports){ // 19.1.3.19 Object.setPrototypeOf(O, proto) -var $export = _dereq_('./$.export'); -$export($export.S, 'Object', {setPrototypeOf: _dereq_('./$.set-proto').set}); -},{"./$.export":74,"./$.set-proto":103}],129:[function(_dereq_,module,exports){ +var $export = _dereq_('./_export'); +$export($export.S, 'Object', {setPrototypeOf: _dereq_('./_set-proto').set}); +},{"./_export":82,"./_set-proto":121}],154:[function(_dereq_,module,exports){ arguments[4][40][0].apply(exports,arguments) -},{"dup":40}],130:[function(_dereq_,module,exports){ +},{"dup":40}],155:[function(_dereq_,module,exports){ 'use strict'; -var $ = _dereq_('./$') - , LIBRARY = _dereq_('./$.library') - , global = _dereq_('./$.global') - , ctx = _dereq_('./$.ctx') - , classof = _dereq_('./$.classof') - , $export = _dereq_('./$.export') - , isObject = _dereq_('./$.is-object') - , anObject = _dereq_('./$.an-object') - , aFunction = _dereq_('./$.a-function') - , strictNew = _dereq_('./$.strict-new') - , forOf = _dereq_('./$.for-of') - , setProto = _dereq_('./$.set-proto').set - , same = _dereq_('./$.same-value') - , SPECIES = _dereq_('./$.wks')('species') - , speciesConstructor = _dereq_('./$.species-constructor') - , asap = _dereq_('./$.microtask') - , PROMISE = 'Promise' - , process = global.process - , isNode = classof(process) == 'process' - , P = global[PROMISE] - , Wrapper; - -var testResolve = function(sub){ - var test = new P(function(){}); - if(sub)test.constructor = Object; - return P.resolve(test) === test; -}; - -var USE_NATIVE = function(){ - var works = false; - function P2(x){ - var self = new P(x); - setProto(self, P2.prototype); - return self; - } +var LIBRARY = _dereq_('./_library') + , global = _dereq_('./_global') + , ctx = _dereq_('./_ctx') + , classof = _dereq_('./_classof') + , $export = _dereq_('./_export') + , isObject = _dereq_('./_is-object') + , aFunction = _dereq_('./_a-function') + , anInstance = _dereq_('./_an-instance') + , forOf = _dereq_('./_for-of') + , speciesConstructor = _dereq_('./_species-constructor') + , task = _dereq_('./_task').set + , microtask = _dereq_('./_microtask')() + , PROMISE = 'Promise' + , TypeError = global.TypeError + , process = global.process + , $Promise = global[PROMISE] + , process = global.process + , isNode = classof(process) == 'process' + , empty = function(){ /* empty */ } + , Internal, GenericPromiseCapability, Wrapper; + +var USE_NATIVE = !!function(){ try { - works = P && P.resolve && testResolve(); - setProto(P2, P); - P2.prototype = $.create(P.prototype, {constructor: {value: P2}}); - // actual Firefox has broken subclass support, test that - if(!(P2.resolve(5).then(function(){}) instanceof P2)){ - works = false; - } - // actual V8 bug, https://code.google.com/p/v8/issues/detail?id=4162 - if(works && _dereq_('./$.descriptors')){ - var thenableThenGotten = false; - P.resolve($.setDesc({}, 'then', { - get: function(){ thenableThenGotten = true; } - })); - works = thenableThenGotten; - } - } catch(e){ works = false; } - return works; + // correct subclassing with @@species support + var promise = $Promise.resolve(1) + , FakePromise = (promise.constructor = {})[_dereq_('./_wks')('species')] = function(exec){ exec(empty, empty); }; + // unhandled rejections tracking support, NodeJS Promise without it fails @@species test + return (isNode || typeof PromiseRejectionEvent == 'function') && promise.then(empty) instanceof FakePromise; + } catch(e){ /* empty */ } }(); // helpers var sameConstructor = function(a, b){ - // library wrapper special case - if(LIBRARY && a === P && b === Wrapper)return true; - return same(a, b); -}; -var getConstructor = function(C){ - var S = anObject(C)[SPECIES]; - return S != undefined ? S : C; + // with library wrapper special case + return a === b || a === $Promise && b === Wrapper; }; var isThenable = function(it){ var then; return isObject(it) && typeof (then = it.then) == 'function' ? then : false; }; -var PromiseCapability = function(C){ +var newPromiseCapability = function(C){ + return sameConstructor($Promise, C) + ? new PromiseCapability(C) + : new GenericPromiseCapability(C); +}; +var PromiseCapability = GenericPromiseCapability = function(C){ var resolve, reject; this.promise = new C(function($$resolve, $$reject){ if(resolve !== undefined || reject !== undefined)throw TypeError('Bad Promise constructor'); resolve = $$resolve; reject = $$reject; }); - this.resolve = aFunction(resolve), - this.reject = aFunction(reject) + this.resolve = aFunction(resolve); + this.reject = aFunction(reject); }; var perform = function(exec){ try { @@ -5990,23 +5962,32 @@ var perform = function(exec){ return {error: e}; } }; -var notify = function(record, isReject){ - if(record.n)return; - record.n = true; - var chain = record.c; - asap(function(){ - var value = record.v - , ok = record.s == 1 +var notify = function(promise, isReject){ + if(promise._n)return; + promise._n = true; + var chain = promise._c; + microtask(function(){ + var value = promise._v + , ok = promise._s == 1 , i = 0; var run = function(reaction){ var handler = ok ? reaction.ok : reaction.fail , resolve = reaction.resolve , reject = reaction.reject + , domain = reaction.domain , result, then; try { if(handler){ - if(!ok)record.h = true; - result = handler === true ? value : handler(value); + if(!ok){ + if(promise._h == 2)onHandleUnhandled(promise); + promise._h = 1; + } + if(handler === true)result = value; + else { + if(domain)domain.enter(); + result = handler(value); + if(domain)domain.exit(); + } if(result === reaction.promise){ reject(TypeError('Promise-chain cycle')); } else if(then = isThenable(result)){ @@ -6018,12 +5999,17 @@ var notify = function(record, isReject){ } }; while(chain.length > i)run(chain[i++]); // variable length - can't use forEach - chain.length = 0; - record.n = false; - if(isReject)setTimeout(function(){ - var promise = record.p - , handler, console; - if(isUnhandled(promise)){ + promise._c = []; + promise._n = false; + if(isReject && !promise._h)onUnhandled(promise); + }); +}; +var onUnhandled = function(promise){ + task.call(global, function(){ + var value = promise._v + , abrupt, handler, console; + if(isUnhandled(promise)){ + abrupt = perform(function(){ if(isNode){ process.emit('unhandledRejection', value, promise); } else if(handler = global.onunhandledrejection){ @@ -6031,42 +6017,54 @@ var notify = function(record, isReject){ } else if((console = global.console) && console.error){ console.error('Unhandled promise rejection', value); } - } record.a = undefined; - }, 1); + }); + // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should + promise._h = isNode || isUnhandled(promise) ? 2 : 1; + } promise._a = undefined; + if(abrupt)throw abrupt.error; }); }; var isUnhandled = function(promise){ - var record = promise._d - , chain = record.a || record.c - , i = 0 + if(promise._h == 1)return false; + var chain = promise._a || promise._c + , i = 0 , reaction; - if(record.h)return false; while(chain.length > i){ reaction = chain[i++]; if(reaction.fail || !isUnhandled(reaction.promise))return false; } return true; }; +var onHandleUnhandled = function(promise){ + task.call(global, function(){ + var handler; + if(isNode){ + process.emit('rejectionHandled', promise); + } else if(handler = global.onrejectionhandled){ + handler({promise: promise, reason: promise._v}); + } + }); +}; var $reject = function(value){ - var record = this; - if(record.d)return; - record.d = true; - record = record.r || record; // unwrap - record.v = value; - record.s = 2; - record.a = record.c.slice(); - notify(record, true); + var promise = this; + if(promise._d)return; + promise._d = true; + promise = promise._w || promise; // unwrap + promise._v = value; + promise._s = 2; + if(!promise._a)promise._a = promise._c.slice(); + notify(promise, true); }; var $resolve = function(value){ - var record = this + var promise = this , then; - if(record.d)return; - record.d = true; - record = record.r || record; // unwrap + if(promise._d)return; + promise._d = true; + promise = promise._w || promise; // unwrap try { - if(record.p === value)throw TypeError("Promise can't be resolved itself"); + if(promise === value)throw TypeError("Promise can't be resolved itself"); if(then = isThenable(value)){ - asap(function(){ - var wrapper = {r: record, d: false}; // wrap + microtask(function(){ + var wrapper = {_w: promise, _d: false}; // wrap try { then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1)); } catch(e){ @@ -6074,114 +6072,122 @@ var $resolve = function(value){ } }); } else { - record.v = value; - record.s = 1; - notify(record, false); + promise._v = value; + promise._s = 1; + notify(promise, false); } } catch(e){ - $reject.call({r: record, d: false}, e); // wrap + $reject.call({_w: promise, _d: false}, e); // wrap } }; // constructor polyfill if(!USE_NATIVE){ // 25.4.3.1 Promise(executor) - P = function Promise(executor){ + $Promise = function Promise(executor){ + anInstance(this, $Promise, PROMISE, '_h'); aFunction(executor); - var record = this._d = { - p: strictNew(this, P, PROMISE), // <- promise - c: [], // <- awaiting reactions - a: undefined, // <- checked in isUnhandled reactions - s: 0, // <- state - d: false, // <- done - v: undefined, // <- value - h: false, // <- handled rejection - n: false // <- notify - }; + Internal.call(this); try { - executor(ctx($resolve, record, 1), ctx($reject, record, 1)); + executor(ctx($resolve, this, 1), ctx($reject, this, 1)); } catch(err){ - $reject.call(record, err); + $reject.call(this, err); } }; - _dereq_('./$.redefine-all')(P.prototype, { + Internal = function Promise(executor){ + this._c = []; // <- awaiting reactions + this._a = undefined; // <- checked in isUnhandled reactions + this._s = 0; // <- state + this._d = false; // <- done + this._v = undefined; // <- value + this._h = 0; // <- rejection state, 0 - default, 1 - handled, 2 - unhandled + this._n = false; // <- notify + }; + Internal.prototype = _dereq_('./_redefine-all')($Promise.prototype, { // 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected) then: function then(onFulfilled, onRejected){ - var reaction = new PromiseCapability(speciesConstructor(this, P)) - , promise = reaction.promise - , record = this._d; - reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true; - reaction.fail = typeof onRejected == 'function' && onRejected; - record.c.push(reaction); - if(record.a)record.a.push(reaction); - if(record.s)notify(record, false); - return promise; + var reaction = newPromiseCapability(speciesConstructor(this, $Promise)); + reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true; + reaction.fail = typeof onRejected == 'function' && onRejected; + reaction.domain = isNode ? process.domain : undefined; + this._c.push(reaction); + if(this._a)this._a.push(reaction); + if(this._s)notify(this, false); + return reaction.promise; }, // 25.4.5.1 Promise.prototype.catch(onRejected) 'catch': function(onRejected){ return this.then(undefined, onRejected); } }); + PromiseCapability = function(){ + var promise = new Internal; + this.promise = promise; + this.resolve = ctx($resolve, promise, 1); + this.reject = ctx($reject, promise, 1); + }; } -$export($export.G + $export.W + $export.F * !USE_NATIVE, {Promise: P}); -_dereq_('./$.set-to-string-tag')(P, PROMISE); -_dereq_('./$.set-species')(PROMISE); -Wrapper = _dereq_('./$.core')[PROMISE]; +$export($export.G + $export.W + $export.F * !USE_NATIVE, {Promise: $Promise}); +_dereq_('./_set-to-string-tag')($Promise, PROMISE); +_dereq_('./_set-species')(PROMISE); +Wrapper = _dereq_('./_core')[PROMISE]; // statics $export($export.S + $export.F * !USE_NATIVE, PROMISE, { // 25.4.4.5 Promise.reject(r) reject: function reject(r){ - var capability = new PromiseCapability(this) + var capability = newPromiseCapability(this) , $$reject = capability.reject; $$reject(r); return capability.promise; } }); -$export($export.S + $export.F * (!USE_NATIVE || testResolve(true)), PROMISE, { +$export($export.S + $export.F * (LIBRARY || !USE_NATIVE), PROMISE, { // 25.4.4.6 Promise.resolve(x) resolve: function resolve(x){ // instanceof instead of internal slot check because we should fix it without replacement native Promise core - if(x instanceof P && sameConstructor(x.constructor, this))return x; - var capability = new PromiseCapability(this) + if(x instanceof $Promise && sameConstructor(x.constructor, this))return x; + var capability = newPromiseCapability(this) , $$resolve = capability.resolve; $$resolve(x); return capability.promise; } }); -$export($export.S + $export.F * !(USE_NATIVE && _dereq_('./$.iter-detect')(function(iter){ - P.all(iter)['catch'](function(){}); +$export($export.S + $export.F * !(USE_NATIVE && _dereq_('./_iter-detect')(function(iter){ + $Promise.all(iter)['catch'](empty); })), PROMISE, { // 25.4.4.1 Promise.all(iterable) all: function all(iterable){ - var C = getConstructor(this) - , capability = new PromiseCapability(C) + var C = this + , capability = newPromiseCapability(C) , resolve = capability.resolve - , reject = capability.reject - , values = []; + , reject = capability.reject; var abrupt = perform(function(){ - forOf(iterable, false, values.push, values); - var remaining = values.length - , results = Array(remaining); - if(remaining)$.each.call(values, function(promise, index){ - var alreadyCalled = false; + var values = [] + , index = 0 + , remaining = 1; + forOf(iterable, false, function(promise){ + var $index = index++ + , alreadyCalled = false; + values.push(undefined); + remaining++; C.resolve(promise).then(function(value){ if(alreadyCalled)return; - alreadyCalled = true; - results[index] = value; - --remaining || resolve(results); + alreadyCalled = true; + values[$index] = value; + --remaining || resolve(values); }, reject); }); - else resolve(results); + --remaining || resolve(values); }); if(abrupt)reject(abrupt.error); return capability.promise; }, // 25.4.4.4 Promise.race(iterable) race: function race(iterable){ - var C = getConstructor(this) - , capability = new PromiseCapability(C) + var C = this + , capability = newPromiseCapability(C) , reject = capability.reject; var abrupt = perform(function(){ forOf(iterable, false, function(promise){ @@ -6192,12 +6198,12 @@ $export($export.S + $export.F * !(USE_NATIVE && _dereq_('./$.iter-detect')(funct return capability.promise; } }); -},{"./$":93,"./$.a-function":60,"./$.an-object":62,"./$.classof":63,"./$.core":68,"./$.ctx":69,"./$.descriptors":71,"./$.export":74,"./$.for-of":76,"./$.global":78,"./$.is-object":86,"./$.iter-detect":90,"./$.library":95,"./$.microtask":96,"./$.redefine-all":100,"./$.same-value":102,"./$.set-proto":103,"./$.set-species":104,"./$.set-to-string-tag":105,"./$.species-constructor":107,"./$.strict-new":108,"./$.wks":116}],131:[function(_dereq_,module,exports){ +},{"./_a-function":60,"./_an-instance":62,"./_classof":69,"./_core":74,"./_ctx":76,"./_export":82,"./_for-of":84,"./_global":85,"./_is-object":94,"./_iter-detect":98,"./_library":102,"./_microtask":104,"./_redefine-all":119,"./_set-species":122,"./_set-to-string-tag":123,"./_species-constructor":126,"./_task":128,"./_wks":138}],156:[function(_dereq_,module,exports){ 'use strict'; -var strong = _dereq_('./$.collection-strong'); +var strong = _dereq_('./_collection-strong'); // 23.2 Set Objects -_dereq_('./$.collection')('Set', function(get){ +module.exports = _dereq_('./_collection')('Set', function(get){ return function Set(){ return get(this, arguments.length > 0 ? arguments[0] : undefined); }; }, { // 23.2.3.1 Set.prototype.add(value) @@ -6205,12 +6211,12 @@ _dereq_('./$.collection')('Set', function(get){ return strong.def(this, value = value === 0 ? 0 : value, value); } }, strong); -},{"./$.collection":67,"./$.collection-strong":65}],132:[function(_dereq_,module,exports){ +},{"./_collection":73,"./_collection-strong":71}],157:[function(_dereq_,module,exports){ 'use strict'; -var $at = _dereq_('./$.string-at')(true); +var $at = _dereq_('./_string-at')(true); // 21.1.3.27 String.prototype[@@iterator]() -_dereq_('./$.iter-define')(String, 'String', function(iterated){ +_dereq_('./_iter-define')(String, 'String', function(iterated){ this._t = String(iterated); // target this._i = 0; // next index // 21.1.5.2.1 %StringIteratorPrototype%.next() @@ -6223,81 +6229,91 @@ _dereq_('./$.iter-define')(String, 'String', function(iterated){ this._i += point.length; return {value: point, done: false}; }); -},{"./$.iter-define":89,"./$.string-at":109}],133:[function(_dereq_,module,exports){ +},{"./_iter-define":97,"./_string-at":127}],158:[function(_dereq_,module,exports){ 'use strict'; // ECMAScript 6 symbols shim -var $ = _dereq_('./$') - , global = _dereq_('./$.global') - , has = _dereq_('./$.has') - , DESCRIPTORS = _dereq_('./$.descriptors') - , $export = _dereq_('./$.export') - , redefine = _dereq_('./$.redefine') - , $fails = _dereq_('./$.fails') - , shared = _dereq_('./$.shared') - , setToStringTag = _dereq_('./$.set-to-string-tag') - , uid = _dereq_('./$.uid') - , wks = _dereq_('./$.wks') - , keyOf = _dereq_('./$.keyof') - , $names = _dereq_('./$.get-names') - , enumKeys = _dereq_('./$.enum-keys') - , isArray = _dereq_('./$.is-array') - , anObject = _dereq_('./$.an-object') - , toIObject = _dereq_('./$.to-iobject') - , createDesc = _dereq_('./$.property-desc') - , getDesc = $.getDesc - , setDesc = $.setDesc - , _create = $.create - , getNames = $names.get +var global = _dereq_('./_global') + , has = _dereq_('./_has') + , DESCRIPTORS = _dereq_('./_descriptors') + , $export = _dereq_('./_export') + , redefine = _dereq_('./_redefine') + , META = _dereq_('./_meta').KEY + , $fails = _dereq_('./_fails') + , shared = _dereq_('./_shared') + , setToStringTag = _dereq_('./_set-to-string-tag') + , uid = _dereq_('./_uid') + , wks = _dereq_('./_wks') + , wksExt = _dereq_('./_wks-ext') + , wksDefine = _dereq_('./_wks-define') + , keyOf = _dereq_('./_keyof') + , enumKeys = _dereq_('./_enum-keys') + , isArray = _dereq_('./_is-array') + , anObject = _dereq_('./_an-object') + , toIObject = _dereq_('./_to-iobject') + , toPrimitive = _dereq_('./_to-primitive') + , createDesc = _dereq_('./_property-desc') + , _create = _dereq_('./_object-create') + , gOPNExt = _dereq_('./_object-gopn-ext') + , $GOPD = _dereq_('./_object-gopd') + , $DP = _dereq_('./_object-dp') + , $keys = _dereq_('./_object-keys') + , gOPD = $GOPD.f + , dP = $DP.f + , gOPN = gOPNExt.f , $Symbol = global.Symbol , $JSON = global.JSON , _stringify = $JSON && $JSON.stringify - , setter = false + , PROTOTYPE = 'prototype' , HIDDEN = wks('_hidden') - , isEnum = $.isEnum + , TO_PRIMITIVE = wks('toPrimitive') + , isEnum = {}.propertyIsEnumerable , SymbolRegistry = shared('symbol-registry') , AllSymbols = shared('symbols') - , useNative = typeof $Symbol == 'function' - , ObjectProto = Object.prototype; + , OPSymbols = shared('op-symbols') + , ObjectProto = Object[PROTOTYPE] + , USE_NATIVE = typeof $Symbol == 'function' + , QObject = global.QObject; +// Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173 +var setter = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild; // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687 var setSymbolDesc = DESCRIPTORS && $fails(function(){ - return _create(setDesc({}, 'a', { - get: function(){ return setDesc(this, 'a', {value: 7}).a; } + return _create(dP({}, 'a', { + get: function(){ return dP(this, 'a', {value: 7}).a; } })).a != 7; }) ? function(it, key, D){ - var protoDesc = getDesc(ObjectProto, key); + var protoDesc = gOPD(ObjectProto, key); if(protoDesc)delete ObjectProto[key]; - setDesc(it, key, D); - if(protoDesc && it !== ObjectProto)setDesc(ObjectProto, key, protoDesc); -} : setDesc; + dP(it, key, D); + if(protoDesc && it !== ObjectProto)dP(ObjectProto, key, protoDesc); +} : dP; var wrap = function(tag){ - var sym = AllSymbols[tag] = _create($Symbol.prototype); + var sym = AllSymbols[tag] = _create($Symbol[PROTOTYPE]); sym._k = tag; - DESCRIPTORS && setter && setSymbolDesc(ObjectProto, tag, { - configurable: true, - set: function(value){ - if(has(this, HIDDEN) && has(this[HIDDEN], tag))this[HIDDEN][tag] = false; - setSymbolDesc(this, tag, createDesc(1, value)); - } - }); return sym; }; -var isSymbol = function(it){ +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(D && has(AllSymbols, key)){ + if(it === ObjectProto)$defineProperty(OPSymbols, key, D); + anObject(it); + key = toPrimitive(key, true); + anObject(D); + if(has(AllSymbols, key)){ if(!D.enumerable){ - if(!has(it, HIDDEN))setDesc(it, HIDDEN, createDesc(1, {})); + if(!has(it, HIDDEN))dP(it, HIDDEN, createDesc(1, {})); it[HIDDEN][key] = true; } else { if(has(it, HIDDEN) && it[HIDDEN][key])it[HIDDEN][key] = false; D = _create(D, {enumerable: createDesc(0, false)}); } return setSymbolDesc(it, key, D); - } return setDesc(it, key, D); + } return dP(it, key, D); }; var $defineProperties = function defineProperties(it, P){ anObject(it); @@ -6312,83 +6328,80 @@ var $create = function create(it, P){ return P === undefined ? _create(it) : $defineProperties(_create(it), P); }; var $propertyIsEnumerable = function propertyIsEnumerable(key){ - var E = isEnum.call(this, key); - return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key] - ? E : true; + var E = isEnum.call(this, key = toPrimitive(key, true)); + if(this === ObjectProto && 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){ - var D = getDesc(it = toIObject(it), key); + it = toIObject(it); + key = toPrimitive(key, true); + if(it === ObjectProto && 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 = getNames(toIObject(it)) + var names = gOPN(toIObject(it)) , result = [] , i = 0 , key; - while(names.length > i)if(!has(AllSymbols, key = names[i++]) && key != HIDDEN)result.push(key); - return result; + 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 names = getNames(toIObject(it)) + var IS_OP = it === ObjectProto + , names = gOPN(IS_OP ? OPSymbols : toIObject(it)) , result = [] , i = 0 , key; - while(names.length > i)if(has(AllSymbols, key = names[i++]))result.push(AllSymbols[key]); - return result; + while(names.length > i){ + if(has(AllSymbols, key = names[i++]) && (IS_OP ? has(ObjectProto, key) : true))result.push(AllSymbols[key]); + } return result; }; -var $stringify = function stringify(it){ - if(it === undefined || isSymbol(it))return; // IE8 returns string on undefined - var args = [it] - , i = 1 - , $$ = arguments - , replacer, $replacer; - while($$.length > i)args.push($$[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); -}; -var buggyJSON = $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)) != '{}'; -}); // 19.4.1.1 Symbol([description]) -if(!useNative){ +if(!USE_NATIVE){ $Symbol = function Symbol(){ - if(isSymbol(this))throw TypeError('Symbol is not a constructor'); - return wrap(uid(arguments.length > 0 ? arguments[0] : undefined)); + 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)$set.call(OPSymbols, value); + if(has(this, HIDDEN) && has(this[HIDDEN], tag))this[HIDDEN][tag] = false; + setSymbolDesc(this, tag, createDesc(1, value)); + }; + if(DESCRIPTORS && setter)setSymbolDesc(ObjectProto, tag, {configurable: true, set: $set}); + return wrap(tag); }; - redefine($Symbol.prototype, 'toString', function toString(){ + redefine($Symbol[PROTOTYPE], 'toString', function toString(){ return this._k; }); - isSymbol = function(it){ - return it instanceof $Symbol; - }; - - $.create = $create; - $.isEnum = $propertyIsEnumerable; - $.getDesc = $getOwnPropertyDescriptor; - $.setDesc = $defineProperty; - $.setDescs = $defineProperties; - $.getNames = $names.get = $getOwnPropertyNames; - $.getSymbols = $getOwnPropertySymbols; + $GOPD.f = $getOwnPropertyDescriptor; + $DP.f = $defineProperty; + _dereq_('./_object-gopn').f = gOPNExt.f = $getOwnPropertyNames; + _dereq_('./_object-pie').f = $propertyIsEnumerable; + _dereq_('./_object-gops').f = $getOwnPropertySymbols; - if(DESCRIPTORS && !_dereq_('./$.library')){ + if(DESCRIPTORS && !_dereq_('./_library')){ redefine(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true); } + + wksExt.f = function(name){ + return wrap(wks(name)); + } } -var symbolStatics = { +$export($export.G + $export.W + $export.F * !USE_NATIVE, {Symbol: $Symbol}); + +for(var symbols = ( + // 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(','), i = 0; symbols.length > i; )wks(symbols[i++]); + +for(var symbols = $keys(wks.store), i = 0; symbols.length > i; )wksDefine(symbols[i++]); + +$export($export.S + $export.F * !USE_NATIVE, 'Symbol', { // 19.4.2.1 Symbol.for(key) 'for': function(key){ return has(SymbolRegistry, key += '') @@ -6397,37 +6410,14 @@ var symbolStatics = { }, // 19.4.2.5 Symbol.keyFor(sym) keyFor: function keyFor(key){ - return keyOf(SymbolRegistry, key); + if(isSymbol(key))return keyOf(SymbolRegistry, key); + throw TypeError(key + ' is not a symbol!'); }, useSetter: function(){ setter = true; }, useSimple: function(){ setter = false; } -}; -// 19.4.2.2 Symbol.hasInstance -// 19.4.2.3 Symbol.isConcatSpreadable -// 19.4.2.4 Symbol.iterator -// 19.4.2.6 Symbol.match -// 19.4.2.8 Symbol.replace -// 19.4.2.9 Symbol.search -// 19.4.2.10 Symbol.species -// 19.4.2.11 Symbol.split -// 19.4.2.12 Symbol.toPrimitive -// 19.4.2.13 Symbol.toStringTag -// 19.4.2.14 Symbol.unscopables -$.each.call(( - 'hasInstance,isConcatSpreadable,iterator,match,replace,search,' + - 'species,split,toPrimitive,toStringTag,unscopables' -).split(','), function(it){ - var sym = wks(it); - symbolStatics[it] = useNative ? sym : wrap(sym); }); -setter = true; - -$export($export.G + $export.W, {Symbol: $Symbol}); - -$export($export.S, 'Symbol', symbolStatics); - -$export($export.S + $export.F * !useNative, 'Object', { +$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) @@ -6443,29 +6433,67 @@ $export($export.S + $export.F * !useNative, 'Object', { }); // 24.3.2 JSON.stringify(value [, replacer [, space]]) -$JSON && $export($export.S + $export.F * (!useNative || buggyJSON), 'JSON', {stringify: $stringify}); +$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] + , i = 1 + , 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][TO_PRIMITIVE] || _dereq_('./_hide')($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].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); -},{"./$":93,"./$.an-object":62,"./$.descriptors":71,"./$.enum-keys":73,"./$.export":74,"./$.fails":75,"./$.get-names":77,"./$.global":78,"./$.has":79,"./$.is-array":85,"./$.keyof":94,"./$.library":95,"./$.property-desc":99,"./$.redefine":101,"./$.set-to-string-tag":105,"./$.shared":106,"./$.to-iobject":112,"./$.uid":115,"./$.wks":116}],134:[function(_dereq_,module,exports){ +},{"./_an-object":63,"./_descriptors":78,"./_enum-keys":81,"./_export":82,"./_fails":83,"./_global":85,"./_has":86,"./_hide":87,"./_is-array":93,"./_keyof":101,"./_library":102,"./_meta":103,"./_object-create":106,"./_object-dp":107,"./_object-gopd":109,"./_object-gopn":111,"./_object-gopn-ext":110,"./_object-gops":112,"./_object-keys":115,"./_object-pie":116,"./_property-desc":118,"./_redefine":120,"./_set-to-string-tag":123,"./_shared":125,"./_to-iobject":131,"./_to-primitive":134,"./_uid":135,"./_wks":138,"./_wks-define":136,"./_wks-ext":137}],159:[function(_dereq_,module,exports){ // https://github.com/DavidBruant/Map-Set.prototype.toJSON -var $export = _dereq_('./$.export'); +var $export = _dereq_('./_export'); -$export($export.P, 'Map', {toJSON: _dereq_('./$.collection-to-json')('Map')}); -},{"./$.collection-to-json":66,"./$.export":74}],135:[function(_dereq_,module,exports){ +$export($export.P + $export.R, 'Map', {toJSON: _dereq_('./_collection-to-json')('Map')}); +},{"./_collection-to-json":72,"./_export":82}],160:[function(_dereq_,module,exports){ // https://github.com/DavidBruant/Map-Set.prototype.toJSON -var $export = _dereq_('./$.export'); - -$export($export.P, 'Set', {toJSON: _dereq_('./$.collection-to-json')('Set')}); -},{"./$.collection-to-json":66,"./$.export":74}],136:[function(_dereq_,module,exports){ +var $export = _dereq_('./_export'); + +$export($export.P + $export.R, 'Set', {toJSON: _dereq_('./_collection-to-json')('Set')}); +},{"./_collection-to-json":72,"./_export":82}],161:[function(_dereq_,module,exports){ +_dereq_('./_wks-define')('asyncIterator'); +},{"./_wks-define":136}],162:[function(_dereq_,module,exports){ +_dereq_('./_wks-define')('observable'); +},{"./_wks-define":136}],163:[function(_dereq_,module,exports){ _dereq_('./es6.array.iterator'); -var Iterators = _dereq_('./$.iterators'); -Iterators.NodeList = Iterators.HTMLCollection = Iterators.Array; -},{"./$.iterators":92,"./es6.array.iterator":121}],137:[function(_dereq_,module,exports){ +var global = _dereq_('./_global') + , hide = _dereq_('./_hide') + , Iterators = _dereq_('./_iterators') + , TO_STRING_TAG = _dereq_('./_wks')('toStringTag'); + +for(var collections = ['NodeList', 'DOMTokenList', 'MediaList', 'StyleSheetList', 'CSSRuleList'], i = 0; i < 5; i++){ + var NAME = collections[i] + , Collection = global[NAME] + , proto = Collection && Collection.prototype; + if(proto && !proto[TO_STRING_TAG])hide(proto, TO_STRING_TAG, NAME); + Iterators[NAME] = Iterators.Array; +} +},{"./_global":85,"./_hide":87,"./_iterators":100,"./_wks":138,"./es6.array.iterator":143}],164:[function(_dereq_,module,exports){ (function (Buffer){ // Copyright Joyent, Inc. and other Node contributors. // @@ -6576,8 +6604,8 @@ function objectToString(o) { } }).call(this,{"isBuffer":_dereq_("../../is-buffer/index.js")}) -//# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9jb3JlLXV0aWwtaXMvbGliL3V0aWwuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FB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c0Vycm9yID0gaXNFcnJvcjtcblxuZnVuY3Rpb24gaXNGdW5jdGlvbihhcmcpIHtcbiAgcmV0dXJuIHR5cGVvZiBhcmcgPT09ICdmdW5jdGlvbic7XG59XG5leHBvcnRzLmlzRnVuY3Rpb24gPSBpc0Z1bmN0aW9uO1xuXG5mdW5jdGlvbiBpc1ByaW1pdGl2ZShhcmcpIHtcbiAgcmV0dXJuIGFyZyA9PT0gbnVsbCB8fFxuICAgICAgICAgdHlwZW9mIGFyZyA9PT0gJ2Jvb2xlYW4nIHx8XG4gICAgICAgICB0eXBlb2YgYXJnID09PSAnbnVtYmVyJyB8fFxuICAgICAgICAgdHlwZW9mIGFyZyA9PT0gJ3N0cmluZycgfHxcbiAgICAgICAgIHR5cGVvZiBhcmcgPT09ICdzeW1ib2wnIHx8ICAvLyBFUzYgc3ltYm9sXG4gICAgICAgICB0eXBlb2YgYXJnID09PSAndW5kZWZpbmVkJztcbn1cbmV4cG9ydHMuaXNQcmltaXRpdmUgPSBpc1ByaW1pdGl2ZTtcblxuZXhwb3J0cy5pc0J1ZmZlciA9IEJ1ZmZlci5pc0J1ZmZlcjtcblxuZnVuY3Rpb24gb2JqZWN0VG9TdHJpbmcobykge1xuICByZXR1cm4gT2JqZWN0LnByb3RvdHlwZS50b1N0cmluZy5jYWxsKG8pO1xufVxuIl19 -},{"../../is-buffer/index.js":161}],138:[function(_dereq_,module,exports){ + +},{"../../is-buffer/index.js":188}],165:[function(_dereq_,module,exports){ // (c) Dean McNamee , 2012. // // https://github.com/deanm/css-color-parser-js @@ -6779,7 +6807,7 @@ function parseCSSColor(css_str) { try { exports.parseCSSColor = parseCSSColor } catch(e) { } -},{}],139:[function(_dereq_,module,exports){ +},{}],166:[function(_dereq_,module,exports){ "use strict" function dupe_array(count, value, i) { @@ -6829,7 +6857,7 @@ function dupe(count, value) { } module.exports = dupe -},{}],140:[function(_dereq_,module,exports){ +},{}],167:[function(_dereq_,module,exports){ 'use strict'; module.exports = earcut; @@ -7475,7 +7503,7 @@ earcut.flatten = function (data) { return result; }; -},{}],141:[function(_dereq_,module,exports){ +},{}],168:[function(_dereq_,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -7535,8 +7563,12 @@ EventEmitter.prototype.emit = function(type) { er = arguments[1]; if (er instanceof Error) { throw er; // Unhandled 'error' event + } else { + // At least give some kind of context to the user + var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); + err.context = er; + throw err; } - throw TypeError('Uncaught, unspecified "error" event.'); } } @@ -7559,18 +7591,11 @@ EventEmitter.prototype.emit = function(type) { break; // slower default: - len = arguments.length; - args = new Array(len - 1); - for (i = 1; i < len; i++) - args[i - 1] = arguments[i]; + args = Array.prototype.slice.call(arguments, 1); handler.apply(this, args); } } else if (isObject(handler)) { - len = arguments.length; - args = new Array(len - 1); - for (i = 1; i < len; i++) - args[i - 1] = arguments[i]; - + args = Array.prototype.slice.call(arguments, 1); listeners = handler.slice(); len = listeners.length; for (i = 0; i < len; i++) @@ -7608,7 +7633,6 @@ EventEmitter.prototype.addListener = function(type, listener) { // Check for listener leak if (isObject(this._events[type]) && !this._events[type].warned) { - var m; if (!isUndefined(this._maxListeners)) { m = this._maxListeners; } else { @@ -7730,7 +7754,7 @@ EventEmitter.prototype.removeAllListeners = function(type) { if (isFunction(listeners)) { this.removeListener(type, listeners); - } else { + } else if (listeners) { // LIFO order while (listeners.length) this.removeListener(type, listeners[listeners.length - 1]); @@ -7751,15 +7775,20 @@ EventEmitter.prototype.listeners = function(type) { return ret; }; +EventEmitter.prototype.listenerCount = function(type) { + if (this._events) { + var evlistener = this._events[type]; + + if (isFunction(evlistener)) + return 1; + else if (evlistener) + return evlistener.length; + } + return 0; +}; + EventEmitter.listenerCount = function(emitter, type) { - var ret; - if (!emitter._events || !emitter._events[type]) - ret = 0; - else if (isFunction(emitter._events[type])) - ret = 1; - else - ret = emitter._events[type].length; - return ret; + return emitter.listenerCount(type); }; function isFunction(arg) { @@ -7778,7 +7807,7 @@ function isUndefined(arg) { return arg === void 0; } -},{}],142:[function(_dereq_,module,exports){ +},{}],169:[function(_dereq_,module,exports){ (function(){var k=!!document.addEventListener;function l(a,b){k?a.addEventListener("scroll",b,!1):a.attachEvent("scroll",b)}function v(a){document.body?a():k?document.addEventListener("DOMContentLoaded",a):document.attachEvent("onreadystatechange",function(){"interactive"!=document.readyState&&"complete"!=document.readyState||a()})};function w(a){this.a=document.createElement("div");this.a.setAttribute("aria-hidden","true");this.a.appendChild(document.createTextNode(a));this.b=document.createElement("span");this.c=document.createElement("span");this.h=document.createElement("span");this.f=document.createElement("span");this.g=-1;this.b.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;";this.c.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;"; this.f.style.cssText="max-width:none;display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;font-size:16px;";this.h.style.cssText="display:inline-block;width:200%;height:200%;font-size:16px;max-width:none;";this.b.appendChild(this.h);this.c.appendChild(this.f);this.a.appendChild(this.b);this.a.appendChild(this.c)} function y(a,b){a.a.style.cssText="max-width:none;min-width:20px;min-height:20px;display:inline-block;overflow:hidden;position:absolute;width:auto;margin:0;padding:0;top:-999px;left:-999px;white-space:nowrap;font:"+b+";"}function z(a){var b=a.a.offsetWidth,c=b+100;a.f.style.width=c+"px";a.c.scrollLeft=c;a.b.scrollLeft=a.b.scrollWidth+100;return a.g!==b?(a.g=b,!0):!1}function A(a,b){function c(){var a=m;z(a)&&null!==a.a.parentNode&&b(a.g)}var m=a;l(a.b,c);l(a.c,c);z(a)};function B(a,b){var c=b||{};this.family=a;this.style=c.style||"normal";this.weight=c.weight||"normal";this.stretch=c.stretch||"normal"}var C=null,D=null,H=!!window.FontFace;function I(){if(null===D){var a=document.createElement("div");try{a.style.font="condensed 100px sans-serif"}catch(b){}D=""!==a.style.font}return D}function J(a,b){return[a.style,a.weight,I()?a.stretch:"","100px",b].join(" ")} @@ -7787,7 +7816,7 @@ h)(b=f!=g&&f!=h&&g!=h)||(null===C&&(b=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec h=p.a.offsetWidth,q();G=setTimeout(F,50)}}var e=new w(m),n=new w(m),p=new w(m),f=-1,g=-1,h=-1,r=-1,t=-1,u=-1,d=document.createElement("div"),G=0;d.dir="ltr";y(e,J(c,"sans-serif"));y(n,J(c,"serif"));y(p,J(c,"monospace"));d.appendChild(e.a);d.appendChild(n.a);d.appendChild(p.a);document.body.appendChild(d);r=e.a.offsetWidth;t=n.a.offsetWidth;u=p.a.offsetWidth;F();A(e,function(a){f=a;q()});y(e,J(c,'"'+c.family+'",sans-serif'));A(n,function(a){g=a;q()});y(n,J(c,'"'+c.family+'",serif'));A(p,function(a){h= a;q()});y(p,J(c,'"'+c.family+'",monospace'))})})};window.FontFaceObserver=B;window.FontFaceObserver.prototype.check=window.FontFaceObserver.prototype.load=B.prototype.load;"undefined"!==typeof module&&(module.exports=window.FontFaceObserver);}()); -},{}],143:[function(_dereq_,module,exports){ +},{}],170:[function(_dereq_,module,exports){ 'use strict'; module.exports = clip; @@ -7940,7 +7969,7 @@ function newSlice(slices, slice, area, dist) { return []; } -},{}],144:[function(_dereq_,module,exports){ +},{}],171:[function(_dereq_,module,exports){ 'use strict'; module.exports = convert; @@ -8086,7 +8115,7 @@ function calcRingBBox(min, max, points) { } } -},{"./simplify":146}],145:[function(_dereq_,module,exports){ +},{"./simplify":173}],172:[function(_dereq_,module,exports){ 'use strict'; module.exports = geojsonvt; @@ -8353,7 +8382,7 @@ function isClippedSquare(tile, extent, buffer) { return true; } -},{"./clip":143,"./convert":144,"./tile":147,"./wrap":148}],146:[function(_dereq_,module,exports){ +},{"./clip":170,"./convert":171,"./tile":174,"./wrap":175}],173:[function(_dereq_,module,exports){ 'use strict'; module.exports = simplify; @@ -8429,7 +8458,7 @@ function getSqSegDist(p, a, b) { return dx * dx + dy * dy; } -},{}],147:[function(_dereq_,module,exports){ +},{}],174:[function(_dereq_,module,exports){ 'use strict'; module.exports = createTile; @@ -8516,7 +8545,7 @@ function addFeature(tile, feature, tolerance, noSimplify) { } } -},{}],148:[function(_dereq_,module,exports){ +},{}],175:[function(_dereq_,module,exports){ 'use strict'; var clip = _dereq_('./clip'); @@ -8579,7 +8608,7 @@ function shiftCoords(points, offset) { return newPoints; } -},{"./clip":143}],149:[function(_dereq_,module,exports){ +},{"./clip":170}],176:[function(_dereq_,module,exports){ module.exports = invert /** @@ -8618,7 +8647,7 @@ function invert(out, a) { return out } -},{}],150:[function(_dereq_,module,exports){ +},{}],177:[function(_dereq_,module,exports){ module.exports = normalFromMat4 /** @@ -8675,7 +8704,7 @@ function normalFromMat4(out, a) { return out } -},{}],151:[function(_dereq_,module,exports){ +},{}],178:[function(_dereq_,module,exports){ module.exports = copy; /** @@ -8704,7 +8733,7 @@ function copy(out, a) { out[15] = a[15]; return out; }; -},{}],152:[function(_dereq_,module,exports){ +},{}],179:[function(_dereq_,module,exports){ module.exports = identity; /** @@ -8732,7 +8761,7 @@ function identity(out) { out[15] = 1; return out; }; -},{}],153:[function(_dereq_,module,exports){ +},{}],180:[function(_dereq_,module,exports){ var identity = _dereq_('./identity'); module.exports = lookAt; @@ -8823,7 +8852,7 @@ function lookAt(out, eye, center, up) { return out; }; -},{"./identity":152}],154:[function(_dereq_,module,exports){ +},{"./identity":179}],181:[function(_dereq_,module,exports){ module.exports = multiply; /** @@ -8866,7 +8895,7 @@ function multiply(out, a, b) { out[15] = b0*a03 + b1*a13 + b2*a23 + b3*a33; return out; }; -},{}],155:[function(_dereq_,module,exports){ +},{}],182:[function(_dereq_,module,exports){ module.exports = perspective; /** @@ -8900,7 +8929,7 @@ function perspective(out, fovy, aspect, near, far) { out[15] = 0; return out; }; -},{}],156:[function(_dereq_,module,exports){ +},{}],183:[function(_dereq_,module,exports){ module.exports = scale; /** @@ -8932,7 +8961,7 @@ function scale(out, a, v) { out[15] = a[15]; return out; }; -},{}],157:[function(_dereq_,module,exports){ +},{}],184:[function(_dereq_,module,exports){ module.exports = translate; /** @@ -8971,7 +9000,7 @@ function translate(out, a, v) { return out; }; -},{}],158:[function(_dereq_,module,exports){ +},{}],185:[function(_dereq_,module,exports){ module.exports = parseErrors function parseErrors(log) { @@ -8999,7 +9028,7 @@ function parseErrors(log) { return logs } -},{}],159:[function(_dereq_,module,exports){ +},{}],186:[function(_dereq_,module,exports){ exports.read = function (buffer, offset, isLE, mLen, nBytes) { var e, m var eLen = nBytes * 8 - mLen - 1 @@ -9085,7 +9114,7 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { buffer[offset + i - d] |= s * 128 } -},{}],160:[function(_dereq_,module,exports){ +},{}],187:[function(_dereq_,module,exports){ if (typeof Object.create === 'function') { // implementation from standard node.js 'util' module module.exports = function inherits(ctor, superCtor) { @@ -9110,26 +9139,37 @@ if (typeof Object.create === 'function') { } } -},{}],161:[function(_dereq_,module,exports){ -/** - * Determine if an object is Buffer - * - * Author: Feross Aboukhadijeh - * License: MIT +},{}],188:[function(_dereq_,module,exports){ +/*! + * Determine if an object is a Buffer * - * `npm install is-buffer` + * @author Feross Aboukhadijeh + * @license MIT */ +// The _isBuffer check is for Safari 5-7 support, because it's missing +// Object.prototype.constructor. Remove this eventually module.exports = function (obj) { - return !!(obj != null && - (obj._isBuffer || // For Safari 5-7 (missing Object.prototype.constructor) - (obj.constructor && - typeof obj.constructor.isBuffer === 'function' && - obj.constructor.isBuffer(obj)) - )) + return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer) } -},{}],162:[function(_dereq_,module,exports){ +function isBuffer (obj) { + return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj) +} + +// For Node v0.10 support. Remove this eventually. +function isSlowBuffer (obj) { + return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0)) +} + +},{}],189:[function(_dereq_,module,exports){ +var toString = {}.toString; + +module.exports = Array.isArray || function (arr) { + return toString.call(arr) == '[object Array]'; +}; + +},{}],190:[function(_dereq_,module,exports){ 'use strict'; @@ -9138,7 +9178,7 @@ var yaml = _dereq_('./lib/js-yaml.js'); module.exports = yaml; -},{"./lib/js-yaml.js":163}],163:[function(_dereq_,module,exports){ +},{"./lib/js-yaml.js":191}],191:[function(_dereq_,module,exports){ 'use strict'; @@ -9179,7 +9219,7 @@ module.exports.parse = deprecated('parse'); module.exports.compose = deprecated('compose'); module.exports.addConstructor = deprecated('addConstructor'); -},{"./js-yaml/exception":165,"./js-yaml/loader":166,"./js-yaml/schema":168,"./js-yaml/schema/core":169,"./js-yaml/schema/default_full":170,"./js-yaml/schema/default_safe":171,"./js-yaml/schema/failsafe":172,"./js-yaml/schema/json":173,"./js-yaml/type":174}],164:[function(_dereq_,module,exports){ +},{"./js-yaml/exception":193,"./js-yaml/loader":194,"./js-yaml/schema":196,"./js-yaml/schema/core":197,"./js-yaml/schema/default_full":198,"./js-yaml/schema/default_safe":199,"./js-yaml/schema/failsafe":200,"./js-yaml/schema/json":201,"./js-yaml/type":202}],192:[function(_dereq_,module,exports){ 'use strict'; @@ -9240,7 +9280,7 @@ module.exports.repeat = repeat; module.exports.isNegativeZero = isNegativeZero; module.exports.extend = extend; -},{}],165:[function(_dereq_,module,exports){ +},{}],193:[function(_dereq_,module,exports){ // YAML error class. http://stackoverflow.com/questions/8458984 // 'use strict'; @@ -9285,7 +9325,7 @@ YAMLException.prototype.toString = function toString(compact) { module.exports = YAMLException; -},{}],166:[function(_dereq_,module,exports){ +},{}],194:[function(_dereq_,module,exports){ 'use strict'; /*eslint-disable max-len,no-use-before-define*/ @@ -10873,7 +10913,7 @@ module.exports.load = load; module.exports.safeLoadAll = safeLoadAll; module.exports.safeLoad = safeLoad; -},{"./common":164,"./exception":165,"./mark":167,"./schema/default_full":170,"./schema/default_safe":171}],167:[function(_dereq_,module,exports){ +},{"./common":192,"./exception":193,"./mark":195,"./schema/default_full":198,"./schema/default_safe":199}],195:[function(_dereq_,module,exports){ 'use strict'; @@ -10951,7 +10991,7 @@ Mark.prototype.toString = function toString(compact) { module.exports = Mark; -},{"./common":164}],168:[function(_dereq_,module,exports){ +},{"./common":192}],196:[function(_dereq_,module,exports){ 'use strict'; /*eslint-disable max-len*/ @@ -11057,7 +11097,7 @@ Schema.create = function createSchema() { module.exports = Schema; -},{"./common":164,"./exception":165,"./type":174}],169:[function(_dereq_,module,exports){ +},{"./common":192,"./exception":193,"./type":202}],197:[function(_dereq_,module,exports){ // Standard YAML's Core schema. // http://www.yaml.org/spec/1.2/spec.html#id2804923 // @@ -11077,7 +11117,7 @@ module.exports = new Schema({ ] }); -},{"../schema":168,"./json":173}],170:[function(_dereq_,module,exports){ +},{"../schema":196,"./json":201}],198:[function(_dereq_,module,exports){ // JS-YAML's default schema for `load` function. // It is not described in the YAML specification. // @@ -11104,7 +11144,7 @@ module.exports = Schema.DEFAULT = new Schema({ ] }); -},{"../schema":168,"../type/js/function":179,"../type/js/regexp":180,"../type/js/undefined":181,"./default_safe":171}],171:[function(_dereq_,module,exports){ +},{"../schema":196,"../type/js/function":207,"../type/js/regexp":208,"../type/js/undefined":209,"./default_safe":199}],199:[function(_dereq_,module,exports){ // JS-YAML's default schema for `safeLoad` function. // It is not described in the YAML specification. // @@ -11134,7 +11174,7 @@ module.exports = new Schema({ ] }); -},{"../schema":168,"../type/binary":175,"../type/merge":183,"../type/omap":185,"../type/pairs":186,"../type/set":188,"../type/timestamp":190,"./core":169}],172:[function(_dereq_,module,exports){ +},{"../schema":196,"../type/binary":203,"../type/merge":211,"../type/omap":213,"../type/pairs":214,"../type/set":216,"../type/timestamp":218,"./core":197}],200:[function(_dereq_,module,exports){ // Standard YAML's Failsafe schema. // http://www.yaml.org/spec/1.2/spec.html#id2802346 @@ -11153,7 +11193,7 @@ module.exports = new Schema({ ] }); -},{"../schema":168,"../type/map":182,"../type/seq":187,"../type/str":189}],173:[function(_dereq_,module,exports){ +},{"../schema":196,"../type/map":210,"../type/seq":215,"../type/str":217}],201:[function(_dereq_,module,exports){ // Standard YAML's JSON schema. // http://www.yaml.org/spec/1.2/spec.html#id2803231 // @@ -11180,7 +11220,7 @@ module.exports = new Schema({ ] }); -},{"../schema":168,"../type/bool":176,"../type/float":177,"../type/int":178,"../type/null":184,"./failsafe":172}],174:[function(_dereq_,module,exports){ +},{"../schema":196,"../type/bool":204,"../type/float":205,"../type/int":206,"../type/null":212,"./failsafe":200}],202:[function(_dereq_,module,exports){ 'use strict'; var YAMLException = _dereq_('./exception'); @@ -11243,7 +11283,7 @@ function Type(tag, options) { module.exports = Type; -},{"./exception":165}],175:[function(_dereq_,module,exports){ +},{"./exception":193}],203:[function(_dereq_,module,exports){ 'use strict'; /*eslint-disable no-bitwise*/ @@ -11375,7 +11415,7 @@ module.exports = new Type('tag:yaml.org,2002:binary', { represent: representYamlBinary }); -},{"../type":174,"buffer":40}],176:[function(_dereq_,module,exports){ +},{"../type":202,"buffer":40}],204:[function(_dereq_,module,exports){ 'use strict'; var Type = _dereq_('../type'); @@ -11412,7 +11452,7 @@ module.exports = new Type('tag:yaml.org,2002:bool', { defaultStyle: 'lowercase' }); -},{"../type":174}],177:[function(_dereq_,module,exports){ +},{"../type":202}],205:[function(_dereq_,module,exports){ 'use strict'; var common = _dereq_('../common'); @@ -11519,7 +11559,7 @@ module.exports = new Type('tag:yaml.org,2002:float', { defaultStyle: 'lowercase' }); -},{"../common":164,"../type":174}],178:[function(_dereq_,module,exports){ +},{"../common":192,"../type":202}],206:[function(_dereq_,module,exports){ 'use strict'; var common = _dereq_('../common'); @@ -11689,7 +11729,7 @@ module.exports = new Type('tag:yaml.org,2002:int', { } }); -},{"../common":164,"../type":174}],179:[function(_dereq_,module,exports){ +},{"../common":192,"../type":202}],207:[function(_dereq_,module,exports){ 'use strict'; var esprima; @@ -11775,7 +11815,7 @@ module.exports = new Type('tag:yaml.org,2002:js/function', { represent: representJavascriptFunction }); -},{"../../type":174}],180:[function(_dereq_,module,exports){ +},{"../../type":202}],208:[function(_dereq_,module,exports){ 'use strict'; var Type = _dereq_('../../type'); @@ -11837,7 +11877,7 @@ module.exports = new Type('tag:yaml.org,2002:js/regexp', { represent: representJavascriptRegExp }); -},{"../../type":174}],181:[function(_dereq_,module,exports){ +},{"../../type":202}],209:[function(_dereq_,module,exports){ 'use strict'; var Type = _dereq_('../../type'); @@ -11867,7 +11907,7 @@ module.exports = new Type('tag:yaml.org,2002:js/undefined', { represent: representJavascriptUndefined }); -},{"../../type":174}],182:[function(_dereq_,module,exports){ +},{"../../type":202}],210:[function(_dereq_,module,exports){ 'use strict'; var Type = _dereq_('../type'); @@ -11877,7 +11917,7 @@ module.exports = new Type('tag:yaml.org,2002:map', { construct: function (data) { return data !== null ? data : {}; } }); -},{"../type":174}],183:[function(_dereq_,module,exports){ +},{"../type":202}],211:[function(_dereq_,module,exports){ 'use strict'; var Type = _dereq_('../type'); @@ -11891,7 +11931,7 @@ module.exports = new Type('tag:yaml.org,2002:merge', { resolve: resolveYamlMerge }); -},{"../type":174}],184:[function(_dereq_,module,exports){ +},{"../type":202}],212:[function(_dereq_,module,exports){ 'use strict'; var Type = _dereq_('../type'); @@ -11927,7 +11967,7 @@ module.exports = new Type('tag:yaml.org,2002:null', { defaultStyle: 'lowercase' }); -},{"../type":174}],185:[function(_dereq_,module,exports){ +},{"../type":202}],213:[function(_dereq_,module,exports){ 'use strict'; var Type = _dereq_('../type'); @@ -11973,7 +12013,7 @@ module.exports = new Type('tag:yaml.org,2002:omap', { construct: constructYamlOmap }); -},{"../type":174}],186:[function(_dereq_,module,exports){ +},{"../type":202}],214:[function(_dereq_,module,exports){ 'use strict'; var Type = _dereq_('../type'); @@ -12028,7 +12068,7 @@ module.exports = new Type('tag:yaml.org,2002:pairs', { construct: constructYamlPairs }); -},{"../type":174}],187:[function(_dereq_,module,exports){ +},{"../type":202}],215:[function(_dereq_,module,exports){ 'use strict'; var Type = _dereq_('../type'); @@ -12038,7 +12078,7 @@ module.exports = new Type('tag:yaml.org,2002:seq', { construct: function (data) { return data !== null ? data : []; } }); -},{"../type":174}],188:[function(_dereq_,module,exports){ +},{"../type":202}],216:[function(_dereq_,module,exports){ 'use strict'; var Type = _dereq_('../type'); @@ -12069,7 +12109,7 @@ module.exports = new Type('tag:yaml.org,2002:set', { construct: constructYamlSet }); -},{"../type":174}],189:[function(_dereq_,module,exports){ +},{"../type":202}],217:[function(_dereq_,module,exports){ 'use strict'; var Type = _dereq_('../type'); @@ -12079,7 +12119,7 @@ module.exports = new Type('tag:yaml.org,2002:str', { construct: function (data) { return data !== null ? data : ''; } }); -},{"../type":174}],190:[function(_dereq_,module,exports){ +},{"../type":202}],218:[function(_dereq_,module,exports){ 'use strict'; var Type = _dereq_('../type'); @@ -12162,7 +12202,7 @@ module.exports = new Type('tag:yaml.org,2002:timestamp', { represent: representYamlTimestamp }); -},{"../type":174}],191:[function(_dereq_,module,exports){ +},{"../type":202}],219:[function(_dereq_,module,exports){ 'use strict'; var utils = _dereq_('./utils'); var support = _dereq_('./support'); @@ -12249,7 +12289,7 @@ exports.decode = function(input) { return output; }; -},{"./support":217,"./utils":219}],192:[function(_dereq_,module,exports){ +},{"./support":245,"./utils":247}],220:[function(_dereq_,module,exports){ 'use strict'; var external = _dereq_("./external"); @@ -12326,7 +12366,7 @@ CompressedObject.createWorkerFrom = function (uncompressedWorker, compression, c module.exports = CompressedObject; -},{"./external":196,"./stream/Crc32Probe":212,"./stream/DataLengthProbe":213,"./stream/DataWorker":214}],193:[function(_dereq_,module,exports){ +},{"./external":224,"./stream/Crc32Probe":240,"./stream/DataLengthProbe":241,"./stream/DataWorker":242}],221:[function(_dereq_,module,exports){ 'use strict'; var GenericWorker = _dereq_("./stream/GenericWorker"); @@ -12342,7 +12382,7 @@ exports.STORE = { }; exports.DEFLATE = _dereq_('./flate'); -},{"./flate":197,"./stream/GenericWorker":215}],194:[function(_dereq_,module,exports){ +},{"./flate":225,"./stream/GenericWorker":243}],222:[function(_dereq_,module,exports){ 'use strict'; var utils = _dereq_('./utils'); @@ -12422,7 +12462,7 @@ module.exports = function crc32wrapper(input, crc) { }; // vim: set shiftwidth=4 softtabstop=4: -},{"./utils":219}],195:[function(_dereq_,module,exports){ +},{"./utils":247}],223:[function(_dereq_,module,exports){ 'use strict'; exports.base64 = false; exports.binary = false; @@ -12435,7 +12475,7 @@ exports.comment = null; exports.unixPermissions = null; exports.dosPermissions = null; -},{}],196:[function(_dereq_,module,exports){ +},{}],224:[function(_dereq_,module,exports){ 'use strict'; // var ES6Promise = require("es6-promise").Promise; @@ -12447,7 +12487,7 @@ module.exports = { Promise: window.Promise }; -},{}],197:[function(_dereq_,module,exports){ +},{}],225:[function(_dereq_,module,exports){ 'use strict'; var USE_TYPEDARRAY = (typeof Uint8Array !== 'undefined') && (typeof Uint16Array !== 'undefined') && (typeof Uint32Array !== 'undefined'); @@ -12517,7 +12557,7 @@ exports.uncompressWorker = function () { return new FlateWorker("Inflate", {}); }; -},{"./stream/GenericWorker":215,"./utils":219,"pako":224}],198:[function(_dereq_,module,exports){ +},{"./stream/GenericWorker":243,"./utils":247,"pako":252}],226:[function(_dereq_,module,exports){ 'use strict'; /** @@ -12567,7 +12607,7 @@ JSZip.loadAsync = function (content, options) { JSZip.external = _dereq_("./external"); module.exports = JSZip; -},{"./defaults":195,"./external":196,"./load":199,"./object":203,"./support":217}],199:[function(_dereq_,module,exports){ +},{"./defaults":223,"./external":224,"./load":227,"./object":231,"./support":245}],227:[function(_dereq_,module,exports){ 'use strict'; var utils = _dereq_('./utils'); var external = _dereq_("./external"); @@ -12651,7 +12691,7 @@ module.exports = function(data, options) { }); }; -},{"./external":196,"./nodejsUtils":202,"./stream/Crc32Probe":212,"./utf8":218,"./utils":219,"./zipEntries":220}],200:[function(_dereq_,module,exports){ +},{"./external":224,"./nodejsUtils":230,"./stream/Crc32Probe":240,"./utf8":246,"./utils":247,"./zipEntries":248}],228:[function(_dereq_,module,exports){ "use strict"; var utils = _dereq_('../utils'); @@ -12727,7 +12767,7 @@ NodejsStreamInputAdapter.prototype.resume = function () { module.exports = NodejsStreamInputAdapter; -},{"../stream/GenericWorker":215,"../utils":219}],201:[function(_dereq_,module,exports){ +},{"../stream/GenericWorker":243,"../utils":247}],229:[function(_dereq_,module,exports){ 'use strict'; var Readable = _dereq_('readable-stream').Readable; @@ -12771,7 +12811,7 @@ NodejsStreamOutputAdapter.prototype._read = function() { module.exports = NodejsStreamOutputAdapter; -},{"readable-stream":245,"util":258}],202:[function(_dereq_,module,exports){ +},{"readable-stream":278,"util":287}],230:[function(_dereq_,module,exports){ (function (Buffer){ 'use strict'; @@ -12809,8 +12849,8 @@ module.exports = { }; }).call(this,_dereq_("buffer").Buffer) -//# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9qc3ppcC9saWIvbm9kZWpzVXRpbHMuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJmaWxlIjoiZ2VuZXJhdGVkLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXNDb250ZW50IjpbIid1c2Ugc3RyaWN0JztcblxubW9kdWxlLmV4cG9ydHMgPSB7XG4gICAgLyoqXG4gICAgICogVHJ1ZSBpZiB0aGlzIGlzIHJ1bm5pbmcgaW4gTm9kZWpzLCB3aWxsIGJlIHVuZGVmaW5lZCBpbiBhIGJyb3dzZXIuXG4gICAgICogSW4gYSBicm93c2VyLCBicm93c2VyaWZ5IHdv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AgICAgICAgICAgdHlwZW9mIG9iai5wYXVzZSA9PT0gXCJmdW5jdGlvblwiICYmXG4gICAgICAgICAgICB0eXBlb2Ygb2JqLnJlc3VtZSA9PT0gXCJmdW5jdGlvblwiO1xuICAgIH1cbn07XG4iXX0= -},{"buffer":41}],203:[function(_dereq_,module,exports){ + +},{"buffer":41}],231:[function(_dereq_,module,exports){ 'use strict'; // var utf8 = require('./utf8'); var utils = _dereq_('./utils'); @@ -13199,7 +13239,7 @@ var out = { }; module.exports = out; -},{"./compressedObject":192,"./defaults":195,"./nodejs/NodejsStreamInputAdapter":200,"./nodejsUtils":202,"./stream/GenericWorker":215,"./utils":219,"./zipObject":222}],204:[function(_dereq_,module,exports){ +},{"./compressedObject":220,"./defaults":223,"./nodejs/NodejsStreamInputAdapter":228,"./nodejsUtils":230,"./stream/GenericWorker":243,"./utils":247,"./zipObject":250}],232:[function(_dereq_,module,exports){ 'use strict'; var DataReader = _dereq_('./DataReader'); var utils = _dereq_('../utils'); @@ -13258,7 +13298,7 @@ ArrayReader.prototype.readData = function(size) { }; module.exports = ArrayReader; -},{"../utils":219,"./DataReader":205}],205:[function(_dereq_,module,exports){ +},{"../utils":247,"./DataReader":233}],233:[function(_dereq_,module,exports){ 'use strict'; var utils = _dereq_('../utils'); @@ -13376,7 +13416,7 @@ DataReader.prototype = { }; module.exports = DataReader; -},{"../utils":219}],206:[function(_dereq_,module,exports){ +},{"../utils":247}],234:[function(_dereq_,module,exports){ 'use strict'; var Uint8ArrayReader = _dereq_('./Uint8ArrayReader'); var utils = _dereq_('../utils'); @@ -13397,7 +13437,7 @@ NodeBufferReader.prototype.readData = function(size) { }; module.exports = NodeBufferReader; -},{"../utils":219,"./Uint8ArrayReader":208}],207:[function(_dereq_,module,exports){ +},{"../utils":247,"./Uint8ArrayReader":236}],235:[function(_dereq_,module,exports){ 'use strict'; var DataReader = _dereq_('./DataReader'); var utils = _dereq_('../utils'); @@ -13437,7 +13477,7 @@ StringReader.prototype.readData = function(size) { }; module.exports = StringReader; -},{"../utils":219,"./DataReader":205}],208:[function(_dereq_,module,exports){ +},{"../utils":247,"./DataReader":233}],236:[function(_dereq_,module,exports){ 'use strict'; var ArrayReader = _dereq_('./ArrayReader'); var utils = _dereq_('../utils'); @@ -13461,7 +13501,7 @@ Uint8ArrayReader.prototype.readData = function(size) { }; module.exports = Uint8ArrayReader; -},{"../utils":219,"./ArrayReader":204}],209:[function(_dereq_,module,exports){ +},{"../utils":247,"./ArrayReader":232}],237:[function(_dereq_,module,exports){ 'use strict'; var utils = _dereq_('../utils'); @@ -13493,7 +13533,7 @@ module.exports = function (data) { // vim: set shiftwidth=4 softtabstop=4: -},{"../support":217,"../utils":219,"./ArrayReader":204,"./NodeBufferReader":206,"./StringReader":207,"./Uint8ArrayReader":208}],210:[function(_dereq_,module,exports){ +},{"../support":245,"../utils":247,"./ArrayReader":232,"./NodeBufferReader":234,"./StringReader":235,"./Uint8ArrayReader":236}],238:[function(_dereq_,module,exports){ 'use strict'; exports.LOCAL_FILE_HEADER = "PK\x03\x04"; exports.CENTRAL_FILE_HEADER = "PK\x01\x02"; @@ -13502,7 +13542,7 @@ exports.ZIP64_CENTRAL_DIRECTORY_LOCATOR = "PK\x06\x07"; exports.ZIP64_CENTRAL_DIRECTORY_END = "PK\x06\x06"; exports.DATA_DESCRIPTOR = "PK\x07\x08"; -},{}],211:[function(_dereq_,module,exports){ +},{}],239:[function(_dereq_,module,exports){ 'use strict'; var GenericWorker = _dereq_('./GenericWorker'); @@ -13530,7 +13570,7 @@ ConvertWorker.prototype.processChunk = function (chunk) { }; module.exports = ConvertWorker; -},{"../utils":219,"./GenericWorker":215}],212:[function(_dereq_,module,exports){ +},{"../utils":247,"./GenericWorker":243}],240:[function(_dereq_,module,exports){ 'use strict'; var GenericWorker = _dereq_('./GenericWorker'); @@ -13555,7 +13595,7 @@ Crc32Probe.prototype.processChunk = function (chunk) { }; module.exports = Crc32Probe; -},{"../crc32":194,"../utils":219,"./GenericWorker":215}],213:[function(_dereq_,module,exports){ +},{"../crc32":222,"../utils":247,"./GenericWorker":243}],241:[function(_dereq_,module,exports){ 'use strict'; var utils = _dereq_('../utils'); @@ -13586,7 +13626,7 @@ DataLengthProbe.prototype.processChunk = function (chunk) { module.exports = DataLengthProbe; -},{"../utils":219,"./GenericWorker":215}],214:[function(_dereq_,module,exports){ +},{"../utils":247,"./GenericWorker":243}],242:[function(_dereq_,module,exports){ 'use strict'; var utils = _dereq_('../utils'); @@ -13704,7 +13744,7 @@ DataWorker.prototype._tick = function() { module.exports = DataWorker; -},{"../utils":219,"./GenericWorker":215}],215:[function(_dereq_,module,exports){ +},{"../utils":247,"./GenericWorker":243}],243:[function(_dereq_,module,exports){ 'use strict'; /** @@ -13969,7 +14009,7 @@ GenericWorker.prototype = { module.exports = GenericWorker; -},{}],216:[function(_dereq_,module,exports){ +},{}],244:[function(_dereq_,module,exports){ (function (Buffer){ 'use strict'; @@ -14178,8 +14218,8 @@ StreamHelper.prototype = { module.exports = StreamHelper; }).call(this,_dereq_("buffer").Buffer) -//# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9qc3ppcC9saWIvc3RyZWFtL1N0cmVhbUhlbHBlci5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtB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VhbSBjb250YWluaW5nIGJsb2IvYXJyYXlidWZmZXIvdWludDhhcnJheS9zdHJpbmdcbiAgICAgICAgICAgIC8vIGlzIHN0cmFuZ2UgYW5kIEkgZG9uJ3Qga25vdyBpZiBpdCB3b3VsZCBiZSB1c2VmdWwuXG4gICAgICAgICAgICAvLyBJIHlvdSBmaW5kIHRoaXMgY29tbWVudCBhbmQgaGF2ZSBhIGdvb2QgdXNlY2FzZSwgcGxlYXNlIG9wZW4gYVxuICAgICAgICAgICAgLy8gYnVnIHJlcG9ydCAhXG4gICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IodGhpcy5fb3V0cHV0VHlwZSArIFwiIGlzIG5vdCBzdXBwb3J0ZWQgYnkgdGhpcyBtZXRob2RcIik7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gbmV3IE5vZGVqc1N0cmVhbU91dHB1dEFkYXB0ZXIodGhpcywge1xuICAgICAgICAgICAgb2JqZWN0TW9kZSA6IHRoaXMuX291dHB1dFR5cGUgIT09IFwibm9kZWJ1ZmZlclwiXG4gICAgICAgIH0sIHVwZGF0ZUNiKTtcbiAgICB9XG59O1xuXG5cbm1vZHVsZS5leHBvcnRzID0gU3RyZWFtSGVscGVyO1xuIl19 -},{"../base64":191,"../external":196,"../nodejs/NodejsStreamOutputAdapter":201,"../utils":219,"./ConvertWorker":211,"./GenericWorker":215,"buffer":41}],217:[function(_dereq_,module,exports){ + +},{"../base64":219,"../external":224,"../nodejs/NodejsStreamOutputAdapter":229,"../utils":247,"./ConvertWorker":239,"./GenericWorker":243,"buffer":41}],245:[function(_dereq_,module,exports){ (function (Buffer){ 'use strict'; @@ -14217,8 +14257,8 @@ else { exports.nodestream = !!_dereq_("./nodejs/NodejsStreamOutputAdapter").prototype; }).call(this,_dereq_("buffer").Buffer) -//# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9qc3ppcC9saWIvc3Vw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AgICBleHBvcnRzLmJsb2IgPSBuZXcgQmxvYihbYnVmZmVyXSwge1xuICAgICAgICAgICAgdHlwZTogXCJhcHBsaWNhdGlvbi96aXBcIlxuICAgICAgICB9KS5zaXplID09PSAwO1xuICAgIH1cbiAgICBjYXRjaCAoZSkge1xuICAgICAgICB0cnkge1xuICAgICAgICAgICAgdmFyIEJ1aWxkZXIgPSB3aW5kb3cuQmxvYkJ1aWxkZXIgfHwgd2luZG93LldlYktpdEJsb2JCdWlsZGVyIHx8IHdpbmRvdy5Nb3pCbG9iQnVpbGRlciB8fCB3aW5kb3cuTVNCbG9iQnVpbGRlcjtcbiAgICAgICAgICAgIHZhciBidWlsZGVyID0gbmV3IEJ1aWxkZXIoKTtcbiAgICAgICAgICAgIGJ1aWxkZXIuYXBwZW5kKGJ1ZmZlcik7XG4gICAgICAgICAgICBleHBvcnRzLmJsb2IgPSBidWlsZGVyLmdldEJsb2IoJ2FwcGxpY2F0aW9uL3ppcCcpLnNpemUgPT09IDA7XG4gICAgICAgIH1cbiAgICAgICAgY2F0Y2ggKGUpIHtcbiAgICAgICAgICAgIGV4cG9ydHMuYmxvYiA9IGZhbHNlO1xuICAgICAgICB9XG4gICAgfVxufVxuXG5leHBvcnRzLm5vZGVzdHJlYW0gPSAhIXJlcXVpcmUoXCIuL25vZGVqcy9Ob2RlanNTdHJlYW1PdXRwdXRBZGFwdGVyXCIpLnByb3RvdHlwZTtcbiJdfQ== -},{"./nodejs/NodejsStreamOutputAdapter":201,"buffer":41}],218:[function(_dereq_,module,exports){ + +},{"./nodejs/NodejsStreamOutputAdapter":229,"buffer":41}],246:[function(_dereq_,module,exports){ 'use strict'; var utils = _dereq_('./utils'); @@ -14495,7 +14535,7 @@ Utf8EncodeWorker.prototype.processChunk = function (chunk) { }; exports.Utf8EncodeWorker = Utf8EncodeWorker; -},{"./nodejsUtils":202,"./stream/GenericWorker":215,"./support":217,"./utils":219}],219:[function(_dereq_,module,exports){ +},{"./nodejsUtils":230,"./stream/GenericWorker":243,"./support":245,"./utils":247}],247:[function(_dereq_,module,exports){ 'use strict'; var support = _dereq_('./support'); @@ -14962,7 +15002,7 @@ exports.prepareContent = function(name, inputData, isBinary, isOptimizedBinarySt }); }; -},{"./base64":191,"./external":196,"./nodejsUtils":202,"./support":217,"asap":1}],220:[function(_dereq_,module,exports){ +},{"./base64":219,"./external":224,"./nodejsUtils":230,"./support":245,"asap":1}],248:[function(_dereq_,module,exports){ 'use strict'; var readerFor = _dereq_('./reader/readerFor'); var utils = _dereq_('./utils'); @@ -15226,7 +15266,7 @@ ZipEntries.prototype = { // }}} end of ZipEntries module.exports = ZipEntries; -},{"./reader/readerFor":209,"./signature":210,"./support":217,"./utf8":218,"./utils":219,"./zipEntry":221}],221:[function(_dereq_,module,exports){ +},{"./reader/readerFor":237,"./signature":238,"./support":245,"./utf8":246,"./utils":247,"./zipEntry":249}],249:[function(_dereq_,module,exports){ 'use strict'; var readerFor = _dereq_('./reader/readerFor'); var utils = _dereq_('./utils'); @@ -15520,7 +15560,7 @@ ZipEntry.prototype = { }; module.exports = ZipEntry; -},{"./compressedObject":192,"./compressions":193,"./crc32":194,"./reader/readerFor":209,"./support":217,"./utf8":218,"./utils":219}],222:[function(_dereq_,module,exports){ +},{"./compressedObject":220,"./compressions":221,"./crc32":222,"./reader/readerFor":237,"./support":245,"./utf8":246,"./utils":247}],250:[function(_dereq_,module,exports){ 'use strict'; var StreamHelper = _dereq_('./stream/StreamHelper'); @@ -15646,9 +15686,146 @@ for(var i = 0; i < removedMethods.length; i++) { } module.exports = ZipObject; -},{"./compressedObject":192,"./stream/DataWorker":214,"./stream/GenericWorker":215,"./stream/StreamHelper":216,"./utf8":218}],223:[function(_dereq_,module,exports){ -arguments[4][42][0].apply(exports,arguments) -},{"dup":42}],224:[function(_dereq_,module,exports){ +},{"./compressedObject":220,"./stream/DataWorker":242,"./stream/GenericWorker":243,"./stream/StreamHelper":244,"./utf8":246}],251:[function(_dereq_,module,exports){ +'use strict'; + +function notNull(x) { return x != null; } +function wrap(x) { return '(' + x + ')';} + +function maybeQuote(value) { + if (typeof value === 'string') { + return '"' + value + '"'; + } + return value; +} + +function lookUp(key) { + if (key[0] === '$') { + return 'context.' + key.substring(1); + } + return 'context.feature.properties.' + key; +} + +function nullValue(key, value) { + return ' true '; +} + +function propertyEqual(key, value) { + return wrap(maybeQuote(value) + ' === ' + lookUp(key)); +} + +function propertyOr(key, values) { + return wrap(values.map(function (x) { return propertyEqual(key, x); }).join(' || ')); +} + +function printNested(values, joiner) { + return wrap(values.filter(notNull).map(function (x) { + return wrap(x.join(' && ')); + }).join(' ' + joiner + ' ')); +} + +function any(_, values) { + return (values && values.length > 0) ? printNested(values.map(parseFilter), '||') : 'true'; +} + +function all(_, values) { + return (values && values.length > 0) ? printNested(values.map(parseFilter), '&&') : 'true'; +} + +function not(key, value) { + return '!' + wrap(parseFilter(value).join(' && ')); +} + +function none(key, values) { + return '!' + wrap(any(null, values)); +} + +function propertyMatchesBoolean(key, value) { + return wrap(lookUp(key) + (value ? ' != ' : ' == ') + 'null'); +} + +function rangeMatch(key, values) { + var expressions = []; + + if (values.max) { + expressions.push('' + lookUp(key) + ' < ' + values.max); + } + + if (values.min) { + expressions.push('' + lookUp(key) + ' >= ' + values.min); + } + + return wrap(expressions.join(' && ')); +} + +function parseFilter(filter) { + var filterAST = []; + + // Function filter + if (typeof filter === 'function') { + return [wrap(filter.toString() + '(context)')]; + } + // Array filter, implicit 'any' + else if (Array.isArray(filter)) { + return [any(null, filter)]; + } + // Null filter object + else if (filter == null) { + return ['true']; + } + + // Object filter, e.g. implicit 'all' + var keys = Object.keys(filter); + for (var k=0; k < keys.length; k++) { + var key = keys[k]; + + var value = filter[key], + type = typeof value; + if (type === 'string' || type === 'number') { + filterAST.push(propertyEqual(key, value)); + } else if (type === 'boolean') { + filterAST.push(propertyMatchesBoolean(key, value)); + } else if (key === 'not') { + filterAST.push(not(key, value)); + } else if (key === 'any') { + filterAST.push(any(key, value)); + } else if (key === 'all') { + filterAST.push(all(key, value)); + } else if (key === 'none') { + filterAST.push(none(key, value)); + } else if (Array.isArray(value)) { + filterAST.push(propertyOr(key, value)); + } else if (type === 'object' && value != null) { + if (value.max || value.min) { + filterAST.push(rangeMatch(key, value)); + } + } else if (value == null) { + filterAST.push(nullValue(key, value)); + } else { + throw new Error('Unknown Query sytnax: ' + value); + } + } + + return keys.length === 0 ? ['true'] : filterAST; +} + +function filterToString(filterAST) { + return wrap(filterAST.join(' && ')); +} + +function match(filter) { + if (filter == null) { return function () { return true; }; } + // jshint evil: true + return new Function('context', 'return ' + filterToString(parseFilter(filter)) + ';'); +} + +module.exports = { + match: match, + filterToString: filterToString, + parseFilter: parseFilter +}; + +},{}],252:[function(_dereq_,module,exports){ // Top level file is just a mixin of submodules & constants 'use strict'; @@ -15664,7 +15841,7 @@ assign(pako, deflate, inflate, constants); module.exports = pako; -},{"./lib/deflate":225,"./lib/inflate":226,"./lib/utils/common":227,"./lib/zlib/constants":230}],225:[function(_dereq_,module,exports){ +},{"./lib/deflate":253,"./lib/inflate":254,"./lib/utils/common":255,"./lib/zlib/constants":258}],253:[function(_dereq_,module,exports){ 'use strict'; @@ -16066,7 +16243,7 @@ exports.deflate = deflate; exports.deflateRaw = deflateRaw; exports.gzip = gzip; -},{"./utils/common":227,"./utils/strings":228,"./zlib/deflate":232,"./zlib/messages":237,"./zlib/zstream":239}],226:[function(_dereq_,module,exports){ +},{"./utils/common":255,"./utils/strings":256,"./zlib/deflate":260,"./zlib/messages":265,"./zlib/zstream":267}],254:[function(_dereq_,module,exports){ 'use strict'; @@ -16486,7 +16663,7 @@ exports.inflate = inflate; exports.inflateRaw = inflateRaw; exports.ungzip = inflate; -},{"./utils/common":227,"./utils/strings":228,"./zlib/constants":230,"./zlib/gzheader":233,"./zlib/inflate":235,"./zlib/messages":237,"./zlib/zstream":239}],227:[function(_dereq_,module,exports){ +},{"./utils/common":255,"./utils/strings":256,"./zlib/constants":258,"./zlib/gzheader":261,"./zlib/inflate":263,"./zlib/messages":265,"./zlib/zstream":267}],255:[function(_dereq_,module,exports){ 'use strict'; @@ -16590,7 +16767,7 @@ exports.setTyped = function (on) { exports.setTyped(TYPED_OK); -},{}],228:[function(_dereq_,module,exports){ +},{}],256:[function(_dereq_,module,exports){ // String encode/decode helpers 'use strict'; @@ -16777,7 +16954,7 @@ exports.utf8border = function (buf, max) { return (pos + _utf8len[buf[pos]] > max) ? pos : max; }; -},{"./common":227}],229:[function(_dereq_,module,exports){ +},{"./common":255}],257:[function(_dereq_,module,exports){ 'use strict'; // Note: adler32 takes 12% for level 0 and 2% for level 6. @@ -16811,7 +16988,7 @@ function adler32(adler, buf, len, pos) { module.exports = adler32; -},{}],230:[function(_dereq_,module,exports){ +},{}],258:[function(_dereq_,module,exports){ 'use strict'; @@ -16863,7 +17040,7 @@ module.exports = { //Z_NULL: null // Use -1 or null inline, depending on var type }; -},{}],231:[function(_dereq_,module,exports){ +},{}],259:[function(_dereq_,module,exports){ 'use strict'; // Note: we can't get significant speed boost here. @@ -16906,7 +17083,7 @@ function crc32(crc, buf, len, pos) { module.exports = crc32; -},{}],232:[function(_dereq_,module,exports){ +},{}],260:[function(_dereq_,module,exports){ 'use strict'; var utils = _dereq_('../utils/common'); @@ -18273,9 +18450,16 @@ function deflateInit2(strm, level, method, windowBits, memLevel, strategy) { s.lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */ s.pending_buf_size = s.lit_bufsize * 4; + + //overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2); + //s->pending_buf = (uchf *) overlay; s.pending_buf = new utils.Buf8(s.pending_buf_size); - s.d_buf = s.lit_bufsize >> 1; + // It is offset from `s.pending_buf` (size is `s.lit_bufsize * 2`) + //s->d_buf = overlay + s->lit_bufsize/sizeof(ush); + s.d_buf = 1 * s.lit_bufsize; + + //s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize; s.l_buf = (1 + 2) * s.lit_bufsize; s.level = level; @@ -18756,7 +18940,7 @@ exports.deflatePrime = deflatePrime; exports.deflateTune = deflateTune; */ -},{"../utils/common":227,"./adler32":229,"./crc32":231,"./messages":237,"./trees":238}],233:[function(_dereq_,module,exports){ +},{"../utils/common":255,"./adler32":257,"./crc32":259,"./messages":265,"./trees":266}],261:[function(_dereq_,module,exports){ 'use strict'; @@ -18798,7 +18982,7 @@ function GZheader() { module.exports = GZheader; -},{}],234:[function(_dereq_,module,exports){ +},{}],262:[function(_dereq_,module,exports){ 'use strict'; // See state defs from inflate.js @@ -19126,7 +19310,7 @@ module.exports = function inflate_fast(strm, start) { return; }; -},{}],235:[function(_dereq_,module,exports){ +},{}],263:[function(_dereq_,module,exports){ 'use strict'; @@ -20666,7 +20850,7 @@ exports.inflateSyncPoint = inflateSyncPoint; exports.inflateUndermine = inflateUndermine; */ -},{"../utils/common":227,"./adler32":229,"./crc32":231,"./inffast":234,"./inftrees":236}],236:[function(_dereq_,module,exports){ +},{"../utils/common":255,"./adler32":257,"./crc32":259,"./inffast":262,"./inftrees":264}],264:[function(_dereq_,module,exports){ 'use strict'; @@ -20995,7 +21179,7 @@ module.exports = function inflate_table(type, lens, lens_index, codes, table, ta return 0; }; -},{"../utils/common":227}],237:[function(_dereq_,module,exports){ +},{"../utils/common":255}],265:[function(_dereq_,module,exports){ 'use strict'; module.exports = { @@ -21010,7 +21194,7 @@ module.exports = { '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */ }; -},{}],238:[function(_dereq_,module,exports){ +},{}],266:[function(_dereq_,module,exports){ 'use strict'; @@ -22214,7 +22398,7 @@ exports._tr_flush_block = _tr_flush_block; exports._tr_tally = _tr_tally; exports._tr_align = _tr_align; -},{"../utils/common":227}],239:[function(_dereq_,module,exports){ +},{"../utils/common":255}],267:[function(_dereq_,module,exports){ 'use strict'; @@ -22245,361 +22429,1293 @@ function ZStream() { module.exports = ZStream; -},{}],240:[function(_dereq_,module,exports){ -// a duplex stream is just a stream that is both readable and writable. -// Since JS doesn't have multiple prototypal inheritance, this class -// prototypally inherits from Readable, and then parasitically from -// Writable. - +},{}],268:[function(_dereq_,module,exports){ 'use strict'; -/**/ - -var objectKeys = Object.keys || function (obj) { - var keys = []; - for (var key in obj) { - keys.push(key); - }return keys; -}; -/**/ +// lightweight Buffer shim for pbf browser build +// based on code from github.com/feross/buffer (MIT-licensed) -module.exports = Duplex; +module.exports = Buffer; -/**/ -var processNextTick = _dereq_('process-nextick-args'); -/**/ +var ieee754 = _dereq_('ieee754'); -/**/ -var util = _dereq_('core-util-is'); -util.inherits = _dereq_('inherits'); -/**/ +var BufferMethods; -var Readable = _dereq_('./_stream_readable'); -var Writable = _dereq_('./_stream_writable'); +function Buffer(length) { + var arr; + if (length && length.length) { + arr = length; + length = arr.length; + } + var buf = new Uint8Array(length || 0); + if (arr) buf.set(arr); -util.inherits(Duplex, Readable); + buf.readUInt32LE = BufferMethods.readUInt32LE; + buf.writeUInt32LE = BufferMethods.writeUInt32LE; + buf.readInt32LE = BufferMethods.readInt32LE; + buf.writeInt32LE = BufferMethods.writeInt32LE; + buf.readFloatLE = BufferMethods.readFloatLE; + buf.writeFloatLE = BufferMethods.writeFloatLE; + buf.readDoubleLE = BufferMethods.readDoubleLE; + buf.writeDoubleLE = BufferMethods.writeDoubleLE; + buf.toString = BufferMethods.toString; + buf.write = BufferMethods.write; + buf.slice = BufferMethods.slice; + buf.copy = BufferMethods.copy; -var keys = objectKeys(Writable.prototype); -for (var v = 0; v < keys.length; v++) { - var method = keys[v]; - if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; + buf._isBuffer = true; + return buf; } -function Duplex(options) { - if (!(this instanceof Duplex)) return new Duplex(options); - - Readable.call(this, options); - Writable.call(this, options); - - if (options && options.readable === false) this.readable = false; +var lastStr, lastStrEncoded; - if (options && options.writable === false) this.writable = false; +BufferMethods = { + readUInt32LE: function(pos) { + return ((this[pos]) | + (this[pos + 1] << 8) | + (this[pos + 2] << 16)) + + (this[pos + 3] * 0x1000000); + }, - this.allowHalfOpen = true; - if (options && options.allowHalfOpen === false) this.allowHalfOpen = false; + writeUInt32LE: function(val, pos) { + this[pos] = val; + this[pos + 1] = (val >>> 8); + this[pos + 2] = (val >>> 16); + this[pos + 3] = (val >>> 24); + }, - this.once('end', onend); -} + readInt32LE: function(pos) { + return ((this[pos]) | + (this[pos + 1] << 8) | + (this[pos + 2] << 16)) + + (this[pos + 3] << 24); + }, -// the no-half-open enforcer -function onend() { - // if we allow half-open state, or if the writable side ended, - // then we're ok. - if (this.allowHalfOpen || this._writableState.ended) return; + readFloatLE: function(pos) { return ieee754.read(this, pos, true, 23, 4); }, + readDoubleLE: function(pos) { return ieee754.read(this, pos, true, 52, 8); }, - // no more data can be written. - // But allow more writes to happen in this tick. - processNextTick(onEndNT, this); -} + writeFloatLE: function(val, pos) { return ieee754.write(this, val, pos, true, 23, 4); }, + writeDoubleLE: function(val, pos) { return ieee754.write(this, val, pos, true, 52, 8); }, -function onEndNT(self) { - self.end(); -} + toString: function(encoding, start, end) { + var str = '', + tmp = ''; -function forEach(xs, f) { - for (var i = 0, l = xs.length; i < l; i++) { - f(xs[i], i); - } -} -},{"./_stream_readable":242,"./_stream_writable":244,"core-util-is":137,"inherits":160,"process-nextick-args":250}],241:[function(_dereq_,module,exports){ -// a passthrough stream. -// basically just the most minimal sort of Transform stream. -// Every written chunk gets output as-is. + start = start || 0; + end = Math.min(this.length, end || this.length); -'use strict'; + for (var i = start; i < end; i++) { + var ch = this[i]; + if (ch <= 0x7F) { + str += decodeURIComponent(tmp) + String.fromCharCode(ch); + tmp = ''; + } else { + tmp += '%' + ch.toString(16); + } + } -module.exports = PassThrough; + str += decodeURIComponent(tmp); -var Transform = _dereq_('./_stream_transform'); + return str; + }, -/**/ -var util = _dereq_('core-util-is'); -util.inherits = _dereq_('inherits'); -/**/ + write: function(str, pos) { + var bytes = str === lastStr ? lastStrEncoded : encodeString(str); + for (var i = 0; i < bytes.length; i++) { + this[pos + i] = bytes[i]; + } + }, -util.inherits(PassThrough, Transform); + slice: function(start, end) { + return this.subarray(start, end); + }, -function PassThrough(options) { - if (!(this instanceof PassThrough)) return new PassThrough(options); + copy: function(buf, pos) { + pos = pos || 0; + for (var i = 0; i < this.length; i++) { + buf[pos + i] = this[i]; + } + } +}; - Transform.call(this, options); -} +BufferMethods.writeInt32LE = BufferMethods.writeUInt32LE; -PassThrough.prototype._transform = function (chunk, encoding, cb) { - cb(null, chunk); +Buffer.byteLength = function(str) { + lastStr = str; + lastStrEncoded = encodeString(str); + return lastStrEncoded.length; }; -},{"./_stream_transform":243,"core-util-is":137,"inherits":160}],242:[function(_dereq_,module,exports){ -(function (process){ -'use strict'; - -module.exports = Readable; -/**/ -var processNextTick = _dereq_('process-nextick-args'); -/**/ +Buffer.isBuffer = function(buf) { + return !!(buf && buf._isBuffer); +}; -/**/ -var isArray = _dereq_('isarray'); -/**/ +function encodeString(str) { + var length = str.length, + bytes = []; -/**/ -var Buffer = _dereq_('buffer').Buffer; -/**/ + for (var i = 0, c, lead; i < length; i++) { + c = str.charCodeAt(i); // code point -Readable.ReadableState = ReadableState; + if (c > 0xD7FF && c < 0xE000) { -var EE = _dereq_('events'); + if (lead) { + if (c < 0xDC00) { + bytes.push(0xEF, 0xBF, 0xBD); + lead = c; + continue; -/**/ -var EElistenerCount = function (emitter, type) { - return emitter.listeners(type).length; -}; -/**/ + } else { + c = lead - 0xD800 << 10 | c - 0xDC00 | 0x10000; + lead = null; + } -/**/ -var Stream; -(function () { - try { - Stream = _dereq_('st' + 'ream'); - } catch (_) {} finally { - if (!Stream) Stream = _dereq_('events').EventEmitter; - } -})(); -/**/ + } else { + if (c > 0xDBFF || (i + 1 === length)) bytes.push(0xEF, 0xBF, 0xBD); + else lead = c; -var Buffer = _dereq_('buffer').Buffer; + continue; + } -/**/ -var util = _dereq_('core-util-is'); -util.inherits = _dereq_('inherits'); -/**/ + } else if (lead) { + bytes.push(0xEF, 0xBF, 0xBD); + lead = null; + } -/**/ -var debugUtil = _dereq_('util'); -var debug = undefined; -if (debugUtil && debugUtil.debuglog) { - debug = debugUtil.debuglog('stream'); -} else { - debug = function () {}; + if (c < 0x80) bytes.push(c); + else if (c < 0x800) bytes.push(c >> 0x6 | 0xC0, c & 0x3F | 0x80); + else if (c < 0x10000) bytes.push(c >> 0xC | 0xE0, c >> 0x6 & 0x3F | 0x80, c & 0x3F | 0x80); + else bytes.push(c >> 0x12 | 0xF0, c >> 0xC & 0x3F | 0x80, c >> 0x6 & 0x3F | 0x80, c & 0x3F | 0x80); + } + return bytes; } -/**/ - -var StringDecoder; -util.inherits(Readable, Stream); +},{"ieee754":186}],269:[function(_dereq_,module,exports){ +(function (global){ +'use strict'; -var Duplex; -function ReadableState(options, stream) { - Duplex = Duplex || _dereq_('./_stream_duplex'); +module.exports = Pbf; - options = options || {}; +var Buffer = global.Buffer || _dereq_('./buffer'); - // object stream flag. Used to make read(n) ignore n and to - // make all the buffer merging and length checks go away - this.objectMode = !!options.objectMode; +function Pbf(buf) { + this.buf = !Buffer.isBuffer(buf) ? new Buffer(buf || 0) : buf; + this.pos = 0; + this.length = this.buf.length; +} - if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.readableObjectMode; +Pbf.Varint = 0; // varint: int32, int64, uint32, uint64, sint32, sint64, bool, enum +Pbf.Fixed64 = 1; // 64-bit: double, fixed64, sfixed64 +Pbf.Bytes = 2; // length-delimited: string, bytes, embedded messages, packed repeated fields +Pbf.Fixed32 = 5; // 32-bit: float, fixed32, sfixed32 - // the point at which it stops calling _read() to fill the buffer - // Note: 0 is a valid value, means "don't call _read preemptively ever" - var hwm = options.highWaterMark; - var defaultHwm = this.objectMode ? 16 : 16 * 1024; - this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm; +var SHIFT_LEFT_32 = (1 << 16) * (1 << 16), + SHIFT_RIGHT_32 = 1 / SHIFT_LEFT_32, + POW_2_63 = Math.pow(2, 63); - // cast to ints. - this.highWaterMark = ~ ~this.highWaterMark; +Pbf.prototype = { - this.buffer = []; - this.length = 0; - this.pipes = null; - this.pipesCount = 0; - this.flowing = null; - this.ended = false; - this.endEmitted = false; - this.reading = false; + destroy: function() { + this.buf = null; + }, - // a flag to be able to tell if the onwrite cb is called immediately, - // or on a later tick. We set this to true at first, because any - // actions that shouldn't happen until "later" should generally also - // not happen before the first write call. - this.sync = true; + // === READING ================================================================= - // whenever we return null, then we set a flag to say - // that we're awaiting a 'readable' event emission. - this.needReadable = false; - this.emittedReadable = false; - this.readableListening = false; - this.resumeScheduled = false; + readFields: function(readField, result, end) { + end = end || this.length; - // Crypto is kind of old and crusty. Historically, its default string - // encoding is 'binary' so we have to make this configurable. - // Everything else in the universe uses 'utf8', though. - this.defaultEncoding = options.defaultEncoding || 'utf8'; + while (this.pos < end) { + var val = this.readVarint(), + tag = val >> 3, + startPos = this.pos; - // when piping, we only care about 'readable' events that happen - // after read()ing all the bytes and not getting any pushback. - this.ranOut = false; + readField(tag, result, this); - // the number of writers that are awaiting a drain event in .pipe()s - this.awaitDrain = 0; + if (this.pos === startPos) this.skip(val); + } + return result; + }, - // if true, a maybeReadMore has been scheduled - this.readingMore = false; + readMessage: function(readField, result) { + return this.readFields(readField, result, this.readVarint() + this.pos); + }, - this.decoder = null; - this.encoding = null; - if (options.encoding) { - if (!StringDecoder) StringDecoder = _dereq_('string_decoder/').StringDecoder; - this.decoder = new StringDecoder(options.encoding); - this.encoding = options.encoding; - } -} + readFixed32: function() { + var val = this.buf.readUInt32LE(this.pos); + this.pos += 4; + return val; + }, -var Duplex; -function Readable(options) { - Duplex = Duplex || _dereq_('./_stream_duplex'); + readSFixed32: function() { + var val = this.buf.readInt32LE(this.pos); + this.pos += 4; + return val; + }, - if (!(this instanceof Readable)) return new Readable(options); + // 64-bit int handling is based on github.com/dpw/node-buffer-more-ints (MIT-licensed) - this._readableState = new ReadableState(options, this); + readFixed64: function() { + var val = this.buf.readUInt32LE(this.pos) + this.buf.readUInt32LE(this.pos + 4) * SHIFT_LEFT_32; + this.pos += 8; + return val; + }, - // legacy - this.readable = true; + readSFixed64: function() { + var val = this.buf.readUInt32LE(this.pos) + this.buf.readInt32LE(this.pos + 4) * SHIFT_LEFT_32; + this.pos += 8; + return val; + }, - if (options && typeof options.read === 'function') this._read = options.read; + readFloat: function() { + var val = this.buf.readFloatLE(this.pos); + this.pos += 4; + return val; + }, - Stream.call(this); -} + readDouble: function() { + var val = this.buf.readDoubleLE(this.pos); + this.pos += 8; + return val; + }, -// Manually shove something into the read() buffer. -// This returns true if the highWaterMark has not been hit yet, -// similar to how Writable.write() returns true if you should -// write() some more. -Readable.prototype.push = function (chunk, encoding) { - var state = this._readableState; + readVarint: function() { + var buf = this.buf, + val, b, b0, b1, b2, b3; - if (!state.objectMode && typeof chunk === 'string') { - encoding = encoding || state.defaultEncoding; - if (encoding !== state.encoding) { - chunk = new Buffer(chunk, encoding); - encoding = ''; - } - } + b0 = buf[this.pos++]; if (b0 < 0x80) return b0; b0 = b0 & 0x7f; + b1 = buf[this.pos++]; if (b1 < 0x80) return b0 | b1 << 7; b1 = (b1 & 0x7f) << 7; + b2 = buf[this.pos++]; if (b2 < 0x80) return b0 | b1 | b2 << 14; b2 = (b2 & 0x7f) << 14; + b3 = buf[this.pos++]; if (b3 < 0x80) return b0 | b1 | b2 | b3 << 21; - return readableAddChunk(this, state, chunk, encoding, false); -}; + val = b0 | b1 | b2 | (b3 & 0x7f) << 21; -// Unshift should *always* be something directly out of read() -Readable.prototype.unshift = function (chunk) { - var state = this._readableState; - return readableAddChunk(this, state, chunk, '', true); -}; + b = buf[this.pos++]; val += (b & 0x7f) * 0x10000000; if (b < 0x80) return val; + b = buf[this.pos++]; val += (b & 0x7f) * 0x800000000; if (b < 0x80) return val; + b = buf[this.pos++]; val += (b & 0x7f) * 0x40000000000; if (b < 0x80) return val; + b = buf[this.pos++]; val += (b & 0x7f) * 0x2000000000000; if (b < 0x80) return val; + b = buf[this.pos++]; val += (b & 0x7f) * 0x100000000000000; if (b < 0x80) return val; + b = buf[this.pos++]; val += (b & 0x7f) * 0x8000000000000000; if (b < 0x80) return val; -Readable.prototype.isPaused = function () { - return this._readableState.flowing === false; -}; + throw new Error('Expected varint not more than 10 bytes'); + }, -function readableAddChunk(stream, state, chunk, encoding, addToFront) { - var er = chunkInvalid(state, chunk); - if (er) { - stream.emit('error', er); - } else if (chunk === null) { - state.reading = false; - onEofChunk(stream, state); - } else if (state.objectMode || chunk && chunk.length > 0) { - if (state.ended && !addToFront) { - var e = new Error('stream.push() after EOF'); - stream.emit('error', e); - } else if (state.endEmitted && addToFront) { - var e = new Error('stream.unshift() after end event'); - stream.emit('error', e); - } else { - var skipAdd; - if (state.decoder && !addToFront && !encoding) { - chunk = state.decoder.write(chunk); - skipAdd = !state.objectMode && chunk.length === 0; - } + readVarint64: function() { + var startPos = this.pos, + val = this.readVarint(); - if (!addToFront) state.reading = false; + if (val < POW_2_63) return val; - // Don't add to the buffer if we've decoded to an empty string chunk and - // we're not in object mode - if (!skipAdd) { - // if we want the data now, just emit it. - if (state.flowing && state.length === 0 && !state.sync) { - stream.emit('data', chunk); - stream.read(0); - } else { - // update the buffer info. - state.length += state.objectMode ? 1 : chunk.length; - if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); + var pos = this.pos - 2; + while (this.buf[pos] === 0xff) pos--; + if (pos < startPos) pos = startPos; - if (state.needReadable) emitReadable(stream); + val = 0; + for (var i = 0; i < pos - startPos + 1; i++) { + var b = ~this.buf[startPos + i] & 0x7f; + val += i < 4 ? b << i * 7 : b * Math.pow(2, i * 7); } - } - maybeReadMore(stream, state); - } - } else if (!addToFront) { - state.reading = false; - } + return -val - 1; + }, - return needMoreData(state); -} + readSVarint: function() { + var num = this.readVarint(); + return num % 2 === 1 ? (num + 1) / -2 : num / 2; // zigzag encoding + }, -// if it's past the high water mark, we can push in some more. -// Also, if we have no data yet, we can stand some -// more bytes. This is to work around cases where hwm=0, -// such as the repl. Also, if the push() triggered a -// readable event, and the user called read(largeNumber) such that -// needReadable was set, then we ought to push more, so that another -// 'readable' event will be triggered. -function needMoreData(state) { - return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0); -} + readBoolean: function() { + return Boolean(this.readVarint()); + }, -// backwards compatibility. -Readable.prototype.setEncoding = function (enc) { - if (!StringDecoder) StringDecoder = _dereq_('string_decoder/').StringDecoder; - this._readableState.decoder = new StringDecoder(enc); - this._readableState.encoding = enc; - return this; -}; + readString: function() { + var end = this.readVarint() + this.pos, + str = this.buf.toString('utf8', this.pos, end); + this.pos = end; + return str; + }, -// Don't raise the hwm > 8MB -var MAX_HWM = 0x800000; -function computeNewHighWaterMark(n) { - if (n >= MAX_HWM) { - n = MAX_HWM; - } else { - // Get the next highest power of 2 - n--; - n |= n >>> 1; - n |= n >>> 2; - n |= n >>> 4; - n |= n >>> 8; - n |= n >>> 16; - n++; + readBytes: function() { + var end = this.readVarint() + this.pos, + buffer = this.buf.slice(this.pos, end); + this.pos = end; + return buffer; + }, + + // verbose for performance reasons; doesn't affect gzipped size + + readPackedVarint: function() { + var end = this.readVarint() + this.pos, arr = []; + while (this.pos < end) arr.push(this.readVarint()); + return arr; + }, + readPackedSVarint: function() { + var end = this.readVarint() + this.pos, arr = []; + while (this.pos < end) arr.push(this.readSVarint()); + return arr; + }, + readPackedBoolean: function() { + var end = this.readVarint() + this.pos, arr = []; + while (this.pos < end) arr.push(this.readBoolean()); + return arr; + }, + readPackedFloat: function() { + var end = this.readVarint() + this.pos, arr = []; + while (this.pos < end) arr.push(this.readFloat()); + return arr; + }, + readPackedDouble: function() { + var end = this.readVarint() + this.pos, arr = []; + while (this.pos < end) arr.push(this.readDouble()); + return arr; + }, + readPackedFixed32: function() { + var end = this.readVarint() + this.pos, arr = []; + while (this.pos < end) arr.push(this.readFixed32()); + return arr; + }, + readPackedSFixed32: function() { + var end = this.readVarint() + this.pos, arr = []; + while (this.pos < end) arr.push(this.readSFixed32()); + return arr; + }, + readPackedFixed64: function() { + var end = this.readVarint() + this.pos, arr = []; + while (this.pos < end) arr.push(this.readFixed64()); + return arr; + }, + readPackedSFixed64: function() { + var end = this.readVarint() + this.pos, arr = []; + while (this.pos < end) arr.push(this.readSFixed64()); + return arr; + }, + + skip: function(val) { + var type = val & 0x7; + if (type === Pbf.Varint) while (this.buf[this.pos++] > 0x7f) {} + else if (type === Pbf.Bytes) this.pos = this.readVarint() + this.pos; + else if (type === Pbf.Fixed32) this.pos += 4; + else if (type === Pbf.Fixed64) this.pos += 8; + else throw new Error('Unimplemented type: ' + type); + }, + + // === WRITING ================================================================= + + writeTag: function(tag, type) { + this.writeVarint((tag << 3) | type); + }, + + realloc: function(min) { + var length = this.length || 16; + + while (length < this.pos + min) length *= 2; + + if (length !== this.length) { + var buf = new Buffer(length); + this.buf.copy(buf); + this.buf = buf; + this.length = length; + } + }, + + finish: function() { + this.length = this.pos; + this.pos = 0; + return this.buf.slice(0, this.length); + }, + + writeFixed32: function(val) { + this.realloc(4); + this.buf.writeUInt32LE(val, this.pos); + this.pos += 4; + }, + + writeSFixed32: function(val) { + this.realloc(4); + this.buf.writeInt32LE(val, this.pos); + this.pos += 4; + }, + + writeFixed64: function(val) { + this.realloc(8); + this.buf.writeInt32LE(val & -1, this.pos); + this.buf.writeUInt32LE(Math.floor(val * SHIFT_RIGHT_32), this.pos + 4); + this.pos += 8; + }, + + writeSFixed64: function(val) { + this.realloc(8); + this.buf.writeInt32LE(val & -1, this.pos); + this.buf.writeInt32LE(Math.floor(val * SHIFT_RIGHT_32), this.pos + 4); + this.pos += 8; + }, + + writeVarint: function(val) { + val = +val; + + if (val <= 0x7f) { + this.realloc(1); + this.buf[this.pos++] = val; + + } else if (val <= 0x3fff) { + this.realloc(2); + this.buf[this.pos++] = ((val >>> 0) & 0x7f) | 0x80; + this.buf[this.pos++] = ((val >>> 7) & 0x7f); + + } else if (val <= 0x1fffff) { + this.realloc(3); + this.buf[this.pos++] = ((val >>> 0) & 0x7f) | 0x80; + this.buf[this.pos++] = ((val >>> 7) & 0x7f) | 0x80; + this.buf[this.pos++] = ((val >>> 14) & 0x7f); + + } else if (val <= 0xfffffff) { + this.realloc(4); + this.buf[this.pos++] = ((val >>> 0) & 0x7f) | 0x80; + this.buf[this.pos++] = ((val >>> 7) & 0x7f) | 0x80; + this.buf[this.pos++] = ((val >>> 14) & 0x7f) | 0x80; + this.buf[this.pos++] = ((val >>> 21) & 0x7f); + + } else { + var pos = this.pos; + while (val >= 0x80) { + this.realloc(1); + this.buf[this.pos++] = (val & 0xff) | 0x80; + val /= 0x80; + } + this.realloc(1); + this.buf[this.pos++] = val | 0; + if (this.pos - pos > 10) throw new Error('Given varint doesn\'t fit into 10 bytes'); + } + }, + + writeSVarint: function(val) { + this.writeVarint(val < 0 ? -val * 2 - 1 : val * 2); + }, + + writeBoolean: function(val) { + this.writeVarint(Boolean(val)); + }, + + writeString: function(str) { + str = String(str); + var bytes = Buffer.byteLength(str); + this.writeVarint(bytes); + this.realloc(bytes); + this.buf.write(str, this.pos); + this.pos += bytes; + }, + + writeFloat: function(val) { + this.realloc(4); + this.buf.writeFloatLE(val, this.pos); + this.pos += 4; + }, + + writeDouble: function(val) { + this.realloc(8); + this.buf.writeDoubleLE(val, this.pos); + this.pos += 8; + }, + + writeBytes: function(buffer) { + var len = buffer.length; + this.writeVarint(len); + this.realloc(len); + for (var i = 0; i < len; i++) this.buf[this.pos++] = buffer[i]; + }, + + writeMessage: function(tag, fn, obj) { + this.writeTag(tag, Pbf.Bytes); + + this.pos++; // reserve 1 byte for short message length + + // write the message directly to the buffer and see how much was written + var startPos = this.pos; + fn(obj, this); + var len = this.pos - startPos; + + var varintLen = + len <= 0x7f ? 1 : + len <= 0x3fff ? 2 : + len <= 0x1fffff ? 3 : + len <= 0xfffffff ? 4 : Math.ceil(Math.log(len) / (Math.LN2 * 7)); + + // if 1 byte isn't enough for encoding message length, shift the data to the right + if (varintLen > 1) { + this.realloc(varintLen - 1); + for (var i = this.pos - 1; i >= startPos; i--) this.buf[i + varintLen - 1] = this.buf[i]; + } + + // finally, write the message length in the reserved place and restore the position + this.pos = startPos - 1; + this.writeVarint(len); + this.pos += len; + }, + + writePackedVarint: function(tag, arr) { this.writeMessage(tag, writePackedVarint, arr); }, + writePackedSVarint: function(tag, arr) { this.writeMessage(tag, writePackedSVarint, arr); }, + writePackedBoolean: function(tag, arr) { this.writeMessage(tag, writePackedBoolean, arr); }, + writePackedFloat: function(tag, arr) { this.writeMessage(tag, writePackedFloat, arr); }, + writePackedDouble: function(tag, arr) { this.writeMessage(tag, writePackedDouble, arr); }, + writePackedFixed32: function(tag, arr) { this.writeMessage(tag, writePackedFixed32, arr); }, + writePackedSFixed32: function(tag, arr) { this.writeMessage(tag, writePackedSFixed32, arr); }, + writePackedFixed64: function(tag, arr) { this.writeMessage(tag, writePackedFixed64, arr); }, + writePackedSFixed64: function(tag, arr) { this.writeMessage(tag, writePackedSFixed64, arr); }, + + writeBytesField: function(tag, buffer) { + this.writeTag(tag, Pbf.Bytes); + this.writeBytes(buffer); + }, + writeFixed32Field: function(tag, val) { + this.writeTag(tag, Pbf.Fixed32); + this.writeFixed32(val); + }, + writeSFixed32Field: function(tag, val) { + this.writeTag(tag, Pbf.Fixed32); + this.writeSFixed32(val); + }, + writeFixed64Field: function(tag, val) { + this.writeTag(tag, Pbf.Fixed64); + this.writeFixed64(val); + }, + writeSFixed64Field: function(tag, val) { + this.writeTag(tag, Pbf.Fixed64); + this.writeSFixed64(val); + }, + writeVarintField: function(tag, val) { + this.writeTag(tag, Pbf.Varint); + this.writeVarint(val); + }, + writeSVarintField: function(tag, val) { + this.writeTag(tag, Pbf.Varint); + this.writeSVarint(val); + }, + writeStringField: function(tag, str) { + this.writeTag(tag, Pbf.Bytes); + this.writeString(str); + }, + writeFloatField: function(tag, val) { + this.writeTag(tag, Pbf.Fixed32); + this.writeFloat(val); + }, + writeDoubleField: function(tag, val) { + this.writeTag(tag, Pbf.Fixed64); + this.writeDouble(val); + }, + writeBooleanField: function(tag, val) { + this.writeVarintField(tag, Boolean(val)); + } +}; + +function writePackedVarint(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeVarint(arr[i]); } +function writePackedSVarint(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSVarint(arr[i]); } +function writePackedFloat(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFloat(arr[i]); } +function writePackedDouble(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeDouble(arr[i]); } +function writePackedBoolean(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeBoolean(arr[i]); } +function writePackedFixed32(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFixed32(arr[i]); } +function writePackedSFixed32(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSFixed32(arr[i]); } +function writePackedFixed64(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFixed64(arr[i]); } +function writePackedSFixed64(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSFixed64(arr[i]); } + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) + +},{"./buffer":268}],270:[function(_dereq_,module,exports){ +'use strict'; + +module.exports = Point; + +function Point(x, y) { + this.x = x; + this.y = y; +} + +Point.prototype = { + clone: function() { return new Point(this.x, this.y); }, + + add: function(p) { return this.clone()._add(p); }, + sub: function(p) { return this.clone()._sub(p); }, + mult: function(k) { return this.clone()._mult(k); }, + div: function(k) { return this.clone()._div(k); }, + rotate: function(a) { return this.clone()._rotate(a); }, + matMult: function(m) { return this.clone()._matMult(m); }, + unit: function() { return this.clone()._unit(); }, + perp: function() { return this.clone()._perp(); }, + round: function() { return this.clone()._round(); }, + + mag: function() { + return Math.sqrt(this.x * this.x + this.y * this.y); + }, + + equals: function(p) { + return this.x === p.x && + this.y === p.y; + }, + + dist: function(p) { + return Math.sqrt(this.distSqr(p)); + }, + + distSqr: function(p) { + var dx = p.x - this.x, + dy = p.y - this.y; + return dx * dx + dy * dy; + }, + + angle: function() { + return Math.atan2(this.y, this.x); + }, + + angleTo: function(b) { + return Math.atan2(this.y - b.y, this.x - b.x); + }, + + angleWith: function(b) { + return this.angleWithSep(b.x, b.y); + }, + + // Find the angle of the two vectors, solving the formula for the cross product a x b = |a||b|sin(θ) for θ. + angleWithSep: function(x, y) { + return Math.atan2( + this.x * y - this.y * x, + this.x * x + this.y * y); + }, + + _matMult: function(m) { + var x = m[0] * this.x + m[1] * this.y, + y = m[2] * this.x + m[3] * this.y; + this.x = x; + this.y = y; + return this; + }, + + _add: function(p) { + this.x += p.x; + this.y += p.y; + return this; + }, + + _sub: function(p) { + this.x -= p.x; + this.y -= p.y; + return this; + }, + + _mult: function(k) { + this.x *= k; + this.y *= k; + return this; + }, + + _div: function(k) { + this.x /= k; + this.y /= k; + return this; + }, + + _unit: function() { + this._div(this.mag()); + return this; + }, + + _perp: function() { + var y = this.y; + this.y = this.x; + this.x = -y; + return this; + }, + + _rotate: function(angle) { + var cos = Math.cos(angle), + sin = Math.sin(angle), + x = cos * this.x - sin * this.y, + y = sin * this.x + cos * this.y; + this.x = x; + this.y = y; + return this; + }, + + _round: function() { + this.x = Math.round(this.x); + this.y = Math.round(this.y); + return this; + } +}; + +// constructs Point from an array if necessary +Point.convert = function (a) { + if (a instanceof Point) { + return a; + } + if (Array.isArray(a)) { + return new Point(a[0], a[1]); + } + return a; +}; + +},{}],271:[function(_dereq_,module,exports){ +(function (process){ +'use strict'; + +if (!process.version || + process.version.indexOf('v0.') === 0 || + process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) { + module.exports = nextTick; +} else { + module.exports = process.nextTick; +} + +function nextTick(fn, arg1, arg2, arg3) { + if (typeof fn !== 'function') { + throw new TypeError('"callback" argument must be a function'); + } + var len = arguments.length; + var args, i; + switch (len) { + case 0: + case 1: + return process.nextTick(fn); + case 2: + return process.nextTick(function afterTickOne() { + fn.call(null, arg1); + }); + case 3: + return process.nextTick(function afterTickTwo() { + fn.call(null, arg1, arg2); + }); + case 4: + return process.nextTick(function afterTickThree() { + fn.call(null, arg1, arg2, arg3); + }); + default: + args = new Array(len - 1); + i = 0; + while (i < args.length) { + args[i++] = arguments[i]; + } + return process.nextTick(function afterTick() { + fn.apply(null, args); + }); + } +} + +}).call(this,_dereq_('_process')) + +},{"_process":272}],272:[function(_dereq_,module,exports){ +// shim for using process in browser +var process = module.exports = {}; + +// cached from whatever global is present so that test runners that stub it +// don't break things. But we need to wrap it in a try catch in case it is +// wrapped in strict mode code which doesn't define any globals. It's inside a +// function because try/catches deoptimize in certain engines. + +var cachedSetTimeout; +var cachedClearTimeout; + +(function () { + try { + cachedSetTimeout = setTimeout; + } catch (e) { + cachedSetTimeout = function () { + throw new Error('setTimeout is not defined'); + } + } + try { + cachedClearTimeout = clearTimeout; + } catch (e) { + cachedClearTimeout = function () { + throw new Error('clearTimeout is not defined'); + } + } +} ()) +function runTimeout(fun) { + if (cachedSetTimeout === setTimeout) { + //normal enviroments in sane situations + return setTimeout(fun, 0); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedSetTimeout(fun, 0); + } catch(e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedSetTimeout.call(null, fun, 0); + } catch(e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error + return cachedSetTimeout.call(this, fun, 0); + } + } + + +} +function runClearTimeout(marker) { + if (cachedClearTimeout === clearTimeout) { + //normal enviroments in sane situations + return clearTimeout(marker); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedClearTimeout(marker); + } catch (e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedClearTimeout.call(null, marker); + } catch (e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. + // Some versions of I.E. have different rules for clearTimeout vs setTimeout + return cachedClearTimeout.call(this, marker); + } + } + + + +} +var queue = []; +var draining = false; +var currentQueue; +var queueIndex = -1; + +function cleanUpNextTick() { + if (!draining || !currentQueue) { + return; + } + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + drainQueue(); + } +} + +function drainQueue() { + if (draining) { + return; + } + var timeout = runTimeout(cleanUpNextTick); + draining = true; + + var len = queue.length; + while(len) { + currentQueue = queue; + queue = []; + while (++queueIndex < len) { + if (currentQueue) { + currentQueue[queueIndex].run(); + } + } + queueIndex = -1; + len = queue.length; + } + currentQueue = null; + draining = false; + runClearTimeout(timeout); +} + +process.nextTick = function (fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } +}; + +// v8 likes predictible objects +function Item(fun, array) { + this.fun = fun; + this.array = array; +} +Item.prototype.run = function () { + this.fun.apply(null, this.array); +}; +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; +process.version = ''; // empty string to avoid regexp issues +process.versions = {}; + +function noop() {} + +process.on = noop; +process.addListener = noop; +process.once = noop; +process.off = noop; +process.removeListener = noop; +process.removeAllListeners = noop; +process.emit = noop; + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +}; + +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; +process.umask = function() { return 0; }; + +},{}],273:[function(_dereq_,module,exports){ +// a duplex stream is just a stream that is both readable and writable. +// Since JS doesn't have multiple prototypal inheritance, this class +// prototypally inherits from Readable, and then parasitically from +// Writable. + +'use strict'; + +/**/ + +var objectKeys = Object.keys || function (obj) { + var keys = []; + for (var key in obj) { + keys.push(key); + }return keys; +}; +/**/ + +module.exports = Duplex; + +/**/ +var processNextTick = _dereq_('process-nextick-args'); +/**/ + +/**/ +var util = _dereq_('core-util-is'); +util.inherits = _dereq_('inherits'); +/**/ + +var Readable = _dereq_('./_stream_readable'); +var Writable = _dereq_('./_stream_writable'); + +util.inherits(Duplex, Readable); + +var keys = objectKeys(Writable.prototype); +for (var v = 0; v < keys.length; v++) { + var method = keys[v]; + if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; +} + +function Duplex(options) { + if (!(this instanceof Duplex)) return new Duplex(options); + + Readable.call(this, options); + Writable.call(this, options); + + if (options && options.readable === false) this.readable = false; + + if (options && options.writable === false) this.writable = false; + + this.allowHalfOpen = true; + if (options && options.allowHalfOpen === false) this.allowHalfOpen = false; + + this.once('end', onend); +} + +// the no-half-open enforcer +function onend() { + // if we allow half-open state, or if the writable side ended, + // then we're ok. + if (this.allowHalfOpen || this._writableState.ended) return; + + // no more data can be written. + // But allow more writes to happen in this tick. + processNextTick(onEndNT, this); +} + +function onEndNT(self) { + self.end(); +} + +function forEach(xs, f) { + for (var i = 0, l = xs.length; i < l; i++) { + f(xs[i], i); + } +} +},{"./_stream_readable":275,"./_stream_writable":277,"core-util-is":164,"inherits":187,"process-nextick-args":271}],274:[function(_dereq_,module,exports){ +// a passthrough stream. +// basically just the most minimal sort of Transform stream. +// Every written chunk gets output as-is. + +'use strict'; + +module.exports = PassThrough; + +var Transform = _dereq_('./_stream_transform'); + +/**/ +var util = _dereq_('core-util-is'); +util.inherits = _dereq_('inherits'); +/**/ + +util.inherits(PassThrough, Transform); + +function PassThrough(options) { + if (!(this instanceof PassThrough)) return new PassThrough(options); + + Transform.call(this, options); +} + +PassThrough.prototype._transform = function (chunk, encoding, cb) { + cb(null, chunk); +}; +},{"./_stream_transform":276,"core-util-is":164,"inherits":187}],275:[function(_dereq_,module,exports){ +(function (process){ +'use strict'; + +module.exports = Readable; + +/**/ +var processNextTick = _dereq_('process-nextick-args'); +/**/ + +/**/ +var isArray = _dereq_('isarray'); +/**/ + +/**/ +var Buffer = _dereq_('buffer').Buffer; +/**/ + +Readable.ReadableState = ReadableState; + +var EE = _dereq_('events'); + +/**/ +var EElistenerCount = function (emitter, type) { + return emitter.listeners(type).length; +}; +/**/ + +/**/ +var Stream; +(function () { + try { + Stream = _dereq_('st' + 'ream'); + } catch (_) {} finally { + if (!Stream) Stream = _dereq_('events').EventEmitter; + } +})(); +/**/ + +var Buffer = _dereq_('buffer').Buffer; + +/**/ +var util = _dereq_('core-util-is'); +util.inherits = _dereq_('inherits'); +/**/ + +/**/ +var debugUtil = _dereq_('util'); +var debug = undefined; +if (debugUtil && debugUtil.debuglog) { + debug = debugUtil.debuglog('stream'); +} else { + debug = function () {}; +} +/**/ + +var StringDecoder; + +util.inherits(Readable, Stream); + +var Duplex; +function ReadableState(options, stream) { + Duplex = Duplex || _dereq_('./_stream_duplex'); + + options = options || {}; + + // object stream flag. Used to make read(n) ignore n and to + // make all the buffer merging and length checks go away + this.objectMode = !!options.objectMode; + + if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.readableObjectMode; + + // the point at which it stops calling _read() to fill the buffer + // Note: 0 is a valid value, means "don't call _read preemptively ever" + var hwm = options.highWaterMark; + var defaultHwm = this.objectMode ? 16 : 16 * 1024; + this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm; + + // cast to ints. + this.highWaterMark = ~ ~this.highWaterMark; + + this.buffer = []; + this.length = 0; + this.pipes = null; + this.pipesCount = 0; + this.flowing = null; + this.ended = false; + this.endEmitted = false; + this.reading = false; + + // a flag to be able to tell if the onwrite cb is called immediately, + // or on a later tick. We set this to true at first, because any + // actions that shouldn't happen until "later" should generally also + // not happen before the first write call. + this.sync = true; + + // whenever we return null, then we set a flag to say + // that we're awaiting a 'readable' event emission. + this.needReadable = false; + this.emittedReadable = false; + this.readableListening = false; + this.resumeScheduled = false; + + // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + this.defaultEncoding = options.defaultEncoding || 'utf8'; + + // when piping, we only care about 'readable' events that happen + // after read()ing all the bytes and not getting any pushback. + this.ranOut = false; + + // the number of writers that are awaiting a drain event in .pipe()s + this.awaitDrain = 0; + + // if true, a maybeReadMore has been scheduled + this.readingMore = false; + + this.decoder = null; + this.encoding = null; + if (options.encoding) { + if (!StringDecoder) StringDecoder = _dereq_('string_decoder/').StringDecoder; + this.decoder = new StringDecoder(options.encoding); + this.encoding = options.encoding; + } +} + +var Duplex; +function Readable(options) { + Duplex = Duplex || _dereq_('./_stream_duplex'); + + if (!(this instanceof Readable)) return new Readable(options); + + this._readableState = new ReadableState(options, this); + + // legacy + this.readable = true; + + if (options && typeof options.read === 'function') this._read = options.read; + + Stream.call(this); +} + +// Manually shove something into the read() buffer. +// This returns true if the highWaterMark has not been hit yet, +// similar to how Writable.write() returns true if you should +// write() some more. +Readable.prototype.push = function (chunk, encoding) { + var state = this._readableState; + + if (!state.objectMode && typeof chunk === 'string') { + encoding = encoding || state.defaultEncoding; + if (encoding !== state.encoding) { + chunk = new Buffer(chunk, encoding); + encoding = ''; + } + } + + return readableAddChunk(this, state, chunk, encoding, false); +}; + +// Unshift should *always* be something directly out of read() +Readable.prototype.unshift = function (chunk) { + var state = this._readableState; + return readableAddChunk(this, state, chunk, '', true); +}; + +Readable.prototype.isPaused = function () { + return this._readableState.flowing === false; +}; + +function readableAddChunk(stream, state, chunk, encoding, addToFront) { + var er = chunkInvalid(state, chunk); + if (er) { + stream.emit('error', er); + } else if (chunk === null) { + state.reading = false; + onEofChunk(stream, state); + } else if (state.objectMode || chunk && chunk.length > 0) { + if (state.ended && !addToFront) { + var e = new Error('stream.push() after EOF'); + stream.emit('error', e); + } else if (state.endEmitted && addToFront) { + var e = new Error('stream.unshift() after end event'); + stream.emit('error', e); + } else { + var skipAdd; + if (state.decoder && !addToFront && !encoding) { + chunk = state.decoder.write(chunk); + skipAdd = !state.objectMode && chunk.length === 0; + } + + if (!addToFront) state.reading = false; + + // Don't add to the buffer if we've decoded to an empty string chunk and + // we're not in object mode + if (!skipAdd) { + // if we want the data now, just emit it. + if (state.flowing && state.length === 0 && !state.sync) { + stream.emit('data', chunk); + stream.read(0); + } else { + // update the buffer info. + state.length += state.objectMode ? 1 : chunk.length; + if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); + + if (state.needReadable) emitReadable(stream); + } + } + + maybeReadMore(stream, state); + } + } else if (!addToFront) { + state.reading = false; + } + + return needMoreData(state); +} + +// if it's past the high water mark, we can push in some more. +// Also, if we have no data yet, we can stand some +// more bytes. This is to work around cases where hwm=0, +// such as the repl. Also, if the push() triggered a +// readable event, and the user called read(largeNumber) such that +// needReadable was set, then we ought to push more, so that another +// 'readable' event will be triggered. +function needMoreData(state) { + return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0); +} + +// backwards compatibility. +Readable.prototype.setEncoding = function (enc) { + if (!StringDecoder) StringDecoder = _dereq_('string_decoder/').StringDecoder; + this._readableState.decoder = new StringDecoder(enc); + this._readableState.encoding = enc; + return this; +}; + +// Don't raise the hwm > 8MB +var MAX_HWM = 0x800000; +function computeNewHighWaterMark(n) { + if (n >= MAX_HWM) { + n = MAX_HWM; + } else { + // Get the next highest power of 2 + n--; + n |= n >>> 1; + n |= n >>> 2; + n |= n >>> 4; + n |= n >>> 8; + n |= n >>> 16; + n++; } return n; } @@ -23231,8 +24347,8 @@ function indexOf(xs, x) { return -1; } }).call(this,_dereq_('_process')) -//# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9qc3ppcC9ub2RlX21vZHVsZXMvcmVhZGFibGUtc3RyZWFtL2xpYi9fc3RyZWFtX3JlYWRhYmxlLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQ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gaGFwcGVuLlxuICBpZiAoc3RhdGUubGVuZ3RoID4gMCkgdGhyb3cgbmV3IEVycm9yKCdlbmRSZWFkYWJsZSBjYWxsZWQgb24gbm9uLWVtcHR5IHN0cmVhbScpO1xuXG4gIGlmICghc3RhdGUuZW5kRW1pdHRlZCkge1xuICAgIHN0YXRlLmVuZGVkID0gdHJ1ZTtcbiAgICBwcm9jZXNzTmV4dFRpY2soZW5kUmVhZGFibGVOVCwgc3RhdGUsIHN0cmVhbSk7XG4gIH1cbn1cblxuZnVuY3Rpb24gZW5kUmVhZGFibGVOVChzdGF0ZSwgc3RyZWFtKSB7XG4gIC8vIENoZWNrIHRoYXQgd2UgZGlkbid0IGdldCBvbmUgbGFzdCB1bnNoaWZ0LlxuICBpZiAoIXN0YXRlLmVuZEVtaXR0ZWQgJiYgc3RhdGUubGVuZ3RoID09PSAwKSB7XG4gICAgc3RhdGUuZW5kRW1pdHRlZCA9IHRydWU7XG4gICAgc3RyZWFtLnJlYWRhYmxlID0gZmFsc2U7XG4gICAgc3RyZWFtLmVtaXQoJ2VuZCcpO1xuICB9XG59XG5cbmZ1bmN0aW9uIGZvckVhY2goeHMsIGYpIHtcbiAgZm9yICh2YXIgaSA9IDAsIGwgPSB4cy5sZW5ndGg7IGkgPCBsOyBpKyspIHtcbiAgICBmKHhzW2ldLCBpKTtcbiAgfVxufVxuXG5mdW5jdGlvbiBpbmRleE9mKHhzLCB4KSB7XG4gIGZvciAodmFyIGkgPSAwLCBsID0geHMubGVuZ3RoOyBpIDwgbDsgaSsrKSB7XG4gICAgaWYgKHhzW2ldID09PSB4KSByZXR1cm4gaTtcbiAgfVxuICByZXR1cm4gLTE7XG59Il19 -},{"./_stream_duplex":240,"_process":251,"buffer":41,"core-util-is":137,"events":141,"inherits":160,"isarray":223,"process-nextick-args":250,"string_decoder/":252,"util":40}],243:[function(_dereq_,module,exports){ + +},{"./_stream_duplex":273,"_process":272,"buffer":41,"core-util-is":164,"events":168,"inherits":187,"isarray":189,"process-nextick-args":271,"string_decoder/":281,"util":40}],276:[function(_dereq_,module,exports){ // a transform stream is a readable/writable stream where you do // something with the data. Sometimes it's called a "filter", // but that's not a great name for it, since that implies a thing where @@ -23413,7 +24529,7 @@ function done(stream, er) { return stream.push(null); } -},{"./_stream_duplex":240,"core-util-is":137,"inherits":160}],244:[function(_dereq_,module,exports){ +},{"./_stream_duplex":273,"core-util-is":164,"inherits":187}],277:[function(_dereq_,module,exports){ (function (process){ // A bit simpler than readable streams. // Implement an async ._write(chunk, encoding, cb), and it'll handle all @@ -23932,8 +25048,8 @@ function CorkedRequest(state) { }; } }).call(this,_dereq_('_process')) -//# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9qc3ppcC9ub2RlX21vZHVsZXMvcmVhZGFibGUtc3RyZWFtL2xpYi9fc3RyZWFtX3dyaXRhYmxlLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7Q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7XG4gICAgICBzdGF0ZS5jb3JrZWRSZXF1ZXN0c0ZyZWUubmV4dCA9IF90aGlzO1xuICAgIH0gZWxzZSB7XG4gICAgICBzdGF0ZS5jb3JrZWRSZXF1ZXN0c0ZyZWUgPSBfdGhpcztcbiAgICB9XG4gIH07XG59Il19 -},{"./_stream_duplex":240,"_process":251,"buffer":41,"core-util-is":137,"events":141,"inherits":160,"process-nextick-args":250,"util-deprecate":256}],245:[function(_dereq_,module,exports){ + +},{"./_stream_duplex":273,"_process":272,"buffer":41,"core-util-is":164,"events":168,"inherits":187,"process-nextick-args":271,"util-deprecate":285}],278:[function(_dereq_,module,exports){ var Stream = (function (){ try { return _dereq_('st' + 'ream'); // hack to fix a circular dependency issue when used with browserify @@ -23947,1037 +25063,716 @@ exports.Duplex = _dereq_('./lib/_stream_duplex.js'); exports.Transform = _dereq_('./lib/_stream_transform.js'); exports.PassThrough = _dereq_('./lib/_stream_passthrough.js'); -},{"./lib/_stream_duplex.js":240,"./lib/_stream_passthrough.js":241,"./lib/_stream_readable.js":242,"./lib/_stream_transform.js":243,"./lib/_stream_writable.js":244}],246:[function(_dereq_,module,exports){ -'use strict'; - -function notNull(x) { return x != null; } -function wrap(x) { return '(' + x + ')';} - -function maybeQuote(value) { - if (typeof value === 'string') { - return '"' + value + '"'; - } - return value; -} - -function lookUp(key) { - if (key[0] === '$') { - return 'context.' + key.substring(1); - } - return 'context.feature.properties.' + key; -} - -function nullValue(key, value) { - return ' true '; -} - -function propertyEqual(key, value) { - return wrap(maybeQuote(value) + ' === ' + lookUp(key)); -} - -function propertyOr(key, values) { - return wrap(values.map(function (x) { return propertyEqual(key, x); }).join(' || ')); -} - -function printNested(values, joiner) { - return wrap(values.filter(notNull).map(function (x) { - return wrap(x.join(' && ')); - }).join(' ' + joiner + ' ')); -} - -function any(_, values) { - return (values && values.length > 0) ? printNested(values.map(parseFilter), '||') : 'true'; -} - -function all(_, values) { - return (values && values.length > 0) ? printNested(values.map(parseFilter), '&&') : 'true'; -} - -function not(key, value) { - return '!' + wrap(parseFilter(value).join(' && ')); -} - -function none(key, values) { - return '!' + wrap(any(null, values)); -} - -function propertyMatchesBoolean(key, value) { - return wrap(lookUp(key) + (value ? ' != ' : ' == ') + 'null'); -} - -function rangeMatch(key, values) { - var expressions = []; - - if (values.max) { - expressions.push('' + lookUp(key) + ' < ' + values.max); - } - - if (values.min) { - expressions.push('' + lookUp(key) + ' >= ' + values.min); - } - - return wrap(expressions.join(' && ')); -} - -function parseFilter(filter) { - var filterAST = []; - - // Function filter - if (typeof filter === 'function') { - return [wrap(filter.toString() + '(context)')]; - } - // Array filter, implicit 'any' - else if (Array.isArray(filter)) { - return [any(null, filter)]; - } - // Null filter object - else if (filter == null) { - return ['true']; - } - - // Object filter, e.g. implicit 'all' - var keys = Object.keys(filter); - for (var k=0; k < keys.length; k++) { - var key = keys[k]; - - var value = filter[key], - type = typeof value; - if (type === 'string' || type === 'number') { - filterAST.push(propertyEqual(key, value)); - } else if (type === 'boolean') { - filterAST.push(propertyMatchesBoolean(key, value)); - } else if (key === 'not') { - filterAST.push(not(key, value)); - } else if (key === 'any') { - filterAST.push(any(key, value)); - } else if (key === 'all') { - filterAST.push(all(key, value)); - } else if (key === 'none') { - filterAST.push(none(key, value)); - } else if (Array.isArray(value)) { - filterAST.push(propertyOr(key, value)); - } else if (type === 'object' && value != null) { - if (value.max || value.min) { - filterAST.push(rangeMatch(key, value)); - } - } else if (value == null) { - filterAST.push(nullValue(key, value)); - } else { - throw new Error('Unknown Query sytnax: ' + value); - } - } - - return keys.length === 0 ? ['true'] : filterAST; -} - -function filterToString(filterAST) { - return wrap(filterAST.join(' && ')); -} - -function match(filter) { - if (filter == null) { return function () { return true; }; } - // jshint evil: true - return new Function('context', 'return ' + filterToString(parseFilter(filter)) + ';'); -} - -module.exports = { - match: match, - filterToString: filterToString, - parseFilter: parseFilter -}; - -},{}],247:[function(_dereq_,module,exports){ -'use strict'; - -// lightweight Buffer shim for pbf browser build -// based on code from github.com/feross/buffer (MIT-licensed) - -module.exports = Buffer; - -var ieee754 = _dereq_('ieee754'); - -var BufferMethods; - -function Buffer(length) { - var arr; - if (length && length.length) { - arr = length; - length = arr.length; - } - var buf = new Uint8Array(length || 0); - if (arr) buf.set(arr); - - buf.readUInt32LE = BufferMethods.readUInt32LE; - buf.writeUInt32LE = BufferMethods.writeUInt32LE; - buf.readInt32LE = BufferMethods.readInt32LE; - buf.writeInt32LE = BufferMethods.writeInt32LE; - buf.readFloatLE = BufferMethods.readFloatLE; - buf.writeFloatLE = BufferMethods.writeFloatLE; - buf.readDoubleLE = BufferMethods.readDoubleLE; - buf.writeDoubleLE = BufferMethods.writeDoubleLE; - buf.toString = BufferMethods.toString; - buf.write = BufferMethods.write; - buf.slice = BufferMethods.slice; - buf.copy = BufferMethods.copy; - - buf._isBuffer = true; - return buf; -} - -var lastStr, lastStrEncoded; - -BufferMethods = { - readUInt32LE: function(pos) { - return ((this[pos]) | - (this[pos + 1] << 8) | - (this[pos + 2] << 16)) + - (this[pos + 3] * 0x1000000); - }, - - writeUInt32LE: function(val, pos) { - this[pos] = val; - this[pos + 1] = (val >>> 8); - this[pos + 2] = (val >>> 16); - this[pos + 3] = (val >>> 24); - }, - - readInt32LE: function(pos) { - return ((this[pos]) | - (this[pos + 1] << 8) | - (this[pos + 2] << 16)) + - (this[pos + 3] << 24); - }, - - readFloatLE: function(pos) { return ieee754.read(this, pos, true, 23, 4); }, - readDoubleLE: function(pos) { return ieee754.read(this, pos, true, 52, 8); }, - - writeFloatLE: function(val, pos) { return ieee754.write(this, val, pos, true, 23, 4); }, - writeDoubleLE: function(val, pos) { return ieee754.write(this, val, pos, true, 52, 8); }, - - toString: function(encoding, start, end) { - var str = '', - tmp = ''; - - start = start || 0; - end = Math.min(this.length, end || this.length); - - for (var i = start; i < end; i++) { - var ch = this[i]; - if (ch <= 0x7F) { - str += decodeURIComponent(tmp) + String.fromCharCode(ch); - tmp = ''; - } else { - tmp += '%' + ch.toString(16); - } - } - - str += decodeURIComponent(tmp); - - return str; - }, - - write: function(str, pos) { - var bytes = str === lastStr ? lastStrEncoded : encodeString(str); - for (var i = 0; i < bytes.length; i++) { - this[pos + i] = bytes[i]; - } - }, - - slice: function(start, end) { - return this.subarray(start, end); - }, - - copy: function(buf, pos) { - pos = pos || 0; - for (var i = 0; i < this.length; i++) { - buf[pos + i] = this[i]; - } - } -}; - -BufferMethods.writeInt32LE = BufferMethods.writeUInt32LE; - -Buffer.byteLength = function(str) { - lastStr = str; - lastStrEncoded = encodeString(str); - return lastStrEncoded.length; -}; - -Buffer.isBuffer = function(buf) { - return !!(buf && buf._isBuffer); -}; - -function encodeString(str) { - var length = str.length, - bytes = []; - - for (var i = 0, c, lead; i < length; i++) { - c = str.charCodeAt(i); // code point - - if (c > 0xD7FF && c < 0xE000) { - - if (lead) { - if (c < 0xDC00) { - bytes.push(0xEF, 0xBF, 0xBD); - lead = c; - continue; - - } else { - c = lead - 0xD800 << 10 | c - 0xDC00 | 0x10000; - lead = null; - } - - } else { - if (c > 0xDBFF || (i + 1 === length)) bytes.push(0xEF, 0xBF, 0xBD); - else lead = c; - - continue; - } - - } else if (lead) { - bytes.push(0xEF, 0xBF, 0xBD); - lead = null; - } - - if (c < 0x80) bytes.push(c); - else if (c < 0x800) bytes.push(c >> 0x6 | 0xC0, c & 0x3F | 0x80); - else if (c < 0x10000) bytes.push(c >> 0xC | 0xE0, c >> 0x6 & 0x3F | 0x80, c & 0x3F | 0x80); - else bytes.push(c >> 0x12 | 0xF0, c >> 0xC & 0x3F | 0x80, c >> 0x6 & 0x3F | 0x80, c & 0x3F | 0x80); - } - return bytes; -} - -},{"ieee754":159}],248:[function(_dereq_,module,exports){ +},{"./lib/_stream_duplex.js":273,"./lib/_stream_passthrough.js":274,"./lib/_stream_readable.js":275,"./lib/_stream_transform.js":276,"./lib/_stream_writable.js":277}],279:[function(_dereq_,module,exports){ (function (global){ -'use strict'; - -module.exports = Pbf; - -var Buffer = global.Buffer || _dereq_('./buffer'); - -function Pbf(buf) { - this.buf = !Buffer.isBuffer(buf) ? new Buffer(buf || 0) : buf; - this.pos = 0; - this.length = this.buf.length; -} - -Pbf.Varint = 0; // varint: int32, int64, uint32, uint64, sint32, sint64, bool, enum -Pbf.Fixed64 = 1; // 64-bit: double, fixed64, sfixed64 -Pbf.Bytes = 2; // length-delimited: string, bytes, embedded messages, packed repeated fields -Pbf.Fixed32 = 5; // 32-bit: float, fixed32, sfixed32 +// This method of obtaining a reference to the global object needs to be +// kept identical to the way it is obtained in runtime.js +var g = + typeof global === "object" ? global : + typeof window === "object" ? window : + typeof self === "object" ? self : this; -var SHIFT_LEFT_32 = (1 << 16) * (1 << 16), - SHIFT_RIGHT_32 = 1 / SHIFT_LEFT_32, - POW_2_63 = Math.pow(2, 63); +// Use `getOwnPropertyNames` because not all browsers support calling +// `hasOwnProperty` on the global `self` object in a worker. See #183. +var hadRuntime = g.regeneratorRuntime && + Object.getOwnPropertyNames(g).indexOf("regeneratorRuntime") >= 0; -Pbf.prototype = { +// Save the old regeneratorRuntime in case it needs to be restored later. +var oldRuntime = hadRuntime && g.regeneratorRuntime; - destroy: function() { - this.buf = null; - }, +// Force reevalutation of runtime.js. +g.regeneratorRuntime = undefined; - // === READING ================================================================= +module.exports = _dereq_("./runtime"); - readFields: function(readField, result, end) { - end = end || this.length; +if (hadRuntime) { + // Restore the original runtime. + g.regeneratorRuntime = oldRuntime; +} else { + // Remove the global property added by runtime.js. + try { + delete g.regeneratorRuntime; + } catch(e) { + g.regeneratorRuntime = undefined; + } +} - while (this.pos < end) { - var val = this.readVarint(), - tag = val >> 3, - startPos = this.pos; +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) - readField(tag, result, this); +},{"./runtime":280}],280:[function(_dereq_,module,exports){ +(function (process,global){ +/** + * Copyright (c) 2014, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * https://raw.github.com/facebook/regenerator/master/LICENSE file. An + * additional grant of patent rights can be found in the PATENTS file in + * the same directory. + */ - if (this.pos === startPos) this.skip(val); - } - return result; - }, +!(function(global) { + "use strict"; - readMessage: function(readField, result) { - return this.readFields(readField, result, this.readVarint() + this.pos); - }, + var hasOwn = Object.prototype.hasOwnProperty; + var undefined; // More compressible than void 0. + var $Symbol = typeof Symbol === "function" ? Symbol : {}; + var iteratorSymbol = $Symbol.iterator || "@@iterator"; + var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; - readFixed32: function() { - var val = this.buf.readUInt32LE(this.pos); - this.pos += 4; - return val; - }, + var inModule = typeof module === "object"; + var runtime = global.regeneratorRuntime; + if (runtime) { + if (inModule) { + // If regeneratorRuntime is defined globally and we're in a module, + // make the exports object identical to regeneratorRuntime. + module.exports = runtime; + } + // Don't bother evaluating the rest of this file if the runtime was + // already defined globally. + return; + } - readSFixed32: function() { - var val = this.buf.readInt32LE(this.pos); - this.pos += 4; - return val; - }, + // Define the runtime globally (as expected by generated code) as either + // module.exports (if we're in a module) or a new, empty object. + runtime = global.regeneratorRuntime = inModule ? module.exports : {}; - // 64-bit int handling is based on github.com/dpw/node-buffer-more-ints (MIT-licensed) + function wrap(innerFn, outerFn, self, tryLocsList) { + // If outerFn provided, then outerFn.prototype instanceof Generator. + var generator = Object.create((outerFn || Generator).prototype); + var context = new Context(tryLocsList || []); - readFixed64: function() { - var val = this.buf.readUInt32LE(this.pos) + this.buf.readUInt32LE(this.pos + 4) * SHIFT_LEFT_32; - this.pos += 8; - return val; - }, + // The ._invoke method unifies the implementations of the .next, + // .throw, and .return methods. + generator._invoke = makeInvokeMethod(innerFn, self, context); - readSFixed64: function() { - var val = this.buf.readUInt32LE(this.pos) + this.buf.readInt32LE(this.pos + 4) * SHIFT_LEFT_32; - this.pos += 8; - return val; - }, + return generator; + } + runtime.wrap = wrap; - readFloat: function() { - var val = this.buf.readFloatLE(this.pos); - this.pos += 4; - return val; - }, + // Try/catch helper to minimize deoptimizations. Returns a completion + // record like context.tryEntries[i].completion. This interface could + // have been (and was previously) designed to take a closure to be + // invoked without arguments, but in all the cases we care about we + // already have an existing method we want to call, so there's no need + // to create a new function object. We can even get away with assuming + // the method takes exactly one argument, since that happens to be true + // in every case, so we don't have to touch the arguments object. The + // only additional allocation required is the completion record, which + // has a stable shape and so hopefully should be cheap to allocate. + function tryCatch(fn, obj, arg) { + try { + return { type: "normal", arg: fn.call(obj, arg) }; + } catch (err) { + return { type: "throw", arg: err }; + } + } - readDouble: function() { - var val = this.buf.readDoubleLE(this.pos); - this.pos += 8; - return val; - }, + var GenStateSuspendedStart = "suspendedStart"; + var GenStateSuspendedYield = "suspendedYield"; + var GenStateExecuting = "executing"; + var GenStateCompleted = "completed"; - readVarint: function() { - var buf = this.buf, - val, b, b0, b1, b2, b3; + // Returning this object from the innerFn has the same effect as + // breaking out of the dispatch switch statement. + var ContinueSentinel = {}; - b0 = buf[this.pos++]; if (b0 < 0x80) return b0; b0 = b0 & 0x7f; - b1 = buf[this.pos++]; if (b1 < 0x80) return b0 | b1 << 7; b1 = (b1 & 0x7f) << 7; - b2 = buf[this.pos++]; if (b2 < 0x80) return b0 | b1 | b2 << 14; b2 = (b2 & 0x7f) << 14; - b3 = buf[this.pos++]; if (b3 < 0x80) return b0 | b1 | b2 | b3 << 21; + // Dummy constructor functions that we use as the .constructor and + // .constructor.prototype properties for functions that return Generator + // objects. For full spec compliance, you may wish to configure your + // minifier not to mangle the names of these two functions. + function Generator() {} + function GeneratorFunction() {} + function GeneratorFunctionPrototype() {} - val = b0 | b1 | b2 | (b3 & 0x7f) << 21; + var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype; + GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; + GeneratorFunctionPrototype.constructor = GeneratorFunction; + GeneratorFunctionPrototype[toStringTagSymbol] = GeneratorFunction.displayName = "GeneratorFunction"; - b = buf[this.pos++]; val += (b & 0x7f) * 0x10000000; if (b < 0x80) return val; - b = buf[this.pos++]; val += (b & 0x7f) * 0x800000000; if (b < 0x80) return val; - b = buf[this.pos++]; val += (b & 0x7f) * 0x40000000000; if (b < 0x80) return val; - b = buf[this.pos++]; val += (b & 0x7f) * 0x2000000000000; if (b < 0x80) return val; - b = buf[this.pos++]; val += (b & 0x7f) * 0x100000000000000; if (b < 0x80) return val; - b = buf[this.pos++]; val += (b & 0x7f) * 0x8000000000000000; if (b < 0x80) return val; + // Helper for defining the .next, .throw, and .return methods of the + // Iterator interface in terms of a single ._invoke method. + function defineIteratorMethods(prototype) { + ["next", "throw", "return"].forEach(function(method) { + prototype[method] = function(arg) { + return this._invoke(method, arg); + }; + }); + } - throw new Error('Expected varint not more than 10 bytes'); - }, + runtime.isGeneratorFunction = function(genFun) { + var ctor = typeof genFun === "function" && genFun.constructor; + return ctor + ? ctor === GeneratorFunction || + // For the native GeneratorFunction constructor, the best we can + // do is to check its .name property. + (ctor.displayName || ctor.name) === "GeneratorFunction" + : false; + }; - readVarint64: function() { - var startPos = this.pos, - val = this.readVarint(); + runtime.mark = function(genFun) { + if (Object.setPrototypeOf) { + Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); + } else { + genFun.__proto__ = GeneratorFunctionPrototype; + if (!(toStringTagSymbol in genFun)) { + genFun[toStringTagSymbol] = "GeneratorFunction"; + } + } + genFun.prototype = Object.create(Gp); + return genFun; + }; - if (val < POW_2_63) return val; + // Within the body of any async function, `await x` is transformed to + // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test + // `value instanceof AwaitArgument` to determine if the yielded value is + // meant to be awaited. Some may consider the name of this method too + // cutesy, but they are curmudgeons. + runtime.awrap = function(arg) { + return new AwaitArgument(arg); + }; - var pos = this.pos - 2; - while (this.buf[pos] === 0xff) pos--; - if (pos < startPos) pos = startPos; + function AwaitArgument(arg) { + this.arg = arg; + } - val = 0; - for (var i = 0; i < pos - startPos + 1; i++) { - var b = ~this.buf[startPos + i] & 0x7f; - val += i < 4 ? b << i * 7 : b * Math.pow(2, i * 7); + function AsyncIterator(generator) { + function invoke(method, arg, resolve, reject) { + var record = tryCatch(generator[method], generator, arg); + if (record.type === "throw") { + reject(record.arg); + } else { + var result = record.arg; + var value = result.value; + if (value instanceof AwaitArgument) { + return Promise.resolve(value.arg).then(function(value) { + invoke("next", value, resolve, reject); + }, function(err) { + invoke("throw", err, resolve, reject); + }); } - return -val - 1; - }, - - readSVarint: function() { - var num = this.readVarint(); - return num % 2 === 1 ? (num + 1) / -2 : num / 2; // zigzag encoding - }, + return Promise.resolve(value).then(function(unwrapped) { + // When a yielded Promise is resolved, its final value becomes + // the .value of the Promise<{value,done}> result for the + // current iteration. If the Promise is rejected, however, the + // result for this iteration will be rejected with the same + // reason. Note that rejections of yielded Promises are not + // thrown back into the generator function, as is the case + // when an awaited Promise is rejected. This difference in + // behavior between yield and await is important, because it + // allows the consumer to decide what to do with the yielded + // rejection (swallow it and continue, manually .throw it back + // into the generator, abandon iteration, whatever). With + // await, by contrast, there is no opportunity to examine the + // rejection reason outside the generator function, so the + // only option is to throw it from the await expression, and + // let the generator function handle the exception. + result.value = unwrapped; + resolve(result); + }, reject); + } + } - readBoolean: function() { - return Boolean(this.readVarint()); - }, + if (typeof process === "object" && process.domain) { + invoke = process.domain.bind(invoke); + } - readString: function() { - var end = this.readVarint() + this.pos, - str = this.buf.toString('utf8', this.pos, end); - this.pos = end; - return str; - }, + var previousPromise; - readBytes: function() { - var end = this.readVarint() + this.pos, - buffer = this.buf.slice(this.pos, end); - this.pos = end; - return buffer; - }, + function enqueue(method, arg) { + function callInvokeWithMethodAndArg() { + return new Promise(function(resolve, reject) { + invoke(method, arg, resolve, reject); + }); + } - // verbose for performance reasons; doesn't affect gzipped size + return previousPromise = + // If enqueue has been called before, then we want to wait until + // all previous Promises have been resolved before calling invoke, + // so that results are always delivered in the correct order. If + // enqueue has not been called before, then it is important to + // call invoke immediately, without waiting on a callback to fire, + // so that the async generator function has the opportunity to do + // any necessary setup in a predictable way. This predictability + // is why the Promise constructor synchronously invokes its + // executor callback, and why async functions synchronously + // execute code before the first await. Since we implement simple + // async functions in terms of async generators, it is especially + // important to get this right, even though it requires care. + previousPromise ? previousPromise.then( + callInvokeWithMethodAndArg, + // Avoid propagating failures to Promises returned by later + // invocations of the iterator. + callInvokeWithMethodAndArg + ) : callInvokeWithMethodAndArg(); + } - readPackedVarint: function() { - var end = this.readVarint() + this.pos, arr = []; - while (this.pos < end) arr.push(this.readVarint()); - return arr; - }, - readPackedSVarint: function() { - var end = this.readVarint() + this.pos, arr = []; - while (this.pos < end) arr.push(this.readSVarint()); - return arr; - }, - readPackedBoolean: function() { - var end = this.readVarint() + this.pos, arr = []; - while (this.pos < end) arr.push(this.readBoolean()); - return arr; - }, - readPackedFloat: function() { - var end = this.readVarint() + this.pos, arr = []; - while (this.pos < end) arr.push(this.readFloat()); - return arr; - }, - readPackedDouble: function() { - var end = this.readVarint() + this.pos, arr = []; - while (this.pos < end) arr.push(this.readDouble()); - return arr; - }, - readPackedFixed32: function() { - var end = this.readVarint() + this.pos, arr = []; - while (this.pos < end) arr.push(this.readFixed32()); - return arr; - }, - readPackedSFixed32: function() { - var end = this.readVarint() + this.pos, arr = []; - while (this.pos < end) arr.push(this.readSFixed32()); - return arr; - }, - readPackedFixed64: function() { - var end = this.readVarint() + this.pos, arr = []; - while (this.pos < end) arr.push(this.readFixed64()); - return arr; - }, - readPackedSFixed64: function() { - var end = this.readVarint() + this.pos, arr = []; - while (this.pos < end) arr.push(this.readSFixed64()); - return arr; - }, + // Define the unified helper method that is used to implement .next, + // .throw, and .return (see defineIteratorMethods). + this._invoke = enqueue; + } - skip: function(val) { - var type = val & 0x7; - if (type === Pbf.Varint) while (this.buf[this.pos++] > 0x7f) {} - else if (type === Pbf.Bytes) this.pos = this.readVarint() + this.pos; - else if (type === Pbf.Fixed32) this.pos += 4; - else if (type === Pbf.Fixed64) this.pos += 8; - else throw new Error('Unimplemented type: ' + type); - }, + defineIteratorMethods(AsyncIterator.prototype); - // === WRITING ================================================================= + // Note that simple async functions are implemented on top of + // AsyncIterator objects; they just return a Promise for the value of + // the final result produced by the iterator. + runtime.async = function(innerFn, outerFn, self, tryLocsList) { + var iter = new AsyncIterator( + wrap(innerFn, outerFn, self, tryLocsList) + ); - writeTag: function(tag, type) { - this.writeVarint((tag << 3) | type); - }, + return runtime.isGeneratorFunction(outerFn) + ? iter // If outerFn is a generator, return the full iterator. + : iter.next().then(function(result) { + return result.done ? result.value : iter.next(); + }); + }; - realloc: function(min) { - var length = this.length || 16; + function makeInvokeMethod(innerFn, self, context) { + var state = GenStateSuspendedStart; - while (length < this.pos + min) length *= 2; + return function invoke(method, arg) { + if (state === GenStateExecuting) { + throw new Error("Generator is already running"); + } - if (length !== this.length) { - var buf = new Buffer(length); - this.buf.copy(buf); - this.buf = buf; - this.length = length; + if (state === GenStateCompleted) { + if (method === "throw") { + throw arg; } - }, - finish: function() { - this.length = this.pos; - this.pos = 0; - return this.buf.slice(0, this.length); - }, - - writeFixed32: function(val) { - this.realloc(4); - this.buf.writeUInt32LE(val, this.pos); - this.pos += 4; - }, + // Be forgiving, per 25.3.3.3.3 of the spec: + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume + return doneResult(); + } - writeSFixed32: function(val) { - this.realloc(4); - this.buf.writeInt32LE(val, this.pos); - this.pos += 4; - }, + while (true) { + var delegate = context.delegate; + if (delegate) { + if (method === "return" || + (method === "throw" && delegate.iterator[method] === undefined)) { + // A return or throw (when the delegate iterator has no throw + // method) always terminates the yield* loop. + context.delegate = null; - writeFixed64: function(val) { - this.realloc(8); - this.buf.writeInt32LE(val & -1, this.pos); - this.buf.writeUInt32LE(Math.floor(val * SHIFT_RIGHT_32), this.pos + 4); - this.pos += 8; - }, + // If the delegate iterator has a return method, give it a + // chance to clean up. + var returnMethod = delegate.iterator["return"]; + if (returnMethod) { + var record = tryCatch(returnMethod, delegate.iterator, arg); + if (record.type === "throw") { + // If the return method threw an exception, let that + // exception prevail over the original return or throw. + method = "throw"; + arg = record.arg; + continue; + } + } - writeSFixed64: function(val) { - this.realloc(8); - this.buf.writeInt32LE(val & -1, this.pos); - this.buf.writeInt32LE(Math.floor(val * SHIFT_RIGHT_32), this.pos + 4); - this.pos += 8; - }, + if (method === "return") { + // Continue with the outer return, now that the delegate + // iterator has been terminated. + continue; + } + } - writeVarint: function(val) { - val = +val; + var record = tryCatch( + delegate.iterator[method], + delegate.iterator, + arg + ); - if (val <= 0x7f) { - this.realloc(1); - this.buf[this.pos++] = val; + if (record.type === "throw") { + context.delegate = null; - } else if (val <= 0x3fff) { - this.realloc(2); - this.buf[this.pos++] = ((val >>> 0) & 0x7f) | 0x80; - this.buf[this.pos++] = ((val >>> 7) & 0x7f); + // Like returning generator.throw(uncaught), but without the + // overhead of an extra function call. + method = "throw"; + arg = record.arg; + continue; + } - } else if (val <= 0x1fffff) { - this.realloc(3); - this.buf[this.pos++] = ((val >>> 0) & 0x7f) | 0x80; - this.buf[this.pos++] = ((val >>> 7) & 0x7f) | 0x80; - this.buf[this.pos++] = ((val >>> 14) & 0x7f); + // Delegate generator ran and handled its own exceptions so + // regardless of what the method was, we continue as if it is + // "next" with an undefined arg. + method = "next"; + arg = undefined; - } else if (val <= 0xfffffff) { - this.realloc(4); - this.buf[this.pos++] = ((val >>> 0) & 0x7f) | 0x80; - this.buf[this.pos++] = ((val >>> 7) & 0x7f) | 0x80; - this.buf[this.pos++] = ((val >>> 14) & 0x7f) | 0x80; - this.buf[this.pos++] = ((val >>> 21) & 0x7f); + var info = record.arg; + if (info.done) { + context[delegate.resultName] = info.value; + context.next = delegate.nextLoc; + } else { + state = GenStateSuspendedYield; + return info; + } - } else { - var pos = this.pos; - while (val >= 0x80) { - this.realloc(1); - this.buf[this.pos++] = (val & 0xff) | 0x80; - val /= 0x80; - } - this.realloc(1); - this.buf[this.pos++] = val | 0; - if (this.pos - pos > 10) throw new Error('Given varint doesn\'t fit into 10 bytes'); + context.delegate = null; } - }, - - writeSVarint: function(val) { - this.writeVarint(val < 0 ? -val * 2 - 1 : val * 2); - }, - - writeBoolean: function(val) { - this.writeVarint(Boolean(val)); - }, - writeString: function(str) { - str = String(str); - var bytes = Buffer.byteLength(str); - this.writeVarint(bytes); - this.realloc(bytes); - this.buf.write(str, this.pos); - this.pos += bytes; - }, + if (method === "next") { + // Setting context._sent for legacy support of Babel's + // function.sent implementation. + context.sent = context._sent = arg; - writeFloat: function(val) { - this.realloc(4); - this.buf.writeFloatLE(val, this.pos); - this.pos += 4; - }, + } else if (method === "throw") { + if (state === GenStateSuspendedStart) { + state = GenStateCompleted; + throw arg; + } - writeDouble: function(val) { - this.realloc(8); - this.buf.writeDoubleLE(val, this.pos); - this.pos += 8; - }, + if (context.dispatchException(arg)) { + // If the dispatched exception was caught by a catch block, + // then let that catch block handle the exception normally. + method = "next"; + arg = undefined; + } - writeBytes: function(buffer) { - var len = buffer.length; - this.writeVarint(len); - this.realloc(len); - for (var i = 0; i < len; i++) this.buf[this.pos++] = buffer[i]; - }, + } else if (method === "return") { + context.abrupt("return", arg); + } - writeMessage: function(tag, fn, obj) { - this.writeTag(tag, Pbf.Bytes); + state = GenStateExecuting; - this.pos++; // reserve 1 byte for short message length + var record = tryCatch(innerFn, self, context); + if (record.type === "normal") { + // If an exception is thrown from innerFn, we leave state === + // GenStateExecuting and loop back for another invocation. + state = context.done + ? GenStateCompleted + : GenStateSuspendedYield; - // write the message directly to the buffer and see how much was written - var startPos = this.pos; - fn(obj, this); - var len = this.pos - startPos; + var info = { + value: record.arg, + done: context.done + }; - var varintLen = - len <= 0x7f ? 1 : - len <= 0x3fff ? 2 : - len <= 0x1fffff ? 3 : - len <= 0xfffffff ? 4 : Math.ceil(Math.log(len) / (Math.LN2 * 7)); + if (record.arg === ContinueSentinel) { + if (context.delegate && method === "next") { + // Deliberately forget the last sent value so that we don't + // accidentally pass it on to the delegate. + arg = undefined; + } + } else { + return info; + } - // if 1 byte isn't enough for encoding message length, shift the data to the right - if (varintLen > 1) { - this.realloc(varintLen - 1); - for (var i = this.pos - 1; i >= startPos; i--) this.buf[i + varintLen - 1] = this.buf[i]; + } else if (record.type === "throw") { + state = GenStateCompleted; + // Dispatch the exception by looping back around to the + // context.dispatchException(arg) call above. + method = "throw"; + arg = record.arg; } + } + }; + } - // finally, write the message length in the reserved place and restore the position - this.pos = startPos - 1; - this.writeVarint(len); - this.pos += len; - }, + // Define Generator.prototype.{next,throw,return} in terms of the + // unified ._invoke helper method. + defineIteratorMethods(Gp); - writePackedVarint: function(tag, arr) { this.writeMessage(tag, writePackedVarint, arr); }, - writePackedSVarint: function(tag, arr) { this.writeMessage(tag, writePackedSVarint, arr); }, - writePackedBoolean: function(tag, arr) { this.writeMessage(tag, writePackedBoolean, arr); }, - writePackedFloat: function(tag, arr) { this.writeMessage(tag, writePackedFloat, arr); }, - writePackedDouble: function(tag, arr) { this.writeMessage(tag, writePackedDouble, arr); }, - writePackedFixed32: function(tag, arr) { this.writeMessage(tag, writePackedFixed32, arr); }, - writePackedSFixed32: function(tag, arr) { this.writeMessage(tag, writePackedSFixed32, arr); }, - writePackedFixed64: function(tag, arr) { this.writeMessage(tag, writePackedFixed64, arr); }, - writePackedSFixed64: function(tag, arr) { this.writeMessage(tag, writePackedSFixed64, arr); }, + Gp[iteratorSymbol] = function() { + return this; + }; - writeBytesField: function(tag, buffer) { - this.writeTag(tag, Pbf.Bytes); - this.writeBytes(buffer); - }, - writeFixed32Field: function(tag, val) { - this.writeTag(tag, Pbf.Fixed32); - this.writeFixed32(val); - }, - writeSFixed32Field: function(tag, val) { - this.writeTag(tag, Pbf.Fixed32); - this.writeSFixed32(val); - }, - writeFixed64Field: function(tag, val) { - this.writeTag(tag, Pbf.Fixed64); - this.writeFixed64(val); - }, - writeSFixed64Field: function(tag, val) { - this.writeTag(tag, Pbf.Fixed64); - this.writeSFixed64(val); - }, - writeVarintField: function(tag, val) { - this.writeTag(tag, Pbf.Varint); - this.writeVarint(val); - }, - writeSVarintField: function(tag, val) { - this.writeTag(tag, Pbf.Varint); - this.writeSVarint(val); - }, - writeStringField: function(tag, str) { - this.writeTag(tag, Pbf.Bytes); - this.writeString(str); - }, - writeFloatField: function(tag, val) { - this.writeTag(tag, Pbf.Fixed32); - this.writeFloat(val); - }, - writeDoubleField: function(tag, val) { - this.writeTag(tag, Pbf.Fixed64); - this.writeDouble(val); - }, - writeBooleanField: function(tag, val) { - this.writeVarintField(tag, Boolean(val)); + Gp[toStringTagSymbol] = "Generator"; + + Gp.toString = function() { + return "[object Generator]"; + }; + + function pushTryEntry(locs) { + var entry = { tryLoc: locs[0] }; + + if (1 in locs) { + entry.catchLoc = locs[1]; } -}; -function writePackedVarint(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeVarint(arr[i]); } -function writePackedSVarint(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSVarint(arr[i]); } -function writePackedFloat(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFloat(arr[i]); } -function writePackedDouble(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeDouble(arr[i]); } -function writePackedBoolean(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeBoolean(arr[i]); } -function writePackedFixed32(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFixed32(arr[i]); } -function writePackedSFixed32(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSFixed32(arr[i]); } -function writePackedFixed64(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFixed64(arr[i]); } -function writePackedSFixed64(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSFixed64(arr[i]); } + if (2 in locs) { + entry.finallyLoc = locs[2]; + entry.afterLoc = locs[3]; + } -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -//# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9wYmYvaW5kZXguanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBO0FB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2ldKTsgICAgfVxuZnVuY3Rpb24gd3JpdGVQYWNrZWREb3VibGUoYXJyLCBwYmYpICAgeyBmb3IgKHZhciBpID0gMDsgaSA8IGFyci5sZW5ndGg7IGkrKykgcGJmLndyaXRlRG91YmxlKGFycltpXSk7ICAgfVxuZnVuY3Rpb24gd3JpdGVQYWNrZWRCb29sZWFuKGFyciwgcGJmKSAgeyBmb3IgKHZhciBpID0gMDsgaSA8IGFyci5sZW5ndGg7IGkrKykgcGJmLndyaXRlQm9vbGVhbihhcnJbaV0pOyAgfVxuZnVuY3Rpb24gd3JpdGVQYWNrZWRGaXhlZDMyKGFyciwgcGJmKSAgeyBmb3IgKHZhciBpID0gMDsgaSA8IGFyci5sZW5ndGg7IGkrKykgcGJmLndyaXRlRml4ZWQzMihhcnJbaV0pOyAgfVxuZnVuY3Rpb24gd3JpdGVQYWNrZWRTRml4ZWQzMihhcnIsIHBiZikgeyBmb3IgKHZhciBpID0gMDsgaSA8IGFyci5sZW5ndGg7IGkrKykgcGJmLndyaXRlU0ZpeGVkMzIoYXJyW2ldKTsgfVxuZnVuY3Rpb24gd3JpdGVQYWNrZWRGaXhlZDY0KGFyciwgcGJmKSAgeyBmb3IgKHZhciBpID0gMDsgaSA8IGFyci5sZW5ndGg7IGkrKykgcGJmLndyaXRlRml4ZWQ2NChhcnJbaV0pOyAgfVxuZnVuY3Rpb24gd3JpdGVQYWNrZWRTRml4ZWQ2NChhcnIsIHBiZikgeyBmb3IgKHZhciBpID0gMDsgaSA8IGFyci5sZW5ndGg7IGkrKykgcGJmLndyaXRlU0ZpeGVkNjQoYXJyW2ldKTsgfVxuIl19 -},{"./buffer":247}],249:[function(_dereq_,module,exports){ -'use strict'; + this.tryEntries.push(entry); + } -module.exports = Point; + function resetTryEntry(entry) { + var record = entry.completion || {}; + record.type = "normal"; + delete record.arg; + entry.completion = record; + } -function Point(x, y) { - this.x = x; - this.y = y; -} + function Context(tryLocsList) { + // The root entry object (effectively a try statement without a catch + // or a finally block) gives us a place to store values thrown from + // locations where there is no enclosing try statement. + this.tryEntries = [{ tryLoc: "root" }]; + tryLocsList.forEach(pushTryEntry, this); + this.reset(true); + } -Point.prototype = { - clone: function() { return new Point(this.x, this.y); }, + runtime.keys = function(object) { + var keys = []; + for (var key in object) { + keys.push(key); + } + keys.reverse(); - add: function(p) { return this.clone()._add(p); }, - sub: function(p) { return this.clone()._sub(p); }, - mult: function(k) { return this.clone()._mult(k); }, - div: function(k) { return this.clone()._div(k); }, - rotate: function(a) { return this.clone()._rotate(a); }, - matMult: function(m) { return this.clone()._matMult(m); }, - unit: function() { return this.clone()._unit(); }, - perp: function() { return this.clone()._perp(); }, - round: function() { return this.clone()._round(); }, + // Rather than returning an object with a next method, we keep + // things simple and return the next function itself. + return function next() { + while (keys.length) { + var key = keys.pop(); + if (key in object) { + next.value = key; + next.done = false; + return next; + } + } - mag: function() { - return Math.sqrt(this.x * this.x + this.y * this.y); - }, + // To avoid creating an additional object, we just hang the .value + // and .done properties off the next function object itself. This + // also ensures that the minifier will not anonymize the function. + next.done = true; + return next; + }; + }; - equals: function(p) { - return this.x === p.x && - this.y === p.y; - }, + function values(iterable) { + if (iterable) { + var iteratorMethod = iterable[iteratorSymbol]; + if (iteratorMethod) { + return iteratorMethod.call(iterable); + } - dist: function(p) { - return Math.sqrt(this.distSqr(p)); - }, + if (typeof iterable.next === "function") { + return iterable; + } - distSqr: function(p) { - var dx = p.x - this.x, - dy = p.y - this.y; - return dx * dx + dy * dy; - }, + if (!isNaN(iterable.length)) { + var i = -1, next = function next() { + while (++i < iterable.length) { + if (hasOwn.call(iterable, i)) { + next.value = iterable[i]; + next.done = false; + return next; + } + } - angle: function() { - return Math.atan2(this.y, this.x); - }, + next.value = undefined; + next.done = true; - angleTo: function(b) { - return Math.atan2(this.y - b.y, this.x - b.x); - }, + return next; + }; - angleWith: function(b) { - return this.angleWithSep(b.x, b.y); - }, + return next.next = next; + } + } - // Find the angle of the two vectors, solving the formula for the cross product a x b = |a||b|sin(θ) for θ. - angleWithSep: function(x, y) { - return Math.atan2( - this.x * y - this.y * x, - this.x * x + this.y * y); - }, + // Return an iterator with no values. + return { next: doneResult }; + } + runtime.values = values; - _matMult: function(m) { - var x = m[0] * this.x + m[1] * this.y, - y = m[2] * this.x + m[3] * this.y; - this.x = x; - this.y = y; - return this; - }, + function doneResult() { + return { value: undefined, done: true }; + } - _add: function(p) { - this.x += p.x; - this.y += p.y; - return this; - }, + Context.prototype = { + constructor: Context, - _sub: function(p) { - this.x -= p.x; - this.y -= p.y; - return this; - }, + reset: function(skipTempReset) { + this.prev = 0; + this.next = 0; + // Resetting context._sent for legacy support of Babel's + // function.sent implementation. + this.sent = this._sent = undefined; + this.done = false; + this.delegate = null; - _mult: function(k) { - this.x *= k; - this.y *= k; - return this; - }, + this.tryEntries.forEach(resetTryEntry); - _div: function(k) { - this.x /= k; - this.y /= k; - return this; + if (!skipTempReset) { + for (var name in this) { + // Not sure about the optimal order of these conditions: + if (name.charAt(0) === "t" && + hasOwn.call(this, name) && + !isNaN(+name.slice(1))) { + this[name] = undefined; + } + } + } }, - _unit: function() { - this._div(this.mag()); - return this; - }, + stop: function() { + this.done = true; - _perp: function() { - var y = this.y; - this.y = this.x; - this.x = -y; - return this; - }, + var rootEntry = this.tryEntries[0]; + var rootRecord = rootEntry.completion; + if (rootRecord.type === "throw") { + throw rootRecord.arg; + } - _rotate: function(angle) { - var cos = Math.cos(angle), - sin = Math.sin(angle), - x = cos * this.x - sin * this.y, - y = sin * this.x + cos * this.y; - this.x = x; - this.y = y; - return this; + return this.rval; }, - _round: function() { - this.x = Math.round(this.x); - this.y = Math.round(this.y); - return this; - } -}; + dispatchException: function(exception) { + if (this.done) { + throw exception; + } -// constructs Point from an array if necessary -Point.convert = function (a) { - if (a instanceof Point) { - return a; - } - if (Array.isArray(a)) { - return new Point(a[0], a[1]); - } - return a; -}; + var context = this; + function handle(loc, caught) { + record.type = "throw"; + record.arg = exception; + context.next = loc; + return !!caught; + } -},{}],250:[function(_dereq_,module,exports){ -(function (process){ -'use strict'; + for (var i = this.tryEntries.length - 1; i >= 0; --i) { + var entry = this.tryEntries[i]; + var record = entry.completion; -if (!process.version || - process.version.indexOf('v0.') === 0 || - process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) { - module.exports = nextTick; -} else { - module.exports = process.nextTick; -} + if (entry.tryLoc === "root") { + // Exception thrown outside of any try block that could handle + // it, so set the completion value of the entire function to + // throw the exception. + return handle("end"); + } -function nextTick(fn, arg1, arg2, arg3) { - if (typeof fn !== 'function') { - throw new TypeError('"callback" argument must be a function'); - } - var len = arguments.length; - var args, i; - switch (len) { - case 0: - case 1: - return process.nextTick(fn); - case 2: - return process.nextTick(function afterTickOne() { - fn.call(null, arg1); - }); - case 3: - return process.nextTick(function afterTickTwo() { - fn.call(null, arg1, arg2); - }); - case 4: - return process.nextTick(function afterTickThree() { - fn.call(null, arg1, arg2, arg3); - }); - default: - args = new Array(len - 1); - i = 0; - while (i < args.length) { - args[i++] = arguments[i]; - } - return process.nextTick(function afterTick() { - fn.apply(null, args); - }); - } -} + if (entry.tryLoc <= this.prev) { + var hasCatch = hasOwn.call(entry, "catchLoc"); + var hasFinally = hasOwn.call(entry, "finallyLoc"); -}).call(this,_dereq_('_process')) -//# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9wcm9jZXNzLW5leHRpY2stYXJncy9pbmRleC5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQT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ja1R3bygpIHtcbiAgICAgIGZuLmNhbGwobnVsbCwgYXJnMSwgYXJnMik7XG4gICAgfSk7XG4gIGNhc2UgNDpcbiAgICByZXR1cm4gcHJvY2Vzcy5uZXh0VGljayhmdW5jdGlvbiBhZnRlclRpY2tUaHJlZSgpIHtcbiAgICAgIGZuLmNhbGwobnVsbCwgYXJnMSwgYXJnMiwgYXJnMyk7XG4gICAgfSk7XG4gIGRlZmF1bHQ6XG4gICAgYXJncyA9IG5ldyBBcnJheShsZW4gLSAxKTtcbiAgICBpID0gMDtcbiAgICB3aGlsZSAoaSA8IGFyZ3MubGVuZ3RoKSB7XG4gICAgICBhcmdzW2krK10gPSBhcmd1bWVudHNbaV07XG4gICAgfVxuICAgIHJldHVybiBwcm9jZXNzLm5leHRUaWNrKGZ1bmN0aW9uIGFmdGVyVGljaygpIHtcbiAgICAgIGZuLmFwcGx5KG51bGwsIGFyZ3MpO1xuICAgIH0pO1xuICB9XG59XG4iXX0= -},{"_process":251}],251:[function(_dereq_,module,exports){ -// shim for using process in browser + if (hasCatch && hasFinally) { + if (this.prev < entry.catchLoc) { + return handle(entry.catchLoc, true); + } else if (this.prev < entry.finallyLoc) { + return handle(entry.finallyLoc); + } -var process = module.exports = {}; + } else if (hasCatch) { + if (this.prev < entry.catchLoc) { + return handle(entry.catchLoc, true); + } -// cached from whatever global is present so that test runners that stub it -// don't break things. But we need to wrap it in a try catch in case it is -// wrapped in strict mode code which doesn't define any globals. It's inside a -// function because try/catches deoptimize in certain engines. + } else if (hasFinally) { + if (this.prev < entry.finallyLoc) { + return handle(entry.finallyLoc); + } -var cachedSetTimeout; -var cachedClearTimeout; + } else { + throw new Error("try statement without catch or finally"); + } + } + } + }, -(function () { - try { - cachedSetTimeout = setTimeout; - } catch (e) { - cachedSetTimeout = function () { - throw new Error('setTimeout is not defined'); - } - } - try { - cachedClearTimeout = clearTimeout; - } catch (e) { - cachedClearTimeout = function () { - throw new Error('clearTimeout is not defined'); - } - } -} ()) -var queue = []; -var draining = false; -var currentQueue; -var queueIndex = -1; + abrupt: function(type, arg) { + for (var i = this.tryEntries.length - 1; i >= 0; --i) { + var entry = this.tryEntries[i]; + if (entry.tryLoc <= this.prev && + hasOwn.call(entry, "finallyLoc") && + this.prev < entry.finallyLoc) { + var finallyEntry = entry; + break; + } + } -function cleanUpNextTick() { - if (!draining || !currentQueue) { - return; - } - draining = false; - if (currentQueue.length) { - queue = currentQueue.concat(queue); - } else { - queueIndex = -1; - } - if (queue.length) { - drainQueue(); - } -} + if (finallyEntry && + (type === "break" || + type === "continue") && + finallyEntry.tryLoc <= arg && + arg <= finallyEntry.finallyLoc) { + // Ignore the finally entry if control is not jumping to a + // location outside the try/catch block. + finallyEntry = null; + } -function drainQueue() { - if (draining) { - return; - } - var timeout = cachedSetTimeout(cleanUpNextTick); - draining = true; + var record = finallyEntry ? finallyEntry.completion : {}; + record.type = type; + record.arg = arg; - var len = queue.length; - while(len) { - currentQueue = queue; - queue = []; - while (++queueIndex < len) { - if (currentQueue) { - currentQueue[queueIndex].run(); - } - } - queueIndex = -1; - len = queue.length; - } - currentQueue = null; - draining = false; - cachedClearTimeout(timeout); -} + if (finallyEntry) { + this.next = finallyEntry.finallyLoc; + } else { + this.complete(record); + } -process.nextTick = function (fun) { - var args = new Array(arguments.length - 1); - if (arguments.length > 1) { - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; + return ContinueSentinel; + }, + + complete: function(record, afterLoc) { + if (record.type === "throw") { + throw record.arg; + } + + if (record.type === "break" || + record.type === "continue") { + this.next = record.arg; + } else if (record.type === "return") { + this.rval = record.arg; + this.next = "end"; + } else if (record.type === "normal" && afterLoc) { + this.next = afterLoc; + } + }, + + finish: function(finallyLoc) { + for (var i = this.tryEntries.length - 1; i >= 0; --i) { + var entry = this.tryEntries[i]; + if (entry.finallyLoc === finallyLoc) { + this.complete(entry.completion, entry.afterLoc); + resetTryEntry(entry); + return ContinueSentinel; } - } - queue.push(new Item(fun, args)); - if (queue.length === 1 && !draining) { - cachedSetTimeout(drainQueue, 0); - } -}; + } + }, -// v8 likes predictible objects -function Item(fun, array) { - this.fun = fun; - this.array = array; -} -Item.prototype.run = function () { - this.fun.apply(null, this.array); -}; -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; -process.version = ''; // empty string to avoid regexp issues -process.versions = {}; + "catch": function(tryLoc) { + for (var i = this.tryEntries.length - 1; i >= 0; --i) { + var entry = this.tryEntries[i]; + if (entry.tryLoc === tryLoc) { + var record = entry.completion; + if (record.type === "throw") { + var thrown = record.arg; + resetTryEntry(entry); + } + return thrown; + } + } -function noop() {} + // The context.catch method must only be called with a location + // argument that corresponds to a known catch block. + throw new Error("illegal catch attempt"); + }, -process.on = noop; -process.addListener = noop; -process.once = noop; -process.off = noop; -process.removeListener = noop; -process.removeAllListeners = noop; -process.emit = noop; + delegateYield: function(iterable, resultName, nextLoc) { + this.delegate = { + iterator: values(iterable), + resultName: resultName, + nextLoc: nextLoc + }; -process.binding = function (name) { - throw new Error('process.binding is not supported'); -}; + return ContinueSentinel; + } + }; +})( + // Among the various tricks for obtaining a reference to the global + // object, this seems to be the most reliable technique that does not + // use indirect eval (which violates Content Security Policy). + typeof global === "object" ? global : + typeof window === "object" ? window : + typeof self === "object" ? self : this +); -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); -}; -process.umask = function() { return 0; }; +}).call(this,_dereq_('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],252:[function(_dereq_,module,exports){ +},{"_process":272}],281:[function(_dereq_,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -25200,7 +25995,7 @@ function base64DetectIncompleteChar(buffer) { this.charLength = this.charReceived ? 3 : 0; } -},{"buffer":41}],253:[function(_dereq_,module,exports){ +},{"buffer":41}],282:[function(_dereq_,module,exports){ /*! * strip-comments * @@ -25275,7 +26070,7 @@ strip.line = function(str, opts) { return str ? str.replace(re, '') : ''; }; -},{}],254:[function(_dereq_,module,exports){ +},{}],283:[function(_dereq_,module,exports){ !function() { var topojson = { version: "1.6.19", @@ -25811,7 +26606,7 @@ strip.line = function(str, opts) { else this.topojson = topojson; }(); -},{}],255:[function(_dereq_,module,exports){ +},{}],284:[function(_dereq_,module,exports){ (function (global,Buffer){ 'use strict' @@ -26028,8 +26823,8 @@ exports.clearCache = function clearCache() { } } }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},_dereq_("buffer").Buffer) -//# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy90eXBlZGFycmF5LXBvb2wvcG9vbC5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUF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T0wuRkxPQVRbaV0ubGVuZ3RoID0gMFxuICAgIFBPT0wuRE9VQkxFW2ldLmxlbmd0aCA9IDBcbiAgICBQT09MLlVJTlQ4Q1tpXS5sZW5ndGggPSAwXG4gICAgREFUQVtpXS5sZW5ndGggPSAwXG4gICAgQlVGRkVSW2ldLmxlbmd0aCA9IDBcbiAgfVxufSJdfQ== -},{"bit-twiddle":32,"buffer":41,"dup":139}],256:[function(_dereq_,module,exports){ + +},{"bit-twiddle":32,"buffer":41,"dup":166}],285:[function(_dereq_,module,exports){ (function (global){ /** @@ -26100,15 +26895,15 @@ function config (name) { } }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -//# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy91dGlsLWRlcHJlY2F0ZS9icm93c2VyLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwiZmlsZSI6ImdlbmVyYXRlZC5qcyIsInNvd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W1lXTtcbiAgaWYgKG51bGwgPT0gdmFsKSByZXR1cm4gZmFsc2U7XG4gIHJldHVybiBTdHJpbmcodmFsKS50b0xvd2VyQ2FzZSgpID09PSAndHJ1ZSc7XG59XG4iXX0= -},{}],257:[function(_dereq_,module,exports){ + +},{}],286:[function(_dereq_,module,exports){ module.exports = function isBuffer(arg) { return arg && typeof arg === 'object' && typeof arg.copy === 'function' && typeof arg.fill === 'function' && typeof arg.readUInt8 === 'function'; } -},{}],258:[function(_dereq_,module,exports){ +},{}],287:[function(_dereq_,module,exports){ (function (process,global){ // Copyright Joyent, Inc. and other Node contributors. // @@ -26698,13 +27493,13 @@ function hasOwnProperty(obj, prop) { } }).call(this,_dereq_('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -//# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy91dGlsL3V0aWwuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7Q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WVzKSkge1xuICAgICAgICBzdHIgPSBmb3JtYXRWYWx1ZShjdHgsIGRlc2MudmFsdWUsIG51bGwpO1xuICAgICAgfSBlbHNlIHtcbiAgICAgICAgc3RyID0gZm9ybWF0VmFsdWUoY3R4LCBkZXNjLnZhbHVlLCByZWN1cnNlVGltZXMgLSAxKTtcbiAgICAgIH1cbiAgICAgIGlmIChzdHIuaW5kZXhPZignXFxuJykgPiAtMSkge1xuICAgICAgICBpZiAoYXJyYXkpIHtcbiAgICAgICAgICBzdHIgPSBzdHIuc3BsaXQoJ1xcbicpLm1hcChmdW5jdGlvbihsaW5lKSB7XG4gICAgICAgICAgICByZXR1cm4gJyAgJyArIGxpbmU7XG4gICAgICAgICAgfSkuam9pbignXFxuJykuc3Vic3RyKDIpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHN0ciA9ICdcXG4nICsgc3RyLnNwbGl0KCdcXG4nKS5tYXAoZnVuY3Rpb24obGluZSkge1xuICAgICAgICAgICAgcmV0dXJuICcgICAnICsgbGluZTtcbiAgICAgICAgICB9KS5qb2luKCdcXG4nKTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH0gZWxzZSB7XG4gICAgICBzdHIgPSBjdHguc3R5bGl6ZSgnW0NpcmN1bGFyXScsICdzcGVjaWFsJyk7XG4gICAgfVxuICB9XG4gIGlmIChpc1VuZGVmaW5lZChuYW1lKSkge1xuICAgIGlmIChhcnJheSAmJiBrZXkubWF0Y2goL15cXGQrJC8pKSB7XG4gICAgICByZXR1cm4gc3RyO1xuICAgIH1cbiAgICBuYW1lID0gSlNPTi5zdHJpbmdpZnkoJycgKyBrZXkpO1xuICAgIGlmIChuYW1lLm1hdGNoKC9eXCIoW2EtekEtWl9dW2EtekEtWl8wLTldKilcIiQvKSkge1xuICAgICAgbmFtZSA9IG5hbWUuc3Vic3RyKDEsIG5hbWUubGVuZ3RoIC0gMik7XG4gICAgICBuYW1lID0gY3R4LnN0eWxpemUobmFtZSwgJ25hbWUnK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W5jdGlvbihvcmlnaW4sIGFkZCkge1xuICAvLyBEb24ndCBkbyBhbnl0aGluZyBpZiBhZGQgaXNuJ3QgYW4gb2JqZWN0XG4gIGlmICghYWRkIHx8ICFpc09iamVjdChhZGQpKSByZXR1cm4gb3JpZ2luO1xuXG4gIHZhciBrZXlzID0gT2JqZWN0LmtleXMoYWRkKTtcbiAgdmFyIGkgPSBrZXlzLmxlbmd0aDtcbiAgd2hpbGUgKGktLSkge1xuICAgIG9yaWdpbltrZXlzW2ldXSA9IGFkZFtrZXlzW2ldXTtcbiAgfVxuICByZXR1cm4gb3JpZ2luO1xufTtcblxuZnVuY3Rpb24gaGFzT3duUHJvcGVydHkob2JqLCBwcm9wKSB7XG4gIHJldHVybiBPYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5LmNhbGwob2JqLCBwcm9wKTtcbn1cbiJdfQ== -},{"./support/isBuffer":257,"_process":251,"inherits":160}],259:[function(_dereq_,module,exports){ + +},{"./support/isBuffer":286,"_process":272,"inherits":187}],288:[function(_dereq_,module,exports){ module.exports.VectorTile = _dereq_('./lib/vectortile.js'); module.exports.VectorTileFeature = _dereq_('./lib/vectortilefeature.js'); module.exports.VectorTileLayer = _dereq_('./lib/vectortilelayer.js'); -},{"./lib/vectortile.js":260,"./lib/vectortilefeature.js":261,"./lib/vectortilelayer.js":262}],260:[function(_dereq_,module,exports){ +},{"./lib/vectortile.js":289,"./lib/vectortilefeature.js":290,"./lib/vectortilelayer.js":291}],289:[function(_dereq_,module,exports){ 'use strict'; var VectorTileLayer = _dereq_('./vectortilelayer'); @@ -26723,7 +27518,7 @@ function readTile(tag, layers, pbf) { } -},{"./vectortilelayer":262}],261:[function(_dereq_,module,exports){ +},{"./vectortilelayer":291}],290:[function(_dereq_,module,exports){ 'use strict'; var Point = _dereq_('point-geometry'); @@ -26887,7 +27682,7 @@ VectorTileFeature.prototype.toGeoJSON = function(x, y, z) { }; }; -},{"point-geometry":249}],262:[function(_dereq_,module,exports){ +},{"point-geometry":270}],291:[function(_dereq_,module,exports){ 'use strict'; var VectorTileFeature = _dereq_('./vectortilefeature.js'); @@ -26950,15 +27745,13 @@ VectorTileLayer.prototype.feature = function(i) { return new VectorTileFeature(this._pbf, end, this.extent, this._keys, this._values); }; -},{"./vectortilefeature.js":261}],263:[function(_dereq_,module,exports){ -// Geometry building functions +},{"./vectortilefeature.js":290}],292:[function(_dereq_,module,exports){ 'use strict'; -var _interopRequireDefault = _dereq_('babel-runtime/helpers/interop-require-default')['default']; - -Object.defineProperty(exports, '__esModule', { +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default_uvs = exports.tile_bounds = undefined; exports.outsideTile = outsideTile; exports.isCoordOutsideTile = isCoordOutsideTile; @@ -26966,16 +27759,14 @@ var _geo = _dereq_('../geo'); var _geo2 = _interopRequireDefault(_geo); -var tile_bounds = [{ x: 0, y: 0 }, { x: _geo2['default'].tile_scale, y: -_geo2['default'].tile_scale } // TODO: correct for flipped y-axis? -]; +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -exports.tile_bounds = tile_bounds; -var default_uvs = [0, 0, 1, 1]; +var tile_bounds = exports.tile_bounds = [{ x: 0, y: 0 }, { x: _geo2.default.tile_scale, y: -_geo2.default.tile_scale } // TODO: correct for flipped y-axis? +]; // Geometry building functions +var default_uvs = exports.default_uvs = [0, 0, 1, 1]; -exports.default_uvs = default_uvs; // Tests if a line segment (from point A to B) is outside the tile bounds // (within a certain tolerance to account for geometry nearly on tile edges) - function outsideTile(_a, _b, tolerance) { var tile_min = tile_bounds[0]; var tile_max = tile_bounds[1]; @@ -26996,23 +27787,26 @@ function isCoordOutsideTile(coord, tolerance) { return coord[0] <= tile_min.x + tolerance || coord[0] >= tile_max.x - tolerance || coord[1] >= tile_min.y - tolerance || coord[1] <= tile_max.y + tolerance; } -},{"../geo":268,"babel-runtime/helpers/interop-require-default":26}],264:[function(_dereq_,module,exports){ -// Point builders +},{"../geo":297}],293:[function(_dereq_,module,exports){ 'use strict'; -var _slicedToArray = _dereq_('babel-runtime/helpers/sliced-to-array')['default']; - -Object.defineProperty(exports, '__esModule', { +Object.defineProperty(exports, "__esModule", { value: true }); + +var _slicedToArray2 = _dereq_('babel-runtime/helpers/slicedToArray'); + +var _slicedToArray3 = _interopRequireDefault(_slicedToArray2); + exports.buildQuadsForPoints = buildQuadsForPoints; var _common = _dereq_('./common'); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + // Build a billboard sprite quad centered on a point. Sprites are intended to be drawn in screenspace, and have // properties for width, height, angle, and a scale factor that can be used to interpolate the screenspace size // of a sprite between two zoom levels. - function buildQuadsForPoints(points, vertex_data, vertex_template, _ref, _ref2) { var texcoord_index = _ref.texcoord_index; var position_index = _ref.position_index; @@ -27034,18 +27828,18 @@ function buildQuadsForPoints(points, vertex_data, vertex_template, _ref, _ref2) var vertex_elements = vertex_data.vertex_elements; var element_offset = vertex_data.vertex_count; - var texcoords = undefined; + var texcoords = void 0; if (texcoord_index) { texcoord_normalize = texcoord_normalize || 1; var _ref3 = texcoord_scale || _common.default_uvs; - var _ref32 = _slicedToArray(_ref3, 4); + var _ref4 = (0, _slicedToArray3.default)(_ref3, 4); - var min_u = _ref32[0]; - var min_v = _ref32[1]; - var max_u = _ref32[2]; - var max_v = _ref32[3]; + var min_u = _ref4[0]; + var min_v = _ref4[1]; + var max_u = _ref4[2]; + var max_v = _ref4[3]; texcoords = [[min_u, min_v], [max_u, min_v], [max_u, max_v], [min_u, max_v]]; } @@ -27084,19 +27878,19 @@ function buildQuadsForPoints(points, vertex_data, vertex_template, _ref, _ref2) element_offset += 4; } -} +} // Point builders -},{"./common":263,"babel-runtime/helpers/sliced-to-array":27}],265:[function(_dereq_,module,exports){ -// Polygon builders +},{"./common":292,"babel-runtime/helpers/slicedToArray":27}],294:[function(_dereq_,module,exports){ 'use strict'; -var _slicedToArray = _dereq_('babel-runtime/helpers/sliced-to-array')['default']; - -var _interopRequireDefault = _dereq_('babel-runtime/helpers/interop-require-default')['default']; - -Object.defineProperty(exports, '__esModule', { +Object.defineProperty(exports, "__esModule", { value: true }); + +var _slicedToArray2 = _dereq_('babel-runtime/helpers/slicedToArray'); + +var _slicedToArray3 = _interopRequireDefault(_slicedToArray2); + exports.buildPolygons = buildPolygons; exports.buildExtrudedPolygons = buildExtrudedPolygons; exports.triangulatePolygon = triangulatePolygon; @@ -27115,16 +27909,19 @@ var _earcut = _dereq_('earcut'); var _earcut2 = _interopRequireDefault(_earcut); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Polygon builders var up_vec3 = [0, 0, 1]; // Tesselate a flat 2D polygon // x & y coordinates will be set as first two elements of provided vertex_template - function buildPolygons(polygons, vertex_data, vertex_template, _ref) { var texcoord_index = _ref.texcoord_index; var texcoord_scale = _ref.texcoord_scale; var texcoord_normalize = _ref.texcoord_normalize; + var vertex_elements = vertex_data.vertex_elements; if (texcoord_index) { @@ -27132,12 +27929,12 @@ function buildPolygons(polygons, vertex_data, vertex_template, _ref) { var _ref2 = texcoord_scale || _common.default_uvs; - var _ref22 = _slicedToArray(_ref2, 4); + var _ref3 = (0, _slicedToArray3.default)(_ref2, 4); - var min_u = _ref22[0]; - var min_v = _ref22[1]; - var max_u = _ref22[2]; - var max_v = _ref22[3]; + var min_u = _ref3[0]; + var min_v = _ref3[1]; + var max_u = _ref3[2]; + var max_v = _ref3[3]; } var num_polygons = polygons.length; @@ -27148,9 +27945,9 @@ function buildPolygons(polygons, vertex_data, vertex_template, _ref) { // Find polygon extents to calculate UVs, fit them to the axis-aligned bounding box if (texcoord_index) { - var _Geo$findBoundingBox = _geo2['default'].findBoundingBox(polygon); + var _Geo$findBoundingBox = _geo2.default.findBoundingBox(polygon); - var _Geo$findBoundingBox2 = _slicedToArray(_Geo$findBoundingBox, 4); + var _Geo$findBoundingBox2 = (0, _slicedToArray3.default)(_Geo$findBoundingBox, 4); var min_x = _Geo$findBoundingBox2[0]; var min_y = _Geo$findBoundingBox2[1]; @@ -27182,22 +27979,22 @@ function buildPolygons(polygons, vertex_data, vertex_template, _ref) { } // Add element indices - var indices = triangulatePolygon(_earcut2['default'].flatten(polygon)); - for (var i = 0; i < indices.length; i++) { - vertex_elements.push(element_offset + indices[i]); + var indices = triangulatePolygon(_earcut2.default.flatten(polygon)); + for (var _i = 0; _i < indices.length; _i++) { + vertex_elements.push(element_offset + indices[_i]); } } } // Tesselate and extrude a flat 2D polygon into a simple 3D model with fixed height and add to GL vertex buffer +function buildExtrudedPolygons(polygons, z, height, min_height, vertex_data, vertex_template, normal_index, normal_normalize, _ref4) { + var remove_tile_edges = _ref4.remove_tile_edges; + var tile_edge_tolerance = _ref4.tile_edge_tolerance; + var texcoord_index = _ref4.texcoord_index; + var texcoord_scale = _ref4.texcoord_scale; + var texcoord_normalize = _ref4.texcoord_normalize; + var winding = _ref4.winding; -function buildExtrudedPolygons(polygons, z, height, min_height, vertex_data, vertex_template, normal_index, normal_normalize, _ref3) { - var remove_tile_edges = _ref3.remove_tile_edges; - var tile_edge_tolerance = _ref3.tile_edge_tolerance; - var texcoord_index = _ref3.texcoord_index; - var texcoord_scale = _ref3.texcoord_scale; - var texcoord_normalize = _ref3.texcoord_normalize; - var winding = _ref3.winding; // Top var min_z = z + (min_height || 0); @@ -27213,14 +28010,14 @@ function buildExtrudedPolygons(polygons, z, height, min_height, vertex_data, ver if (texcoord_index) { texcoord_normalize = texcoord_normalize || 1; - var _ref4 = texcoord_scale || _common.default_uvs; + var _ref5 = texcoord_scale || _common.default_uvs; - var _ref42 = _slicedToArray(_ref4, 4); + var _ref6 = (0, _slicedToArray3.default)(_ref5, 4); - var min_u = _ref42[0]; - var min_v = _ref42[1]; - var max_u = _ref42[2]; - var max_v = _ref42[3]; + var min_u = _ref6[0]; + var min_v = _ref6[1]; + var max_u = _ref6[2]; + var max_v = _ref6[3]; var texcoords = [[min_u, max_v], [min_u, min_v], [max_u, min_v], [max_u, max_v]]; } @@ -27238,8 +28035,8 @@ function buildExtrudedPolygons(polygons, z, height, min_height, vertex_data, ver } // Wall order is dependent on winding order, so that normals face outward - var w0 = undefined, - w1 = undefined; + var w0 = void 0, + w1 = void 0; if (winding === 'CCW') { w0 = w; w1 = w + 1; @@ -27252,8 +28049,8 @@ function buildExtrudedPolygons(polygons, z, height, min_height, vertex_data, ver var wall_vertices = [[contour[w1][0], contour[w1][1], max_z], [contour[w1][0], contour[w1][1], min_z], [contour[w0][0], contour[w0][1], min_z], [contour[w0][0], contour[w0][1], max_z]]; // Calc the normal of the wall from up vector and one segment of the wall triangles - var wall_vec = _vector2['default'].normalize([contour[w1][0] - contour[w0][0], contour[w1][1] - contour[w0][1], 0]); - var normal = _vector2['default'].cross(up_vec3, wall_vec); + var wall_vec = _vector2.default.normalize([contour[w1][0] - contour[w0][0], contour[w1][1] - contour[w0][1], 0]); + var normal = _vector2.default.cross(up_vec3, wall_vec); // Update vertex template with current surface normal vertex_template[normal_index + 0] = normal[0] * normal_normalize; @@ -27288,23 +28085,21 @@ function buildExtrudedPolygons(polygons, z, height, min_height, vertex_data, ver // Triangulation using earcut // https://github.com/mapbox/earcut - function triangulatePolygon(data) { - return (0, _earcut2['default'])(data.vertices, data.holes, data.dimensions); + return (0, _earcut2.default)(data.vertices, data.holes, data.dimensions); } -},{"../geo":268,"../vector":329,"./common":263,"babel-runtime/helpers/interop-require-default":26,"babel-runtime/helpers/sliced-to-array":27,"earcut":140}],266:[function(_dereq_,module,exports){ -// Geometry building functions - +},{"../geo":297,"../vector":358,"./common":292,"babel-runtime/helpers/slicedToArray":27,"earcut":167}],295:[function(_dereq_,module,exports){ 'use strict'; -var _Math$log2 = _dereq_('babel-runtime/core-js/math/log2')['default']; - -var _interopRequireDefault = _dereq_('babel-runtime/helpers/interop-require-default')['default']; - -Object.defineProperty(exports, '__esModule', { +Object.defineProperty(exports, "__esModule", { value: true }); + +var _log = _dereq_('babel-runtime/core-js/math/log2'); + +var _log2 = _interopRequireDefault(_log); + exports.buildPolylines = buildPolylines; var _vector = _dereq_('../vector'); @@ -27317,9 +28112,13 @@ var _geo2 = _interopRequireDefault(_geo); var _common = _dereq_('./common'); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + var zero_vec2 = [0, 0]; // Build tessellated triangles for a polyline +// Geometry building functions + var CAP_TYPE = { butt: 0, square: 1, @@ -27340,7 +28139,7 @@ var DEFAULT = { }; // Scaling factor to add precision to line texture V coordinate packed as normalized short -var v_scale_adjust = _geo2['default'].tile_scale; +var v_scale_adjust = _geo2.default.tile_scale; function buildPolylines(lines, width, vertex_data, vertex_template, _ref) { var closed_polygon = _ref.closed_polygon; @@ -27357,6 +28156,7 @@ function buildPolylines(lines, width, vertex_data, vertex_template, _ref) { var cap = _ref.cap; var miter_limit = _ref.miter_limit; + var cap_type = cap ? CAP_TYPE[cap] : CAP_TYPE.butt; var join_type = join ? JOIN_TYPE[join] : JOIN_TYPE.miter; @@ -27402,8 +28202,8 @@ function buildPolylines(lines, width, vertex_data, vertex_template, _ref) { } // Process extra lines - for (var index = 0; index < extra_lines.length; index++) { - buildPolyline(extra_lines[index], context, extra_lines); + for (var _index = 0; _index < extra_lines.length; _index++) { + buildPolyline(extra_lines[_index], context, extra_lines); } } @@ -27440,14 +28240,14 @@ function buildPolyline(line, context, extra_lines) { coordNext = line[1]; // If first pair of points is redundant, slice and push to the lines array - if (_vector2['default'].isEqual(coordCurr, coordNext)) { + if (_vector2.default.isEqual(coordCurr, coordNext)) { if (line.length > 2) { extra_lines.push(line.slice(1)); } return; } - normNext = _vector2['default'].normalize(_vector2['default'].perp(coordCurr, coordNext)); + normNext = _vector2.default.normalize(_vector2.default.perp(coordCurr, coordNext)); // Skip tile boundary lines and append a new line if needed if (remove_tile_edges && (0, _common.outsideTile)(coordCurr, coordNext, tile_edge_tolerance)) { @@ -27460,7 +28260,7 @@ function buildPolyline(line, context, extra_lines) { if (closed_polygon) { // Begin the polygon with a join (connecting the first and last segments) - normPrev = _vector2['default'].normalize(_vector2['default'].perp(line[line.length - 2], coordCurr)); + normPrev = _vector2.default.normalize(_vector2.default.perp(line[line.length - 2], coordCurr)); startPolygon(coordCurr, normPrev, normNext, join_type, context); } else { // If line begins at edge, don't add a cap @@ -27473,11 +28273,11 @@ function buildPolyline(line, context, extra_lines) { // Add first pair of points for the line strip addVertex(coordCurr, normNext, [1, v], context); - addVertex(coordCurr, _vector2['default'].neg(normNext), [0, v], context); + addVertex(coordCurr, _vector2.default.neg(normNext), [0, v], context); } // INTERMEDIARY POINTS - v += v_scale * _vector2['default'].length(_vector2['default'].sub(coordNext, coordCurr)); + v += v_scale * _vector2.default.length(_vector2.default.sub(coordNext, coordCurr)); for (var i = 1; i < line.length - 1; i++) { var currIndex = i; var nextIndex = i + 1; @@ -27485,14 +28285,14 @@ function buildPolyline(line, context, extra_lines) { coordNext = line[nextIndex]; // Skip redundant vertices - if (_vector2['default'].isEqual(coordCurr, coordNext)) { + if (_vector2.default.isEqual(coordCurr, coordNext)) { continue; } // Remove tile boundaries if (remove_tile_edges && (0, _common.outsideTile)(coordCurr, coordNext, tile_edge_tolerance)) { addVertex(coordCurr, normNext, [1, v], context); - addVertex(coordCurr, _vector2['default'].neg(normNext), [0, v], context); + addVertex(coordCurr, _vector2.default.neg(normNext), [0, v], context); indexPairs(1, context); var nonBoundaryLines = getNextNonBoundarySegment(line, currIndex + 1, tile_edge_tolerance); @@ -27503,7 +28303,7 @@ function buildPolyline(line, context, extra_lines) { } normPrev = normNext; - normNext = _vector2['default'].normalize(_vector2['default'].perp(coordCurr, coordNext)); + normNext = _vector2.default.normalize(_vector2.default.perp(coordCurr, coordNext)); // Add join if (join_type === JOIN_TYPE.miter) { @@ -27512,7 +28312,7 @@ function buildPolyline(line, context, extra_lines) { addJoin(join_type, v, coordCurr, normPrev, normNext, false, context); } - v += v_scale * _vector2['default'].length(_vector2['default'].sub(coordNext, coordCurr)); + v += v_scale * _vector2.default.length(_vector2.default.sub(coordNext, coordCurr)); } // LAST POINT @@ -27521,12 +28321,12 @@ function buildPolyline(line, context, extra_lines) { if (closed_polygon) { // Close the polygon with a miter joint or butt cap if on a tile boundary - normNext = _vector2['default'].normalize(_vector2['default'].perp(coordCurr, line[1])); + normNext = _vector2.default.normalize(_vector2.default.perp(coordCurr, line[1])); endPolygon(coordCurr, normPrev, normNext, join_type, v, context); } else { // Finish the line strip addVertex(coordCurr, normPrev, [1, v], context); - addVertex(coordCurr, _vector2['default'].neg(normPrev), [0, v], context); + addVertex(coordCurr, _vector2.default.neg(normPrev), [0, v], context); indexPairs(1, context); // If line ends at edge, don't add a cap @@ -27567,7 +28367,7 @@ function startPolygon(coordCurr, normPrev, normNext, join_type, context) { // If polygon starts on a tile boundary, don't add a join if (join_type === undefined || (0, _common.isCoordOutsideTile)(coordCurr)) { addVertex(coordCurr, normNext, [1, 0], context); - addVertex(coordCurr, _vector2['default'].neg(normNext), [0, 0], context); + addVertex(coordCurr, _vector2.default.neg(normNext), [0, 0], context); } else { // If polygon starts within a tile, add a join var v = 0; @@ -27584,32 +28384,32 @@ function endPolygon(coordCurr, normPrev, normNext, join_type, v, context) { // If polygon ends on a tile boundary, don't add a join if ((0, _common.isCoordOutsideTile)(coordCurr)) { addVertex(coordCurr, normPrev, [1, v], context); - addVertex(coordCurr, _vector2['default'].neg(normPrev), [0, v], context); + addVertex(coordCurr, _vector2.default.neg(normPrev), [0, v], context); indexPairs(1, context); } else { // If polygon ends within a tile, add Miter or no joint (join added on startPolygon) var miterVec = createMiterVec(normPrev, normNext); - if (join_type === JOIN_TYPE.miter && _vector2['default'].lengthSq(miterVec) > context.miter_len_sq) { + if (join_type === JOIN_TYPE.miter && _vector2.default.lengthSq(miterVec) > context.miter_len_sq) { join_type = JOIN_TYPE.bevel; // switch to bevel } if (join_type === JOIN_TYPE.miter) { addVertex(coordCurr, miterVec, [1, v], context); - addVertex(coordCurr, _vector2['default'].neg(miterVec), [0, v], context); + addVertex(coordCurr, _vector2.default.neg(miterVec), [0, v], context); indexPairs(1, context); } else { addVertex(coordCurr, normPrev, [1, v], context); - addVertex(coordCurr, _vector2['default'].neg(normPrev), [0, v], context); + addVertex(coordCurr, _vector2.default.neg(normPrev), [0, v], context); indexPairs(1, context); } } } function createMiterVec(normPrev, normNext) { - var miterVec = _vector2['default'].normalize(_vector2['default'].add(normPrev, normNext)); - var scale = 2 / (1 + Math.abs(_vector2['default'].dot(normPrev, miterVec))); - return _vector2['default'].mult(miterVec, scale * scale); + var miterVec = _vector2.default.normalize(_vector2.default.add(normPrev, normNext)); + var scale = 2 / (1 + Math.abs(_vector2.default.dot(normPrev, miterVec))); + return _vector2.default.mult(miterVec, scale * scale); } // Add a miter vector or a join if the miter is too sharp @@ -27617,11 +28417,11 @@ function addMiter(v, coordCurr, normPrev, normNext, miter_len_sq, isBeginning, c var miterVec = createMiterVec(normPrev, normNext); // Miter limit: if miter join is too sharp, convert to bevel instead - if (_vector2['default'].lengthSq(miterVec) > miter_len_sq) { + if (_vector2.default.lengthSq(miterVec) > miter_len_sq) { addJoin(JOIN_TYPE.miter, v, coordCurr, normPrev, normNext, isBeginning, context); } else { addVertex(coordCurr, miterVec, [1, v], context); - addVertex(coordCurr, _vector2['default'].neg(miterVec), [0, v], context); + addVertex(coordCurr, _vector2.default.neg(miterVec), [0, v], context); if (!isBeginning) { indexPairs(1, context); } @@ -27635,36 +28435,36 @@ function addJoin(join_type, v, coordCurr, normPrev, normNext, isBeginning, conte if (isClockwise) { addVertex(coordCurr, miterVec, [1, v], context); - addVertex(coordCurr, _vector2['default'].neg(normPrev), [0, v], context); + addVertex(coordCurr, _vector2.default.neg(normPrev), [0, v], context); if (!isBeginning) { indexPairs(1, context); } if (join_type === JOIN_TYPE.bevel) { - addBevel(coordCurr, _vector2['default'].neg(normPrev), miterVec, _vector2['default'].neg(normNext), [0, v], [1, v], [0, v], context); + addBevel(coordCurr, _vector2.default.neg(normPrev), miterVec, _vector2.default.neg(normNext), [0, v], [1, v], [0, v], context); } else if (join_type === JOIN_TYPE.round) { - addFan(coordCurr, _vector2['default'].neg(normPrev), miterVec, _vector2['default'].neg(normNext), [0, v], [1, v], [0, v], false, context); + addFan(coordCurr, _vector2.default.neg(normPrev), miterVec, _vector2.default.neg(normNext), [0, v], [1, v], [0, v], false, context); } addVertex(coordCurr, miterVec, [1, v], context); - addVertex(coordCurr, _vector2['default'].neg(normNext), [0, v], context); + addVertex(coordCurr, _vector2.default.neg(normNext), [0, v], context); } else { addVertex(coordCurr, normPrev, [1, v], context); - addVertex(coordCurr, _vector2['default'].neg(miterVec), [0, v], context); + addVertex(coordCurr, _vector2.default.neg(miterVec), [0, v], context); if (!isBeginning) { indexPairs(1, context); } if (join_type === JOIN_TYPE.bevel) { - addBevel(coordCurr, normPrev, _vector2['default'].neg(miterVec), normNext, [1, v], [0, v], [1, v], context); + addBevel(coordCurr, normPrev, _vector2.default.neg(miterVec), normNext, [1, v], [0, v], [1, v], context); } else if (join_type === JOIN_TYPE.round) { - addFan(coordCurr, normPrev, _vector2['default'].neg(miterVec), normNext, [1, v], [0, v], [1, v], false, context); + addFan(coordCurr, normPrev, _vector2.default.neg(miterVec), normNext, [1, v], [0, v], [1, v], false, context); } addVertex(coordCurr, normNext, [1, v], context); - addVertex(coordCurr, _vector2['default'].neg(miterVec), [0, v], context); + addVertex(coordCurr, _vector2.default.neg(miterVec), [0, v], context); } } @@ -27717,7 +28517,7 @@ function buildVertexTemplate(vertex_template, vertex, texture_coord, scale, cont // \./ function addFan(coord, nA, nC, nB, uvA, uvC, uvB, isCap, context) { var cross = nA[0] * nB[1] - nA[1] * nB[0]; - var dot = _vector2['default'].dot(nA, nB); + var dot = _vector2.default.dot(nA, nB); var angle = Math.atan2(cross, dot); while (angle >= Math.PI) { @@ -27741,27 +28541,27 @@ function addFan(coord, nA, nC, nB, uvA, uvC, uvB, isCap, context) { var uvCurr; if (isCap) { uvCurr = []; - var affine_uvCurr = _vector2['default'].sub(uvA, uvC); + var affine_uvCurr = _vector2.default.sub(uvA, uvC); } else { - uvCurr = _vector2['default'].set(uvA); - var uv_delta = _vector2['default'].div(_vector2['default'].sub(uvB, uvA), numTriangles); + uvCurr = _vector2.default.set(uvA); + var uv_delta = _vector2.default.div(_vector2.default.sub(uvB, uvA), numTriangles); } } var angle_step = angle / numTriangles; for (var i = 0; i < numTriangles; i++) { - blade = _vector2['default'].rot(blade, angle_step); + blade = _vector2.default.rot(blade, angle_step); if (context.texcoord_index !== undefined) { if (isCap) { // UV textures go "through" the cap - affine_uvCurr = _vector2['default'].rot(affine_uvCurr, angle_step); + affine_uvCurr = _vector2.default.rot(affine_uvCurr, angle_step); uvCurr[0] = affine_uvCurr[0] + uvC[0]; uvCurr[1] = affine_uvCurr[1] * context.texcoord_width * context.v_scale + uvC[1]; // scale the v-coordinate } else { - // UV textures go "around" the join - uvCurr = _vector2['default'].add(uvCurr, uv_delta); - } + // UV textures go "around" the join + uvCurr = _vector2.default.add(uvCurr, uv_delta); + } } addVertex(coord, blade, uvCurr, context); @@ -27802,7 +28602,7 @@ function addBevel(coord, nA, nC, nB, uA, uC, uB, context) { // Function to add the vertex need for line caps, // because re-use the buffers needs to be at the end function addCap(coord, v, normal, type, isBeginning, context) { - var neg_normal = _vector2['default'].neg(normal); + var neg_normal = _vector2.default.neg(normal); switch (type) { case CAP_TYPE.square: @@ -27810,8 +28610,8 @@ function addCap(coord, v, normal, type, isBeginning, context) { if (isBeginning) { tangent = [normal[1], -normal[0]]; - addVertex(coord, _vector2['default'].add(normal, tangent), [1, v], context); - addVertex(coord, _vector2['default'].add(neg_normal, tangent), [0, v], context); + addVertex(coord, _vector2.default.add(normal, tangent), [1, v], context); + addVertex(coord, _vector2.default.add(neg_normal, tangent), [0, v], context); // Add length of square cap to texture coordinate v += 0.5 * context.texcoord_width * context.v_scale; @@ -27827,8 +28627,8 @@ function addCap(coord, v, normal, type, isBeginning, context) { // Add length of square cap to texture coordinate v += 0.5 * context.texcoord_width * context.v_scale; - addVertex(coord, _vector2['default'].add(normal, tangent), [1, v], context); - addVertex(coord, _vector2['default'].add(neg_normal, tangent), [0, v], context); + addVertex(coord, _vector2.default.add(normal, tangent), [1, v], context); + addVertex(coord, _vector2.default.add(neg_normal, tangent), [0, v], context); } indexPairs(1, context); @@ -27870,7 +28670,7 @@ function trianglesPerArc(angle, width) { angle = -angle; } - var numTriangles = width > 2 * DEFAULT.MIN_FAN_WIDTH ? _Math$log2(width / DEFAULT.MIN_FAN_WIDTH) : 1; + var numTriangles = width > 2 * DEFAULT.MIN_FAN_WIDTH ? (0, _log2.default)(width / DEFAULT.MIN_FAN_WIDTH) : 1; return Math.ceil(angle / Math.PI * numTriangles); } @@ -27888,76 +28688,78 @@ function permuteLine(line, startIndex) { return newLine; } -},{"../geo":268,"../vector":329,"./common":263,"babel-runtime/core-js/math/log2":7,"babel-runtime/helpers/interop-require-default":26}],267:[function(_dereq_,module,exports){ +},{"../geo":297,"../vector":358,"./common":292,"babel-runtime/core-js/math/log2":8}],296:[function(_dereq_,module,exports){ 'use strict'; -var _createClass = _dereq_('babel-runtime/helpers/create-class')['default']; +Object.defineProperty(exports, "__esModule", { + value: true +}); -var _classCallCheck = _dereq_('babel-runtime/helpers/class-call-check')['default']; +var _getPrototypeOf = _dereq_('babel-runtime/core-js/object/get-prototype-of'); -var _get = _dereq_('babel-runtime/helpers/get')['default']; +var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf); -var _inherits = _dereq_('babel-runtime/helpers/inherits')['default']; +var _possibleConstructorReturn2 = _dereq_('babel-runtime/helpers/possibleConstructorReturn'); -var _interopRequireDefault = _dereq_('babel-runtime/helpers/interop-require-default')['default']; +var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2); -Object.defineProperty(exports, '__esModule', { - value: true -}); +var _get2 = _dereq_('babel-runtime/helpers/get'); -var _utilsUtils = _dereq_('./utils/utils'); +var _get3 = _interopRequireDefault(_get2); -var _utilsUtils2 = _interopRequireDefault(_utilsUtils); +var _inherits2 = _dereq_('babel-runtime/helpers/inherits'); -var _glShader_program = _dereq_('./gl/shader_program'); +var _inherits3 = _interopRequireDefault(_inherits2); -var _glShader_program2 = _interopRequireDefault(_glShader_program); +var _classCallCheck2 = _dereq_('babel-runtime/helpers/classCallCheck'); -var _utilsGlMatrix = _dereq_('./utils/gl-matrix'); +var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); -// Abstract base class +var _createClass2 = _dereq_('babel-runtime/helpers/createClass'); + +var _createClass3 = _interopRequireDefault(_createClass2); + +var _utils = _dereq_('./utils/utils'); + +var _utils2 = _interopRequireDefault(_utils); + +var _shader_program = _dereq_('./gl/shader_program'); + +var _shader_program2 = _interopRequireDefault(_shader_program); + +var _glMatrix = _dereq_('./utils/gl-matrix'); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -var Camera = (function () { +// Abstract base class +var Camera = function () { function Camera(name, view) { var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; - - _classCallCheck(this, Camera); + (0, _classCallCheck3.default)(this, Camera); this.view = view; this.position = options.position; this.zoom = options.zoom; } - /** - Perspective matrix projection - - This is a specialized perspective camera that, given a desired camera focal length (which can also vary by zoom level), - constrains the camera height above the ground plane such that the displayed ground area of the map matches that of - a traditional web mercator map. This means you can set the camera location by [lat, lng, zoom] as you would a typical - web mercator map, then adjust the focal length as needed. - - Vanishing point can also be adjusted to achieve different "viewing angles", e.g. instead of looking straight down into - the center of the viewport, the camera appears to be tilted at an angle. For example: - - [0, 0] = looking towards center of viewport - [-250, -250] = looking 250 pixels from the viewport center to the lower-left corner - [400, 0] = looking 400 pixels to the right of the viewport center - */ - // Create a camera by type name, factory-style - _createClass(Camera, [{ + + (0, _createClass3.default)(Camera, [{ key: 'update', + // Update method called once per frame value: function update() {} // Called once per frame per program (e.g. for main render pass, then for each additional pass for feature selection, etc.) + }, { key: 'setupProgram', value: function setupProgram(program) {} // Sync camera position/zoom to scene view + }, { key: 'updateView', value: function updateView() { @@ -27974,16 +28776,17 @@ var Camera = (function () { } // Set model-view and normal matrices + }, { key: 'setupMatrices', value: function setupMatrices(matrices, program) { // Model view matrix - transform tile space into view space (meters, relative to camera) - _utilsGlMatrix.mat4.multiply(matrices.model_view32, this.view_matrix, matrices.model); + _glMatrix.mat4.multiply(matrices.model_view32, this.view_matrix, matrices.model); program.uniform('Matrix4fv', 'u_modelView', matrices.model_view32); // Normal matrices - transforms surface normals into view space - _utilsGlMatrix.mat3.normalFromMat4(matrices.normal32, matrices.model_view32); - _utilsGlMatrix.mat3.invert(matrices.inverse_normal32, matrices.normal32); + _glMatrix.mat3.normalFromMat4(matrices.normal32, matrices.model_view32); + _glMatrix.mat3.invert(matrices.inverse_normal32, matrices.normal32); program.uniform('Matrix3fv', 'u_normalMatrix', matrices.normal32); program.uniform('Matrix3fv', 'u_inverseNormalMatrix', matrices.inverse_normal32); } @@ -28002,54 +28805,66 @@ var Camera = (function () { } } }]); - return Camera; -})(); +}(); + +/** + Perspective matrix projection + + This is a specialized perspective camera that, given a desired camera focal length (which can also vary by zoom level), + constrains the camera height above the ground plane such that the displayed ground area of the map matches that of + a traditional web mercator map. This means you can set the camera location by [lat, lng, zoom] as you would a typical + web mercator map, then adjust the focal length as needed. + + Vanishing point can also be adjusted to achieve different "viewing angles", e.g. instead of looking straight down into + the center of the viewport, the camera appears to be tilted at an angle. For example: + + [0, 0] = looking towards center of viewport + [-250, -250] = looking 250 pixels from the viewport center to the lower-left corner + [400, 0] = looking 400 pixels to the right of the viewport center +*/ -exports['default'] = Camera; -var PerspectiveCamera = (function (_Camera) { - _inherits(PerspectiveCamera, _Camera); +exports.default = Camera; + +var PerspectiveCamera = function (_Camera) { + (0, _inherits3.default)(PerspectiveCamera, _Camera); function PerspectiveCamera(name, view) { var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; + (0, _classCallCheck3.default)(this, PerspectiveCamera); - _classCallCheck(this, PerspectiveCamera); + var _this = (0, _possibleConstructorReturn3.default)(this, (0, _getPrototypeOf2.default)(PerspectiveCamera).call(this, name, view, options)); - _get(Object.getPrototypeOf(PerspectiveCamera.prototype), 'constructor', this).call(this, name, view, options); - this.type = 'perspective'; + _this.type = 'perspective'; // a single scalar, or pairs of stops mapping zoom levels, e.g. [zoom, focal length] - this.focal_length = options.focal_length; - this.fov = options.fov; - if (!this.focal_length && !this.fov) { + _this.focal_length = options.focal_length; + _this.fov = options.fov; + if (!_this.focal_length && !_this.fov) { // Default focal length ranges by zoom - this.focal_length = [[16, 2], [17, 2.5], [18, 3], [19, 4], [20, 6]]; + _this.focal_length = [[16, 2], [17, 2.5], [18, 3], [19, 4], [20, 6]]; } - this.vanishing_point = options.vanishing_point || [0, 0]; // [x, y] - this.vanishing_point = this.vanishing_point.map(parseFloat); // we implicitly only support px units here - this.vanishing_point_skew = []; + _this.vanishing_point = options.vanishing_point || [0, 0]; // [x, y] + _this.vanishing_point = _this.vanishing_point.map(parseFloat); // we implicitly only support px units here + _this.vanishing_point_skew = []; - this.position_meters = null; - this.view_matrix = new Float64Array(16); - this.projection_matrix = new Float32Array(16); + _this.position_meters = null; + _this.view_matrix = new Float64Array(16); + _this.projection_matrix = new Float32Array(16); // 'camera' is the name of the shader block, e.g. determines where in the shader this code is injected - _glShader_program2['default'].replaceBlock('camera', '\n uniform mat4 u_projection;\n uniform vec3 u_eye;\n uniform vec2 u_vanishing_point;\n\n void cameraProjection (inout vec4 position) {\n position = u_projection * position;\n }'); + _shader_program2.default.replaceBlock('camera', '\n uniform mat4 u_projection;\n uniform vec3 u_eye;\n uniform vec2 u_vanishing_point;\n\n void cameraProjection (inout vec4 position) {\n position = u_projection * position;\n }'); + return _this; } - // Isometric-style projection - // Note: this is actually an "axonometric" projection, but I'm using the colloquial term isometric because it is more recognizable. - // An isometric projection is a specific subset of axonometric projections. - // 'axis' determines the xy skew applied to a vertex based on its z coordinate, e.g. [0, 1] axis causes buildings to be drawn - // straight upwards on screen at their true height, [0, .5] would draw them up at half-height, [1, 0] would be sideways, etc. - // Constrains the camera so that the viewable area matches given the viewport height // (in world space, e.g. meters), given either a camera focal length or field-of-view // (focal length is used if both are passed). - _createClass(PerspectiveCamera, [{ + + (0, _createClass3.default)(PerspectiveCamera, [{ key: 'constrainCamera', value: function constrainCamera(_ref) { var view_height = _ref.view_height; @@ -28093,14 +28908,15 @@ var PerspectiveCamera = (function (_Camera) { var _constrainCamera = this.constrainCamera({ view_height: viewport_height, - focal_length: _utilsUtils2['default'].interpolate(this.view.zoom, this.focal_length), - fov: _utilsUtils2['default'].interpolate(this.view.zoom, this.fov) + focal_length: _utils2.default.interpolate(this.view.zoom, this.focal_length), + fov: _utils2.default.interpolate(this.view.zoom, this.fov) }); var height = _constrainCamera.height; var fov = _constrainCamera.fov; // View matrix + var position = [this.view.center.meters.x, this.view.center.meters.y, height]; this.position_meters = position; @@ -28109,10 +28925,10 @@ var PerspectiveCamera = (function (_Camera) { // vec3.fromValues(position[0], position[1], height - 1), // vec3.fromValues(0, 1, 0)); // Exclude camera height from view matrix - _utilsGlMatrix.mat4.lookAt(this.view_matrix, _utilsGlMatrix.vec3.fromValues(position[0], position[1], 0), _utilsGlMatrix.vec3.fromValues(position[0], position[1], -1), _utilsGlMatrix.vec3.fromValues(0, 1, 0)); + _glMatrix.mat4.lookAt(this.view_matrix, _glMatrix.vec3.fromValues(position[0], position[1], 0), _glMatrix.vec3.fromValues(position[0], position[1], -1), _glMatrix.vec3.fromValues(0, 1, 0)); // Projection matrix - _utilsGlMatrix.mat4.perspective(this.projection_matrix, fov, this.view.aspect, 1, height * 2); + _glMatrix.mat4.perspective(this.projection_matrix, fov, this.view.aspect, 1, height * 2); // Convert vanishing point from pixels to viewport space this.vanishing_point_skew[0] = this.vanishing_point[0] / this.view.size.css.width; @@ -28125,15 +28941,15 @@ var PerspectiveCamera = (function (_Camera) { // Translate geometry into the distance so that camera is appropriate height above ground // Additionally, adjust xy to compensate for any vanishing point skew, e.g. move geometry so that the displayed g // plane of the map matches that expected by a traditional web mercator map at this [lat, lng, zoom]. - _utilsGlMatrix.mat4.translate(this.projection_matrix, this.projection_matrix, _utilsGlMatrix.vec3.fromValues(viewport_height / 2 * this.view.aspect * (-this.vanishing_point_skew[0] * 2), viewport_height / 2 * (-this.vanishing_point_skew[1] * 2), 0)); + _glMatrix.mat4.translate(this.projection_matrix, this.projection_matrix, _glMatrix.vec3.fromValues(viewport_height / 2 * this.view.aspect * (-this.vanishing_point_skew[0] * 2), viewport_height / 2 * (-this.vanishing_point_skew[1] * 2), 0)); // Include camera height in projection matrix - _utilsGlMatrix.mat4.translate(this.projection_matrix, this.projection_matrix, _utilsGlMatrix.vec3.fromValues(0, 0, -height)); + _glMatrix.mat4.translate(this.projection_matrix, this.projection_matrix, _glMatrix.vec3.fromValues(0, 0, -height)); } }, { key: 'update', value: function update() { - _get(Object.getPrototypeOf(PerspectiveCamera.prototype), 'update', this).call(this); + (0, _get3.default)((0, _getPrototypeOf2.default)(PerspectiveCamera.prototype), 'update', this).call(this); this.updateMatrices(); } }, { @@ -28144,59 +28960,64 @@ var PerspectiveCamera = (function (_Camera) { program.uniform('2fv', 'u_vanishing_point', this.vanishing_point_skew); } }]); - return PerspectiveCamera; -})(Camera); +}(Camera); + +// Isometric-style projection +// Note: this is actually an "axonometric" projection, but I'm using the colloquial term isometric because it is more recognizable. +// An isometric projection is a specific subset of axonometric projections. +// 'axis' determines the xy skew applied to a vertex based on its z coordinate, e.g. [0, 1] axis causes buildings to be drawn +// straight upwards on screen at their true height, [0, .5] would draw them up at half-height, [1, 0] would be sideways, etc. -var IsometricCamera = (function (_Camera2) { - _inherits(IsometricCamera, _Camera2); + +var IsometricCamera = function (_Camera2) { + (0, _inherits3.default)(IsometricCamera, _Camera2); function IsometricCamera(name, view) { var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; + (0, _classCallCheck3.default)(this, IsometricCamera); - _classCallCheck(this, IsometricCamera); + var _this2 = (0, _possibleConstructorReturn3.default)(this, (0, _getPrototypeOf2.default)(IsometricCamera).call(this, name, view, options)); - _get(Object.getPrototypeOf(IsometricCamera.prototype), 'constructor', this).call(this, name, view, options); - this.type = 'isometric'; - this.axis = options.axis || { x: 0, y: 1 }; - if (this.axis.length === 2) { - this.axis = { x: this.axis[0], y: this.axis[1] }; // allow axis to also be passed as 2-elem array + _this2.type = 'isometric'; + _this2.axis = options.axis || { x: 0, y: 1 }; + if (_this2.axis.length === 2) { + _this2.axis = { x: _this2.axis[0], y: _this2.axis[1] }; // allow axis to also be passed as 2-elem array } - this.position_meters = null; - this.viewport_height = null; + _this2.position_meters = null; + _this2.viewport_height = null; - this.view_matrix = new Float64Array(16); - this.projection_matrix = new Float32Array(16); + _this2.view_matrix = new Float64Array(16); + _this2.projection_matrix = new Float32Array(16); // 'camera' is the name of the shader block, e.g. determines where in the shader this code is injected - _glShader_program2['default'].replaceBlock('camera', '\n uniform mat4 u_projection;\n uniform vec3 u_eye;\n uniform vec2 u_vanishing_point;\n\n void cameraProjection (inout vec4 position) {\n position = u_projection * position;\n // position.xy += position.z * u_isometric_axis;\n\n // Reverse z for depth buffer so up is negative,\n // and scale down values so objects higher than one screen height will not get clipped\n // pull forward slightly to avoid going past far clipping plane\n position.z = -position.z / 100. + 1. - 0.001;\n }'); + _shader_program2.default.replaceBlock('camera', '\n uniform mat4 u_projection;\n uniform vec3 u_eye;\n uniform vec2 u_vanishing_point;\n\n void cameraProjection (inout vec4 position) {\n position = u_projection * position;\n // position.xy += position.z * u_isometric_axis;\n\n // Reverse z for depth buffer so up is negative,\n // and scale down values so objects higher than one screen height will not get clipped\n // pull forward slightly to avoid going past far clipping plane\n position.z = -position.z / 100. + 1. - 0.001;\n }'); + return _this2; } - // Flat projection (e.g. just top-down, no perspective) - a degenerate isometric camera - - _createClass(IsometricCamera, [{ + (0, _createClass3.default)(IsometricCamera, [{ key: 'update', value: function update() { - _get(Object.getPrototypeOf(IsometricCamera.prototype), 'update', this).call(this); + (0, _get3.default)((0, _getPrototypeOf2.default)(IsometricCamera.prototype), 'update', this).call(this); this.viewport_height = this.view.size.css.height * this.view.meters_per_pixel; var position = [this.view.center.meters.x, this.view.center.meters.y, this.viewport_height]; this.position_meters = position; // View - _utilsGlMatrix.mat4.identity(this.view_matrix); - _utilsGlMatrix.mat4.translate(this.view_matrix, this.view_matrix, _utilsGlMatrix.vec3.fromValues(-position[0], -position[1], 0)); + _glMatrix.mat4.identity(this.view_matrix); + _glMatrix.mat4.translate(this.view_matrix, this.view_matrix, _glMatrix.vec3.fromValues(-position[0], -position[1], 0)); // Projection - _utilsGlMatrix.mat4.identity(this.projection_matrix); + _glMatrix.mat4.identity(this.projection_matrix); // apply isometric skew this.projection_matrix[8] = this.axis.x / this.view.aspect; // z column of x row, e.g. amount z skews x this.projection_matrix[9] = this.axis.y; // z column of x row, e.g. amount z skews y // convert meters to viewport - _utilsGlMatrix.mat4.scale(this.projection_matrix, this.projection_matrix, _utilsGlMatrix.vec3.fromValues(2 / this.view.size.meters.x, 2 / this.view.size.meters.y, 2 / this.view.size.meters.y)); + _glMatrix.mat4.scale(this.projection_matrix, this.projection_matrix, _glMatrix.vec3.fromValues(2 / this.view.size.meters.x, 2 / this.view.size.meters.y, 2 / this.view.size.meters.y)); } }, { key: 'setupProgram', @@ -28208,54 +29029,62 @@ var IsometricCamera = (function (_Camera2) { program.uniform('2fv', 'u_vanishing_point', [0, 0]); } }]); - return IsometricCamera; -})(Camera); +}(Camera); + +// Flat projection (e.g. just top-down, no perspective) - a degenerate isometric camera -var FlatCamera = (function (_IsometricCamera) { - _inherits(FlatCamera, _IsometricCamera); + +var FlatCamera = function (_IsometricCamera) { + (0, _inherits3.default)(FlatCamera, _IsometricCamera); function FlatCamera(name, view) { var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; + (0, _classCallCheck3.default)(this, FlatCamera); - _classCallCheck(this, FlatCamera); + var _this3 = (0, _possibleConstructorReturn3.default)(this, (0, _getPrototypeOf2.default)(FlatCamera).call(this, name, view, options)); - _get(Object.getPrototypeOf(FlatCamera.prototype), 'constructor', this).call(this, name, view, options); - this.type = 'flat'; + _this3.type = 'flat'; + return _this3; } - _createClass(FlatCamera, [{ + (0, _createClass3.default)(FlatCamera, [{ key: 'update', value: function update() { // Axis is fixed to (0, 0) for flat camera this.axis.x = 0; this.axis.y = 0; - _get(Object.getPrototypeOf(FlatCamera.prototype), 'update', this).call(this); + (0, _get3.default)((0, _getPrototypeOf2.default)(FlatCamera.prototype), 'update', this).call(this); } }]); - return FlatCamera; -})(IsometricCamera); +}(IsometricCamera); -module.exports = exports['default']; +},{"./gl/shader_program":303,"./utils/gl-matrix":349,"./utils/utils":355,"babel-runtime/core-js/object/get-prototype-of":14,"babel-runtime/helpers/classCallCheck":21,"babel-runtime/helpers/createClass":22,"babel-runtime/helpers/get":24,"babel-runtime/helpers/inherits":25,"babel-runtime/helpers/possibleConstructorReturn":26}],297:[function(_dereq_,module,exports){ +'use strict'; -},{"./gl/shader_program":274,"./utils/gl-matrix":320,"./utils/utils":326,"babel-runtime/helpers/class-call-check":21,"babel-runtime/helpers/create-class":22,"babel-runtime/helpers/get":24,"babel-runtime/helpers/inherits":25,"babel-runtime/helpers/interop-require-default":26}],268:[function(_dereq_,module,exports){ -// Miscellaneous geo functions +Object.defineProperty(exports, "__esModule", { + value: true +}); -'use strict'; +var _getIterator2 = _dereq_('babel-runtime/core-js/get-iterator'); -var _slicedToArray = _dereq_('babel-runtime/helpers/sliced-to-array')['default']; +var _getIterator3 = _interopRequireDefault(_getIterator2); -var _getIterator = _dereq_('babel-runtime/core-js/get-iterator')['default']; +var _slicedToArray2 = _dereq_('babel-runtime/helpers/slicedToArray'); + +var _slicedToArray3 = _interopRequireDefault(_slicedToArray2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Miscellaneous geo functions -Object.defineProperty(exports, '__esModule', { - value: true -}); var Geo; -exports['default'] = Geo = {}; +exports.default = Geo = {}; // Projection constants + Geo.default_source_max_zoom = 18; Geo.default_view_max_zoom = 20; Geo.tile_size = 256; @@ -28298,7 +29127,7 @@ Geo.metersForTile = function (tile) { Given a point in mercator meters and a zoom level, return the tile X/Y/Z that the point lies in */ Geo.tileForMeters = function (_ref, zoom) { - var _ref2 = _slicedToArray(_ref, 2); + var _ref2 = (0, _slicedToArray3.default)(_ref, 2); var x = _ref2[0]; var y = _ref2[1]; @@ -28332,10 +29161,11 @@ Geo.wrapTile = function (_ref3) { Convert mercator meters to lat-lng */ Geo.metersToLatLng = function (_ref4) { - var _ref42 = _slicedToArray(_ref4, 2); + var _ref5 = (0, _slicedToArray3.default)(_ref4, 2); + + var x = _ref5[0]; + var y = _ref5[1]; - var x = _ref42[0]; - var y = _ref42[1]; x /= Geo.half_circumference_meters; y /= Geo.half_circumference_meters; @@ -28351,11 +29181,12 @@ Geo.metersToLatLng = function (_ref4) { /** Convert lat-lng to mercator meters */ -Geo.latLngToMeters = function (_ref5) { - var _ref52 = _slicedToArray(_ref5, 2); +Geo.latLngToMeters = function (_ref6) { + var _ref7 = (0, _slicedToArray3.default)(_ref6, 2); + + var x = _ref7[0]; + var y = _ref7[1]; - var x = _ref52[0]; - var y = _ref52[1]; // Latitude y = Math.log(Math.tan(y * Math.PI / 360 + Math.PI / 4)) / Math.PI; @@ -28527,7 +29358,7 @@ Geo.ringWinding = function (ring) { // Enforce winding order on outer/inner rings // winding: 'CW' or 'CCW' Geo.enforceWinding = function (geom, winding) { - var polys = undefined; + var polys = void 0; if (geom.type === 'Polygon') { polys = [geom.coordinates]; } else if (geom.type === 'MultiPolygon') { @@ -28547,7 +29378,7 @@ Geo.enforceWinding = function (geom, winding) { var _iteratorError = undefined; try { - for (var _iterator = _getIterator(poly), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + for (var _iterator = (0, _getIterator3.default)(poly), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { var ring = _step.value; ring.reverse(); @@ -28557,8 +29388,8 @@ Geo.enforceWinding = function (geom, winding) { _iteratorError = err; } finally { try { - if (!_iteratorNormalCompletion && _iterator['return']) { - _iterator['return'](); + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); } } finally { if (_didIteratorError) { @@ -28570,20 +29401,20 @@ Geo.enforceWinding = function (geom, winding) { } return geom; }; -module.exports = exports['default']; - -},{"babel-runtime/core-js/get-iterator":4,"babel-runtime/helpers/sliced-to-array":27}],269:[function(_dereq_,module,exports){ -// WebGL constants - need to import these separately to make them available in the web worker +},{"babel-runtime/core-js/get-iterator":4,"babel-runtime/helpers/slicedToArray":27}],298:[function(_dereq_,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +// WebGL constants - need to import these separately to make them available in the web worker + var gl; -exports["default"] = gl = {}; +exports.default = gl = {}; /* DataType */ + gl.BYTE = 0x1400; gl.UNSIGNED_BYTE = 0x1401; gl.SHORT = 0x1402; @@ -28591,21 +29422,21 @@ gl.UNSIGNED_SHORT = 0x1403; gl.INT = 0x1404; gl.UNSIGNED_INT = 0x1405; gl.FLOAT = 0x1406; -module.exports = exports["default"]; - -},{}],270:[function(_dereq_,module,exports){ -// WebGL context wrapper +},{}],299:[function(_dereq_,module,exports){ 'use strict'; -Object.defineProperty(exports, '__esModule', { +Object.defineProperty(exports, "__esModule", { value: true }); +// WebGL context wrapper + var Context; -exports['default'] = Context = {}; +exports.default = Context = {}; // Setup a WebGL context // If no canvas element is provided, one is created and added to the document body + Context.getContext = function getContext(canvas, options) { var fullscreen = false; if (canvas == null) { @@ -28644,26 +29475,31 @@ Context.resize = function (gl, width, height, device_pixel_ratio) { gl.bindFramebuffer(gl.FRAMEBUFFER, null); gl.viewport(0, 0, gl.canvas.width, gl.canvas.height); }; -module.exports = exports['default']; - -},{}],271:[function(_dereq_,module,exports){ -// WebGL extension wrapper -// Stores extensions by name and GL context +},{}],300:[function(_dereq_,module,exports){ "use strict"; -var _Map = _dereq_("babel-runtime/core-js/map")["default"]; - Object.defineProperty(exports, "__esModule", { value: true }); -exports["default"] = getExtension; -var extensions = new _Map(); // map of extensions by GL context + +var _map = _dereq_("babel-runtime/core-js/map"); + +var _map2 = _interopRequireDefault(_map); + +exports.default = getExtension; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// WebGL extension wrapper +// Stores extensions by name and GL context + +var extensions = new _map2.default(); // map of extensions by GL context function getExtension(gl, name) { var exts = extensions.get(gl); if (!exts) { - extensions.set(gl, new _Map()); + extensions.set(gl, new _map2.default()); exts = extensions.get(gl); } @@ -28673,18 +29509,21 @@ function getExtension(gl, name) { return exts.get(name); } -module.exports = exports["default"]; - -},{"babel-runtime/core-js/map":6}],272:[function(_dereq_,module,exports){ +},{"babel-runtime/core-js/map":7}],301:[function(_dereq_,module,exports){ 'use strict'; -var _toConsumableArray = _dereq_('babel-runtime/helpers/to-consumable-array')['default']; - -Object.defineProperty(exports, '__esModule', { +Object.defineProperty(exports, "__esModule", { value: true }); + +var _toConsumableArray2 = _dereq_('babel-runtime/helpers/toConsumableArray'); + +var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + var GLSL = {}; -exports['default'] = GLSL; +exports.default = GLSL; /** Parse uniforms from a JS object, infers types and returns an array of objects with the @@ -28702,6 +29541,7 @@ exports['default'] = GLSL; for actually setting the uniforms). For example, this could be used as a key into a dictionary of known texture names, or it could simply be used as a URL to dynamically load the texture from. */ + GLSL.parseUniforms = function (uniforms) { var parsed = []; @@ -28907,9 +29747,9 @@ GLSL.isSymbolReferenced = function (name, source) { GLSL.expandVec3 = function (v) { var z = arguments.length <= 1 || arguments[1] === undefined ? 1 : arguments[1]; - var x = undefined; + var x = void 0; if (Array.isArray(v) && v.length === 2) { - x = [].concat(_toConsumableArray(v), [z]).map(parseFloat); + x = [].concat((0, _toConsumableArray3.default)(v), [z]).map(parseFloat); } else { x = [v, v, v].map(parseFloat); } @@ -28929,9 +29769,9 @@ GLSL.expandVec3 = function (v) { GLSL.expandVec4 = function (v) { var w = arguments.length <= 1 || arguments[1] === undefined ? 1 : arguments[1]; - var x = undefined; + var x = void 0; if (Array.isArray(v) && v.length === 3) { - x = [].concat(_toConsumableArray(v), [w]).map(parseFloat); + x = [].concat((0, _toConsumableArray3.default)(v), [w]).map(parseFloat); } else { x = [v, v, v, w].map(parseFloat); } @@ -28942,46 +29782,53 @@ GLSL.expandVec4 = function (v) { return x; } }; -module.exports = exports['default']; -},{"babel-runtime/helpers/to-consumable-array":28}],273:[function(_dereq_,module,exports){ +},{"babel-runtime/helpers/toConsumableArray":28}],302:[function(_dereq_,module,exports){ "use strict"; -var _createClass = _dereq_("babel-runtime/helpers/create-class")["default"]; - -var _classCallCheck = _dereq_("babel-runtime/helpers/class-call-check")["default"]; - Object.defineProperty(exports, "__esModule", { value: true }); +exports.RenderState = undefined; + +var _stringify = _dereq_("babel-runtime/core-js/json/stringify"); + +var _stringify2 = _interopRequireDefault(_stringify); + +var _classCallCheck2 = _dereq_("babel-runtime/helpers/classCallCheck"); + +var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); + +var _createClass2 = _dereq_("babel-runtime/helpers/createClass"); -var RenderState = (function () { +var _createClass3 = _interopRequireDefault(_createClass2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var RenderState = exports.RenderState = function () { function RenderState(value, setup) { - _classCallCheck(this, RenderState); + (0, _classCallCheck3.default)(this, RenderState); setup(value); this.value = value; this.setup = setup; } - _createClass(RenderState, [{ + (0, _createClass3.default)(RenderState, [{ key: "set", value: function set(value) { // if the states are different, call the GL context for a state change - if (JSON.stringify(this.value) !== JSON.stringify(value)) { + if ((0, _stringify2.default)(this.value) !== (0, _stringify2.default)(value)) { this.setup(value); this.value = value; } } }]); - return RenderState; -})(); - -exports.RenderState = RenderState; +}(); var RenderStateManager = function RenderStateManager(gl) { - _classCallCheck(this, RenderStateManager); + (0, _classCallCheck3.default)(this, RenderStateManager); this.defaults = {}; @@ -29047,33 +29894,38 @@ var RenderStateManager = function RenderStateManager(gl) { }); }; -exports["default"] = RenderStateManager; - -},{"babel-runtime/helpers/class-call-check":21,"babel-runtime/helpers/create-class":22}],274:[function(_dereq_,module,exports){ -// GL program wrapper to cache uniform locations/values, do compile-time pre-processing -// (injecting #defines and #pragma blocks into shaders), etc. +exports.default = RenderStateManager; +},{"babel-runtime/core-js/json/stringify":6,"babel-runtime/helpers/classCallCheck":21,"babel-runtime/helpers/createClass":22}],303:[function(_dereq_,module,exports){ 'use strict'; -var _createClass = _dereq_('babel-runtime/helpers/create-class')['default']; +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _toConsumableArray2 = _dereq_('babel-runtime/helpers/toConsumableArray'); -var _classCallCheck = _dereq_('babel-runtime/helpers/class-call-check')['default']; +var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2); -var _toConsumableArray = _dereq_('babel-runtime/helpers/to-consumable-array')['default']; +var _getIterator2 = _dereq_('babel-runtime/core-js/get-iterator'); -var _Object$assign = _dereq_('babel-runtime/core-js/object/assign')['default']; +var _getIterator3 = _interopRequireDefault(_getIterator2); -var _getIterator = _dereq_('babel-runtime/core-js/get-iterator')['default']; +var _assign = _dereq_('babel-runtime/core-js/object/assign'); -var _interopRequireDefault = _dereq_('babel-runtime/helpers/interop-require-default')['default']; +var _assign2 = _interopRequireDefault(_assign); -Object.defineProperty(exports, '__esModule', { - value: true -}); +var _classCallCheck2 = _dereq_('babel-runtime/helpers/classCallCheck'); + +var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); -var _utilsLog = _dereq_('../utils/log'); +var _createClass2 = _dereq_('babel-runtime/helpers/createClass'); -var _utilsLog2 = _interopRequireDefault(_utilsLog); +var _createClass3 = _interopRequireDefault(_createClass2); + +var _log = _dereq_('../utils/log'); + +var _log2 = _interopRequireDefault(_log); var _glsl = _dereq_('./glsl'); @@ -29095,13 +29947,18 @@ var _glShaderErrors = _dereq_('gl-shader-errors'); var _glShaderErrors2 = _interopRequireDefault(_glShaderErrors); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + // Regex patterns +// GL program wrapper to cache uniform locations/values, do compile-time pre-processing +// (injecting #defines and #pragma blocks into shaders), etc. + var re_pragma = /^\s*#pragma.*$/gm; // for removing unused pragmas after shader block injection var re_continue_line = /\\\s*\n/mg; // for removing backslash line continuations -var ShaderProgram = (function () { +var ShaderProgram = function () { function ShaderProgram(gl, vertex_source, fragment_source, options) { - _classCallCheck(this, ShaderProgram); + (0, _classCallCheck3.default)(this, ShaderProgram); options = options || {}; @@ -29112,11 +29969,11 @@ var ShaderProgram = (function () { this.error = null; // key/values inserted as #defines into shaders at compile-time - this.defines = _Object$assign({}, options.defines || {}); + this.defines = (0, _assign2.default)({}, options.defines || {}); // key/values for blocks that can be injected into shaders at compile-time - this.blocks = _Object$assign({}, options.blocks || {}); - this.block_scopes = _Object$assign({}, options.block_scopes || {}); + this.blocks = (0, _assign2.default)({}, options.blocks || {}); + this.block_scopes = (0, _assign2.default)({}, options.block_scopes || {}); // list of extensions to activate this.extensions = options.extensions || []; @@ -29137,9 +29994,7 @@ var ShaderProgram = (function () { this.name = options.name; // can provide a program name (useful for debugging) } - // Static methods and state - - _createClass(ShaderProgram, [{ + (0, _createClass3.default)(ShaderProgram, [{ key: 'destroy', value: function destroy() { this.gl.useProgram(null); @@ -29152,6 +30007,7 @@ var ShaderProgram = (function () { } // Use program wrapper with simple state cache + }, { key: 'use', value: function use() { @@ -29285,7 +30141,7 @@ var ShaderProgram = (function () { var _iteratorError = undefined; try { - for (var _iterator = _getIterator(this.shader_errors), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + for (var _iterator = (0, _getIterator3.default)(this.shader_errors), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { var e = _step.value; e.type = error.type; @@ -29296,8 +30152,8 @@ var ShaderProgram = (function () { _iteratorError = err; } finally { try { - if (!_iteratorNormalCompletion && _iterator['return']) { - _iterator['return'](); + if (!_iteratorNormalCompletion && _iterator.return) { + _iterator.return(); } } finally { if (_didIteratorError) { @@ -29316,6 +30172,7 @@ var ShaderProgram = (function () { } // Make list of defines (global, then program-specific) + }, { key: 'buildDefineList', value: function buildDefineList() { @@ -29331,10 +30188,11 @@ var ShaderProgram = (function () { } // Make list of shader blocks (global, then program-specific) + }, { key: 'buildShaderBlockList', value: function buildShaderBlockList() { - var key = undefined, + var key = void 0, blocks = {}; // Global blocks @@ -29344,7 +30202,7 @@ var ShaderProgram = (function () { if (Array.isArray(ShaderProgram.blocks[key])) { var _blocks$key; - (_blocks$key = blocks[key]).push.apply(_blocks$key, _toConsumableArray(ShaderProgram.blocks[key].map(function (source, num) { + (_blocks$key = blocks[key]).push.apply(_blocks$key, (0, _toConsumableArray3.default)(ShaderProgram.blocks[key].map(function (source, num) { return { key: key, source: source, num: num, scope: 'ShaderProgram' }; }))); } else { @@ -29387,6 +30245,7 @@ var ShaderProgram = (function () { } // Detect uniform definitions, inject any missing ones + }, { key: 'ensureUniforms', value: function ensureUniforms(uniforms) { @@ -29394,8 +30253,8 @@ var ShaderProgram = (function () { return; } - var vs = (0, _stripComments2['default'])(this.computed_vertex_source); - var fs = (0, _stripComments2['default'])(this.computed_fragment_source); + var vs = (0, _stripComments2.default)(this.computed_vertex_source); + var fs = (0, _stripComments2.default)(this.computed_fragment_source); var inject, vs_injections = [], fs_injections = []; @@ -29405,19 +30264,19 @@ var ShaderProgram = (function () { inject = null; // Check vertex shader - if (!_glsl2['default'].isUniformDefined(name, vs)) { + if (!_glsl2.default.isUniformDefined(name, vs)) { if (!inject) { - inject = _glsl2['default'].defineUniform(name, uniforms[name]); + inject = _glsl2.default.defineUniform(name, uniforms[name]); } - (0, _utilsLog2['default'])('trace', 'Program ' + this.name + ': ' + name + ' not defined in vertex shader, injecting: \'' + inject + '\''); + (0, _log2.default)('trace', 'Program ' + this.name + ': ' + name + ' not defined in vertex shader, injecting: \'' + inject + '\''); vs_injections.push(inject); } // Check fragment shader - if (!_glsl2['default'].isUniformDefined(name, fs)) { + if (!_glsl2.default.isUniformDefined(name, fs)) { if (!inject) { - inject = _glsl2['default'].defineUniform(name, uniforms[name]); + inject = _glsl2.default.defineUniform(name, uniforms[name]); } - (0, _utilsLog2['default'])('trace', 'Program ' + this.name + ': ' + name + ' not defined in fragment shader, injecting: \'' + inject + '\''); + (0, _log2.default)('trace', 'Program ' + this.name + ': ' + name + ' not defined in fragment shader, injecting: \'' + inject + '\''); fs_injections.push(inject); } } @@ -29435,6 +30294,7 @@ var ShaderProgram = (function () { } // Set uniforms from a JS object, with inferred types + }, { key: 'setUniforms', value: function setUniforms(uniforms) { @@ -29455,7 +30315,7 @@ var ShaderProgram = (function () { } // Parse uniform types and values from the JS object - var parsed = _glsl2['default'].parseUniforms(uniforms); + var parsed = _glsl2.default.parseUniforms(uniforms); // Set each uniform for (var u = 0; u < parsed.length; u++) { @@ -29470,6 +30330,7 @@ var ShaderProgram = (function () { } // Cache some or all uniform values so they can be restored + }, { key: 'saveUniforms', value: function saveUniforms(subset) { @@ -29484,6 +30345,7 @@ var ShaderProgram = (function () { } // Restore some or all uniforms to saved values + }, { key: 'restoreUniforms', value: function restoreUniforms(subset) { @@ -29499,12 +30361,13 @@ var ShaderProgram = (function () { } // Set a texture uniform, finds texture by name or creates a new one + }, { key: 'setTextureUniform', value: function setTextureUniform(uniform_name, texture_name) { - var texture = _texture2['default'].textures[texture_name]; + var texture = _texture2.default.textures[texture_name]; if (texture == null) { - (0, _utilsLog2['default'])('warn', 'Cannot find texture \'' + texture_name + '\''); + (0, _log2.default)('warn', 'Cannot find texture \'' + texture_name + '\''); return; } @@ -29515,6 +30378,7 @@ var ShaderProgram = (function () { // ex: program.uniform('3fv', 'position', [x, y, z]); // TODO: only update uniforms when changed + }, { key: 'uniform', value: function uniform(method, name, value) { @@ -29535,6 +30399,7 @@ var ShaderProgram = (function () { } // Set a single uniform + }, { key: 'updateUniform', value: function updateUniform(uniform) { @@ -29551,6 +30416,7 @@ var ShaderProgram = (function () { } // Commits the uniform to the GPU + }, { key: 'commitUniform', value: function commitUniform(uniform) { @@ -29601,6 +30467,7 @@ var ShaderProgram = (function () { } // Refresh uniform locations and set to last cached values + }, { key: 'refreshUniforms', value: function refreshUniforms() { @@ -29625,6 +30492,7 @@ var ShaderProgram = (function () { } // Get the location of a vertex attribute + }, { key: 'attribute', value: function attribute(name) { @@ -29648,6 +30516,7 @@ var ShaderProgram = (function () { } // Get shader source as string + }, { key: 'source', value: function source(type) { @@ -29659,6 +30528,7 @@ var ShaderProgram = (function () { } // Get shader source as array of line strings + }, { key: 'lines', value: function lines(type) { @@ -29670,6 +30540,7 @@ var ShaderProgram = (function () { } // Get a specific line from shader source + }, { key: 'line', value: function line(type, num) { @@ -29690,11 +30561,12 @@ var ShaderProgram = (function () { // We could track line ranges for shader blocks as they are inserted, but as this code is only used for // error handling on compilation failure, it was simpler to keep it separate than to burden the core // compilation path. + }, { key: 'block', value: function block(type, num) { var lines = this.lines(type); - var block = undefined; + var block = void 0; for (var i = 0; i < num && i < lines.length; i++) { var line = lines[i]; var match = line.match(/\/\/ tangram-block-start: ([A-Za-z0-9_-]+), ([A-Za-z0-9_-]+), (\d+)/); @@ -29724,6 +30596,7 @@ var ShaderProgram = (function () { // Returns list of available extensions from those requested // Sets internal #defines indicating availability of each requested extension + }, { key: 'checkExtensions', value: function checkExtensions() { @@ -29733,18 +30606,18 @@ var ShaderProgram = (function () { var _iteratorError2 = undefined; try { - for (var _iterator2 = _getIterator(this.extensions), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { - var _name = _step2.value; + for (var _iterator2 = (0, _getIterator3.default)(this.extensions), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { + var name = _step2.value; - var ext = (0, _extensions2['default'])(this.gl, _name); - var def = 'TANGRAM_EXTENSION_' + _name; + var ext = (0, _extensions2.default)(this.gl, name); + var def = 'TANGRAM_EXTENSION_' + name; this.defines[def] = ext != null; if (ext) { - exts.push(_name); + exts.push(name); } else { - (0, _utilsLog2['default'])('debug', 'Could not enable extension \'' + _name + '\''); + (0, _log2.default)('debug', 'Could not enable extension \'' + name + '\''); } } } catch (err) { @@ -29752,8 +30625,8 @@ var ShaderProgram = (function () { _iteratorError2 = err; } finally { try { - if (!_iteratorNormalCompletion2 && _iterator2['return']) { - _iterator2['return'](); + if (!_iteratorNormalCompletion2 && _iterator2.return) { + _iterator2.return(); } } finally { if (_didIteratorError2) { @@ -29765,11 +30638,12 @@ var ShaderProgram = (function () { return exts; } }]); - return ShaderProgram; -})(); +}(); + +// Static methods and state -exports['default'] = ShaderProgram; +exports.default = ShaderProgram; ShaderProgram.id = 0; // assign each program a unique id ShaderProgram.programs = {}; // programs, by id ShaderProgram.current = null; // currently bound program @@ -29807,7 +30681,7 @@ ShaderProgram.buildExtensionString = function (extensions) { var _iteratorError3 = undefined; try { - for (var _iterator3 = _getIterator(extensions), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { + for (var _iterator3 = (0, _getIterator3.default)(extensions), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { var ext = _step3.value; str += '#ifdef GL_' + ext + '\n#extension GL_' + ext + ' : enable\n#endif\n'; @@ -29817,8 +30691,8 @@ ShaderProgram.buildExtensionString = function (extensions) { _iteratorError3 = err; } finally { try { - if (!_iteratorNormalCompletion3 && _iterator3['return']) { - _iterator3['return'](); + if (!_iteratorNormalCompletion3 && _iterator3.return) { + _iterator3.return(); } } finally { if (_didIteratorError3) { @@ -29831,7 +30705,7 @@ ShaderProgram.buildExtensionString = function (extensions) { }; ShaderProgram.addBlock = function (key) { - var _ShaderProgram$blocks$key; + var _ShaderProgram$blocks; ShaderProgram.blocks[key] = ShaderProgram.blocks[key] || []; @@ -29839,7 +30713,7 @@ ShaderProgram.addBlock = function (key) { blocks[_key - 1] = arguments[_key]; } - (_ShaderProgram$blocks$key = ShaderProgram.blocks[key]).push.apply(_ShaderProgram$blocks$key, blocks); + (_ShaderProgram$blocks = ShaderProgram.blocks[key]).push.apply(_ShaderProgram$blocks, blocks); }; // Remove all global shader blocks for a given key @@ -29864,7 +30738,7 @@ ShaderProgram.updateProgram = function (gl, program, vertex_shader_source, fragm var vertex_shader = ShaderProgram.createShader(gl, vertex_shader_source, gl.VERTEX_SHADER); var fragment_shader = ShaderProgram.createShader(gl, fragment_shader_source, gl.FRAGMENT_SHADER); } catch (err) { - (0, _utilsLog2['default'])('error', err.message); + (0, _log2.default)('error', err.message); throw err; } @@ -29894,7 +30768,7 @@ ShaderProgram.updateProgram = function (gl, program, vertex_shader_source, fragm var message = new Error('WebGL program error:\n VALIDATE_STATUS: ' + gl.getProgramParameter(program, gl.VALIDATE_STATUS) + '\n ERROR: ' + gl.getError() + '\n --- Vertex Shader ---\n ' + vertex_shader_source + '\n --- Fragment Shader ---\n ' + fragment_shader_source); var error = { type: 'program', message: message }; - (0, _utilsLog2['default'])('error', error.message); + (0, _log2.default)('error', error.message); throw error; } @@ -29911,59 +30785,72 @@ ShaderProgram.createShader = function (gl, source, stype) { if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) { var type = stype === gl.VERTEX_SHADER ? 'vertex' : 'fragment'; var message = gl.getShaderInfoLog(shader); - var errors = (0, _glShaderErrors2['default'])(message); + var errors = (0, _glShaderErrors2.default)(message); throw { type: type, message: message, errors: errors }; } return shader; }; -module.exports = exports['default']; -},{"../utils/log":321,"./extensions":271,"./glsl":272,"./texture":275,"babel-runtime/core-js/get-iterator":4,"babel-runtime/core-js/object/assign":8,"babel-runtime/helpers/class-call-check":21,"babel-runtime/helpers/create-class":22,"babel-runtime/helpers/interop-require-default":26,"babel-runtime/helpers/to-consumable-array":28,"gl-shader-errors":158,"strip-comments":253}],275:[function(_dereq_,module,exports){ -// Texture management +},{"../utils/log":350,"./extensions":300,"./glsl":301,"./texture":304,"babel-runtime/core-js/get-iterator":4,"babel-runtime/core-js/object/assign":9,"babel-runtime/helpers/classCallCheck":21,"babel-runtime/helpers/createClass":22,"babel-runtime/helpers/toConsumableArray":28,"gl-shader-errors":185,"strip-comments":282}],304:[function(_dereq_,module,exports){ 'use strict'; -var _createClass = _dereq_('babel-runtime/helpers/create-class')['default']; +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _getIterator2 = _dereq_('babel-runtime/core-js/get-iterator'); -var _classCallCheck = _dereq_('babel-runtime/helpers/class-call-check')['default']; +var _getIterator3 = _interopRequireDefault(_getIterator2); -var _Object$assign = _dereq_('babel-runtime/core-js/object/assign')['default']; +var _keys = _dereq_('babel-runtime/core-js/object/keys'); -var _Promise = _dereq_('babel-runtime/core-js/promise')['default']; +var _keys2 = _interopRequireDefault(_keys); -var _Object$keys = _dereq_('babel-runtime/core-js/object/keys')['default']; +var _stringify = _dereq_('babel-runtime/core-js/json/stringify'); -var _getIterator = _dereq_('babel-runtime/core-js/get-iterator')['default']; +var _stringify2 = _interopRequireDefault(_stringify); -var _interopRequireDefault = _dereq_('babel-runtime/helpers/interop-require-default')['default']; +var _promise = _dereq_('babel-runtime/core-js/promise'); -Object.defineProperty(exports, '__esModule', { - value: true -}); +var _promise2 = _interopRequireDefault(_promise); + +var _assign = _dereq_('babel-runtime/core-js/object/assign'); -var _utilsLog = _dereq_('../utils/log'); +var _assign2 = _interopRequireDefault(_assign); -var _utilsLog2 = _interopRequireDefault(_utilsLog); +var _classCallCheck2 = _dereq_('babel-runtime/helpers/classCallCheck'); -var _utilsUtils = _dereq_('../utils/utils'); +var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); -var _utilsUtils2 = _interopRequireDefault(_utilsUtils); +var _createClass2 = _dereq_('babel-runtime/helpers/createClass'); -var _utilsSubscribe = _dereq_('../utils/subscribe'); +var _createClass3 = _interopRequireDefault(_createClass2); -var _utilsSubscribe2 = _interopRequireDefault(_utilsSubscribe); +var _log = _dereq_('../utils/log'); -var _utilsWorker_broker = _dereq_('../utils/worker_broker'); +var _log2 = _interopRequireDefault(_log); -var _utilsWorker_broker2 = _interopRequireDefault(_utilsWorker_broker); +var _utils = _dereq_('../utils/utils'); -// GL texture wrapper object for keeping track of a global set of textures, keyed by a unique user-defined name +var _utils2 = _interopRequireDefault(_utils); -var Texture = (function () { +var _subscribe = _dereq_('../utils/subscribe'); + +var _subscribe2 = _interopRequireDefault(_subscribe); + +var _worker_broker = _dereq_('../utils/worker_broker'); + +var _worker_broker2 = _interopRequireDefault(_worker_broker); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// GL texture wrapper object for keeping track of a global set of textures, keyed by a unique user-defined name +// Texture management +var Texture = function () { function Texture(gl, name) { var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; - - _classCallCheck(this, Texture); + (0, _classCallCheck3.default)(this, Texture); this.gl = gl; this.texture = gl.createTexture(); @@ -29998,17 +30885,16 @@ var Texture = (function () { // Cache texture instance and definition Texture.textures[this.name] = this; - Texture.texture_configs[this.name] = _Object$assign({ name: name }, options); + Texture.texture_configs[this.name] = (0, _assign2.default)({ name: name }, options); this.load(options); - (0, _utilsLog2['default'])('trace', 'creating Texture ' + this.name); + (0, _log2.default)('trace', 'creating Texture ' + this.name); } - // Static/class methods and state - // Destroy a single texture instance - _createClass(Texture, [{ + + (0, _createClass3.default)(Texture, [{ key: 'destroy', value: function destroy() { var _ref = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; @@ -30016,7 +30902,7 @@ var Texture = (function () { var force = _ref.force; if (this.retain_count > 0 && !force) { - (0, _utilsLog2['default'])('error', 'Texture \'' + this.name + '\': destroying texture with retain count of \'' + this.retain_count + '\''); + (0, _log2.default)('error', 'Texture \'' + this.name + '\': destroying texture with retain count of \'' + this.retain_count + '\''); return; } @@ -30029,7 +30915,7 @@ var Texture = (function () { this.data = null; delete Texture.textures[this.name]; this.valid = false; - (0, _utilsLog2['default'])('trace', 'destroying Texture ' + this.name); + (0, _log2.default)('trace', 'destroying Texture ' + this.name); } }, { key: 'retain', @@ -30040,7 +30926,7 @@ var Texture = (function () { key: 'release', value: function release() { if (this.retain_count <= 0) { - (0, _utilsLog2['default'])('error', 'Texture \'' + this.name + '\': releasing texture with retain count of \'' + this.retain_count + '\''); + (0, _log2.default)('error', 'Texture \'' + this.name + '\': releasing texture with retain count of \'' + this.retain_count + '\''); } this.retain_count--; @@ -30074,7 +30960,7 @@ var Texture = (function () { var _this = this; if (!options) { - return this.loading || _Promise.resolve(this); + return this.loading || _promise2.default.resolve(this); } this.loading = null; @@ -30091,11 +30977,12 @@ var Texture = (function () { this.loading = this.loading && this.loading.then(function () { _this.calculateSprites();return _this; - }) || _Promise.resolve(this); + }) || _promise2.default.resolve(this); return this.loading; } // Sets texture from an url + }, { key: 'setUrl', value: function setUrl(url) { @@ -30108,21 +30995,21 @@ var Texture = (function () { } if (Texture.base_url) { - url = _utilsUtils2['default'].addBaseURL(url, Texture.base_url); + url = _utils2.default.addBaseURL(url, Texture.base_url); } this.url = url; // save URL reference (will be overwritten when element is loaded below) this.source = this.url; this.source_type = 'url'; - this.loading = new _Promise(function (resolve, reject) { + this.loading = new _promise2.default(function (resolve, reject) { var image = new Image(); image.onload = function () { try { _this2.setElement(image, options); } catch (e) { _this2.loaded = false; - (0, _utilsLog2['default'])('warn', 'Texture \'' + _this2.name + '\': failed to load url: \'' + _this2.source + '\'', e, options); + (0, _log2.default)('warn', 'Texture \'' + _this2.name + '\': failed to load url: \'' + _this2.source + '\'', e, options); Texture.trigger('warning', { message: 'Failed to load texture from ' + _this2.source, error: e, texture: options }); } @@ -30132,14 +31019,14 @@ var Texture = (function () { image.onerror = function (e) { // Warn and resolve on error _this2.loaded = false; - (0, _utilsLog2['default'])('warn', 'Texture \'' + _this2.name + '\': failed to load url: \'' + _this2.source + '\'', e, options); + (0, _log2.default)('warn', 'Texture \'' + _this2.name + '\': failed to load url: \'' + _this2.source + '\'', e, options); Texture.trigger('warning', { message: 'Failed to load texture from ' + _this2.source, error: e, texture: options }); resolve(_this2); }; // Safari has a bug loading data-URL images with CORS enabled, so it must be disabled in that case // https://bugs.webkit.org/show_bug.cgi?id=123978 - if (!(_utilsUtils2['default'].isSafari() && _this2.source.slice(0, 5) === 'data:')) { + if (!(_utils2.default.isSafari() && _this2.source.slice(0, 5) === 'data:')) { image.crossOrigin = 'anonymous'; } @@ -30149,6 +31036,7 @@ var Texture = (function () { } // Sets texture to a raw image buffer + }, { key: 'setData', value: function setData(width, height, data) { @@ -30169,11 +31057,12 @@ var Texture = (function () { this.setFiltering(options); this.loaded = true; - this.loading = _Promise.resolve(this); + this.loading = _promise2.default.resolve(this); return this.loading; } // Sets the texture to track a element (canvas/image) + }, { key: 'setElement', value: function setElement(element, options) { @@ -30192,18 +31081,19 @@ var Texture = (function () { this.setFiltering(options); } else { this.loaded = false; - var msg = 'the \'element\' parameter (`element: ' + JSON.stringify(el) + '`) must be a CSS '; + var msg = 'the \'element\' parameter (`element: ' + (0, _stringify2.default)(el) + '`) must be a CSS '; msg += 'selector string, or a , or