You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

635 lines
14 KiB

  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. angular.module('nemLogging', []);
  3. angular.module('nemLogging').provider('nemDebug', function (){
  4. var ourDebug = null;
  5. ourDebug = require('debug');
  6. this.$get = function(){
  7. //avail as service
  8. return ourDebug;
  9. };
  10. //avail at provider, config time
  11. this.debug = ourDebug;
  12. return this;
  13. });
  14. var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
  15. slice = [].slice;
  16. angular.module('nemLogging').provider('nemSimpleLogger', [
  17. 'nemDebugProvider', function(nemDebugProvider) {
  18. var LEVELS, Logger, _debugCache, _fns, _isValidLogObject, _maybeExecLevel, _wrapDebug, i, key, len, nemDebug, val;
  19. nemDebug = nemDebugProvider.debug;
  20. _debugCache = {};
  21. _fns = ['debug', 'info', 'warn', 'error', 'log'];
  22. LEVELS = {};
  23. for (key = i = 0, len = _fns.length; i < len; key = ++i) {
  24. val = _fns[key];
  25. LEVELS[val] = key;
  26. }
  27. _maybeExecLevel = function(level, current, fn) {
  28. if (level >= current) {
  29. return fn();
  30. }
  31. };
  32. _isValidLogObject = function(logObject) {
  33. var isValid, j, len1;
  34. isValid = false;
  35. if (!logObject) {
  36. return isValid;
  37. }
  38. for (j = 0, len1 = _fns.length; j < len1; j++) {
  39. val = _fns[j];
  40. isValid = (logObject[val] != null) && typeof logObject[val] === 'function';
  41. if (!isValid) {
  42. break;
  43. }
  44. }
  45. return isValid;
  46. };
  47. /*
  48. Overide logeObject.debug with a nemDebug instance
  49. see: https://github.com/visionmedia/debug/blob/master/Readme.md
  50. */
  51. _wrapDebug = function(namespace, logObject) {
  52. var debugInstance, j, len1, newLogger;
  53. if (_debugCache[namespace] == null) {
  54. _debugCache[namespace] = nemDebug(namespace);
  55. }
  56. debugInstance = _debugCache[namespace];
  57. newLogger = {};
  58. for (j = 0, len1 = _fns.length; j < len1; j++) {
  59. val = _fns[j];
  60. newLogger[val] = val === 'debug' ? debugInstance : logObject[val];
  61. }
  62. return newLogger;
  63. };
  64. Logger = (function() {
  65. function Logger($log1) {
  66. var fn1, j, len1, level, logFns;
  67. this.$log = $log1;
  68. this.spawn = bind(this.spawn, this);
  69. if (!this.$log) {
  70. throw 'internalLogger undefined';
  71. }
  72. if (!_isValidLogObject(this.$log)) {
  73. throw '@$log is invalid';
  74. }
  75. this.doLog = true;
  76. logFns = {};
  77. fn1 = (function(_this) {
  78. return function(level) {
  79. logFns[level] = function() {
  80. var args;
  81. args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
  82. if (_this.doLog) {
  83. return _maybeExecLevel(LEVELS[level], _this.currentLevel, function() {
  84. var ref;
  85. return (ref = _this.$log)[level].apply(ref, args);
  86. });
  87. }
  88. };
  89. return _this[level] = logFns[level];
  90. };
  91. })(this);
  92. for (j = 0, len1 = _fns.length; j < len1; j++) {
  93. level = _fns[j];
  94. fn1(level);
  95. }
  96. this.LEVELS = LEVELS;
  97. this.currentLevel = LEVELS.error;
  98. }
  99. Logger.prototype.spawn = function(newInternalLogger) {
  100. if (typeof newInternalLogger === 'string') {
  101. if (!_isValidLogObject(this.$log)) {
  102. throw '@$log is invalid';
  103. }
  104. if (!nemDebug) {
  105. throw 'nemDebug is undefined this is probably the light version of this library sep debug logggers is not supported!';
  106. }
  107. return _wrapDebug(newInternalLogger, this.$log);
  108. }
  109. return new Logger(newInternalLogger || this.$log);
  110. };
  111. return Logger;
  112. })();
  113. this.decorator = [
  114. '$log', function($delegate) {
  115. var log;
  116. log = new Logger($delegate);
  117. log.currentLevel = LEVELS.debug;
  118. return log;
  119. }
  120. ];
  121. this.$get = [
  122. '$log', function($log) {
  123. return new Logger($log);
  124. }
  125. ];
  126. return this;
  127. }
  128. ]);
  129. },{"debug":2}],2:[function(require,module,exports){
  130. /**
  131. * This is the web browser implementation of `debug()`.
  132. *
  133. * Expose `debug()` as the module.
  134. */
  135. exports = module.exports = require('./debug');
  136. exports.log = log;
  137. exports.formatArgs = formatArgs;
  138. exports.save = save;
  139. exports.load = load;
  140. exports.useColors = useColors;
  141. exports.storage = 'undefined' != typeof chrome
  142. && 'undefined' != typeof chrome.storage
  143. ? chrome.storage.local
  144. : localstorage();
  145. /**
  146. * Colors.
  147. */
  148. exports.colors = [
  149. 'lightseagreen',
  150. 'forestgreen',
  151. 'goldenrod',
  152. 'dodgerblue',
  153. 'darkorchid',
  154. 'crimson'
  155. ];
  156. /**
  157. * Currently only WebKit-based Web Inspectors, Firefox >= v31,
  158. * and the Firebug extension (any Firefox version) are known
  159. * to support "%c" CSS customizations.
  160. *
  161. * TODO: add a `localStorage` variable to explicitly enable/disable colors
  162. */
  163. function useColors() {
  164. // is webkit? http://stackoverflow.com/a/16459606/376773
  165. return ('WebkitAppearance' in document.documentElement.style) ||
  166. // is firebug? http://stackoverflow.com/a/398120/376773
  167. (window.console && (console.firebug || (console.exception && console.table))) ||
  168. // is firefox >= v31?
  169. // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
  170. (navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31);
  171. }
  172. /**
  173. * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
  174. */
  175. exports.formatters.j = function(v) {
  176. return JSON.stringify(v);
  177. };
  178. /**
  179. * Colorize log arguments if enabled.
  180. *
  181. * @api public
  182. */
  183. function formatArgs() {
  184. var args = arguments;
  185. var useColors = this.useColors;
  186. args[0] = (useColors ? '%c' : '')
  187. + this.namespace
  188. + (useColors ? ' %c' : ' ')
  189. + args[0]
  190. + (useColors ? '%c ' : ' ')
  191. + '+' + exports.humanize(this.diff);
  192. if (!useColors) return args;
  193. var c = 'color: ' + this.color;
  194. args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1));
  195. // the final "%c" is somewhat tricky, because there could be other
  196. // arguments passed either before or after the %c, so we need to
  197. // figure out the correct index to insert the CSS into
  198. var index = 0;
  199. var lastC = 0;
  200. args[0].replace(/%[a-z%]/g, function(match) {
  201. if ('%%' === match) return;
  202. index++;
  203. if ('%c' === match) {
  204. // we only are interested in the *last* %c
  205. // (the user may have provided their own)
  206. lastC = index;
  207. }
  208. });
  209. args.splice(lastC, 0, c);
  210. return args;
  211. }
  212. /**
  213. * Invokes `console.log()` when available.
  214. * No-op when `console.log` is not a "function".
  215. *
  216. * @api public
  217. */
  218. function log() {
  219. // this hackery is required for IE8/9, where
  220. // the `console.log` function doesn't have 'apply'
  221. return 'object' === typeof console
  222. && console.log
  223. && Function.prototype.apply.call(console.log, console, arguments);
  224. }
  225. /**
  226. * Save `namespaces`.
  227. *
  228. * @param {String} namespaces
  229. * @api private
  230. */
  231. function save(namespaces) {
  232. try {
  233. if (null == namespaces) {
  234. exports.storage.removeItem('debug');
  235. } else {
  236. exports.storage.debug = namespaces;
  237. }
  238. } catch(e) {}
  239. }
  240. /**
  241. * Load `namespaces`.
  242. *
  243. * @return {String} returns the previously persisted debug modes
  244. * @api private
  245. */
  246. function load() {
  247. var r;
  248. try {
  249. r = exports.storage.debug;
  250. } catch(e) {}
  251. return r;
  252. }
  253. /**
  254. * Enable namespaces listed in `localStorage.debug` initially.
  255. */
  256. exports.enable(load());
  257. /**
  258. * Localstorage attempts to return the localstorage.
  259. *
  260. * This is necessary because safari throws
  261. * when a user disables cookies/localstorage
  262. * and you attempt to access it.
  263. *
  264. * @return {LocalStorage}
  265. * @api private
  266. */
  267. function localstorage(){
  268. try {
  269. return window.localStorage;
  270. } catch (e) {}
  271. }
  272. },{"./debug":3}],3:[function(require,module,exports){
  273. /**
  274. * This is the common logic for both the Node.js and web browser
  275. * implementations of `debug()`.
  276. *
  277. * Expose `debug()` as the module.
  278. */
  279. exports = module.exports = debug;
  280. exports.coerce = coerce;
  281. exports.disable = disable;
  282. exports.enable = enable;
  283. exports.enabled = enabled;
  284. exports.humanize = require('ms');
  285. /**
  286. * The currently active debug mode names, and names to skip.
  287. */
  288. exports.names = [];
  289. exports.skips = [];
  290. /**
  291. * Map of special "%n" handling functions, for the debug "format" argument.
  292. *
  293. * Valid key names are a single, lowercased letter, i.e. "n".
  294. */
  295. exports.formatters = {};
  296. /**
  297. * Previously assigned color.
  298. */
  299. var prevColor = 0;
  300. /**
  301. * Previous log timestamp.
  302. */
  303. var prevTime;
  304. /**
  305. * Select a color.
  306. *
  307. * @return {Number}
  308. * @api private
  309. */
  310. function selectColor() {
  311. return exports.colors[prevColor++ % exports.colors.length];
  312. }
  313. /**
  314. * Create a debugger with the given `namespace`.
  315. *
  316. * @param {String} namespace
  317. * @return {Function}
  318. * @api public
  319. */
  320. function debug(namespace) {
  321. // define the `disabled` version
  322. function disabled() {
  323. }
  324. disabled.enabled = false;
  325. // define the `enabled` version
  326. function enabled() {
  327. var self = enabled;
  328. // set `diff` timestamp
  329. var curr = +new Date();
  330. var ms = curr - (prevTime || curr);
  331. self.diff = ms;
  332. self.prev = prevTime;
  333. self.curr = curr;
  334. prevTime = curr;
  335. // add the `color` if not set
  336. if (null == self.useColors) self.useColors = exports.useColors();
  337. if (null == self.color && self.useColors) self.color = selectColor();
  338. var args = Array.prototype.slice.call(arguments);
  339. args[0] = exports.coerce(args[0]);
  340. if ('string' !== typeof args[0]) {
  341. // anything else let's inspect with %o
  342. args = ['%o'].concat(args);
  343. }
  344. // apply any `formatters` transformations
  345. var index = 0;
  346. args[0] = args[0].replace(/%([a-z%])/g, function(match, format) {
  347. // if we encounter an escaped % then don't increase the array index
  348. if (match === '%%') return match;
  349. index++;
  350. var formatter = exports.formatters[format];
  351. if ('function' === typeof formatter) {
  352. var val = args[index];
  353. match = formatter.call(self, val);
  354. // now we need to remove `args[index]` since it's inlined in the `format`
  355. args.splice(index, 1);
  356. index--;
  357. }
  358. return match;
  359. });
  360. if ('function' === typeof exports.formatArgs) {
  361. args = exports.formatArgs.apply(self, args);
  362. }
  363. var logFn = enabled.log || exports.log || console.log.bind(console);
  364. logFn.apply(self, args);
  365. }
  366. enabled.enabled = true;
  367. var fn = exports.enabled(namespace) ? enabled : disabled;
  368. fn.namespace = namespace;
  369. return fn;
  370. }
  371. /**
  372. * Enables a debug mode by namespaces. This can include modes
  373. * separated by a colon and wildcards.
  374. *
  375. * @param {String} namespaces
  376. * @api public
  377. */
  378. function enable(namespaces) {
  379. exports.save(namespaces);
  380. var split = (namespaces || '').split(/[\s,]+/);
  381. var len = split.length;
  382. for (var i = 0; i < len; i++) {
  383. if (!split[i]) continue; // ignore empty strings
  384. namespaces = split[i].replace(/\*/g, '.*?');
  385. if (namespaces[0] === '-') {
  386. exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
  387. } else {
  388. exports.names.push(new RegExp('^' + namespaces + '$'));
  389. }
  390. }
  391. }
  392. /**
  393. * Disable debug output.
  394. *
  395. * @api public
  396. */
  397. function disable() {
  398. exports.enable('');
  399. }
  400. /**
  401. * Returns true if the given mode name is enabled, false otherwise.
  402. *
  403. * @param {String} name
  404. * @return {Boolean}
  405. * @api public
  406. */
  407. function enabled(name) {
  408. var i, len;
  409. for (i = 0, len = exports.skips.length; i < len; i++) {
  410. if (exports.skips[i].test(name)) {
  411. return false;
  412. }
  413. }
  414. for (i = 0, len = exports.names.length; i < len; i++) {
  415. if (exports.names[i].test(name)) {
  416. return true;
  417. }
  418. }
  419. return false;
  420. }
  421. /**
  422. * Coerce `val`.
  423. *
  424. * @param {Mixed} val
  425. * @return {Mixed}
  426. * @api private
  427. */
  428. function coerce(val) {
  429. if (val instanceof Error) return val.stack || val.message;
  430. return val;
  431. }
  432. },{"ms":4}],4:[function(require,module,exports){
  433. /**
  434. * Helpers.
  435. */
  436. var s = 1000;
  437. var m = s * 60;
  438. var h = m * 60;
  439. var d = h * 24;
  440. var y = d * 365.25;
  441. /**
  442. * Parse or format the given `val`.
  443. *
  444. * Options:
  445. *
  446. * - `long` verbose formatting [false]
  447. *
  448. * @param {String|Number} val
  449. * @param {Object} options
  450. * @return {String|Number}
  451. * @api public
  452. */
  453. module.exports = function(val, options){
  454. options = options || {};
  455. if ('string' == typeof val) return parse(val);
  456. return options.long
  457. ? long(val)
  458. : short(val);
  459. };
  460. /**
  461. * Parse the given `str` and return milliseconds.
  462. *
  463. * @param {String} str
  464. * @return {Number}
  465. * @api private
  466. */
  467. function parse(str) {
  468. str = '' + str;
  469. if (str.length > 10000) return;
  470. var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str);
  471. if (!match) return;
  472. var n = parseFloat(match[1]);
  473. var type = (match[2] || 'ms').toLowerCase();
  474. switch (type) {
  475. case 'years':
  476. case 'year':
  477. case 'yrs':
  478. case 'yr':
  479. case 'y':
  480. return n * y;
  481. case 'days':
  482. case 'day':
  483. case 'd':
  484. return n * d;
  485. case 'hours':
  486. case 'hour':
  487. case 'hrs':
  488. case 'hr':
  489. case 'h':
  490. return n * h;
  491. case 'minutes':
  492. case 'minute':
  493. case 'mins':
  494. case 'min':
  495. case 'm':
  496. return n * m;
  497. case 'seconds':
  498. case 'second':
  499. case 'secs':
  500. case 'sec':
  501. case 's':
  502. return n * s;
  503. case 'milliseconds':
  504. case 'millisecond':
  505. case 'msecs':
  506. case 'msec':
  507. case 'ms':
  508. return n;
  509. }
  510. }
  511. /**
  512. * Short format for `ms`.
  513. *
  514. * @param {Number} ms
  515. * @return {String}
  516. * @api private
  517. */
  518. function short(ms) {
  519. if (ms >= d) return Math.round(ms / d) + 'd';
  520. if (ms >= h) return Math.round(ms / h) + 'h';
  521. if (ms >= m) return Math.round(ms / m) + 'm';
  522. if (ms >= s) return Math.round(ms / s) + 's';
  523. return ms + 'ms';
  524. }
  525. /**
  526. * Long format for `ms`.
  527. *
  528. * @param {Number} ms
  529. * @return {String}
  530. * @api private
  531. */
  532. function long(ms) {
  533. return plural(ms, d, 'day')
  534. || plural(ms, h, 'hour')
  535. || plural(ms, m, 'minute')
  536. || plural(ms, s, 'second')
  537. || ms + ' ms';
  538. }
  539. /**
  540. * Pluralization helper.
  541. */
  542. function plural(ms, n, name) {
  543. if (ms < n) return;
  544. if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name;
  545. return Math.ceil(ms / n) + ' ' + name + 's';
  546. }
  547. },{}]},{},[1]);