index.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. module.exports = (function() {
  2. var __MODS__ = {};
  3. var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexports: {} }; __MODS__[modId] = { status: 0, func: func, req: req, m: m }; };
  4. var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = __MODS__[modId].m; m._exports = m._tempexports; var desp = Object.getOwnPropertyDescriptor(m, "exports"); if (desp && desp.configurable) Object.defineProperty(m, "exports", { set: function (val) { if(typeof val === "object" && val !== m._exports) { m._exports.__proto__ = val.__proto__; Object.keys(val).forEach(function (k) { m._exports[k] = val[k]; }); } m._tempexports = val }, get: function () { return m._tempexports; } }); __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); } return __MODS__[modId].m.exports; };
  5. var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } };
  6. var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; };
  7. __DEFINE__(1662612701765, function(require, module, exports) {
  8. /**
  9. * Detect Electron renderer process, which is node, but we should
  10. * treat as a browser.
  11. */
  12. if (typeof process === 'undefined' || process.type === 'renderer') {
  13. module.exports = require('./browser.js');
  14. } else {
  15. module.exports = require('./node.js');
  16. }
  17. }, function(modId) {var map = {"./browser.js":1662612701766,"./node.js":1662612701768}; return __REQUIRE__(map[modId], modId); })
  18. __DEFINE__(1662612701766, function(require, module, exports) {
  19. /**
  20. * This is the web browser implementation of `debug()`.
  21. *
  22. * Expose `debug()` as the module.
  23. */
  24. exports = module.exports = require('./debug');
  25. exports.log = log;
  26. exports.formatArgs = formatArgs;
  27. exports.save = save;
  28. exports.load = load;
  29. exports.useColors = useColors;
  30. exports.storage = 'undefined' != typeof chrome
  31. && 'undefined' != typeof chrome.storage
  32. ? chrome.storage.local
  33. : localstorage();
  34. /**
  35. * Colors.
  36. */
  37. exports.colors = [
  38. '#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC',
  39. '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF',
  40. '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC',
  41. '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF',
  42. '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC',
  43. '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033',
  44. '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366',
  45. '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933',
  46. '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC',
  47. '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF',
  48. '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'
  49. ];
  50. /**
  51. * Currently only WebKit-based Web Inspectors, Firefox >= v31,
  52. * and the Firebug extension (any Firefox version) are known
  53. * to support "%c" CSS customizations.
  54. *
  55. * TODO: add a `localStorage` variable to explicitly enable/disable colors
  56. */
  57. function useColors() {
  58. // NB: In an Electron preload script, document will be defined but not fully
  59. // initialized. Since we know we're in Chrome, we'll just detect this case
  60. // explicitly
  61. if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') {
  62. return true;
  63. }
  64. // Internet Explorer and Edge do not support colors.
  65. if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
  66. return false;
  67. }
  68. // is webkit? http://stackoverflow.com/a/16459606/376773
  69. // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
  70. return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
  71. // is firebug? http://stackoverflow.com/a/398120/376773
  72. (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
  73. // is firefox >= v31?
  74. // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
  75. (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
  76. // double check webkit in userAgent just in case we are in a worker
  77. (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
  78. }
  79. /**
  80. * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
  81. */
  82. exports.formatters.j = function(v) {
  83. try {
  84. return JSON.stringify(v);
  85. } catch (err) {
  86. return '[UnexpectedJSONParseError]: ' + err.message;
  87. }
  88. };
  89. /**
  90. * Colorize log arguments if enabled.
  91. *
  92. * @api public
  93. */
  94. function formatArgs(args) {
  95. var useColors = this.useColors;
  96. args[0] = (useColors ? '%c' : '')
  97. + this.namespace
  98. + (useColors ? ' %c' : ' ')
  99. + args[0]
  100. + (useColors ? '%c ' : ' ')
  101. + '+' + exports.humanize(this.diff);
  102. if (!useColors) return;
  103. var c = 'color: ' + this.color;
  104. args.splice(1, 0, c, 'color: inherit')
  105. // the final "%c" is somewhat tricky, because there could be other
  106. // arguments passed either before or after the %c, so we need to
  107. // figure out the correct index to insert the CSS into
  108. var index = 0;
  109. var lastC = 0;
  110. args[0].replace(/%[a-zA-Z%]/g, function(match) {
  111. if ('%%' === match) return;
  112. index++;
  113. if ('%c' === match) {
  114. // we only are interested in the *last* %c
  115. // (the user may have provided their own)
  116. lastC = index;
  117. }
  118. });
  119. args.splice(lastC, 0, c);
  120. }
  121. /**
  122. * Invokes `console.log()` when available.
  123. * No-op when `console.log` is not a "function".
  124. *
  125. * @api public
  126. */
  127. function log() {
  128. // this hackery is required for IE8/9, where
  129. // the `console.log` function doesn't have 'apply'
  130. return 'object' === typeof console
  131. && console.log
  132. && Function.prototype.apply.call(console.log, console, arguments);
  133. }
  134. /**
  135. * Save `namespaces`.
  136. *
  137. * @param {String} namespaces
  138. * @api private
  139. */
  140. function save(namespaces) {
  141. try {
  142. if (null == namespaces) {
  143. exports.storage.removeItem('debug');
  144. } else {
  145. exports.storage.debug = namespaces;
  146. }
  147. } catch(e) {}
  148. }
  149. /**
  150. * Load `namespaces`.
  151. *
  152. * @return {String} returns the previously persisted debug modes
  153. * @api private
  154. */
  155. function load() {
  156. var r;
  157. try {
  158. r = exports.storage.debug;
  159. } catch(e) {}
  160. // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
  161. if (!r && typeof process !== 'undefined' && 'env' in process) {
  162. r = process.env.DEBUG;
  163. }
  164. return r;
  165. }
  166. /**
  167. * Enable namespaces listed in `localStorage.debug` initially.
  168. */
  169. exports.enable(load());
  170. /**
  171. * Localstorage attempts to return the localstorage.
  172. *
  173. * This is necessary because safari throws
  174. * when a user disables cookies/localstorage
  175. * and you attempt to access it.
  176. *
  177. * @return {LocalStorage}
  178. * @api private
  179. */
  180. function localstorage() {
  181. try {
  182. return window.localStorage;
  183. } catch (e) {}
  184. }
  185. }, function(modId) { var map = {"./debug":1662612701767}; return __REQUIRE__(map[modId], modId); })
  186. __DEFINE__(1662612701767, function(require, module, exports) {
  187. /**
  188. * This is the common logic for both the Node.js and web browser
  189. * implementations of `debug()`.
  190. *
  191. * Expose `debug()` as the module.
  192. */
  193. exports = module.exports = createDebug.debug = createDebug['default'] = createDebug;
  194. exports.coerce = coerce;
  195. exports.disable = disable;
  196. exports.enable = enable;
  197. exports.enabled = enabled;
  198. exports.humanize = require('ms');
  199. /**
  200. * Active `debug` instances.
  201. */
  202. exports.instances = [];
  203. /**
  204. * The currently active debug mode names, and names to skip.
  205. */
  206. exports.names = [];
  207. exports.skips = [];
  208. /**
  209. * Map of special "%n" handling functions, for the debug "format" argument.
  210. *
  211. * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
  212. */
  213. exports.formatters = {};
  214. /**
  215. * Select a color.
  216. * @param {String} namespace
  217. * @return {Number}
  218. * @api private
  219. */
  220. function selectColor(namespace) {
  221. var hash = 0, i;
  222. for (i in namespace) {
  223. hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
  224. hash |= 0; // Convert to 32bit integer
  225. }
  226. return exports.colors[Math.abs(hash) % exports.colors.length];
  227. }
  228. /**
  229. * Create a debugger with the given `namespace`.
  230. *
  231. * @param {String} namespace
  232. * @return {Function}
  233. * @api public
  234. */
  235. function createDebug(namespace) {
  236. var prevTime;
  237. function debug() {
  238. // disabled?
  239. if (!debug.enabled) return;
  240. var self = debug;
  241. // set `diff` timestamp
  242. var curr = +new Date();
  243. var ms = curr - (prevTime || curr);
  244. self.diff = ms;
  245. self.prev = prevTime;
  246. self.curr = curr;
  247. prevTime = curr;
  248. // turn the `arguments` into a proper Array
  249. var args = new Array(arguments.length);
  250. for (var i = 0; i < args.length; i++) {
  251. args[i] = arguments[i];
  252. }
  253. args[0] = exports.coerce(args[0]);
  254. if ('string' !== typeof args[0]) {
  255. // anything else let's inspect with %O
  256. args.unshift('%O');
  257. }
  258. // apply any `formatters` transformations
  259. var index = 0;
  260. args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {
  261. // if we encounter an escaped % then don't increase the array index
  262. if (match === '%%') return match;
  263. index++;
  264. var formatter = exports.formatters[format];
  265. if ('function' === typeof formatter) {
  266. var val = args[index];
  267. match = formatter.call(self, val);
  268. // now we need to remove `args[index]` since it's inlined in the `format`
  269. args.splice(index, 1);
  270. index--;
  271. }
  272. return match;
  273. });
  274. // apply env-specific formatting (colors, etc.)
  275. exports.formatArgs.call(self, args);
  276. var logFn = debug.log || exports.log || console.log.bind(console);
  277. logFn.apply(self, args);
  278. }
  279. debug.namespace = namespace;
  280. debug.enabled = exports.enabled(namespace);
  281. debug.useColors = exports.useColors();
  282. debug.color = selectColor(namespace);
  283. debug.destroy = destroy;
  284. // env-specific initialization logic for debug instances
  285. if ('function' === typeof exports.init) {
  286. exports.init(debug);
  287. }
  288. exports.instances.push(debug);
  289. return debug;
  290. }
  291. function destroy () {
  292. var index = exports.instances.indexOf(this);
  293. if (index !== -1) {
  294. exports.instances.splice(index, 1);
  295. return true;
  296. } else {
  297. return false;
  298. }
  299. }
  300. /**
  301. * Enables a debug mode by namespaces. This can include modes
  302. * separated by a colon and wildcards.
  303. *
  304. * @param {String} namespaces
  305. * @api public
  306. */
  307. function enable(namespaces) {
  308. exports.save(namespaces);
  309. exports.names = [];
  310. exports.skips = [];
  311. var i;
  312. var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
  313. var len = split.length;
  314. for (i = 0; i < len; i++) {
  315. if (!split[i]) continue; // ignore empty strings
  316. namespaces = split[i].replace(/\*/g, '.*?');
  317. if (namespaces[0] === '-') {
  318. exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
  319. } else {
  320. exports.names.push(new RegExp('^' + namespaces + '$'));
  321. }
  322. }
  323. for (i = 0; i < exports.instances.length; i++) {
  324. var instance = exports.instances[i];
  325. instance.enabled = exports.enabled(instance.namespace);
  326. }
  327. }
  328. /**
  329. * Disable debug output.
  330. *
  331. * @api public
  332. */
  333. function disable() {
  334. exports.enable('');
  335. }
  336. /**
  337. * Returns true if the given mode name is enabled, false otherwise.
  338. *
  339. * @param {String} name
  340. * @return {Boolean}
  341. * @api public
  342. */
  343. function enabled(name) {
  344. if (name[name.length - 1] === '*') {
  345. return true;
  346. }
  347. var i, len;
  348. for (i = 0, len = exports.skips.length; i < len; i++) {
  349. if (exports.skips[i].test(name)) {
  350. return false;
  351. }
  352. }
  353. for (i = 0, len = exports.names.length; i < len; i++) {
  354. if (exports.names[i].test(name)) {
  355. return true;
  356. }
  357. }
  358. return false;
  359. }
  360. /**
  361. * Coerce `val`.
  362. *
  363. * @param {Mixed} val
  364. * @return {Mixed}
  365. * @api private
  366. */
  367. function coerce(val) {
  368. if (val instanceof Error) return val.stack || val.message;
  369. return val;
  370. }
  371. }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); })
  372. __DEFINE__(1662612701768, function(require, module, exports) {
  373. /**
  374. * Module dependencies.
  375. */
  376. var tty = require('tty');
  377. var util = require('util');
  378. /**
  379. * This is the Node.js implementation of `debug()`.
  380. *
  381. * Expose `debug()` as the module.
  382. */
  383. exports = module.exports = require('./debug');
  384. exports.init = init;
  385. exports.log = log;
  386. exports.formatArgs = formatArgs;
  387. exports.save = save;
  388. exports.load = load;
  389. exports.useColors = useColors;
  390. /**
  391. * Colors.
  392. */
  393. exports.colors = [ 6, 2, 3, 4, 5, 1 ];
  394. try {
  395. var supportsColor = require('supports-color');
  396. if (supportsColor && supportsColor.level >= 2) {
  397. exports.colors = [
  398. 20, 21, 26, 27, 32, 33, 38, 39, 40, 41, 42, 43, 44, 45, 56, 57, 62, 63, 68,
  399. 69, 74, 75, 76, 77, 78, 79, 80, 81, 92, 93, 98, 99, 112, 113, 128, 129, 134,
  400. 135, 148, 149, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171,
  401. 172, 173, 178, 179, 184, 185, 196, 197, 198, 199, 200, 201, 202, 203, 204,
  402. 205, 206, 207, 208, 209, 214, 215, 220, 221
  403. ];
  404. }
  405. } catch (err) {
  406. // swallow - we only care if `supports-color` is available; it doesn't have to be.
  407. }
  408. /**
  409. * Build up the default `inspectOpts` object from the environment variables.
  410. *
  411. * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
  412. */
  413. exports.inspectOpts = Object.keys(process.env).filter(function (key) {
  414. return /^debug_/i.test(key);
  415. }).reduce(function (obj, key) {
  416. // camel-case
  417. var prop = key
  418. .substring(6)
  419. .toLowerCase()
  420. .replace(/_([a-z])/g, function (_, k) { return k.toUpperCase() });
  421. // coerce string value into JS value
  422. var val = process.env[key];
  423. if (/^(yes|on|true|enabled)$/i.test(val)) val = true;
  424. else if (/^(no|off|false|disabled)$/i.test(val)) val = false;
  425. else if (val === 'null') val = null;
  426. else val = Number(val);
  427. obj[prop] = val;
  428. return obj;
  429. }, {});
  430. /**
  431. * Is stdout a TTY? Colored output is enabled when `true`.
  432. */
  433. function useColors() {
  434. return 'colors' in exports.inspectOpts
  435. ? Boolean(exports.inspectOpts.colors)
  436. : tty.isatty(process.stderr.fd);
  437. }
  438. /**
  439. * Map %o to `util.inspect()`, all on a single line.
  440. */
  441. exports.formatters.o = function(v) {
  442. this.inspectOpts.colors = this.useColors;
  443. return util.inspect(v, this.inspectOpts)
  444. .split('\n').map(function(str) {
  445. return str.trim()
  446. }).join(' ');
  447. };
  448. /**
  449. * Map %o to `util.inspect()`, allowing multiple lines if needed.
  450. */
  451. exports.formatters.O = function(v) {
  452. this.inspectOpts.colors = this.useColors;
  453. return util.inspect(v, this.inspectOpts);
  454. };
  455. /**
  456. * Adds ANSI color escape codes if enabled.
  457. *
  458. * @api public
  459. */
  460. function formatArgs(args) {
  461. var name = this.namespace;
  462. var useColors = this.useColors;
  463. if (useColors) {
  464. var c = this.color;
  465. var colorCode = '\u001b[3' + (c < 8 ? c : '8;5;' + c);
  466. var prefix = ' ' + colorCode + ';1m' + name + ' ' + '\u001b[0m';
  467. args[0] = prefix + args[0].split('\n').join('\n' + prefix);
  468. args.push(colorCode + 'm+' + exports.humanize(this.diff) + '\u001b[0m');
  469. } else {
  470. args[0] = getDate() + name + ' ' + args[0];
  471. }
  472. }
  473. function getDate() {
  474. if (exports.inspectOpts.hideDate) {
  475. return '';
  476. } else {
  477. return new Date().toISOString() + ' ';
  478. }
  479. }
  480. /**
  481. * Invokes `util.format()` with the specified arguments and writes to stderr.
  482. */
  483. function log() {
  484. return process.stderr.write(util.format.apply(util, arguments) + '\n');
  485. }
  486. /**
  487. * Save `namespaces`.
  488. *
  489. * @param {String} namespaces
  490. * @api private
  491. */
  492. function save(namespaces) {
  493. if (null == namespaces) {
  494. // If you set a process.env field to null or undefined, it gets cast to the
  495. // string 'null' or 'undefined'. Just delete instead.
  496. delete process.env.DEBUG;
  497. } else {
  498. process.env.DEBUG = namespaces;
  499. }
  500. }
  501. /**
  502. * Load `namespaces`.
  503. *
  504. * @return {String} returns the previously persisted debug modes
  505. * @api private
  506. */
  507. function load() {
  508. return process.env.DEBUG;
  509. }
  510. /**
  511. * Init logic for `debug` instances.
  512. *
  513. * Create a new `inspectOpts` object in case `useColors` is set
  514. * differently for a particular `debug` instance.
  515. */
  516. function init (debug) {
  517. debug.inspectOpts = {};
  518. var keys = Object.keys(exports.inspectOpts);
  519. for (var i = 0; i < keys.length; i++) {
  520. debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
  521. }
  522. }
  523. /**
  524. * Enable namespaces listed in `process.env.DEBUG` initially.
  525. */
  526. exports.enable(load());
  527. }, function(modId) { var map = {"./debug":1662612701767}; return __REQUIRE__(map[modId], modId); })
  528. return __REQUIRE__(1662612701765);
  529. })()
  530. //miniprogram-npm-outsideDeps=["ms","tty","util","supports-color"]
  531. //# sourceMappingURL=index.js.map