@socketsecurity/cli-with-sentry 1.0.20 → 1.0.22

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.
Files changed (64) hide show
  1. package/dist/cli.js +349 -326
  2. package/dist/cli.js.map +1 -1
  3. package/dist/constants.js +4 -4
  4. package/dist/constants.js.map +1 -1
  5. package/dist/shadow-npm-inject.js +64 -7
  6. package/dist/shadow-npm-inject.js.map +1 -1
  7. package/dist/types/commands/audit-log/output-audit-log.d.mts.map +1 -1
  8. package/dist/types/commands/fix/agent-fix.d.mts +3 -5
  9. package/dist/types/commands/fix/agent-fix.d.mts.map +1 -1
  10. package/dist/types/commands/fix/fix-branch-helpers.d.mts +3 -4
  11. package/dist/types/commands/fix/fix-branch-helpers.d.mts.map +1 -1
  12. package/dist/types/commands/fix/fix-env-helpers.d.mts +9 -9
  13. package/dist/types/commands/fix/fix-env-helpers.d.mts.map +1 -1
  14. package/dist/types/commands/fix/git.d.mts +1 -0
  15. package/dist/types/commands/fix/git.d.mts.map +1 -1
  16. package/dist/types/commands/fix/handle-fix.d.mts.map +1 -1
  17. package/dist/types/commands/fix/npm-fix.d.mts.map +1 -1
  18. package/dist/types/commands/fix/pnpm-fix.d.mts.map +1 -1
  19. package/dist/types/commands/fix/{open-pr.d.mts → pull-request.d.mts} +11 -6
  20. package/dist/types/commands/fix/pull-request.d.mts.map +1 -0
  21. package/dist/types/commands/fix/shared.d.mts +1 -2
  22. package/dist/types/commands/fix/shared.d.mts.map +1 -1
  23. package/dist/types/commands/manifest/cmd-manifest-cdxgen.d.mts.map +1 -1
  24. package/dist/types/commands/manifest/cmd-manifest-gradle.d.mts.map +1 -1
  25. package/dist/types/commands/manifest/cmd-manifest-kotlin.d.mts.map +1 -1
  26. package/dist/types/commands/manifest/cmd-manifest-scala.d.mts.map +1 -1
  27. package/dist/types/commands/manifest/detect-manifest-actions.d.mts.map +1 -1
  28. package/dist/types/commands/optimize/update-lockfile.d.mts.map +1 -1
  29. package/dist/types/commands/repository/fetch-list-all-repos.d.mts.map +1 -1
  30. package/dist/types/commands/scan/fetch-report-data.d.mts.map +1 -1
  31. package/dist/types/commands/scan/fetch-scan.d.mts.map +1 -1
  32. package/dist/types/commands/wrapper/postinstall-wrapper.d.mts.map +1 -1
  33. package/dist/types/shadow/npm/arborist-helpers.d.mts.map +1 -1
  34. package/dist/types/utils/alerts-map.d.mts +0 -1
  35. package/dist/types/utils/alerts-map.d.mts.map +1 -1
  36. package/dist/types/utils/api.d.mts.map +1 -1
  37. package/dist/types/utils/npm-config.d.mts +14 -0
  38. package/dist/types/utils/npm-config.d.mts.map +1 -0
  39. package/dist/types/utils/npm-paths.d.mts +2 -2
  40. package/dist/types/utils/npm-paths.d.mts.map +1 -1
  41. package/dist/types/utils/package-environment.d.mts.map +1 -1
  42. package/dist/types/utils/path-resolve.d.mts.map +1 -1
  43. package/dist/types/utils/socket-package-alert.d.mts +1 -2
  44. package/dist/types/utils/socket-package-alert.d.mts.map +1 -1
  45. package/dist/types/utils/socketjson.d.mts.map +1 -1
  46. package/dist/utils.js +148 -70
  47. package/dist/utils.js.map +1 -1
  48. package/dist/vendor.js +66962 -66962
  49. package/external/@coana-tech/cli/cli.mjs +60278 -55993
  50. package/external/@socketsecurity/registry/external/@inquirer/confirm.js +1 -1
  51. package/external/@socketsecurity/registry/external/@inquirer/input.js +10 -2
  52. package/external/@socketsecurity/registry/external/@inquirer/password.js +1 -1
  53. package/external/@socketsecurity/registry/external/@inquirer/search.js +1 -1
  54. package/external/@socketsecurity/registry/external/@inquirer/select.js +1 -1
  55. package/external/@socketsecurity/registry/external/browserslist.js +572 -570
  56. package/external/@socketsecurity/registry/external/debug.js +1163 -0
  57. package/external/@socketsecurity/registry/lib/constants/env.js +9 -4
  58. package/external/@socketsecurity/registry/lib/debug.js +139 -47
  59. package/external/@socketsecurity/registry/lib/logger.js +2 -2
  60. package/external/@socketsecurity/registry/lib/packages.js +1 -2
  61. package/package.json +18 -18
  62. package/dist/types/commands/fix/open-pr.d.mts.map +0 -1
  63. package/dist/types/shadow/npm/proc-log/index.d.mts +0 -3
  64. package/dist/types/shadow/npm/proc-log/index.d.mts.map +0 -1
