browser.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
  2. 'use strict';
  3. var keys = require('object-keys').shim();
  4. delete keys.shim;
  5. var assign = require('./');
  6. module.exports = assign.shim();
  7. delete assign.shim;
  8. },{"./":3,"object-keys":9}],2:[function(require,module,exports){
  9. 'use strict';
  10. // modified from https://github.com/es-shims/es6-shim
  11. var keys = require('object-keys');
  12. var bind = require('function-bind');
  13. var canBeObject = function (obj) {
  14. return typeof obj !== 'undefined' && obj !== null;
  15. };
  16. var hasSymbols = require('has-symbols/shams')();
  17. var toObject = Object;
  18. var push = bind.call(Function.call, Array.prototype.push);
  19. var propIsEnumerable = bind.call(Function.call, Object.prototype.propertyIsEnumerable);
  20. var originalGetSymbols = hasSymbols ? Object.getOwnPropertySymbols : null;
  21. module.exports = function assign(target, source1) {
  22. if (!canBeObject(target)) { throw new TypeError('target must be an object'); }
  23. var objTarget = toObject(target);
  24. var s, source, i, props, syms, value, key;
  25. for (s = 1; s < arguments.length; ++s) {
  26. source = toObject(arguments[s]);
  27. props = keys(source);
  28. var getSymbols = hasSymbols && (Object.getOwnPropertySymbols || originalGetSymbols);
  29. if (getSymbols) {
  30. syms = getSymbols(source);
  31. for (i = 0; i < syms.length; ++i) {
  32. key = syms[i];
  33. if (propIsEnumerable(source, key)) {
  34. push(props, key);
  35. }
  36. }
  37. }
  38. for (i = 0; i < props.length; ++i) {
  39. key = props[i];
  40. value = source[key];
  41. if (propIsEnumerable(source, key)) {
  42. objTarget[key] = value;
  43. }
  44. }
  45. }
  46. return objTarget;
  47. };
  48. },{"function-bind":7,"has-symbols/shams":8,"object-keys":9}],3:[function(require,module,exports){
  49. 'use strict';
  50. var defineProperties = require('define-properties');
  51. var implementation = require('./implementation');
  52. var getPolyfill = require('./polyfill');
  53. var shim = require('./shim');
  54. var polyfill = getPolyfill();
  55. defineProperties(polyfill, {
  56. getPolyfill: getPolyfill,
  57. implementation: implementation,
  58. shim: shim
  59. });
  60. module.exports = polyfill;
  61. },{"./implementation":2,"./polyfill":11,"./shim":12,"define-properties":4}],4:[function(require,module,exports){
  62. 'use strict';
  63. var keys = require('object-keys');
  64. var foreach = require('foreach');
  65. var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol';
  66. var toStr = Object.prototype.toString;
  67. var isFunction = function (fn) {
  68. return typeof fn === 'function' && toStr.call(fn) === '[object Function]';
  69. };
  70. var arePropertyDescriptorsSupported = function () {
  71. var obj = {};
  72. try {
  73. Object.defineProperty(obj, 'x', { enumerable: false, value: obj });
  74. /* eslint-disable no-unused-vars, no-restricted-syntax */
  75. for (var _ in obj) { return false; }
  76. /* eslint-enable no-unused-vars, no-restricted-syntax */
  77. return obj.x === obj;
  78. } catch (e) { /* this is IE 8. */
  79. return false;
  80. }
  81. };
  82. var supportsDescriptors = Object.defineProperty && arePropertyDescriptorsSupported();
  83. var defineProperty = function (object, name, value, predicate) {
  84. if (name in object && (!isFunction(predicate) || !predicate())) {
  85. return;
  86. }
  87. if (supportsDescriptors) {
  88. Object.defineProperty(object, name, {
  89. configurable: true,
  90. enumerable: false,
  91. value: value,
  92. writable: true
  93. });
  94. } else {
  95. object[name] = value;
  96. }
  97. };
  98. var defineProperties = function (object, map) {
  99. var predicates = arguments.length > 2 ? arguments[2] : {};
  100. var props = keys(map);
  101. if (hasSymbols) {
  102. props = props.concat(Object.getOwnPropertySymbols(map));
  103. }
  104. foreach(props, function (name) {
  105. defineProperty(object, name, map[name], predicates[name]);
  106. });
  107. };
  108. defineProperties.supportsDescriptors = !!supportsDescriptors;
  109. module.exports = defineProperties;
  110. },{"foreach":5,"object-keys":9}],5:[function(require,module,exports){
  111. var hasOwn = Object.prototype.hasOwnProperty;
  112. var toString = Object.prototype.toString;
  113. module.exports = function forEach (obj, fn, ctx) {
  114. if (toString.call(fn) !== '[object Function]') {
  115. throw new TypeError('iterator must be a function');
  116. }
  117. var l = obj.length;
  118. if (l === +l) {
  119. for (var i = 0; i < l; i++) {
  120. fn.call(ctx, obj[i], i, obj);
  121. }
  122. } else {
  123. for (var k in obj) {
  124. if (hasOwn.call(obj, k)) {
  125. fn.call(ctx, obj[k], k, obj);
  126. }
  127. }
  128. }
  129. };
  130. },{}],6:[function(require,module,exports){
  131. 'use strict';
  132. /* eslint no-invalid-this: 1 */
  133. var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
  134. var slice = Array.prototype.slice;
  135. var toStr = Object.prototype.toString;
  136. var funcType = '[object Function]';
  137. module.exports = function bind(that) {
  138. var target = this;
  139. if (typeof target !== 'function' || toStr.call(target) !== funcType) {
  140. throw new TypeError(ERROR_MESSAGE + target);
  141. }
  142. var args = slice.call(arguments, 1);
  143. var bound;
  144. var binder = function () {
  145. if (this instanceof bound) {
  146. var result = target.apply(
  147. this,
  148. args.concat(slice.call(arguments))
  149. );
  150. if (Object(result) === result) {
  151. return result;
  152. }
  153. return this;
  154. } else {
  155. return target.apply(
  156. that,
  157. args.concat(slice.call(arguments))
  158. );
  159. }
  160. };
  161. var boundLength = Math.max(0, target.length - args.length);
  162. var boundArgs = [];
  163. for (var i = 0; i < boundLength; i++) {
  164. boundArgs.push('$' + i);
  165. }
  166. bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
  167. if (target.prototype) {
  168. var Empty = function Empty() {};
  169. Empty.prototype = target.prototype;
  170. bound.prototype = new Empty();
  171. Empty.prototype = null;
  172. }
  173. return bound;
  174. };
  175. },{}],7:[function(require,module,exports){
  176. 'use strict';
  177. var implementation = require('./implementation');
  178. module.exports = Function.prototype.bind || implementation;
  179. },{"./implementation":6}],8:[function(require,module,exports){
  180. 'use strict';
  181. /* eslint complexity: [2, 17], max-statements: [2, 33] */
  182. module.exports = function hasSymbols() {
  183. if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; }
  184. if (typeof Symbol.iterator === 'symbol') { return true; }
  185. var obj = {};
  186. var sym = Symbol('test');
  187. var symObj = Object(sym);
  188. if (typeof sym === 'string') { return false; }
  189. if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; }
  190. if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; }
  191. // temp disabled per https://github.com/ljharb/object.assign/issues/17
  192. // if (sym instanceof Symbol) { return false; }
  193. // temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4
  194. // if (!(symObj instanceof Symbol)) { return false; }
  195. // if (typeof Symbol.prototype.toString !== 'function') { return false; }
  196. // if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; }
  197. var symVal = 42;
  198. obj[sym] = symVal;
  199. for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax
  200. if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; }
  201. if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; }
  202. var syms = Object.getOwnPropertySymbols(obj);
  203. if (syms.length !== 1 || syms[0] !== sym) { return false; }
  204. if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; }
  205. if (typeof Object.getOwnPropertyDescriptor === 'function') {
  206. var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
  207. if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; }
  208. }
  209. return true;
  210. };
  211. },{}],9:[function(require,module,exports){
  212. 'use strict';
  213. // modified from https://github.com/es-shims/es5-shim
  214. var has = Object.prototype.hasOwnProperty;
  215. var toStr = Object.prototype.toString;
  216. var slice = Array.prototype.slice;
  217. var isArgs = require('./isArguments');
  218. var isEnumerable = Object.prototype.propertyIsEnumerable;
  219. var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString');
  220. var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype');
  221. var dontEnums = [
  222. 'toString',
  223. 'toLocaleString',
  224. 'valueOf',
  225. 'hasOwnProperty',
  226. 'isPrototypeOf',
  227. 'propertyIsEnumerable',
  228. 'constructor'
  229. ];
  230. var equalsConstructorPrototype = function (o) {
  231. var ctor = o.constructor;
  232. return ctor && ctor.prototype === o;
  233. };
  234. var excludedKeys = {
  235. $console: true,
  236. $external: true,
  237. $frame: true,
  238. $frameElement: true,
  239. $frames: true,
  240. $innerHeight: true,
  241. $innerWidth: true,
  242. $outerHeight: true,
  243. $outerWidth: true,
  244. $pageXOffset: true,
  245. $pageYOffset: true,
  246. $parent: true,
  247. $scrollLeft: true,
  248. $scrollTop: true,
  249. $scrollX: true,
  250. $scrollY: true,
  251. $self: true,
  252. $webkitIndexedDB: true,
  253. $webkitStorageInfo: true,
  254. $window: true
  255. };
  256. var hasAutomationEqualityBug = (function () {
  257. /* global window */
  258. if (typeof window === 'undefined') { return false; }
  259. for (var k in window) {
  260. try {
  261. if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
  262. try {
  263. equalsConstructorPrototype(window[k]);
  264. } catch (e) {
  265. return true;
  266. }
  267. }
  268. } catch (e) {
  269. return true;
  270. }
  271. }
  272. return false;
  273. }());
  274. var equalsConstructorPrototypeIfNotBuggy = function (o) {
  275. /* global window */
  276. if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
  277. return equalsConstructorPrototype(o);
  278. }
  279. try {
  280. return equalsConstructorPrototype(o);
  281. } catch (e) {
  282. return false;
  283. }
  284. };
  285. var keysShim = function keys(object) {
  286. var isObject = object !== null && typeof object === 'object';
  287. var isFunction = toStr.call(object) === '[object Function]';
  288. var isArguments = isArgs(object);
  289. var isString = isObject && toStr.call(object) === '[object String]';
  290. var theKeys = [];
  291. if (!isObject && !isFunction && !isArguments) {
  292. throw new TypeError('Object.keys called on a non-object');
  293. }
  294. var skipProto = hasProtoEnumBug && isFunction;
  295. if (isString && object.length > 0 && !has.call(object, 0)) {
  296. for (var i = 0; i < object.length; ++i) {
  297. theKeys.push(String(i));
  298. }
  299. }
  300. if (isArguments && object.length > 0) {
  301. for (var j = 0; j < object.length; ++j) {
  302. theKeys.push(String(j));
  303. }
  304. } else {
  305. for (var name in object) {
  306. if (!(skipProto && name === 'prototype') && has.call(object, name)) {
  307. theKeys.push(String(name));
  308. }
  309. }
  310. }
  311. if (hasDontEnumBug) {
  312. var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
  313. for (var k = 0; k < dontEnums.length; ++k) {
  314. if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) {
  315. theKeys.push(dontEnums[k]);
  316. }
  317. }
  318. }
  319. return theKeys;
  320. };
  321. keysShim.shim = function shimObjectKeys() {
  322. if (Object.keys) {
  323. var keysWorksWithArguments = (function () {
  324. // Safari 5.0 bug
  325. return (Object.keys(arguments) || '').length === 2;
  326. }(1, 2));
  327. if (!keysWorksWithArguments) {
  328. var originalKeys = Object.keys;
  329. Object.keys = function keys(object) {
  330. if (isArgs(object)) {
  331. return originalKeys(slice.call(object));
  332. } else {
  333. return originalKeys(object);
  334. }
  335. };
  336. }
  337. } else {
  338. Object.keys = keysShim;
  339. }
  340. return Object.keys || keysShim;
  341. };
  342. module.exports = keysShim;
  343. },{"./isArguments":10}],10:[function(require,module,exports){
  344. 'use strict';
  345. var toStr = Object.prototype.toString;
  346. module.exports = function isArguments(value) {
  347. var str = toStr.call(value);
  348. var isArgs = str === '[object Arguments]';
  349. if (!isArgs) {
  350. isArgs = str !== '[object Array]' &&
  351. value !== null &&
  352. typeof value === 'object' &&
  353. typeof value.length === 'number' &&
  354. value.length >= 0 &&
  355. toStr.call(value.callee) === '[object Function]';
  356. }
  357. return isArgs;
  358. };
  359. },{}],11:[function(require,module,exports){
  360. 'use strict';
  361. var implementation = require('./implementation');
  362. var lacksProperEnumerationOrder = function () {
  363. if (!Object.assign) {
  364. return false;
  365. }
  366. // v8, specifically in node 4.x, has a bug with incorrect property enumeration order
  367. // note: this does not detect the bug unless there's 20 characters
  368. var str = 'abcdefghijklmnopqrst';
  369. var letters = str.split('');
  370. var map = {};
  371. for (var i = 0; i < letters.length; ++i) {
  372. map[letters[i]] = letters[i];
  373. }
  374. var obj = Object.assign({}, map);
  375. var actual = '';
  376. for (var k in obj) {
  377. actual += k;
  378. }
  379. return str !== actual;
  380. };
  381. var assignHasPendingExceptions = function () {
  382. if (!Object.assign || !Object.preventExtensions) {
  383. return false;
  384. }
  385. // Firefox 37 still has "pending exception" logic in its Object.assign implementation,
  386. // which is 72% slower than our shim, and Firefox 40's native implementation.
  387. var thrower = Object.preventExtensions({ 1: 2 });
  388. try {
  389. Object.assign(thrower, 'xy');
  390. } catch (e) {
  391. return thrower[1] === 'y';
  392. }
  393. return false;
  394. };
  395. module.exports = function getPolyfill() {
  396. if (!Object.assign) {
  397. return implementation;
  398. }
  399. if (lacksProperEnumerationOrder()) {
  400. return implementation;
  401. }
  402. if (assignHasPendingExceptions()) {
  403. return implementation;
  404. }
  405. return Object.assign;
  406. };
  407. },{"./implementation":2}],12:[function(require,module,exports){
  408. 'use strict';
  409. var define = require('define-properties');
  410. var getPolyfill = require('./polyfill');
  411. module.exports = function shimAssign() {
  412. var polyfill = getPolyfill();
  413. define(
  414. Object,
  415. { assign: polyfill },
  416. { assign: function () { return Object.assign !== polyfill; } }
  417. );
  418. return polyfill;
  419. };
  420. },{"./polyfill":11,"define-properties":4}]},{},[1]);