glitch-javascript-sdk 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -14347,7 +14347,162 @@ var followRedirects$1 = {exports: {}};
14347
14347
 
14348
14348
  var src = {exports: {}};
14349
14349
 
14350
- var browser = {exports: {}};
14350
+ var node = {exports: {}};
14351
+
14352
+ var hasFlag;
14353
+ var hasRequiredHasFlag;
14354
+
14355
+ function requireHasFlag () {
14356
+ if (hasRequiredHasFlag) return hasFlag;
14357
+ hasRequiredHasFlag = 1;
14358
+ hasFlag = (flag, argv) => {
14359
+ argv = argv || process.argv;
14360
+ const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
14361
+ const pos = argv.indexOf(prefix + flag);
14362
+ const terminatorPos = argv.indexOf('--');
14363
+ return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
14364
+ };
14365
+ return hasFlag;
14366
+ }
14367
+
14368
+ var supportsColor_1;
14369
+ var hasRequiredSupportsColor;
14370
+
14371
+ function requireSupportsColor () {
14372
+ if (hasRequiredSupportsColor) return supportsColor_1;
14373
+ hasRequiredSupportsColor = 1;
14374
+ const os = require$$0$2;
14375
+ const hasFlag = requireHasFlag();
14376
+
14377
+ const env = process.env;
14378
+
14379
+ let forceColor;
14380
+ if (hasFlag('no-color') ||
14381
+ hasFlag('no-colors') ||
14382
+ hasFlag('color=false')) {
14383
+ forceColor = false;
14384
+ } else if (hasFlag('color') ||
14385
+ hasFlag('colors') ||
14386
+ hasFlag('color=true') ||
14387
+ hasFlag('color=always')) {
14388
+ forceColor = true;
14389
+ }
14390
+ if ('FORCE_COLOR' in env) {
14391
+ forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0;
14392
+ }
14393
+
14394
+ function translateLevel(level) {
14395
+ if (level === 0) {
14396
+ return false;
14397
+ }
14398
+
14399
+ return {
14400
+ level,
14401
+ hasBasic: true,
14402
+ has256: level >= 2,
14403
+ has16m: level >= 3
14404
+ };
14405
+ }
14406
+
14407
+ function supportsColor(stream) {
14408
+ if (forceColor === false) {
14409
+ return 0;
14410
+ }
14411
+
14412
+ if (hasFlag('color=16m') ||
14413
+ hasFlag('color=full') ||
14414
+ hasFlag('color=truecolor')) {
14415
+ return 3;
14416
+ }
14417
+
14418
+ if (hasFlag('color=256')) {
14419
+ return 2;
14420
+ }
14421
+
14422
+ if (stream && !stream.isTTY && forceColor !== true) {
14423
+ return 0;
14424
+ }
14425
+
14426
+ const min = forceColor ? 1 : 0;
14427
+
14428
+ if (process.platform === 'win32') {
14429
+ // Node.js 7.5.0 is the first version of Node.js to include a patch to
14430
+ // libuv that enables 256 color output on Windows. Anything earlier and it
14431
+ // won't work. However, here we target Node.js 8 at minimum as it is an LTS
14432
+ // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
14433
+ // release that supports 256 colors. Windows 10 build 14931 is the first release
14434
+ // that supports 16m/TrueColor.
14435
+ const osRelease = os.release().split('.');
14436
+ if (
14437
+ Number(process.versions.node.split('.')[0]) >= 8 &&
14438
+ Number(osRelease[0]) >= 10 &&
14439
+ Number(osRelease[2]) >= 10586
14440
+ ) {
14441
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
14442
+ }
14443
+
14444
+ return 1;
14445
+ }
14446
+
14447
+ if ('CI' in env) {
14448
+ if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
14449
+ return 1;
14450
+ }
14451
+
14452
+ return min;
14453
+ }
14454
+
14455
+ if ('TEAMCITY_VERSION' in env) {
14456
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
14457
+ }
14458
+
14459
+ if (env.COLORTERM === 'truecolor') {
14460
+ return 3;
14461
+ }
14462
+
14463
+ if ('TERM_PROGRAM' in env) {
14464
+ const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
14465
+
14466
+ switch (env.TERM_PROGRAM) {
14467
+ case 'iTerm.app':
14468
+ return version >= 3 ? 3 : 2;
14469
+ case 'Apple_Terminal':
14470
+ return 2;
14471
+ // No default
14472
+ }
14473
+ }
14474
+
14475
+ if (/-256(color)?$/i.test(env.TERM)) {
14476
+ return 2;
14477
+ }
14478
+
14479
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
14480
+ return 1;
14481
+ }
14482
+
14483
+ if ('COLORTERM' in env) {
14484
+ return 1;
14485
+ }
14486
+
14487
+ if (env.TERM === 'dumb') {
14488
+ return min;
14489
+ }
14490
+
14491
+ return min;
14492
+ }
14493
+
14494
+ function getSupportLevel(stream) {
14495
+ const level = supportsColor(stream);
14496
+ return translateLevel(level);
14497
+ }
14498
+
14499
+ supportsColor_1 = {
14500
+ supportsColor: getSupportLevel,
14501
+ stdout: getSupportLevel(process.stdout),
14502
+ stderr: getSupportLevel(process.stderr)
14503
+ };
14504
+ return supportsColor_1;
14505
+ }
14351
14506
 