@@ -0,0 +1,1163 @@
1
+ 'use strict'
2
+
3
+ const require$$1 = require('tty')
4
+ const require$$1$1 = require('util')
5
+ const require$$0 = require('os')
6
+
7
+ const src = { exports: {} }
8
+
9
+ const browser = { exports: {} }
10
+
11
+ /**
12
+ * Helpers.
13
+ */
14
+ let ms
15
+ let hasRequiredMs
16
+ function requireMs() {
17
+ if (hasRequiredMs) {
18
+ return ms
19
+ }
20
+ hasRequiredMs = 1
21
+ const s = 1000
22
+ const m = s * 60
23
+ const h = m * 60
24
+ const d = h * 24
25
+ const w = d * 7
26
+ const y = d * 365.25
27
+
28
+ /**
29
+ * Parse or format the given `val`.
30
+ *
31
+ * Options:
32
+ *
33
+ * - `long` verbose formatting [false]
34
+ *
35
+ * @param {String|Number} val
36
+ * @param {Object} [options]
37
+ * @throws {Error} throw an error if val is not a non-empty string or a number
38
+ * @return {String|Number}
39
+ * @api public
40
+ */
41
+
42
+ ms = function (val, options) {
43
+ options = options || {}
44
+ const type = typeof val
45
+ if (type === 'string' && val.length > 0) {
46
+ return parse(val)
47
+ } else if (type === 'number' && isFinite(val)) {
48
+ return options.long ? fmtLong(val) : fmtShort(val)
49
+ }
50
+ throw new Error(
51
+ 'val is not a non-empty string or a valid number. val=' +
52
+ JSON.stringify(val)
53
+ )
54
+ }
55
+
56
+ /**
57
+ * Parse the given `str` and return milliseconds.
58
+ *
59
+ * @param {String} str
60
+ * @return {Number}
61
+ * @api private
62
+ */
63
+
64
+ function parse(str) {
65
+ str = String(str)
66
+ if (str.length > 100) {
67
+ return
68
+ }
69
+ const match =
70
+ /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
71
+ str
72
+ )
73
+ if (!match) {
74
+ return
75
+ }
76
+ const n = parseFloat(match[1])
77
+ const type = (match[2] || 'ms').toLowerCase()
78
+ switch (type) {
79
+ case 'years':
80
+ case 'year':
81
+ case 'yrs':
82
+ case 'yr':
83
+ case 'y':
84
+ return n * y
85
+ case 'weeks':
86
+ case 'week':
87
+ case 'w':
88
+ return n * w
89
+ case 'days':
90
+ case 'day':
91
+ case 'd':
92
+ return n * d
93
+ case 'hours':
94
+ case 'hour':
95
+ case 'hrs':
96
+ case 'hr':
97
+ case 'h':
98
+ return n * h
99
+ case 'minutes':
100
+ case 'minute':
101
+ case 'mins':
102
+ case 'min':
103
+ case 'm':
104
+ return n * m
105
+ case 'seconds':
106
+ case 'second':
107
+ case 'secs':
108
+ case 'sec':
109
+ case 's':
110
+ return n * s
111
+ case 'milliseconds':
112
+ case 'millisecond':
113
+ case 'msecs':
114
+ case 'msec':
115
+ case 'ms':
116
+ return n
117
+ default:
118
+ return undefined
119
+ }
120
+ }
121
+
122
+ /**
123
+ * Short format for `ms`.
124
+ *
125
+ * @param {Number} ms
126
+ * @return {String}
127
+ * @api private
128
+ */
129
+
130
+ function fmtShort(ms) {
131
+ const msAbs = Math.abs(ms)
132
+ if (msAbs >= d) {
133
+ return Math.round(ms / d) + 'd'
134
+ }
135
+ if (msAbs >= h) {
136
+ return Math.round(ms / h) + 'h'
137
+ }
138
+ if (msAbs >= m) {
139
+ return Math.round(ms / m) + 'm'
140
+ }
141
+ if (msAbs >= s) {
142
+ return Math.round(ms / s) + 's'
143
+ }
144
+ return ms + 'ms'
145
+ }
146
+
147
+ /**
148
+ * Long format for `ms`.
149
+ *
150
+ * @param {Number} ms
151
+ * @return {String}
152
+ * @api private
153
+ */
154
+
155
+ function fmtLong(ms) {
156
+ const msAbs = Math.abs(ms)
157
+ if (msAbs >= d) {
158
+ return plural(ms, msAbs, d, 'day')
159
+ }
160
+ if (msAbs >= h) {
161
+ return plural(ms, msAbs, h, 'hour')
162
+ }
163
+ if (msAbs >= m) {
164
+ return plural(ms, msAbs, m, 'minute')
165
+ }
166
+ if (msAbs >= s) {
167
+ return plural(ms, msAbs, s, 'second')
168
+ }
169
+ return ms + ' ms'
170
+ }
171
+
172
+ /**
173
+ * Pluralization helper.
174
+ */
175
+
176
+ function plural(ms, msAbs, n, name) {
177
+ const isPlural = msAbs >= n * 1.5
178
+ return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '')
179
+ }
180
+ return ms
181
+ }
182
+
183
+ let common
184
+ let hasRequiredCommon
185
+ function requireCommon() {
186
+ if (hasRequiredCommon) {
187
+ return common
188
+ }
189
+ hasRequiredCommon = 1
190
+ /**
191
+ * This is the common logic for both the Node.js and web browser
192
+ * implementations of `debug()`.
193
+ */
194
+
195
+ function setup(env) {
196
+ createDebug.debug = createDebug
197
+ createDebug.default = createDebug
198
+ createDebug.coerce = coerce
199
+ createDebug.disable = disable
200
+ createDebug.enable = enable
201
+ createDebug.enabled = enabled
202
+ createDebug.humanize = requireMs()
203
+ createDebug.destroy = destroy
204
+ Object.keys(env).forEach(key => {
205
+ createDebug[key] = env[key]
206
+ })
207
+
208
+ /**
209
+ * The currently active debug mode names, and names to skip.
210
+ */
211
+
212
+ createDebug.names = []
213
+ createDebug.skips = []
214
+
215
+ /**
216
+ * Map of special "%n" handling functions, for the debug "format" argument.
217
+ *
218
+ * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
219
+ */
220
+ createDebug.formatters = {}
221
+
222
+ /**
223
+ * Selects a color for a debug namespace
224
+ * @param {String} namespace The namespace string for the debug instance to be colored
225
+ * @return {Number|String} An ANSI color code for the given namespace
226
+ * @api private
227
+ */
228
+ function selectColor(namespace) {
229
+ let hash = 0
230
+ for (let i = 0; i < namespace.length; i++) {
231
+ hash = (hash << 5) - hash + namespace.charCodeAt(i)
232
+ hash |= 0 // Convert to 32bit integer
233
+ }
234
+ return createDebug.colors[Math.abs(hash) % createDebug.colors.length]
235
+ }
236
+ createDebug.selectColor = selectColor
237
+
238
+ /**
239
+ * Create a debugger with the given `namespace`.
240
+ *
241
+ * @param {String} namespace
242
+ * @return {Function}
243
+ * @api public
244
+ */
245
+ function createDebug(namespace) {
246
+ let prevTime
247
+ let enableOverride = null
248
+ let namespacesCache
249
+ let enabledCache
250
+ function debug(...args) {
251
+ // Disabled?
252
+ if (!debug.enabled) {
253
+ return
254
+ }
255
+ const self = debug
256
+
257
+ // Set `diff` timestamp
258
+ const curr = Number(new Date())
259
+ const ms = curr - (prevTime || curr)
260
+ self.diff = ms
261
+ self.prev = prevTime
262
+ self.curr = curr
263
+ prevTime = curr
264
+ args[0] = createDebug.coerce(args[0])
265
+ if (typeof args[0] !== 'string') {
266
+ // Anything else let's inspect with %O
267
+ args.unshift('%O')
268
+ }
269
+
270
+ // Apply any `formatters` transformations
271
+ let index = 0
272
+ args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
273
+ // If we encounter an escaped % then don't increase the array index
274
+ if (match === '%%') {
275
+ return '%'
276
+ }
277
+ index++
278
+ const formatter = createDebug.formatters[format]
279
+ if (typeof formatter === 'function') {
280
+ const val = args[index]
281
+ match = formatter.call(self, val)
282
+
283
+ // Now we need to remove `args[index]` since it's inlined in the `format`
284
+ args.splice(index, 1)
285
+ index--
286
+ }
287
+ return match
288
+ })
289
+
290
+ // Apply env-specific formatting (colors, etc.)
291
+ createDebug.formatArgs.call(self, args)
292
+ const logFn = self.log || createDebug.log
293
+ logFn.apply(self, args)
294
+ }
295
+ debug.namespace = namespace
296
+ debug.useColors = createDebug.useColors()
297
+ debug.color = createDebug.selectColor(namespace)
298
+ debug.extend = extend
299
+ debug.destroy = createDebug.destroy // XXX Temporary. Will be removed in the next major release.
300
+
301
+ Object.defineProperty(debug, 'enabled', {
302
+ enumerable: true,
303
+ configurable: false,
304
+ get: () => {
305
+ if (enableOverride !== null) {
306
+ return enableOverride
307
+ }
308
+ if (namespacesCache !== createDebug.namespaces) {
309
+ namespacesCache = createDebug.namespaces
310
+ enabledCache = createDebug.enabled(namespace)
311
+ }
312
+ return enabledCache
313
+ },
314
+ set: v => {
315
+ enableOverride = v
316
+ }
317
+ })
318
+
319
+ // Env-specific initialization logic for debug instances
320
+ if (typeof createDebug.init === 'function') {
321
+ createDebug.init(debug)
322
+ }
323
+ return debug
324
+ }
325
+ function extend(namespace, delimiter) {
326
+ const newDebug = createDebug(
327
+ this.namespace +
328
+ (typeof delimiter === 'undefined' ? ':' : delimiter) +
329
+ namespace
330
+ )
331
+ newDebug.log = this.log
332
+ return newDebug
333
+ }
334
+
335
+ /**
336
+ * Enables a debug mode by namespaces. This can include modes
337
+ * separated by a colon and wildcards.
338
+ *
339
+ * @param {String} namespaces
340
+ * @api public
341
+ */
342
+ function enable(namespaces) {
343
+ createDebug.save(namespaces)
344
+ createDebug.namespaces = namespaces
345
+ createDebug.names = []
346
+ createDebug.skips = []
347
+ const split = (typeof namespaces === 'string' ? namespaces : '')
348
+ .trim()
349
+ .replace(/\s+/g, ',')
350
+ .split(',')
351
+ .filter(Boolean)
352
+ for (const ns of split) {
353
+ if (ns[0] === '-') {
354
+ createDebug.skips.push(ns.slice(1))
355
+ } else {
356
+ createDebug.names.push(ns)
357
+ }
358
+ }
359
+ }
360
+
361
+ /**
362
+ * Checks if the given string matches a namespace template, honoring
363
+ * asterisks as wildcards.
364
+ *
365
+ * @param {String} search
366
+ * @param {String} template
367
+ * @return {Boolean}
368
+ */
369
+ function matchesTemplate(search, template) {
370
+ let searchIndex = 0
371
+ let templateIndex = 0
372
+ let starIndex = -1
373
+ let matchIndex = 0
374
+ while (searchIndex < search.length) {
375
+ if (
376
+ templateIndex < template.length &&
377
+ (template[templateIndex] === search[searchIndex] ||
378
+ template[templateIndex] === '*')
379
+ ) {
380
+ // Match character or proceed with wildcard
381
+ if (template[templateIndex] === '*') {
382
+ starIndex = templateIndex
383
+ matchIndex = searchIndex
384
+ templateIndex++ // Skip the '*'
385
+ } else {
386
+ searchIndex++
387
+ templateIndex++
388
+ }
389
+ } else if (starIndex !== -1) {
390
+ // eslint-disable-line no-negated-condition
391
+ // Backtrack to the last '*' and try to match more characters
392
+ templateIndex = starIndex + 1
393
+ matchIndex++
394
+ searchIndex = matchIndex
395
+ } else {
396
+ return false // No match
397
+ }
398
+ }
399
+
400
+ // Handle trailing '*' in template
401
+ while (
402
+ templateIndex < template.length &&
403
+ template[templateIndex] === '*'
404
+ ) {
405
+ templateIndex++
406
+ }
407
+ return templateIndex === template.length
408
+ }
409
+
410
+ /**
411
+ * Disable debug output.
412
+ *
413
+ * @return {String} namespaces
414
+ * @api public
415
+ */
416
+ function disable() {
417
+ const namespaces = [
418
+ ...createDebug.names,
419
+ ...createDebug.skips.map(namespace => '-' + namespace)
420
+ ].join(',')
421
+ createDebug.enable('')
422
+ return namespaces
423
+ }
424
+
425
+ /**
426
+ * Returns true if the given mode name is enabled, false otherwise.
427
+ *
428
+ * @param {String} name
429
+ * @return {Boolean}
430
+ * @api public
431
+ */
432
+ function enabled(name) {
433
+ for (const skip of createDebug.skips) {
434
+ if (matchesTemplate(name, skip)) {
435
+ return false
436
+ }
437
+ }
438
+ for (const ns of createDebug.names) {
439
+ if (matchesTemplate(name, ns)) {
440
+ return true
441
+ }
442
+ }
443
+ return false
444
+ }
445
+
446
+ /**
447
+ * Coerce `val`.
448
+ *
449
+ * @param {Mixed} val
450
+ * @return {Mixed}
451
+ * @api private
452
+ */
453
+ function coerce(val) {
454
+ if (val instanceof Error) {
455
+ return val.stack || val.message
456
+ }
457
+ return val
458
+ }
459
+
460
+ /**
461
+ * XXX DO NOT USE. This is a temporary stub function.
462
+ * XXX It WILL be removed in the next major release.
463
+ */
464
+ function destroy() {
465
+ console.warn(
466
+ 'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
467
+ )
468
+ }
469
+ createDebug.enable(createDebug.load())
470
+ return createDebug
471
+ }
472
+ common = setup
473
+ return common
474
+ }
475
+
476
+ /* eslint-env browser */
477
+ let hasRequiredBrowser
478
+ function requireBrowser() {
479
+ if (hasRequiredBrowser) {
480
+ return browser.exports
481
+ }
482
+ hasRequiredBrowser = 1
483
+ ;(function (module, exports) {
484
+ /**
485
+ * This is the web browser implementation of `debug()`.
486
+ */
487
+
488
+ exports.formatArgs = formatArgs
489
+ exports.save = save
490
+ exports.load = load
491
+ exports.useColors = useColors
492
+ exports.storage = localstorage()
493
+ exports.destroy = (() => {
494
+ let warned = false
495
+ return () => {
496
+ if (!warned) {
497
+ warned = true
498
+ console.warn(
499
+ 'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
500
+ )
501
+ }
502
+ }
503
+ })()
504
+
505
+ /**
506
+ * Colors.
507
+ */
508
+
509
+ exports.colors = [
510
+ '#0000CC',
511
+ '#0000FF',
512
+ '#0033CC',
513
+ '#0033FF',
514
+ '#0066CC',
515
+ '#0066FF',
516
+ '#0099CC',
517
+ '#0099FF',
518
+ '#00CC00',
519
+ '#00CC33',
520
+ '#00CC66',
521
+ '#00CC99',
522
+ '#00CCCC',
523
+ '#00CCFF',
524
+ '#3300CC',
525
+ '#3300FF',
526
+ '#3333CC',
527
+ '#3333FF',
528
+ '#3366CC',
529
+ '#3366FF',
530
+ '#3399CC',
531
+ '#3399FF',
532
+ '#33CC00',
533
+ '#33CC33',
534
+ '#33CC66',
535
+ '#33CC99',
536
+ '#33CCCC',
537
+ '#33CCFF',
538
+ '#6600CC',
539
+ '#6600FF',
540
+ '#6633CC',
541
+ '#6633FF',
542
+ '#66CC00',
543
+ '#66CC33',
544
+ '#9900CC',
545
+ '#9900FF',
546
+ '#9933CC',
547
+ '#9933FF',
548
+ '#99CC00',
549
+ '#99CC33',
550
+ '#CC0000',
551
+ '#CC0033',
552
+ '#CC0066',
553
+ '#CC0099',
554
+ '#CC00CC',
555
+ '#CC00FF',
556
+ '#CC3300',
557
+ '#CC3333',
558
+ '#CC3366',
559
+ '#CC3399',
560
+ '#CC33CC',
561
+ '#CC33FF',
562
+ '#CC6600',
563
+ '#CC6633',
564
+ '#CC9900',
565
+ '#CC9933',
566
+ '#CCCC00',
567
+ '#CCCC33',
568
+ '#FF0000',
569
+ '#FF0033',
570
+ '#FF0066',
571
+ '#FF0099',
572
+ '#FF00CC',
573
+ '#FF00FF',
574
+ '#FF3300',
575
+ '#FF3333',
576
+ '#FF3366',
577
+ '#FF3399',
578
+ '#FF33CC',
579
+ '#FF33FF',
580
+ '#FF6600',
581
+ '#FF6633',
582
+ '#FF9900',
583
+ '#FF9933',
584
+ '#FFCC00',
585
+ '#FFCC33'
586
+ ]
587
+
588
+ /**
589
+ * Currently only WebKit-based Web Inspectors, Firefox >= v31,
590
+ * and the Firebug extension (any Firefox version) are known
591
+ * to support "%c" CSS customizations.
592
+ *
593
+ * TODO: add a `localStorage` variable to explicitly enable/disable colors
594
+ */
595
+
596
+ // eslint-disable-next-line complexity
597
+ function useColors() {
598
+ // NB: In an Electron preload script, document will be defined but not fully
599
+ // initialized. Since we know we're in Chrome, we'll just detect this case
600
+ // explicitly
601
+ if (
602
+ typeof window !== 'undefined' &&
603
+ window.process &&
604
+ (window.process.type === 'renderer' || window.process.__nwjs)
605
+ ) {
606
+ return true
607
+ }
608
+
609
+ // Internet Explorer and Edge do not support colors.
610
+ if (
611
+ typeof navigator !== 'undefined' &&
612
+ navigator.userAgent &&
613
+ navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)
614
+ ) {
615
+ return false
616
+ }
617
+ let m
618
+
619
+ // Is webkit? http://stackoverflow.com/a/16459606/376773
620
+ // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
621
+ // eslint-disable-next-line no-return-assign
622
+ return (
623
+ (typeof document !== 'undefined' &&
624
+ document.documentElement &&
625
+ document.documentElement.style &&
626
+ document.documentElement.style.WebkitAppearance) ||
627
+ // Is firebug? http://stackoverflow.com/a/398120/376773
628
+ (typeof window !== 'undefined' &&
629
+ window.console &&
630
+ (window.console.firebug ||
631
+ (window.console.exception && window.console.table))) ||
632
+ // Is firefox >= v31?
633
+ // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
634
+ (typeof navigator !== 'undefined' &&
635
+ navigator.userAgent &&
636
+ (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) &&
637
+ parseInt(m[1], 10) >= 31) ||
638
+ // Double check webkit in userAgent just in case we are in a worker
639
+ (typeof navigator !== 'undefined' &&
640
+ navigator.userAgent &&
641
+ navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))
642
+ )
643
+ }
644
+
645
+ /**
646
+ * Colorize log arguments if enabled.
647
+ *
648
+ * @api public
649
+ */
650
+
651
+ function formatArgs(args) {
652
+ args[0] =
653
+ (this.useColors ? '%c' : '') +
654
+ this.namespace +
655
+ (this.useColors ? ' %c' : ' ') +
656
+ args[0] +
657
+ (this.useColors ? '%c ' : ' ') +
658
+ '+' +
659
+ module.exports.humanize(this.diff)
660
+ if (!this.useColors) {
661
+ return
662
+ }
663
+ const c = 'color: ' + this.color
664
+ args.splice(1, 0, c, 'color: inherit')
665
+
666
+ // The final "%c" is somewhat tricky, because there could be other
667
+ // arguments passed either before or after the %c, so we need to
668
+ // figure out the correct index to insert the CSS into
669
+ let index = 0
670
+ let lastC = 0
671
+ args[0].replace(/%[a-zA-Z%]/g, match => {
672
+ if (match === '%%') {
673
+ return
674
+ }
675
+ index++
676
+ if (match === '%c') {
677
+ // We only are interested in the *last* %c
678
+ // (the user may have provided their own)
679
+ lastC = index
680
+ }
681
+ })
682
+ args.splice(lastC, 0, c)
683
+ }
684
+
685
+ /**
686
+ * Invokes `console.debug()` when available.
687
+ * No-op when `console.debug` is not a "function".
688
+ * If `console.debug` is not available, falls back
689
+ * to `console.log`.
690
+ *
691
+ * @api public
692
+ */
693
+ exports.log = console.debug || console.log || (() => {})
694
+
695
+ /**
696
+ * Save `namespaces`.
697
+ *
698
+ * @param {String} namespaces
699
+ * @api private
700
+ */
701
+ function save(namespaces) {
702
+ try {
703
+ if (namespaces) {
704
+ exports.storage.setItem('debug', namespaces)
705
+ } else {
706
+ exports.storage.removeItem('debug')
707
+ }
708
+ } catch (error) {
709
+ // Swallow
710
+ // XXX (@Qix-) should we be logging these?
711
+ }
712
+ }
713
+
714
+ /**
715
+ * Load `namespaces`.
716
+ *
717
+ * @return {String} returns the previously persisted debug modes
718
+ * @api private
719
+ */
720
+ function load() {
721
+ let r
722
+ try {
723
+ r = exports.storage.getItem('debug') || exports.storage.getItem('DEBUG')
724
+ } catch (error) {
725
+ // Swallow
726
+ // XXX (@Qix-) should we be logging these?
727
+ }
728
+
729
+ // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
730
+ if (!r && typeof process !== 'undefined' && 'env' in process) {
731
+ r = process.env.DEBUG
732
+ }
733
+ return r
734
+ }
735
+
736
+ /**
737
+ * Localstorage attempts to return the localstorage.
738
+ *
739
+ * This is necessary because safari throws
740
+ * when a user disables cookies/localstorage
741
+ * and you attempt to access it.
742
+ *
743
+ * @return {LocalStorage}
744
+ * @api private
745
+ */
746
+
747
+ function localstorage() {
748
+ try {
749
+ // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
750
+ // The Browser also has localStorage in the global context.
751
+ return localStorage
752
+ } catch (error) {
753
+ // Swallow
754
+ // XXX (@Qix-) should we be logging these?
755
+ }
756
+ }
757
+ module.exports = requireCommon()(exports)
758
+ const { formatters } = module.exports
759
+
760
+ /**
761
+ * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
762
+ */
763
+
764
+ formatters.j = function (v) {
765
+ try {
766
+ return JSON.stringify(v)
767
+ } catch (error) {
768
+ return '[UnexpectedJSONParseError]: ' + error.message
769
+ }
770
+ }
771
+ })(browser, browser.exports)
772
+ return browser.exports
773
+ }
774
+
775
+ const node = { exports: {} }
776
+
777
+ let hasFlag
778
+ let hasRequiredHasFlag
779
+ function requireHasFlag() {
780
+ if (hasRequiredHasFlag) {
781
+ return hasFlag
782
+ }
783
+ hasRequiredHasFlag = 1
784
+ hasFlag = (flag, argv = process.argv) => {
785
+ const prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--'
786
+ const position = argv.indexOf(prefix + flag)
787
+ const terminatorPosition = argv.indexOf('--')
788
+ return (
789
+ position !== -1 &&
790
+ (terminatorPosition === -1 || position < terminatorPosition)
791
+ )
792
+ }
793
+ return hasFlag
794
+ }
795
+
796
+ let supportsColor_1
797
+ let hasRequiredSupportsColor
798
+ function requireSupportsColor() {
799
+ if (hasRequiredSupportsColor) {
800
+ return supportsColor_1
801
+ }
802
+ hasRequiredSupportsColor = 1
803
+ const os = require$$0
804
+ const tty = require$$1
805
+ const hasFlag = requireHasFlag()
806
+ const { env } = process
807
+ let forceColor
808
+ if (
809
+ hasFlag('no-color') ||
810
+ hasFlag('no-colors') ||
811
+ hasFlag('color=false') ||
812
+ hasFlag('color=never')
813
+ ) {
814
+ forceColor = 0
815
+ } else if (
816
+ hasFlag('color') ||
817
+ hasFlag('colors') ||
818
+ hasFlag('color=true') ||
819
+ hasFlag('color=always')
820
+ ) {
821
+ forceColor = 1
822
+ }
823
+ if ('FORCE_COLOR' in env) {
824
+ if (env.FORCE_COLOR === 'true') {
825
+ forceColor = 1
826
+ } else if (env.FORCE_COLOR === 'false') {
827
+ forceColor = 0
828
+ } else {
829
+ forceColor =
830
+ env.FORCE_COLOR.length === 0
831
+ ? 1
832
+ : Math.min(parseInt(env.FORCE_COLOR, 10), 3)
833
+ }
834
+ }
835
+ function translateLevel(level) {
836
+ if (level === 0) {
837
+ return false
838
+ }
839
+ return {
840
+ level,
841
+ hasBasic: true,
842
+ has256: level >= 2,
843
+ has16m: level >= 3
844
+ }
845
+ }
846
+ function supportsColor(haveStream, streamIsTTY) {
847
+ if (forceColor === 0) {
848
+ return 0
849
+ }
850
+ if (
851
+ hasFlag('color=16m') ||
852
+ hasFlag('color=full') ||
853
+ hasFlag('color=truecolor')
854
+ ) {
855
+ return 3
856
+ }
857
+ if (hasFlag('color=256')) {
858
+ return 2
859
+ }
860
+ if (haveStream && !streamIsTTY && forceColor === undefined) {
861
+ return 0
862
+ }
863
+ const min = forceColor || 0
864
+ if (env.TERM === 'dumb') {
865
+ return min
866
+ }
867
+ if (process.platform === 'win32') {
868
+ // Windows 10 build 10586 is the first Windows release that supports 256 colors.
869
+ // Windows 10 build 14931 is the first release that supports 16m/TrueColor.
870
+ const osRelease = os.release().split('.')
871
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
872
+ return Number(osRelease[2]) >= 14931 ? 3 : 2
873
+ }
874
+ return 1
875
+ }
876
+ if ('CI' in env) {
877
+ if (
878
+ [
879
+ 'TRAVIS',
880
+ 'CIRCLECI',
881
+ 'APPVEYOR',
882
+ 'GITLAB_CI',
883
+ 'GITHUB_ACTIONS',
884
+ 'BUILDKITE'
885
+ ].some(sign => sign in env) ||
886
+ env.CI_NAME === 'codeship'
887
+ ) {
888
+ return 1
889
+ }
890
+ return min
891
+ }
892
+ if ('TEAMCITY_VERSION' in env) {
893
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0
894
+ }
895
+ if (env.COLORTERM === 'truecolor') {
896
+ return 3
897
+ }
898
+ if ('TERM_PROGRAM' in env) {
899
+ const version = parseInt(
900
+ (env.TERM_PROGRAM_VERSION || '').split('.')[0],
901
+ 10
902
+ )
903
+ switch (env.TERM_PROGRAM) {
904
+ case 'iTerm.app':
905
+ return version >= 3 ? 3 : 2
906
+ case 'Apple_Terminal':
907
+ return 2
908
+ // No default
909
+ }
910
+ }
911
+ if (/-256(color)?$/i.test(env.TERM)) {
912
+ return 2
913
+ }
914
+ if (
915
+ /^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(
916
+ env.TERM
917
+ )
918
+ ) {
919
+ return 1
920
+ }
921
+ if ('COLORTERM' in env) {
922
+ return 1
923
+ }
924
+ return min
925
+ }
926
+ function getSupportLevel(stream) {
927
+ const level = supportsColor(stream, stream && stream.isTTY)
928
+ return translateLevel(level)
929
+ }
930
+ supportsColor_1 = {
931
+ supportsColor: getSupportLevel,
932
+ stdout: translateLevel(supportsColor(true, tty.isatty(1))),
933
+ stderr: translateLevel(supportsColor(true, tty.isatty(2)))
934
+ }
935
+ return supportsColor_1
936
+ }
937
+
938
+ /**
939
+ * Module dependencies.
940
+ */
941
+ let hasRequiredNode
942
+ function requireNode() {
943
+ if (hasRequiredNode) {
944
+ return node.exports
945
+ }
946
+ hasRequiredNode = 1
947
+ ;(function (module, exports) {
948
+ const tty = require$$1
949
+ const util = require$$1$1
950
+
951
+ /**
952
+ * This is the Node.js implementation of `debug()`.
953
+ */
954
+
955
+ exports.init = init
956
+ exports.log = log
957
+ exports.formatArgs = formatArgs
958
+ exports.save = save
959
+ exports.load = load
960
+ exports.useColors = useColors
961
+ exports.destroy = util.deprecate(
962
+ () => {},
963
+ 'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
964
+ )
965
+
966
+ /**
967
+ * Colors.
968
+ */
969
+
970
+ exports.colors = [6, 2, 3, 4, 5, 1]
971
+ try {
972
+ // Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
973
+ // eslint-disable-next-line import/no-extraneous-dependencies
974
+ const supportsColor = requireSupportsColor()
975
+ if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
976
+ exports.colors = [
977
+ 20, 21, 26, 27, 32, 33, 38, 39, 40, 41, 42, 43, 44, 45, 56, 57, 62,
978
+ 63, 68, 69, 74, 75, 76, 77, 78, 79, 80, 81, 92, 93, 98, 99, 112, 113,
979
+ 128, 129, 134, 135, 148, 149, 160, 161, 162, 163, 164, 165, 166, 167,
980
+ 168, 169, 170, 171, 172, 173, 178, 179, 184, 185, 196, 197, 198, 199,
981
+ 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 214, 215, 220, 221
982
+ ]
983
+ }
984
+ } catch (error) {
985
+ // Swallow - we only care if `supports-color` is available; it doesn't have to be.
986
+ }
987
+
988
+ /**
989
+ * Build up the default `inspectOpts` object from the environment variables.
990
+ *
991
+ * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
992
+ */
993
+
994
+ exports.inspectOpts = Object.keys(process.env)
995
+ .filter(key => {
996
+ return /^debug_/i.test(key)
997
+ })
998
+ .reduce((obj, key) => {
999
+ // Camel-case
1000
+ const prop = key
1001
+ .substring(6)
1002
+ .toLowerCase()
1003
+ .replace(/_([a-z])/g, (_, k) => {
1004
+ return k.toUpperCase()
1005
+ })
1006
+
1007
+ // Coerce string value into JS value
1008
+ let val = process.env[key]
1009
+ if (/^(yes|on|true|enabled)$/i.test(val)) {
1010
+ val = true
1011
+ } else if (/^(no|off|false|disabled)$/i.test(val)) {
1012
+ val = false
1013
+ } else if (val === 'null') {
1014
+ val = null
1015
+ } else {
1016
+ val = Number(val)
1017
+ }
1018
+ obj[prop] = val
1019
+ return obj
1020
+ }, {})
1021
+
1022
+ /**
1023
+ * Is stdout a TTY? Colored output is enabled when `true`.
1024
+ */
1025
+
1026
+ function useColors() {
1027
+ return 'colors' in exports.inspectOpts
1028
+ ? Boolean(exports.inspectOpts.colors)
1029
+ : tty.isatty(process.stderr.fd)
1030
+ }
1031
+
1032
+ /**
1033
+ * Adds ANSI color escape codes if enabled.
1034
+ *
1035
+ * @api public
1036
+ */
1037
+
1038
+ function formatArgs(args) {
1039
+ const { namespace: name, useColors } = this
1040
+ if (useColors) {
1041
+ const c = this.color
1042
+ const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c)
1043
+ const prefix = ` ${colorCode};1m${name} \u001B[0m`
1044
+ args[0] = prefix + args[0].split('\n').join('\n' + prefix)
1045
+ args.push(
1046
+ colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m'
1047
+ )
1048
+ } else {
1049
+ args[0] = getDate() + name + ' ' + args[0]
1050
+ }
1051
+ }
1052
+ function getDate() {
1053
+ if (exports.inspectOpts.hideDate) {
1054
+ return ''
1055
+ }
1056
+ return new Date().toISOString() + ' '
1057
+ }
1058
+
1059
+ /**
1060
+ * Invokes `util.formatWithOptions()` with the specified arguments and writes to stderr.
1061
+ */
1062
+
1063
+ function log(...args) {
1064
+ return process.stderr.write(
1065
+ util.formatWithOptions(exports.inspectOpts, ...args) + '\n'
1066
+ )
1067
+ }
1068
+
1069
+ /**
1070
+ * Save `namespaces`.
1071
+ *
1072
+ * @param {String} namespaces
1073
+ * @api private
1074
+ */
1075
+ function save(namespaces) {
1076
+ if (namespaces) {
1077
+ process.env.DEBUG = namespaces
1078
+ } else {
1079
+ // If you set a process.env field to null or undefined, it gets cast to the
1080
+ // string 'null' or 'undefined'. Just delete instead.
1081
+ delete process.env.DEBUG
1082
+ }
1083
+ }
1084
+
1085
+ /**
1086
+ * Load `namespaces`.
1087
+ *
1088
+ * @return {String} returns the previously persisted debug modes
1089
+ * @api private
1090
+ */
1091
+
1092
+ function load() {
1093
+ return process.env.DEBUG
1094
+ }
1095
+
1096
+ /**
1097
+ * Init logic for `debug` instances.
1098
+ *
1099
+ * Create a new `inspectOpts` object in case `useColors` is set
1100
+ * differently for a particular `debug` instance.
1101
+ */
1102
+
1103
+ function init(debug) {
1104
+ debug.inspectOpts = {}
1105
+ const keys = Object.keys(exports.inspectOpts)
1106
+ for (let i = 0; i < keys.length; i++) {
1107
+ debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]]
1108
+ }
1109
+ }
1110
+ module.exports = requireCommon()(exports)
1111
+ const { formatters } = module.exports
1112
+
1113
+ /**
1114
+ * Map %o to `util.inspect()`, all on a single line.
1115
+ */
1116
+
1117
+ formatters.o = function (v) {
1118
+ this.inspectOpts.colors = this.useColors
1119
+ return util
1120
+ .inspect(v, this.inspectOpts)
1121
+ .split('\n')
1122
+ .map(str => str.trim())
1123
+ .join(' ')
1124
+ }
1125
+
1126
+ /**
1127
+ * Map %O to `util.inspect()`, allowing multiple lines if needed.
1128
+ */
1129
+
1130
+ formatters.O = function (v) {
1131
+ this.inspectOpts.colors = this.useColors
1132
+ return util.inspect(v, this.inspectOpts)
1133
+ }
1134
+ })(node, node.exports)
1135
+ return node.exports
1136
+ }
1137
+
1138
+ /**
1139
+ * Detect Electron renderer / nwjs process, which is node, but we should
1140
+ * treat as a browser.
1141
+ */
1142
+ let hasRequiredSrc
1143
+ function requireSrc() {
1144
+ if (hasRequiredSrc) {
1145
+ return src.exports
1146
+ }
1147
+ hasRequiredSrc = 1
1148
+ if (
1149
+ typeof process === 'undefined' ||
1150
+ process.type === 'renderer' ||
1151
+ process.browser === true ||
1152
+ process.__nwjs
1153
+ ) {
1154
+ src.exports = requireBrowser()
1155
+ } else {
1156
+ src.exports = requireNode()
1157
+ }
1158
+ return src.exports
1159
+ }
1160
+
1161
+ const srcExports = requireSrc()
1162
+
1163
+ module.exports = srcExports