1+ "use strict" ;
2+
3+ function _typeof ( obj ) { if ( typeof Symbol === "function" && typeof Symbol . iterator === "symbol" ) { _typeof = function _typeof ( obj ) { return typeof obj ; } ; } else { _typeof = function _typeof ( obj ) { return obj && typeof Symbol === "function" && obj . constructor === Symbol && obj !== Symbol . prototype ? "symbol" : typeof obj ; } ; } return _typeof ( obj ) ; }
4+
15/* eslint-env browser */
26
37/**
48 * This is the web browser implementation of `debug()`.
59 */
6-
710exports . log = log ;
811exports . formatArgs = formatArgs ;
912exports . save = save ;
1013exports . load = load ;
1114exports . useColors = useColors ;
1215exports . storage = localstorage ( ) ;
13-
1416/**
1517 * Colors.
1618 */
1719
18- exports . colors = [
19- '#0000CC' ,
20- '#0000FF' ,
21- '#0033CC' ,
22- '#0033FF' ,
23- '#0066CC' ,
24- '#0066FF' ,
25- '#0099CC' ,
26- '#0099FF' ,
27- '#00CC00' ,
28- '#00CC33' ,
29- '#00CC66' ,
30- '#00CC99' ,
31- '#00CCCC' ,
32- '#00CCFF' ,
33- '#3300CC' ,
34- '#3300FF' ,
35- '#3333CC' ,
36- '#3333FF' ,
37- '#3366CC' ,
38- '#3366FF' ,
39- '#3399CC' ,
40- '#3399FF' ,
41- '#33CC00' ,
42- '#33CC33' ,
43- '#33CC66' ,
44- '#33CC99' ,
45- '#33CCCC' ,
46- '#33CCFF' ,
47- '#6600CC' ,
48- '#6600FF' ,
49- '#6633CC' ,
50- '#6633FF' ,
51- '#66CC00' ,
52- '#66CC33' ,
53- '#9900CC' ,
54- '#9900FF' ,
55- '#9933CC' ,
56- '#9933FF' ,
57- '#99CC00' ,
58- '#99CC33' ,
59- '#CC0000' ,
60- '#CC0033' ,
61- '#CC0066' ,
62- '#CC0099' ,
63- '#CC00CC' ,
64- '#CC00FF' ,
65- '#CC3300' ,
66- '#CC3333' ,
67- '#CC3366' ,
68- '#CC3399' ,
69- '#CC33CC' ,
70- '#CC33FF' ,
71- '#CC6600' ,
72- '#CC6633' ,
73- '#CC9900' ,
74- '#CC9933' ,
75- '#CCCC00' ,
76- '#CCCC33' ,
77- '#FF0000' ,
78- '#FF0033' ,
79- '#FF0066' ,
80- '#FF0099' ,
81- '#FF00CC' ,
82- '#FF00FF' ,
83- '#FF3300' ,
84- '#FF3333' ,
85- '#FF3366' ,
86- '#FF3399' ,
87- '#FF33CC' ,
88- '#FF33FF' ,
89- '#FF6600' ,
90- '#FF6633' ,
91- '#FF9900' ,
92- '#FF9933' ,
93- '#FFCC00' ,
94- '#FFCC33'
95- ] ;
96-
20+ exports . colors = [ '#0000CC' , '#0000FF' , '#0033CC' , '#0033FF' , '#0066CC' , '#0066FF' , '#0099CC' , '#0099FF' , '#00CC00' , '#00CC33' , '#00CC66' , '#00CC99' , '#00CCCC' , '#00CCFF' , '#3300CC' , '#3300FF' , '#3333CC' , '#3333FF' , '#3366CC' , '#3366FF' , '#3399CC' , '#3399FF' , '#33CC00' , '#33CC33' , '#33CC66' , '#33CC99' , '#33CCCC' , '#33CCFF' , '#6600CC' , '#6600FF' , '#6633CC' , '#6633FF' , '#66CC00' , '#66CC33' , '#9900CC' , '#9900FF' , '#9933CC' , '#9933FF' , '#99CC00' , '#99CC33' , '#CC0000' , '#CC0033' , '#CC0066' , '#CC0099' , '#CC00CC' , '#CC00FF' , '#CC3300' , '#CC3333' , '#CC3366' , '#CC3399' , '#CC33CC' , '#CC33FF' , '#CC6600' , '#CC6633' , '#CC9900' , '#CC9933' , '#CCCC00' , '#CCCC33' , '#FF0000' , '#FF0033' , '#FF0066' , '#FF0099' , '#FF00CC' , '#FF00FF' , '#FF3300' , '#FF3333' , '#FF3366' , '#FF3399' , '#FF33CC' , '#FF33FF' , '#FF6600' , '#FF6633' , '#FF9900' , '#FF9933' , '#FFCC00' , '#FFCC33' ] ;
9721/**
9822 * Currently only WebKit-based Web Inspectors, Firefox >= v31,
9923 * and the Firebug extension (any Firefox version) are known
10024 * to support "%c" CSS customizations.
10125 *
10226 * TODO: add a `localStorage` variable to explicitly enable/disable colors
10327 */
104-
10528// eslint-disable-next-line complexity
29+
10630function useColors ( ) {
107- // NB: In an Electron preload script, document will be defined but not fully
108- // initialized. Since we know we're in Chrome, we'll just detect this case
109- // explicitly
110- if ( typeof window !== 'undefined' && window . process && ( window . process . type === 'renderer' || window . process . __nwjs ) ) {
111- return true ;
112- }
113-
114- // Internet Explorer and Edge do not support colors.
115- if ( typeof navigator !== 'undefined' && navigator . userAgent && navigator . userAgent . toLowerCase ( ) . match ( / ( e d g e | t r i d e n t ) \/ ( \d + ) / ) ) {
116- return false ;
117- }
118-
119- // Is webkit? http://stackoverflow.com/a/16459606/376773
120- // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
121- return ( typeof document !== 'undefined' && document . documentElement && document . documentElement . style && document . documentElement . style . WebkitAppearance ) ||
122- // Is firebug? http://stackoverflow.com/a/398120/376773
123- ( typeof window !== 'undefined' && window . console && ( window . console . firebug || ( window . console . exception && window . console . table ) ) ) ||
124- // Is firefox >= v31?
125- // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
126- ( typeof navigator !== 'undefined' && navigator . userAgent && navigator . userAgent . toLowerCase ( ) . match ( / f i r e f o x \/ ( \d + ) / ) && parseInt ( RegExp . $1 , 10 ) >= 31 ) ||
127- // Double check webkit in userAgent just in case we are in a worker
128- ( typeof navigator !== 'undefined' && navigator . userAgent && navigator . userAgent . toLowerCase ( ) . match ( / a p p l e w e b k i t \/ ( \d + ) / ) ) ;
129- }
31+ // NB: In an Electron preload script, document will be defined but not fully
32+ // initialized. Since we know we're in Chrome, we'll just detect this case
33+ // explicitly
34+ if ( typeof window !== 'undefined' && window . process && ( window . process . type === 'renderer' || window . process . __nwjs ) ) {
35+ return true ;
36+ } // Internet Explorer and Edge do not support colors.
13037
38+
39+ if ( typeof navigator !== 'undefined' && navigator . userAgent && navigator . userAgent . toLowerCase ( ) . match ( / ( e d g e | t r i d e n t ) \/ ( \d + ) / ) ) {
40+ return false ;
41+ } // Is webkit? http://stackoverflow.com/a/16459606/376773
42+ // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
43+
44+
45+ return typeof document !== 'undefined' && document . documentElement && document . documentElement . style && document . documentElement . style . WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
46+ typeof window !== 'undefined' && window . console && ( window . console . firebug || window . console . exception && window . console . table ) || // Is firefox >= v31?
47+ // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
48+ typeof navigator !== 'undefined' && navigator . userAgent && navigator . userAgent . toLowerCase ( ) . match ( / f i r e f o x \/ ( \d + ) / ) && parseInt ( RegExp . $1 , 10 ) >= 31 || // Double check webkit in userAgent just in case we are in a worker
49+ typeof navigator !== 'undefined' && navigator . userAgent && navigator . userAgent . toLowerCase ( ) . match ( / a p p l e w e b k i t \/ ( \d + ) / ) ;
50+ }
13151/**
13252 * Colorize log arguments if enabled.
13353 *
13454 * @api public
13555 */
13656
57+
13758function formatArgs ( args ) {
138- args [ 0 ] = ( this . useColors ? '%c' : '' ) +
139- this . namespace +
140- ( this . useColors ? ' %c' : ' ' ) +
141- args [ 0 ] +
142- ( this . useColors ? '%c ' : ' ' ) +
143- '+' + module . exports . humanize ( this . diff ) ;
144-
145- if ( ! this . useColors ) {
146- return ;
147- }
148-
149- const c = 'color: ' + this . color ;
150- args . splice ( 1 , 0 , c , 'color: inherit' ) ;
151-
152- // The final "%c" is somewhat tricky, because there could be other
153- // arguments passed either before or after the %c, so we need to
154- // figure out the correct index to insert the CSS into
155- let index = 0 ;
156- let lastC = 0 ;
157- args [ 0 ] . replace ( / % [ a - z A - Z % ] / g, match => {
158- if ( match === '%%' ) {
159- return ;
160- }
161- index ++ ;
162- if ( match === '%c' ) {
163- // We only are interested in the *last* %c
164- // (the user may have provided their own)
165- lastC = index ;
166- }
167- } ) ;
168-
169- args . splice ( lastC , 0 , c ) ;
59+ args [ 0 ] = ( this . useColors ? '%c' : '' ) + this . namespace + ( this . useColors ? ' %c' : ' ' ) + args [ 0 ] + ( this . useColors ? '%c ' : ' ' ) + '+' + module . exports . humanize ( this . diff ) ;
60+
61+ if ( ! this . useColors ) {
62+ return ;
63+ }
64+
65+ var c = 'color: ' + this . color ;
66+ args . splice ( 1 , 0 , c , 'color: inherit' ) ; // The final "%c" is somewhat tricky, because there could be other
67+ // arguments passed either before or after the %c, so we need to
68+ // figure out the correct index to insert the CSS into
69+
70+ var index = 0 ;
71+ var lastC = 0 ;
72+ args [ 0 ] . replace ( / % [ a - z A - Z % ] / g, function ( match ) {
73+ if ( match === '%%' ) {
74+ return ;
75+ }
76+
77+ index ++ ;
78+
79+ if ( match === '%c' ) {
80+ // We only are interested in the *last* %c
81+ // (the user may have provided their own)
82+ lastC = index ;
83+ }
84+ } ) ;
85+ args . splice ( lastC , 0 , c ) ;
17086}
171-
17287/**
17388 * Invokes `console.log()` when available.
17489 * No-op when `console.log` is not a "function".
17590 *
17691 * @api public
17792 */
178- function log ( ...args ) {
179- // This hackery is required for IE8/9, where
180- // the `console.log` function doesn't have 'apply'
181- return typeof console === 'object' &&
182- console . log &&
183- console . log ( ...args ) ;
184- }
18593
94+
95+ function log ( ) {
96+ var _console ;
97+
98+ // This hackery is required for IE8/9, where
99+ // the `console.log` function doesn't have 'apply'
100+ return ( typeof console === "undefined" ? "undefined" : _typeof ( console ) ) === 'object' && console . log && ( _console = console ) . log . apply ( _console , arguments ) ;
101+ }
186102/**
187103 * Save `namespaces`.
188104 *
189105 * @param {String } namespaces
190106 * @api private
191107 */
108+
109+
192110function save ( namespaces ) {
193- try {
194- if ( namespaces ) {
195- exports . storage . setItem ( 'debug' , namespaces ) ;
196- } else {
197- exports . storage . removeItem ( 'debug' ) ;
198- }
199- } catch ( error ) {
200- // Swallow
201- // XXX (@Qix-) should we be logging these?
202- }
111+ try {
112+ if ( namespaces ) {
113+ exports . storage . setItem ( 'debug' , namespaces ) ;
114+ } else {
115+ exports . storage . removeItem ( 'debug' ) ;
116+ }
117+ } catch ( error ) { // Swallow
118+ // XXX (@Qix-) should we be logging these?
119+ }
203120}
204-
205121/**
206122 * Load `namespaces`.
207123 *
208124 * @return {String } returns the previously persisted debug modes
209125 * @api private
210126 */
127+
128+
211129function load ( ) {
212- let r ;
213- try {
214- r = exports . storage . getItem ( 'debug' ) ;
215- } catch ( error ) {
216- // Swallow
217- // XXX (@Qix-) should we be logging these?
218- }
219-
220- // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
221- if ( ! r && typeof process !== 'undefined' && 'env' in process ) {
222- r = process . env . DEBUG ;
223- }
224-
225- return r ;
226- }
130+ var r ;
227131
132+ try {
133+ r = exports . storage . getItem ( 'debug' ) ;
134+ } catch ( error ) { } // Swallow
135+ // XXX (@Qix-) should we be logging these?
136+ // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
137+
138+
139+ if ( ! r && typeof process !== 'undefined' && 'env' in process ) {
140+ r = process . env . DEBUG ;
141+ }
142+
143+ return r ;
144+ }
228145/**
229146 * Localstorage attempts to return the localstorage.
230147 *
@@ -236,29 +153,28 @@ function load() {
236153 * @api private
237154 */
238155
156+
239157function localstorage ( ) {
240- try {
241- // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
242- // The Browser also has localStorage in the global context.
243- return localStorage ;
244- } catch ( error ) {
245- // Swallow
246- // XXX (@Qix-) should we be logging these?
247- }
158+ try {
159+ // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
160+ // The Browser also has localStorage in the global context.
161+ return localStorage ;
162+ } catch ( error ) { // Swallow
163+ // XXX (@Qix-) should we be logging these?
164+ }
248165}
249166
250167module . exports = require ( './common' ) ( exports ) ;
251-
252- const { formatters} = module . exports ;
253-
168+ var formatters = module . exports . formatters ;
254169/**
255170 * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
256171 */
257172
258173formatters . j = function ( v ) {
259- try {
260- return JSON . stringify ( v ) ;
261- } catch ( error ) {
262- return '[UnexpectedJSONParseError]: ' + error . message ;
263- }
174+ try {
175+ return JSON . stringify ( v ) ;
176+ } catch ( error ) {
177+ return '[UnexpectedJSONParseError]: ' + error . message ;
178+ }
264179} ;
180+
0 commit comments