14352
14507
  /**
14353
14508
  * Helpers.
@@ -14802,469 +14957,33 @@ function requireCommon () {
14802
14957
  return common;
14803
14958
  }
14804
14959
 
14805
- /* eslint-env browser */
14960
+ /**
14961
+ * Module dependencies.
14962
+ */
14806
14963
 
14807
- var hasRequiredBrowser;
14964
+ var hasRequiredNode;
14808
14965
 
14809
- function requireBrowser () {
14810
- if (hasRequiredBrowser) return browser.exports;
14811
- hasRequiredBrowser = 1;
14966
+ function requireNode () {
14967
+ if (hasRequiredNode) return node.exports;
14968
+ hasRequiredNode = 1;
14812
14969
  (function (module, exports) {
14970
+ const tty = require$$0$3;
14971
+ const util = require$$1;
14972
+
14813
14973
  /**
14814
- * This is the web browser implementation of `debug()`.
14974
+ * This is the Node.js implementation of `debug()`.
14815
14975
  */
14816
14976
 
14977
+ exports.init = init;
14978
+ exports.log = log;
14817
14979
  exports.formatArgs = formatArgs;
14818
14980
  exports.save = save;
14819
14981
  exports.load = load;
14820
14982
  exports.useColors = useColors;
14821
- exports.storage = localstorage();
14822
- exports.destroy = (() => {
14823
- let warned = false;
14824
-
14825
- return () => {
14826
- if (!warned) {
14827
- warned = true;
14828
- console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
14829
- }
14830
- };
14831
- })();
14832
-
14833
- /**
14834
- * Colors.
14835
- */
14836
-
14837
- exports.colors = [
14838
- '#0000CC',
14839
- '#0000FF',
14840
- '#0033CC',
14841
- '#0033FF',
14842
- '#0066CC',
14843
- '#0066FF',
14844
- '#0099CC',
14845
- '#0099FF',
14846
- '#00CC00',
14847
- '#00CC33',
14848
- '#00CC66',
14849
- '#00CC99',
14850
- '#00CCCC',
14851
- '#00CCFF',
14852
- '#3300CC',
14853
- '#3300FF',
14854
- '#3333CC',
14855
- '#3333FF',
14856
- '#3366CC',
14857
- '#3366FF',
14858
- '#3399CC',
14859
- '#3399FF',
14860
- '#33CC00',
14861
- '#33CC33',
14862
- '#33CC66',
14863
- '#33CC99',
14864
- '#33CCCC',
14865
- '#33CCFF',
14866
- '#6600CC',
14867
- '#6600FF',
14868
- '#6633CC',
14869
- '#6633FF',
14870
- '#66CC00',
14871
- '#66CC33',
14872
- '#9900CC',
14873
- '#9900FF',
14874
- '#9933CC',
14875
- '#9933FF',
14876
- '#99CC00',
14877
- '#99CC33',
14878
- '#CC0000',
14879
- '#CC0033',
14880
- '#CC0066',
14881
- '#CC0099',
14882
- '#CC00CC',
14883
- '#CC00FF',
14884
- '#CC3300',
14885
- '#CC3333',
14886
- '#CC3366',
14887
- '#CC3399',
14888
- '#CC33CC',
14889
- '#CC33FF',
14890
- '#CC6600',
14891
- '#CC6633',
14892
- '#CC9900',
14893
- '#CC9933',
14894
- '#CCCC00',
14895
- '#CCCC33',
14896
- '#FF0000',
14897
- '#FF0033',
14898
- '#FF0066',
14899
- '#FF0099',
14900
- '#FF00CC',
14901
- '#FF00FF',
14902
- '#FF3300',
14903
- '#FF3333',
14904
- '#FF3366',
14905
- '#FF3399',
14906
- '#FF33CC',
14907
- '#FF33FF',
14908
- '#FF6600',
14909
- '#FF6633',
14910
- '#FF9900',
14911
- '#FF9933',
14912
- '#FFCC00',
14913
- '#FFCC33'
14914
- ];
14915
-
14916
- /**
14917
- * Currently only WebKit-based Web Inspectors, Firefox >= v31,
14918
- * and the Firebug extension (any Firefox version) are known
14919
- * to support "%c" CSS customizations.
14920
- *
14921
- * TODO: add a `localStorage` variable to explicitly enable/disable colors
14922
- */
14923
-
14924
- // eslint-disable-next-line complexity
14925
- function useColors() {
14926
- // NB: In an Electron preload script, document will be defined but not fully
14927
- // initialized. Since we know we're in Chrome, we'll just detect this case
14928
- // explicitly
14929
- if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
14930
- return true;
14931
- }
14932
-
14933
- // Internet Explorer and Edge do not support colors.
14934
- if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
14935
- return false;
14936
- }
14937
-
14938
- // Is webkit? http://stackoverflow.com/a/16459606/376773
14939
- // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
14940
- return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
14941
- // Is firebug? http://stackoverflow.com/a/398120/376773
14942
- (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
14943
- // Is firefox >= v31?
14944
- // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
14945
- (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
14946
- // Double check webkit in userAgent just in case we are in a worker
14947
- (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
14948
- }
14949
-
14950
- /**
14951
- * Colorize log arguments if enabled.
14952
- *
14953
- * @api public
14954
- */
14955
-
14956
- function formatArgs(args) {
14957
- args[0] = (this.useColors ? '%c' : '') +
14958
- this.namespace +
14959
- (this.useColors ? ' %c' : ' ') +
14960
- args[0] +
14961
- (this.useColors ? '%c ' : ' ') +
14962
- '+' + module.exports.humanize(this.diff);
14963
-
14964
- if (!this.useColors) {
14965
- return;
14966
- }
14967
-
14968
- const c = 'color: ' + this.color;
14969
- args.splice(1, 0, c, 'color: inherit');
14970
-
14971
- // The final "%c" is somewhat tricky, because there could be other
14972
- // arguments passed either before or after the %c, so we need to
14973
- // figure out the correct index to insert the CSS into
14974
- let index = 0;
14975
- let lastC = 0;
14976
- args[0].replace(/%[a-zA-Z%]/g, match => {
14977
- if (match === '%%') {
14978
- return;
14979
- }
14980
- index++;
14981
- if (match === '%c') {
14982
- // We only are interested in the *last* %c
14983
- // (the user may have provided their own)
14984
- lastC = index;
14985
- }
14986
- });
14987
-
14988
- args.splice(lastC, 0, c);
14989
- }
14990
-
14991
- /**
14992
- * Invokes `console.debug()` when available.
14993
- * No-op when `console.debug` is not a "function".
14994
- * If `console.debug` is not available, falls back
14995
- * to `console.log`.
14996
- *
14997
- * @api public
14998
- */
14999
- exports.log = console.debug || console.log || (() => {});
15000
-
15001
- /**
15002
- * Save `namespaces`.
15003
- *
15004
- * @param {String} namespaces
15005
- * @api private
15006
- */
15007
- function save(namespaces) {
15008
- try {
15009
- if (namespaces) {
15010
- exports.storage.setItem('debug', namespaces);
15011
- } else {
15012
- exports.storage.removeItem('debug');
15013
- }
15014
- } catch (error) {
15015
- // Swallow
15016
- // XXX (@Qix-) should we be logging these?
15017
- }
15018
- }
15019
-
15020
- /**
15021
- * Load `namespaces`.
15022
- *
15023
- * @return {String} returns the previously persisted debug modes
15024
- * @api private
15025
- */
15026
- function load() {
15027
- let r;
15028
- try {
15029
- r = exports.storage.getItem('debug');
15030
- } catch (error) {
15031
- // Swallow
15032
- // XXX (@Qix-) should we be logging these?
15033
- }
15034
-
15035
- // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
15036
- if (!r && typeof process !== 'undefined' && 'env' in process) {
15037
- r = process.env.DEBUG;
15038
- }
15039
-
15040
- return r;
15041
- }
15042
-
15043
- /**
15044
- * Localstorage attempts to return the localstorage.
15045
- *
15046
- * This is necessary because safari throws
15047
- * when a user disables cookies/localstorage
15048
- * and you attempt to access it.
15049
- *
15050
- * @return {LocalStorage}
15051
- * @api private
15052
- */
15053
-
15054
- function localstorage() {
15055
- try {
15056
- // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
15057
- // The Browser also has localStorage in the global context.
15058
- return localStorage;
15059
- } catch (error) {
15060
- // Swallow
15061
- // XXX (@Qix-) should we be logging these?
15062
- }
15063
- }
15064
-
15065
- module.exports = requireCommon()(exports);
15066
-
15067
- const {formatters} = module.exports;
15068
-
15069
- /**
15070
- * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
15071
- */
15072
-
15073
- formatters.j = function (v) {
15074
- try {
15075
- return JSON.stringify(v);
15076
- } catch (error) {
15077
- return '[UnexpectedJSONParseError]: ' + error.message;
15078
- }
15079
- };
15080
- } (browser, browser.exports));
15081
- return browser.exports;
15082
- }
15083
-
15084
- var node = {exports: {}};
15085
-
15086
- var hasFlag;
15087
- var hasRequiredHasFlag;
15088
-
15089
- function requireHasFlag () {
15090
- if (hasRequiredHasFlag) return hasFlag;
15091
- hasRequiredHasFlag = 1;
15092
- hasFlag = (flag, argv) => {
15093
- argv = argv || process.argv;
15094
- const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
15095
- const pos = argv.indexOf(prefix + flag);
15096
- const terminatorPos = argv.indexOf('--');
15097
- return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
15098
- };
15099
- return hasFlag;
15100
- }
15101
-
15102
- var supportsColor_1;
15103
- var hasRequiredSupportsColor;
15104
-
15105
- function requireSupportsColor () {
15106
- if (hasRequiredSupportsColor) return supportsColor_1;
15107
- hasRequiredSupportsColor = 1;
15108
- const os = require$$0$2;
15109
- const hasFlag = requireHasFlag();
15110
-
15111
- const env = process.env;
15112
-
15113
- let forceColor;
15114
- if (hasFlag('no-color') ||
15115
- hasFlag('no-colors') ||
15116
- hasFlag('color=false')) {
15117
- forceColor = false;
15118
- } else if (hasFlag('color') ||
15119
- hasFlag('colors') ||
15120
- hasFlag('color=true') ||
15121
- hasFlag('color=always')) {
15122
- forceColor = true;
15123
- }
15124
- if ('FORCE_COLOR' in env) {
15125
- forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0;
15126
- }
15127
-
15128
- function translateLevel(level) {
15129
- if (level === 0) {
15130
- return false;
15131
- }
15132
-
15133
- return {
15134
- level,
15135
- hasBasic: true,
15136
- has256: level >= 2,
15137
- has16m: level >= 3
15138
- };
15139
- }
15140
-
15141
- function supportsColor(stream) {
15142
- if (forceColor === false) {
15143
- return 0;
15144
- }
15145
-
15146
- if (hasFlag('color=16m') ||
15147
- hasFlag('color=full') ||
15148
- hasFlag('color=truecolor')) {
15149
- return 3;
15150
- }
15151
-
15152
- if (hasFlag('color=256')) {
15153
- return 2;
15154
- }
15155
-
15156
- if (stream && !stream.isTTY && forceColor !== true) {
15157
- return 0;
15158
- }
15159
-
15160
- const min = forceColor ? 1 : 0;
15161
-
15162
- if (process.platform === 'win32') {
15163
- // Node.js 7.5.0 is the first version of Node.js to include a patch to
15164
- // libuv that enables 256 color output on Windows. Anything earlier and it
15165
- // won't work. However, here we target Node.js 8 at minimum as it is an LTS
15166
- // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
15167
- // release that supports 256 colors. Windows 10 build 14931 is the first release
15168
- // that supports 16m/TrueColor.
15169
- const osRelease = os.release().split('.');
15170
- if (
15171
- Number(process.versions.node.split('.')[0]) >= 8 &&
15172
- Number(osRelease[0]) >= 10 &&
15173
- Number(osRelease[2]) >= 10586
15174
- ) {
15175
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
15176
- }
15177
-
15178
- return 1;
15179
- }
15180
-
15181
- if ('CI' in env) {
15182
- if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
15183
- return 1;
15184
- }
15185
-
15186
- return min;
15187
- }
15188
-
15189
- if ('TEAMCITY_VERSION' in env) {
15190
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
15191
- }
15192
-
15193
- if (env.COLORTERM === 'truecolor') {
15194
- return 3;
15195
- }
15196
-
15197
- if ('TERM_PROGRAM' in env) {
15198
- const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
15199
-
15200
- switch (env.TERM_PROGRAM) {
15201
- case 'iTerm.app':
15202
- return version >= 3 ? 3 : 2;
15203
- case 'Apple_Terminal':
15204
- return 2;
15205
- // No default
15206
- }
15207
- }
15208
-
15209
- if (/-256(color)?$/i.test(env.TERM)) {
15210
- return 2;
15211
- }
15212
-
15213
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
15214
- return 1;
15215
- }
15216
-
15217
- if ('COLORTERM' in env) {
15218
- return 1;
15219
- }
15220
-
15221
- if (env.TERM === 'dumb') {
15222
- return min;
15223
- }
15224
-
15225
- return min;
15226
- }
15227
-
15228
- function getSupportLevel(stream) {
15229
- const level = supportsColor(stream);
15230
- return translateLevel(level);
15231
- }
15232
-
15233
- supportsColor_1 = {
15234
- supportsColor: getSupportLevel,
15235
- stdout: getSupportLevel(process.stdout),
15236
- stderr: getSupportLevel(process.stderr)
15237
- };
15238
- return supportsColor_1;
15239
- }
15240
-
15241
- /**
15242
- * Module dependencies.
15243
- */
15244
-
15245
- var hasRequiredNode;
15246
-
15247
- function requireNode () {
15248
- if (hasRequiredNode) return node.exports;
15249
- hasRequiredNode = 1;
15250
- (function (module, exports) {
15251
- const tty = require$$0$3;
15252
- const util = require$$1;
15253
-
15254
- /**
15255
- * This is the Node.js implementation of `debug()`.
15256
- */
15257
-
15258
- exports.init = init;
15259
- exports.log = log;
15260
- exports.formatArgs = formatArgs;
15261
- exports.save = save;
15262
- exports.load = load;
15263
- exports.useColors = useColors;
15264
- exports.destroy = util.deprecate(
15265
- () => {},
15266
- 'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
15267
- );
14983
+ exports.destroy = util.deprecate(
14984
+ () => {},
14985
+ 'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
14986
+ );
15268
14987
 
15269
14988
  /**
15270
14989
  * Colors.
@@ -15362,83 +15081,352 @@ function requireNode () {
15362
15081
  }
15363
15082
 
15364
15083
  /**
15365
- * Build up the default `inspectOpts` object from the environment variables.
15084
+ * Build up the default `inspectOpts` object from the environment variables.
15085
+ *
15086
+ * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
15087
+ */
15088
+
15089
+ exports.inspectOpts = Object.keys(process.env).filter(key => {
15090
+ return /^debug_/i.test(key);
15091
+ }).reduce((obj, key) => {
15092
+ // Camel-case
15093
+ const prop = key
15094
+ .substring(6)
15095
+ .toLowerCase()
15096
+ .replace(/_([a-z])/g, (_, k) => {
15097
+ return k.toUpperCase();
15098
+ });
15099
+
15100
+ // Coerce string value into JS value
15101
+ let val = process.env[key];
15102
+ if (/^(yes|on|true|enabled)$/i.test(val)) {
15103
+ val = true;
15104
+ } else if (/^(no|off|false|disabled)$/i.test(val)) {
15105
+ val = false;
15106
+ } else if (val === 'null') {
15107
+ val = null;
15108
+ } else {
15109
+ val = Number(val);
15110
+ }
15111
+
15112
+ obj[prop] = val;
15113
+ return obj;
15114
+ }, {});
15115
+
15116
+ /**
15117
+ * Is stdout a TTY? Colored output is enabled when `true`.
15118
+ */
15119
+
15120
+ function useColors() {
15121
+ return 'colors' in exports.inspectOpts ?
15122
+ Boolean(exports.inspectOpts.colors) :
15123
+ tty.isatty(process.stderr.fd);
15124
+ }
15125
+
15126
+ /**
15127
+ * Adds ANSI color escape codes if enabled.
15128
+ *
15129
+ * @api public
15130
+ */
15131
+
15132
+ function formatArgs(args) {
15133
+ const {namespace: name, useColors} = this;
15134
+
15135
+ if (useColors) {
15136
+ const c = this.color;
15137
+ const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
15138
+ const prefix = ` ${colorCode};1m${name} \u001B[0m`;
15139
+
15140
+ args[0] = prefix + args[0].split('\n').join('\n' + prefix);
15141
+ args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
15142
+ } else {
15143
+ args[0] = getDate() + name + ' ' + args[0];
15144
+ }
15145
+ }
15146
+
15147
+ function getDate() {
15148
+ if (exports.inspectOpts.hideDate) {
15149
+ return '';
15150
+ }
15151
+ return new Date().toISOString() + ' ';
15152
+ }
15153
+
15154
+ /**
15155
+ * Invokes `util.format()` with the specified arguments and writes to stderr.
15156
+ */
15157
+
15158
+ function log(...args) {
15159
+ return process.stderr.write(util.format(...args) + '\n');
15160
+ }
15161
+
15162
+ /**
15163
+ * Save `namespaces`.
15164
+ *
15165
+ * @param {String} namespaces
15166
+ * @api private
15167
+ */
15168
+ function save(namespaces) {
15169
+ if (namespaces) {
15170
+ process.env.DEBUG = namespaces;
15171
+ } else {
15172
+ // If you set a process.env field to null or undefined, it gets cast to the
15173
+ // string 'null' or 'undefined'. Just delete instead.
15174
+ delete process.env.DEBUG;
15175
+ }
15176
+ }
15177
+
15178
+ /**
15179
+ * Load `namespaces`.
15180
+ *
15181
+ * @return {String} returns the previously persisted debug modes
15182
+ * @api private
15183
+ */
15184
+
15185
+ function load() {
15186
+ return process.env.DEBUG;
15187
+ }
15188
+
15189
+ /**
15190
+ * Init logic for `debug` instances.
15191
+ *
15192
+ * Create a new `inspectOpts` object in case `useColors` is set
15193
+ * differently for a particular `debug` instance.
15194
+ */
15195
+
15196
+ function init(debug) {
15197
+ debug.inspectOpts = {};
15198
+
15199
+ const keys = Object.keys(exports.inspectOpts);
15200
+ for (let i = 0; i < keys.length; i++) {
15201
+ debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
15202
+ }
15203
+ }
15204
+
15205
+ module.exports = requireCommon()(exports);
15206
+
15207
+ const {formatters} = module.exports;
15208
+
15209
+ /**
15210
+ * Map %o to `util.inspect()`, all on a single line.
15211
+ */
15212
+
15213
+ formatters.o = function (v) {
15214
+ this.inspectOpts.colors = this.useColors;
15215
+ return util.inspect(v, this.inspectOpts)
15216
+ .split('\n')
15217
+ .map(str => str.trim())
15218
+ .join(' ');
15219
+ };
15220
+
15221
+ /**
15222
+ * Map %O to `util.inspect()`, allowing multiple lines if needed.
15223
+ */
15224
+
15225
+ formatters.O = function (v) {
15226
+ this.inspectOpts.colors = this.useColors;
15227
+ return util.inspect(v, this.inspectOpts);
15228
+ };
15229
+ } (node, node.exports));
15230
+ return node.exports;
15231
+ }
15232
+
15233
+ var browser = {exports: {}};
15234
+
15235
+ /* eslint-env browser */
15236
+
15237
+ var hasRequiredBrowser;
15238
+
15239
+ function requireBrowser () {
15240
+ if (hasRequiredBrowser) return browser.exports;
15241
+ hasRequiredBrowser = 1;
15242
+ (function (module, exports) {
15243
+ /**
15244
+ * This is the web browser implementation of `debug()`.
15245
+ */
15246
+
15247
+ exports.formatArgs = formatArgs;
15248
+ exports.save = save;
15249
+ exports.load = load;
15250
+ exports.useColors = useColors;
15251
+ exports.storage = localstorage();
15252
+ exports.destroy = (() => {
15253
+ let warned = false;
15254
+
15255
+ return () => {
15256
+ if (!warned) {
15257
+ warned = true;
15258
+ console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
15259
+ }
15260
+ };
15261
+ })();
15262
+
15263
+ /**
15264
+ * Colors.
15265
+ */
15266
+
15267
+ exports.colors = [
15268
+ '#0000CC',
15269
+ '#0000FF',
15270
+ '#0033CC',
15271
+ '#0033FF',
15272
+ '#0066CC',
15273
+ '#0066FF',
15274
+ '#0099CC',
15275
+ '#0099FF',
15276
+ '#00CC00',
15277
+ '#00CC33',
15278
+ '#00CC66',
15279
+ '#00CC99',
15280
+ '#00CCCC',
15281
+ '#00CCFF',
15282
+ '#3300CC',
15283
+ '#3300FF',
15284
+ '#3333CC',
15285
+ '#3333FF',
15286
+ '#3366CC',
15287
+ '#3366FF',
15288
+ '#3399CC',
15289
+ '#3399FF',
15290
+ '#33CC00',
15291
+ '#33CC33',
15292
+ '#33CC66',
15293
+ '#33CC99',
15294
+ '#33CCCC',
15295
+ '#33CCFF',
15296
+ '#6600CC',
15297
+ '#6600FF',
15298
+ '#6633CC',
15299
+ '#6633FF',
15300
+ '#66CC00',
15301
+ '#66CC33',
15302
+ '#9900CC',
15303
+ '#9900FF',
15304
+ '#9933CC',
15305
+ '#9933FF',
15306
+ '#99CC00',
15307
+ '#99CC33',
15308
+ '#CC0000',
15309
+ '#CC0033',
15310
+ '#CC0066',
15311
+ '#CC0099',
15312
+ '#CC00CC',
15313
+ '#CC00FF',
15314
+ '#CC3300',
15315
+ '#CC3333',
15316
+ '#CC3366',
15317
+ '#CC3399',
15318
+ '#CC33CC',
15319
+ '#CC33FF',
15320
+ '#CC6600',
15321
+ '#CC6633',
15322
+ '#CC9900',
15323
+ '#CC9933',
15324
+ '#CCCC00',
15325
+ '#CCCC33',
15326
+ '#FF0000',
15327
+ '#FF0033',
15328
+ '#FF0066',
15329
+ '#FF0099',
15330
+ '#FF00CC',
15331
+ '#FF00FF',
15332
+ '#FF3300',
15333
+ '#FF3333',
15334
+ '#FF3366',
15335
+ '#FF3399',
15336
+ '#FF33CC',
15337
+ '#FF33FF',
15338
+ '#FF6600',
15339
+ '#FF6633',
15340
+ '#FF9900',
15341
+ '#FF9933',
15342
+ '#FFCC00',
15343
+ '#FFCC33'
15344
+ ];
15345
+
15346
+ /**
15347
+ * Currently only WebKit-based Web Inspectors, Firefox >= v31,
15348
+ * and the Firebug extension (any Firefox version) are known
15349
+ * to support "%c" CSS customizations.
15366
15350
  *
15367
- * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
15351
+ * TODO: add a `localStorage` variable to explicitly enable/disable colors
15368
15352
  */
15369
15353
 
15370
- exports.inspectOpts = Object.keys(process.env).filter(key => {
15371
- return /^debug_/i.test(key);
15372
- }).reduce((obj, key) => {
15373
- // Camel-case
15374
- const prop = key
15375
- .substring(6)
15376
- .toLowerCase()
15377
- .replace(/_([a-z])/g, (_, k) => {
15378
- return k.toUpperCase();
15379
- });
15380
-
15381
- // Coerce string value into JS value
15382
- let val = process.env[key];
15383
- if (/^(yes|on|true|enabled)$/i.test(val)) {
15384
- val = true;
15385
- } else if (/^(no|off|false|disabled)$/i.test(val)) {
15386
- val = false;
15387
- } else if (val === 'null') {
15388
- val = null;
15389
- } else {
15390
- val = Number(val);
15354
+ // eslint-disable-next-line complexity
15355
+ function useColors() {
15356
+ // NB: In an Electron preload script, document will be defined but not fully
15357
+ // initialized. Since we know we're in Chrome, we'll just detect this case
15358
+ // explicitly
15359
+ if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
15360
+ return true;
15391
15361
  }
15392
15362
 
15393
- obj[prop] = val;
15394
- return obj;
15395
- }, {});
15396
-
15397
- /**
15398
- * Is stdout a TTY? Colored output is enabled when `true`.
15399
- */
15363
+ // Internet Explorer and Edge do not support colors.
15364
+ if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
15365
+ return false;
15366
+ }
15400
15367
 
15401
- function useColors() {
15402
- return 'colors' in exports.inspectOpts ?
15403
- Boolean(exports.inspectOpts.colors) :
15404
- tty.isatty(process.stderr.fd);
15368
+ // Is webkit? http://stackoverflow.com/a/16459606/376773
15369
+ // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
15370
+ return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
15371
+ // Is firebug? http://stackoverflow.com/a/398120/376773
15372
+ (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
15373
+ // Is firefox >= v31?
15374
+ // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
15375
+ (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
15376
+ // Double check webkit in userAgent just in case we are in a worker
15377
+ (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
15405
15378
  }
15406
15379
 
15407
15380
  /**
15408
- * Adds ANSI color escape codes if enabled.
15381
+ * Colorize log arguments if enabled.
15409
15382
  *
15410
15383
  * @api public
15411
15384
  */
15412
15385
 
15413
15386
  function formatArgs(args) {
15414
- const {namespace: name, useColors} = this;
15415
-
15416
- if (useColors) {
15417
- const c = this.color;
15418
- const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
15419
- const prefix = ` ${colorCode};1m${name} \u001B[0m`;
15387
+ args[0] = (this.useColors ? '%c' : '') +
15388
+ this.namespace +
15389
+ (this.useColors ? ' %c' : ' ') +
15390
+ args[0] +
15391
+ (this.useColors ? '%c ' : ' ') +
15392
+ '+' + module.exports.humanize(this.diff);
15420
15393
 
15421
- args[0] = prefix + args[0].split('\n').join('\n' + prefix);
15422
- args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
15423
- } else {
15424
- args[0] = getDate() + name + ' ' + args[0];
15394
+ if (!this.useColors) {
15395
+ return;
15425
15396
  }
15426
- }
15427
15397
 
15428
- function getDate() {
15429
- if (exports.inspectOpts.hideDate) {
15430
- return '';
15431
- }
15432
- return new Date().toISOString() + ' ';
15398
+ const c = 'color: ' + this.color;
15399
+ args.splice(1, 0, c, 'color: inherit');
15400
+
15401
+ // The final "%c" is somewhat tricky, because there could be other
15402
+ // arguments passed either before or after the %c, so we need to
15403
+ // figure out the correct index to insert the CSS into
15404
+ let index = 0;
15405
+ let lastC = 0;
15406
+ args[0].replace(/%[a-zA-Z%]/g, match => {
15407
+ if (match === '%%') {
15408
+ return;
15409
+ }
15410
+ index++;
15411
+ if (match === '%c') {
15412
+ // We only are interested in the *last* %c
15413
+ // (the user may have provided their own)
15414
+ lastC = index;
15415
+ }
15416
+ });
15417
+
15418
+ args.splice(lastC, 0, c);
15433
15419
  }
15434
15420
 
15435
15421
  /**
15436
- * Invokes `util.format()` with the specified arguments and writes to stderr.
15422
+ * Invokes `console.debug()` when available.
15423
+ * No-op when `console.debug` is not a "function".
15424
+ * If `console.debug` is not available, falls back
15425
+ * to `console.log`.
15426
+ *
15427
+ * @api public
15437
15428
  */
15438
-
15439
- function log(...args) {
15440
- return process.stderr.write(util.format(...args) + '\n');
15441
- }
15429
+ exports.log = console.debug || console.log || (() => {});
15442
15430
 
15443
15431
  /**
15444
15432
  * Save `namespaces`.
@@ -15447,12 +15435,15 @@ function requireNode () {
15447
15435
  * @api private
15448
15436
  */
15449
15437
  function save(namespaces) {
15450
- if (namespaces) {
15451
- process.env.DEBUG = namespaces;
15452
- } else {
15453
- // If you set a process.env field to null or undefined, it gets cast to the
15454
- // string 'null' or 'undefined'. Just delete instead.
15455
- delete process.env.DEBUG;
15438
+ try {
15439
+ if (namespaces) {
15440
+ exports.storage.setItem('debug', namespaces);
15441
+ } else {
15442
+ exports.storage.removeItem('debug');
15443
+ }
15444
+ } catch (error) {
15445
+ // Swallow
15446
+ // XXX (@Qix-) should we be logging these?
15456
15447
  }
15457
15448
  }
15458
15449
 
@@ -15462,24 +15453,42 @@ function requireNode () {
15462
15453
  * @return {String} returns the previously persisted debug modes
15463
15454
  * @api private
15464
15455
  */
15465
-
15466
15456
  function load() {
15467
- return process.env.DEBUG;
15457
+ let r;
15458
+ try {
15459
+ r = exports.storage.getItem('debug');
15460
+ } catch (error) {
15461
+ // Swallow
15462
+ // XXX (@Qix-) should we be logging these?
15463
+ }
15464
+
15465
+ // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
15466
+ if (!r && typeof process !== 'undefined' && 'env' in process) {
15467
+ r = process.env.DEBUG;
15468
+ }
15469
+
15470
+ return r;
15468
15471
  }
15469
15472
 
15470
15473
  /**
15471
- * Init logic for `debug` instances.
15474
+ * Localstorage attempts to return the localstorage.
15472
15475
  *
15473
- * Create a new `inspectOpts` object in case `useColors` is set
15474
- * differently for a particular `debug` instance.
15476
+ * This is necessary because safari throws
15477
+ * when a user disables cookies/localstorage
15478
+ * and you attempt to access it.
15479
+ *
15480
+ * @return {LocalStorage}
15481
+ * @api private
15475
15482
  */
15476
15483
 
15477
- function init(debug) {
15478
- debug.inspectOpts = {};
15479
-
15480
- const keys = Object.keys(exports.inspectOpts);
15481
- for (let i = 0; i < keys.length; i++) {
15482
- debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
15484
+ function localstorage() {
15485
+ try {
15486
+ // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
15487
+ // The Browser also has localStorage in the global context.
15488
+ return localStorage;
15489
+ } catch (error) {
15490
+ // Swallow
15491
+ // XXX (@Qix-) should we be logging these?
15483
15492
  }
15484
15493
  }
15485
15494
 
@@ -15488,27 +15497,18 @@ function requireNode () {
15488
15497
  const {formatters} = module.exports;
15489
15498
 
15490
15499
  /**
15491
- * Map %o to `util.inspect()`, all on a single line.
15492
- */
15493
-
15494
- formatters.o = function (v) {
15495
- this.inspectOpts.colors = this.useColors;
15496
- return util.inspect(v, this.inspectOpts)
15497
- .split('\n')
15498
- .map(str => str.trim())
15499
- .join(' ');
15500
- };
15501
-
15502
- /**
15503
- * Map %O to `util.inspect()`, allowing multiple lines if needed.
15500
+ * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
15504
15501
  */
15505
15502
 
15506
- formatters.O = function (v) {
15507
- this.inspectOpts.colors = this.useColors;
15508
- return util.inspect(v, this.inspectOpts);
15503
+ formatters.j = function (v) {
15504
+ try {
15505
+ return JSON.stringify(v);
15506
+ } catch (error) {
15507
+ return '[UnexpectedJSONParseError]: ' + error.message;
15508
+ }
15509
15509
  };
15510
- } (node, node.exports));
15511
- return node.exports;
15510
+ } (browser, browser.exports));
15511
+ return browser.exports;
15512
15512
  }
15513
15513
 
15514
15514
  /**